func_code_string: #include <bits/stdc++.h>   const int N_MAX = 600007;   std::map<std::pair<int, int>, int> ext;   long long ans[N_MAX], now;   int fa[N_MAX], siz[N_MAX][2], top;   std::pair<int, int> stk[N_MAX];   int find(int x) {     while (fa[x] != x) x = fa[x];     return x;   }   void merge(std::pair<int, int> v) {     int x = find(v.first), y = find(v.second);     if (x != y) {       if (siz[x][0] + siz[x][1] < siz[y][0] + siz[y][1]) std::swap(x, y);       now -= 1ll * siz[x][0] * siz[x][1] + 1ll * siz[y][0] * siz[y][1];       siz[x][0] += siz[y][0], siz[x][1] += siz[y][1];       now += 1ll * siz[x][0] * siz[x][1];       fa[y] = x, stk[++top] = std::make_pair(x, y);     }   }   void undoMerge() {     int x = stk[top].first, y = stk[top].second;     now -= 1ll * siz[x][0] * siz[x][1];     siz[x][0] -= siz[y][0], siz[x][1] -= siz[y][1];     now += 1ll * siz[x][0] * siz[x][1] + 1ll * siz[y][0] * siz[y][1];     fa[y] = y, --top;   }   static const int T_MAX = 1200007;   std::vector<std::pair<int, int> > op[T_MAX];   void modify(int k, int l, int r, int x, int y, std::pair<int, int> v) {     if (x <= l && r <= y) {       op[k].push_back(v);       return;     }     if (x <= ((l + r) >> 1)) modify((k << 1), l, ((l + r) >> 1), x, y, v);     if (((l + r) >> 1) < y) modify((k << 1 | 1), ((l + r) >> 1) + 1, r, x, y, v);   }   void dfs(int k, int l, int r) {     int temp = top;     for (auto v : op[k]) merge(v);     if (l == r)       ans[l] = now;     else       dfs((k << 1), l, ((l + r) >> 1)), dfs((k << 1 | 1), ((l + r) >> 1) + 1, r);     while (top > temp) undoMerge();   }   int main() {     const int n = 3e5;     int Q;     scanf( %d , &Q);     for (int i = 1; i <= Q; ++i) {       std::pair<int, int> temp;       scanf( %d%d , &temp.first, &temp.second), temp.second += n;       if (ext.find(temp) == ext.end())         ext[temp] = i;       else         modify(1, 1, Q, ext[temp], i - 1, temp), ext.erase(temp);     }     for (auto i : ext) modify(1, 1, Q, i.second, Q, i.first);     for (int i = 1; i <= n; ++i) fa[i] = i, siz[i][0] = 1;     for (int i = n + 1; i <= n + n; ++i) fa[i] = i, siz[i][1] = 1;     dfs(1, 1, Q);     for (int i = 1; i <= Q; ++i) printf( %lld  , ans[i]);     return 0;   }   