func_code_string: #include <bits/stdc++.h>   const int MAX_VAL = 1000000;   struct AInt {     int sum;     int minSum;   };   AInt aInt[1 << 21];   void update(int index, int left, int right, int addIndex, int addValue) {     if (left == right) {       aInt[index].sum += addValue;       aInt[index].minSum += addValue;     } else {       int avg = (left + right) / 2;       if (addIndex <= avg) {         update(2 * index + 0, left, avg, addIndex, addValue);       } else {         update(2 * index + 1, avg + 1, right, addIndex, addValue);       }       aInt[index].sum = aInt[2 * index].sum + aInt[2 * index + 1].sum;       aInt[index].minSum =           std::min(aInt[2 * index].minSum + aInt[2 * index + 1].sum,                    aInt[2 * index + 1].minSum);     }   }   int query(int index, int suffSum, int left, int right) {     if (aInt[index].minSum + suffSum >= 0) {       return -1;     } else if (left == right) {       return left;     } else {       int avg = (left + right) / 2;       int q2 = query(2 * index + 1, suffSum, avg + 1, right);       if (q2 == -1) {         int q1 =             query(2 * index + 0, aInt[2 * index + 1].sum + suffSum, left, avg);         return q1;       } else {         return q2;       }     }   }   void update(int value, int sign) { update(1, 1, MAX_VAL, value, sign); }   int query() { return query(1, 0, 1, MAX_VAL); }   int main() {     int n, m;     scanf( %d%d , &n, &m);     int a[n];     int b[m];     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       update(a[i], -1);     }     for (int i = 0; i < m; i++) {       scanf( %d , &b[i]);       update(b[i], +1);     }     int q;     scanf( %d , &q);     for (int z = 0; z < q; z++) {       int t, i, x;       scanf( %d%d%d , &t, &i, &x);       i--;       if (t == 1) {         update(a[i], +1);         a[i] = x;         update(a[i], -1);       } else {         update(b[i], -1);         b[i] = x;         update(b[i], +1);       }       printf( %d n , query());     }     return 0;   }   