func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long LINF = (long long)1e18;   const long double PI = acos((long double)-1);   const long double EPS = 1e-9;   inline long long gcd(long long a, long long b) {     long long r;     while (b) {       r = a % b;       a = b;       b = r;     }     return a;   }   inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   inline long long fpow(long long n, long long k, int p = MOD) {     long long r = 1;     for (; k; k >>= 1) {       if (k & 1) r = r * n % p;       n = n * n % p;     }     return r;   }   inline long long isqrt(long long k) {     long long r = sqrt(k) + 1;     while (r * r > k) r--;     return r;   }   inline long long icbrt(long long k) {     long long r = cbrt(k) + 1;     while (r * r * r > k) r--;     return r;   }   inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }   inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }   inline int sign(long double x, long double y) { return sign(x - y); }   template <class T>   void dbv(T a) {     for (auto x : a) {       cout << x <<   **  ;     }     cout << endl;   }   long long calc(long long in, vector<long long> &a) {     priority_queue<long long> pq;     long long cum = in;     long long cnt = 0;     long long n = a.size();     for (int i = (0); i < (n); ++i) {       pq.push(-a[i]);       cum += a[i];       if (cum < 0) {         cum += pq.top();         pq.pop();         cnt++;       }     }     return cnt;   }   void output() {     long long n, q;     cin >> n >> q;     vector<long long> a(n);     for (int i = (0); i < (n); ++i) {       cin >> a[i];     }     long long st = calc(0, a);     vector<long long> lims;     lims.push_back(0);     for (int val = (st - 1); val >= (0); --val) {       long long low = lims[st - val - 1] + 1;       long long high = LINF;       while (low < high) {         long long mid = (low + high) / 2;         if (calc(mid, a) <= val)           high = mid;         else           low = mid + 1;       }       lims.push_back(low);     }     lims.push_back(1e18);     for (int i = (0); i < (q); ++i) {       long long qu;       cin >> qu;       long long low = 0;       long long high = st + 1;       while (low < high) {         long long mid = (low + high) / 2;         if (qu < lims[mid])           high = mid;         else           low = mid + 1;       }       cout << (st - (low - 1)) << endl;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     for (int i = (0); i < (t); ++i) {       output();     }     return 0;   }   