๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
The Undefeated Magician

def is_possible(N, X):
    attempts = 0
    while N > 0:
        N >>= 1
        attempts += 1
    return attempts <= X

def min_attempts(N):
    left, right = 0, N
    result = -1
    while left <= right:
        mid = (left + right) // 2
        if is_possible(N, mid):
            result = mid
            right = mid - 1
        else:
            left = mid + 1
    return result

T = int(input().strip())
for _ in range(T):
    N = int(input().strip())

    print(min_attempts(N))
def is_satisfied(N, W, R, weights):
    # Check if the weight of the rod itself is at least W
    if abs(R) >= W:
        return "waku waku"
   
    # Check if Aditya Sama can balance the weights symmetrically
    left_sum = 0
    right_sum = 0
    for weight in weights:
        if weight < 0:
            left_sum += abs(weight)
        else:
            right_sum += weight
   
    if left_sum == right_sum and left_sum >= W:
        return "waku waku"
    else:
        return "orewa kanashii desu"

N, W, R = map(int, input().split())
weights = list(map(int, input().split()))

print(is_satisfied(N, W, R, weights))

Aditya-Sama and Gym
๐Ÿ‘1
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int T;
    cin >> T;
    while (T--) {
        int N;
        long long K;
        cin >> N >> K;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }

        int maxLength = -1;
        long long sum = 0;
        int left = 0;

        for (int right = 0; right < N; ++right) {
            sum += A[right];
            int length = right - left + 1;

            while (sum * length > K && left < right) {
                sum -= A[left];
                left++;
                length = right - left + 1;
            }

            if (sum * length <= K && length > 1) {
                maxLength = max(maxLength, length);
            }
        }

        cout << maxLength << endl;
    }
    return 0;
}

Shiv and Subarray โœ…
โค1
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define int long long

signed main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */  
   
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int ans=0;
        while(n--){
            int x;
            cin>>x;
            ans=(ans|x);
        }
        cout<<ans<<endl;
    }
   
    return 0;
}

Shiv and Subsequences โœ…
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define int long long

signed main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
   
    int n;
    cin>>n;
   
    vector<int> a(n);
    for(auto&x:a) cin>>x;
   
    vector<int> suff(n,0);
   
    suff[n-1]=n-1;
    for(int i=n-2;i>=0;i--){
        if(a[i]>a[suff[i+1]]) suff[i]=i;
        else suff[i]=suff[i+1];
    }
   
    int ans=0;
   
    int i=0;
    while(i!=n-1){
        ans+=a[suff[i+1]]*(suff[i+1]-i);
        i=suff[i+1];
    }
   
    cout<<ans;
   
    return 0;
}

Shiv and Jumpโœ…
int MaxGCD(int a[], int n)
{

  int Prefix[n + 2];
  int Suffix[n + 2];

  Prefix[1] = a[0];
  for (int i = 2; i <= n; i += 1)
    Prefix[i] = __gcd(Prefix[i - 1], a[i - 1]);

  Suffix[n] = a[n - 1];

  for (int i = n - 1; i >= 1; i -= 1)
    Suffix[i] = __gcd(Suffix[i + 1], a[i - 1]);

  int ans = max(Suffix[2], Prefix[n - 1]);

  for (int i = 2; i < n; i += 1)
    ans = max(ans, __gcd(Prefix[i - 1], Suffix[i + 1]));

  return ans;
}


Shiv and gcd โœ…
class UserMainCode(object):
    @classmethod
    def solve(cls, input1, input2):
        maxi = float('-inf')
        total_sum = sum(input1)
       
        for it in input1:
            maxi = max(maxi, total_sum - it)
       
        return maxi

frog in the pond โœ…
int maxLcmOfPairs(int arr[], int n){ 
  int maxLCM = -1;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {

      maxLCM  = max(maxLCM, (arr[i] * arr[j]) / __gcd(arr[i], arr[j]));
    }
  }

  return maxLCM;
}

Pair problem โœ…
class UserMainCode(object):
    @classmethod
    def reduceTheBill(cls, input1):
        binary_input = bin(input1)[2:]
        res = []
        for i in range(len(binary_input)):
            flipped_bit = '1' if binary_input[i] == '0' else '0'
            flipped_binary = binary_input[:i] + flipped_bit + binary_input[i+1:]
            res.append(int(flipped_binary, 2))
        return min(res)

Reduce the Bill โœ…
public static int countBountyNumbers(int N) {
        int MOD = 10007;

        long totalNDigitNumbers = 9 * (long) Math.pow(10, N - 1);
        long noZeros = (long) Math.pow(9, N);
        long oneZero = (N - 1) * 9 * (long) Math.pow(9, N - 2);
        long validNumbers = (totalNDigitNumbers - noZeros - oneZero) % MOD;

        if (validNumbers < 0) {
            validNumbers += MOD;
        }

        return (int) validNumbers;
    }

Bounty โœ…
def lineUp(commands):
    size = len(commands)
    deg = 0
    temp = 0
    for i in range(0,size):
        if commands[i] == 'L':
            deg += -90
        elif commands[i] == 'R':
            deg += 90
        elif commands[i] == 'A':
            deg += 180
        if deg%180==0:
            temp += 1
            deg = 0
    return temp
#include <iostream>
#include <vector>
using namespace std;
int andyTrucker(int N, int K, vector<int>& A) {
    int maxWeight = 0;
    for (int i = 0; i <= N - K; ++i) {
        int currentWeight = 0;
        for (int j = i; j < i + K; ++j) {
            currentWeight += A[j];
        }
        maxWeight = max(maxWeight, currentWeight);
    }

    return maxWeight;
}