func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   int n, Q, pos;   long long a[maxn], sum[maxn], x;   long long tr[maxn << 2], tag[maxn << 2];   void pushup(int rt) { tr[rt] = max(tr[rt << 1], tr[rt << 1 | 1]); }   void build(int rt = 1, int l = 1, int r = n) {     tag[rt] = 0;     if (l == r) {       tr[rt] = sum[l];       return;     }     int mid = (l + r) >> 1;     build(rt << 1, l, mid);     build(rt << 1 | 1, mid + 1, r);     pushup(rt);   }   void load(int rt, long long k) {     tag[rt] += k;     tr[rt] += k;   }   void pushdown(int rt, int l, int r) {     if (tag[rt] == 0) return;     load(rt << 1, tag[rt]);     load(rt << 1 | 1, tag[rt]);     tag[rt] = 0;   }   void update(int nl, int nr, long long k, int l = 1, int r = n, int rt = 1) {     if (nl <= l && nr >= r) {       load(rt, k);       return;     }     pushdown(rt, l, r);     int mid = (l + r) >> 1;     if (nl <= mid) update(nl, nr, k, l, mid, rt << 1);     if (nr >= mid + 1) update(nl, nr, k, mid + 1, r, rt << 1 | 1);     pushup(rt);   }   long long temp_x;   int id;   int get_pos(long long limit, int l = 1, int r = n, int rt = 1) {     if (l == r) {       temp_x = tr[rt];       return l;     }     pushdown(rt, l, r);     int mid = (l + r) >> 1;     if (tr[rt << 1] >= limit)       return get_pos(limit, l, mid, rt << 1);     else       return get_pos(limit, mid + 1, r, rt << 1 | 1);   }   void go() {     long long now_x = 0;     int now_id = 0;     while (now_id != n) {       int temp_id = get_pos(2 * now_x);       if (temp_x == 2 * a[temp_id]) {         printf( %d n , temp_id);         return;       }       now_id = temp_id;       now_x = temp_x;     }     puts( -1 );   }   int main() {     scanf( %d %d , &n, &Q);     for (int i = 1; i <= n; i++) {       scanf( %lld , a + i);       sum[i] = sum[i - 1] + a[i];     }     build();     while (Q--) {       scanf( %d %lld , &pos, &x);       update(pos, n, x - a[pos]);       a[pos] = x;       go();     }     return 0;   }   