func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 400005;   int n, m, h[N], p[N];   set<int> S;   set<int>::iterator it;   inline void read(int &i) {     i = 0;     char c = getchar();     bool j = 0;     for (; !isdigit(c); c = getchar())       if (c ==  - ) j = 1;     for (; isdigit(c); c = getchar()) i = (i << 1) + (i << 3) + c -  0 ;     i = j ? -i : i;   }   struct Segment_Tree {     int sz, mx[N << 2];     inline void mdf(int u, int l, int r, int x, int y) {       if (l == r) {         mx[u] = y;         return;       }       int mid = (l + r) >> 1;       if (x <= mid)         mdf(u << 1, l, mid, x, y);       else         mdf(u << 1 | 1, mid + 1, r, x, y);       mx[u] = max(mx[u << 1], mx[u << 1 | 1]);     }     inline int qry(int u, int l, int r, int L, int R) {       if (L <= l && r <= R) return mx[u];       int mid = (l + r) >> 1, as = 0;       if (L <= mid) as = max(as, qry(u << 1, l, mid, L, R));       if (mid < R) as = max(as, qry(u << 1 | 1, mid + 1, r, L, R));       return as;     }     inline void mdf(int x, int y) { mdf(1, 0, sz, x, y); }     inline int qry(int l, int r) { return qry(1, 0, sz, l, r); }   } A, B;   int main() {     read(n);     read(m);     A.sz = n + 100;     B.sz = m + 200;     int op, x, y;     for (int tim = 1; tim <= m; ++tim) {       read(op), read(x);       if (op == 1) {         x = n + 1 - x;         read(y);         y = tim + 10 - y;         p[y] = x;         h[x] = y;         S.insert(x);         for (int i = y + 1; i <= y + 9; ++i)           if (p[i]) A.mdf(p[i], 0);         for (int i = y; i <= y + 9; ++i)           if (p[i]) {             int f = A.qry(0, p[i] - 1) + 1;             A.mdf(p[i], f);             B.mdf(i, f);           }       } else {         it = S.end();         while (x--) it--, B.mdf(h[*it], 0);         int del = *it;         A.mdf(*it, 0);         it++;         for (; it != S.end(); it++) {           int f = B.qry(0, h[*it] - 1) + 1;           B.mdf(h[*it], f);           A.mdf(*it, f);         }         S.erase(del);         p[h[del]] = 0;         h[del] = 0;       }       printf( %d n , A.qry(1, n));     }     return 0;   }   