func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 300000 + 10;   int n;   const int nn = 65536 * 4;   long long sha[maxn];   long long tree[nn * 2 + 10], tag[nn * 2 + 10];   long long fix;   long long og[maxn];   void _down(int id) {     tree[id * 2] += tag[id], tag[id * 2] += tag[id];     tree[id * 2 + 1] += tag[id], tag[id * 2 + 1] += tag[id];     tag[id] = 0;   }   void _update(int a, int b, int l, int r, int id) {     if (l >= a and r <= b) {       tree[id] += fix;       tag[id] += fix;       return;     }     _down(id);     int mid = (l + r) / 2;     if (a <= mid) _update(a, b, l, mid, id << 1);     if (b > mid) _update(a, b, mid + 1, r, id << 1 | 1);     tree[id] = max(tree[id << 1], tree[id << 1 | 1]);   }   long long _query(int a, int b, int l, int r, int id) {     if (l >= a and r <= b) return tree[id];     _down(id);     int mid = (l + r) / 2;     if (a <= mid)       return _query(a, b, l, (l + r) / 2, id << 1);     else       return _query(a, b, (l + r) / 2 + 1, r, id << 1 | 1);   }   int _nxt(int l, int r, int id) {     if (l == r) return l;     _down(id);     if (tree[id << 1] >= fix)       return _nxt(l, (l + r) / 2, id << 1);     else       return _nxt((l + r) / 2 + 1, r, id << 1 | 1);   }   int main() {     int Q;     scanf( %d%d , &n, &Q);     for (int i = 1; i <= n; i++) {       scanf( %I64d , &sha[i]);       og[i] = sha[i];       sha[i] += sha[i - 1];       fix = sha[i];       _update(i, i, 1, nn, 1);     }     while (Q--) {       int x;       long long y;       scanf( %d%I64d , &x, &y);       fix = y - og[x];       og[x] = y;       _update(x, n, 1, nn, 1);       int now = 1;       long long op;       int ui = 0;       while (1) {         op = _query(now, now, 1, nn, 1);         if (op == (now != 1 ? _query(now - 1, now - 1, 1, nn, 1) * 2 : 0)) {           ui = 1;           printf( %d n , now);           break;         }         fix = op * 2;         if (fix > tree[1]) break;         now = _nxt(1, nn, 1);       }       if (!ui) puts( -1 );     }     return 0;   }   