func_code_string: #include <bits/stdc++.h>   #pragma optimize( TKACHENKO-GORYACHENKO )   using namespace std;   const int maxn = 11e5;   const int inf = 1e18;   int n, m, k;   int A[maxn];   int B[maxn];   int C[maxn];   int V[4 * maxn];   int T[4 * maxn];   inline void push(int v, int tl, int tr) {     if (T[v] == 0) {       return;     }     V[v] += T[v];     if (tl != tr) {       T[2 * v] += T[v];       T[2 * v + 1] += T[v];     }     T[v] = 0;   }   inline void build(int v, int tl, int tr) {     if (tl == tr) {       V[v] = C[tl];       return;     }     int tm = (tl + tr) / 2;     build(2 * v, tl, tm);     build(2 * v + 1, tm + 1, tr);     V[v] = min(V[2 * v], V[2 * v + 1]);   }   inline void update(int v, int tl, int tr, int l, int r, int color) {     push(v, tl, tr);     if (l > r || tl > r || l > tr) {       return;     }     if (tl == l && tr == r) {       T[v] += color;       push(v, tl, tr);       return;     }     int tm = (tl + tr) / 2;     update(2 * v, tl, tm, l, min(r, tm), color);     update(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, color);     V[v] = min(V[2 * v], V[2 * v + 1]);   }   inline void changea(int i, int j) {     if (j >= i) {       update(1, 0, maxn - 1, i + 1, j, -1);     } else {       update(1, 0, maxn - 1, j + 1, i, 1);     }   }   inline void changeb(int i, int j) {     if (j >= i) {       update(1, 0, maxn - 1, i + 1, j, 1);     } else {       update(1, 0, maxn - 1, j + 1, i, -1);     }   }   inline int getans(int v, int tl, int tr) {     push(v, tl, tr);     int tm = (tl + tr) / 2;     if (tl != tr) {       push(2 * v, tl, tm);       push(2 * v + 1, tm + 1, tr);     }     if (V[v] >= 0) {       return -1;     }     if (tl == tr) {       return tl;     }     if (V[2 * v + 1] < 0) {       return getans(2 * v + 1, tm + 1, tr);     }     if (V[2 * v] < 0) {       return getans(2 * v, tl, tm);     }   }   int main() {     int q, w, e, a, b, f;     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> m;     for (q = 0; q < n; q++) {       cin >> A[q];       C[A[q]]--;     }     for (q = 0; q < m; q++) {       cin >> B[q];       C[B[q]]++;     }     cin >> k;     for (q = maxn - 2; q >= 0; q--) {       C[q] += C[q + 1];     }     build(1, 0, maxn - 1);     for (e = 0; e < k; e++) {       int i, x, comm;       cin >> comm >> i >> x;       i--;       if (comm == 1) {         changea(A[i], x);         A[i] = x;       } else {         changeb(B[i], x);         B[i] = x;       }       cout << getans(1, 0, maxn - 1) <<   n ;     }     return 0;   }   