func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 300005;   int n, tt, rt, ans, ls[N], rs[N], val[N], tg[N], rd[N];   inline int nw(int v) {     val[++tt] = v;     rd[tt] = rand();     return tt;   }   inline void add(int x, int v) {     val[x] += v;     tg[x] += v;   }   inline void dn(int x) {     add(ls[x], tg[x]);     add(rs[x], tg[x]);     tg[x] = 0;   }   void split(int x, int k, int& a, int& b) {     if (!x) {       a = b = 0;       return;     }     dn(x);     val[x] < k ? (a = x, split(rs[x], k, rs[a], b))                : (b = x, split(ls[x], k, a, ls[b]));   }   int merge(int x, int y) {     if (!x || !y)       return x | y;     else if (rd[x] < rd[y]) {       dn(x);       rs[x] = merge(rs[x], y);       return x;     } else {       dn(y);       ls[y] = merge(x, ls[y]);       return y;     }   }   int main() {     scanf( %d , &n);     while (n--) {       int l, r, x, y, z;       scanf( %d%d , &l, &r);       split(rt, r, x, z);       split(x, l, x, y);       add(y, 1);       if (z) {         int w = z;         while (ls[w]) dn(w), w = ls[w];         split(z, val[w] + 1, w, z);       } else         ans++;       rt = merge(merge(x, nw(l)), merge(y, z));     }     printf( %d n , ans);     return 0;   }   