func_code_string: #include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   const long long inf = (long long)1e9;   double PI = 3.14159265;   double eps = 1e-9;   long long t = 0;   long long pow(long long a, long long b) {     if (b == 0) return 1;     if (b % 2 == 1) {       return (pow(a, b - 1) * a);     }     if (b % 2 == 0) {       long long c = pow(a, b / 2);       return (c * c);     }   }   vector<pair<long long, long long>> reb;   long long dp[1 << 17];   long long krask[1 << 17];   vector<vector<long long>> g;   vector<long long> dep;   vector<vector<long long>> p;   vector<vector<long long>> dep2;   vector<long long> u;   vector<long long> tin, tout;   void dfs(long long v, long long k) {     tin[v] = t++;     p[v][0] = k;     for (long long i = 1; i < 20; i++) {       p[v][i] = p[p[v][i - 1]][i - 1];     }     for (long long i = 0; i < g[v].size(); i++) {       long long to = g[v][i];       if (dep[to] == -1) {         dep[to] = dep[v] + 1;         dep2[dep[to]].push_back(t);         dfs(to, v);       }     }     tout[v] = t;   }   long long parent(long long v, long long h) {     for (long long i = 0; i < 20; i++) {       if ((h & (1 << i))) {         v = p[v][i];       }     }     return v;   }   long long lca(long long a, long long b) {     if (dep[a] < dep[b]) swap(a, b);     a = parent(a, dep[a] - dep[b]);     if (a == b) return a;     for (long long i = 19; i >= 0; i--) {       if (p[a][i] != p[b][i]) {         a = p[a][i];         b = p[b][i];       }     }     return parent(a, 1);   }   struct stree {     vector<long long> t;     int n;     stree(vector<long long> a) {       n = 1;       while (n < a.size()) {         n *= 2;       }       t.resize(n + n);       for (int i = n; i < n + a.size(); i++) {         t[i] = a[i - n];       }       for (int i = n - 1; i > 0; i--) {         t[i] = t[i + i] + t[i + i + 1];       }     }     long long sum(long long l, long long r) {       long long sum = 0;       for (l += n, r += n; l <= r; l /= 2, r /= 2) {         if (l % 2 == 1) {           sum += t[l++];         }         if (r % 2 == 0) {           sum += t[r--];         }       }       return sum;     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, q;     cin >> n >> q;     vector<long long> a;     a.resize(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     stree d(a);     vector<long long> k;     k.resize(q);     long long gl = 0;     int pred = 0;     for (int i = 0; i < q; i++) {       cin >> k[i];       long long r = a.size(), l = gl - 1;       while (r - l > 1) {         long long mid = (l + r) / 2;         long long sum = d.sum(gl, mid);         if (sum > k[i] + pred)           r = mid;         else {           l = mid;         }       }       if (r == a.size()) {         gl = 0;         pred = 0;       } else {         if (k[i] + pred < d.sum(gl, r - 1)) {           pred = k[i] + pred;         } else {           pred = k[i] + pred - d.sum(gl, r - 1);           gl = r;         }       }       cout << a.size() - gl << endl;     }   }   