func_code_string: #include <bits/stdc++.h>   using namespace std;   struct tree {     int maxv[650001];     void set(int x, int d, int o, int l, int r) {       if (l == r) {         maxv[o] = d;         return;       }       int m = (l + r) / 2;       if (x <= m)         set(x, d, o * 2, l, m);       else         set(x, d, o * 2 + 1, m + 1, r);       maxv[o] = max(maxv[o * 2], maxv[o * 2 + 1]);     }     int query(int x, int y, int o, int l, int r) {       if (x <= l && r <= y) return maxv[o];       int m = (l + r) / 2, ans = 0;       if (x <= m) ans = max(ans, query(x, y, o * 2, l, m));       if (y > m) ans = max(ans, query(x, y, o * 2 + 1, m + 1, r));       return ans;     }   } Tx, Ty;   int n, m;   map<int, int> h, pos;   void modify(int x, int y, int val) {     Tx.set(x, val, 1, 1, n);     Ty.set(y, val, 1, 1, m + 20);   }   void remove_all(map<int, int>::iterator del) {     modify(del->first, del->second, 0);     pos.erase(pos.lower_bound(del->second));     h.erase(del);   }   int main() {     scanf( %d%d , &n, &m);     for (int T = 1; T <= m; T++) {       int op, p, v;       scanf( %d%d , &op, &p);       if (op == 1) {         scanf( %d , &v);         v += m - T;         h[p] = v;         pos[v] = p;         auto it = pos.lower_bound(v), it2 = it;         for (;; it2--) {           modify(it2->second, it2->first, 0);           if (it2 == pos.begin()) break;         }         for (;; it--) {           int x = it->second, y = it->first, val = Tx.query(x, n, 1, 1, n) + 1;           modify(x, y, val);           if (it == pos.begin()) break;         }       } else {         auto del = h.begin();         for (int i = 1; i < p; i++) del++;         if (del == h.begin())           remove_all(del);         else {           auto it = del, it2 = --it;           remove_all(del);           for (;; it2--) {             modify(it2->first, it2->second, 0);             if (it2 == h.begin()) break;           }           for (;; it--) {             int x = it->first, y = it->second,                 val = Ty.query(y + 1, m + 20, 1, 1, m + 20) + 1;             modify(x, y, val);             if (it == h.begin()) break;           }         }       }       printf( %d n , Tx.query(1, n, 1, 1, n));     }   }   