func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     register int X = 0;     register char ch = 0;     while (ch < 48 || ch > 57) ch = getchar();     while (ch >= 48 && ch <= 57) X = X * 10 + (ch ^ 48), ch = getchar();     return X;   }   int n, m;   struct Point {     int l, r, x, y;   } b[600500];   int tn;   map<pair<int, int>, int> mmp;   int f[600500], xc[600500], yc[600500];   struct Data {     int x, y;   } stk[600500];   int top;   long long ans;   int findf(int x) { return f[x] == x ? x : findf(f[x]); }   void marge(int x, int y) {     x = findf(x);     y = findf(y);     if (x == y) return;     ans -= 1ll * xc[x] * yc[x] + 1ll * xc[y] * yc[y];     if (xc[x] + yc[x] > xc[y] + yc[y]) swap(x, y);     stk[++top] = (Data){x, y};     f[x] = y;     xc[y] += xc[x];     yc[y] += yc[x];     ans += 1ll * xc[y] * yc[y];   }   void undo(int x, int y) {     f[x] = x;     xc[y] -= xc[x];     yc[y] -= yc[x];   }   vector<int> s[600500 << 1];   void solve(int l, int r, int num) {     long long sav = ans;     int tim = top;     Point *v;     for (int i = 0; i < s[num].size(); i++) {       v = &b[s[num][i]];       if (v->l <= l && r <= v->r) marge(v->x, v->y);     }     if (l == r)       printf( %lld  , ans);     else {       int mid = (l + r) >> 1;       for (int i = 0; i < s[num].size(); i++) {         v = &b[s[num][i]];         if (!(v->l <= l && r <= v->r)) {           if (v->l <= mid) s[num << 1].push_back(s[num][i]);           if (v->r > mid) s[num << 1 | 1].push_back(s[num][i]);         }       }       s[num].clear();       solve(l, mid, num << 1);       solve(mid + 1, r, num << 1 | 1);     }     while (tim < top) {       undo(stk[top].x, stk[top].y);       top--;     }     ans = sav;   }   int main() {     m = read();     n = 300005;     pair<int, int> sav;     for (int i = 1, x, y; i <= m; i++) {       x = read();       y = read() + n;       sav = make_pair(x, y);       if (mmp[sav]) {         b[mmp[sav]].r = i - 1;         mmp[sav] = 0;       } else         b[mmp[sav] = ++tn] = (Point){i, 0, x, y};     }     for (int i = 1; i <= tn; i++) {       if (b[i].r == 0) b[i].r = m;       s[1].push_back(i);     }     for (int i = 1; i <= n + n; i++) {       f[i] = i;       xc[i] = (i <= n);       yc[i] = !xc[i];     }     solve(1, m, 1);     return 0;   }   