//
// Created by adavy on 7/23/2025.
//
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void insert(map<ll,ll>& mp, ll i, ll x){
    if (mp.count(i)) {
        mp[i] += x;
    } else {
        mp[i] = x;
    }
}
long long count_tastiness(long long x, std::vector<long long> a) {
    int B = 60;
    while(a.size() < B-1) a.push_back(0);
    vector<ll> divs(B);
    ll ctr = 0;
    for(int i=0;i<B;++i){
        ctr += (1LL<<i)*a[i];
        divs[i] = ctr/x;
    }
    ll ans = (1LL<<B);
    map<ll,ll> blocks; //i, ct;
    blocks[(1LL<<B) - 1] = 1;
    ll t;
    for(int i=B-1;i>=0;--i){
        map<ll,ll> blocks2;
        for(auto [k,v]:blocks){
            t = k;
            if (k > divs[i]){
                ans -= v*(k - divs[i]);
                t = divs[i];
            }
            insert(blocks2, t%(1LL<<i), v);
            if (t >= (1LL<<i)) insert(blocks2, (1LL<<i) - 1, v);
        }
        blocks = blocks2;
    }
    return ans;
}
/*
int main() {
    int q;
    assert(scanf("%d", &q) == 1);
    vector<int> k(q);
    vector<long long> x(q);
    vector<vector<long long>> a(q);
    vector<long long> results(q);
    for (int t = 0; t < q; t++) {
        assert(scanf("%d%lld", &k[t], &x[t]) == 2);
        a[t] = vector<long long>(k[t]);
        for (int i = 0; i < k[t]; i++) {
            assert(scanf("%lld", &a[t][i]) == 1);
        }
    }
    fclose(stdin);
    for (int t = 0; t < q; t++) {
        results[t] = count_tastiness(x[t], a[t]);
    }
    for (int t = 0; t < q; t++) {
        printf("%lld\n", results[t]);
    }
    fclose(stdout);
    return 0;
}*/
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |