func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, x, zhan[100500], tree[100500], o, ans[100500], now = 1;   struct edge {     int x, t, id, r;     bool operator<(const edge &xx) const {       if (x != xx.x) return x < xx.x;       return id < xx.id;     }   } aa[100500];   void add(int x, int y) {     for (int i = x; i <= n; i += (i & (-i))) tree[i] += y;   }   int get(int x) {     int ans = 0;     for (int i = x; i >= 1; i -= (i & (-i))) ans += tree[i];     return ans;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       scanf( %d%d%d , &aa[i].r, &aa[i].t, &aa[i].x);       aa[i].id = i;       zhan[++o] = aa[i].t;     }     sort(zhan + 1, zhan + o + 1);     o = unique(zhan + 1, zhan + o + 1) - zhan - 1;     for (int i = 1; i <= n; i++) {       aa[i].t = lower_bound(zhan + 1, zhan + o + 1, aa[i].t) - zhan;     }     sort(aa + 1, aa + n + 1);     memset(ans, -1, sizeof(ans));     for (int i = 1; i <= n; i++) {       if (aa[i].x != aa[i - 1].x)         while (now != i) {           if (aa[now].r == 1) add(aa[now].t, -1);           if (aa[now].r == 2) add(aa[now].t, 1);           now++;         }       if (aa[i].r == 1) add(aa[i].t, 1);       if (aa[i].r == 2) add(aa[i].t, -1);       if (aa[i].r == 3) ans[aa[i].id] = get(aa[i].t);     }     for (int i = 1; i <= n; i++)       if (ans[i] != -1) printf( %d n , ans[i]);   }   