func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5;   set<int> v[MAXN];   int last = -1, lastx = -1;   vector<int> f;   int ans = 0;   int t[MAXN], x_[MAXN];   bool find(vector<int> &d, int k) {     if (d.empty()) return false;     int l = 0, r = int(d.size());     while (r - l > 1) {       int m = (l + r) / 2;       if (d[m] <= k)         l = m;       else         r = m;     }     return d[l] == k;   }   int main() {     ios_base::sync_with_stdio(false);     int n, q;     cin >> n >> q;     for (int i = 0; i < q; i++) {       int type, x;       cin >> type >> x;       x--;       t[i] = type, x_[i] = x;       if (type == 1) {         v[x].insert(i);         f.push_back(i);         ans++;       } else if (type == 2) {         ans -= (int)v[x].size();         v[x].clear();       } else if (type == 3)         if (last < f[x]) {           for (int j = lastx + 1; j <= x; j++) {             int id = f[j];             if (v[x_[id]].find(id) != v[x_[id]].end()) v[x_[id]].erase(id), ans--;           }           last = f[x], lastx = x;         }       cout << ans << endl;     }     return 0;   }   