Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    bool checker[100050];
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
        for(int i = 0; i <= 1e5; i++) checker[i] = false;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

ll N;
ll x[100500], y[100050];
map<ll, ll> appearx, appeary;
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> x[i] >> y[i];
        xs.push_back(x[i]);
        ys.push_back(y[i]);
    }
    UnionFind X(100050), Y(100050);
    for(int i = 1; i <= N; i++) {
        if(appearx[x[i]] == 0) {
            appearx[x[i]] = i;
        } else {
            Y.merge(y[appearx[x[i]]], y[i]);
        }
        if(appeary[y[i]] == 0) {
            appearx[y[i]] = i;
        } else {
            X.merge(x[appeary[y[i]]], x[i]);
        }
    }
    ll ans = -N;
    for(int i = 1; i <= N; i++) {
        if(X.checker[X.root(x[i])]) continue;
        X.checker[X.root(x[i])] = true;
        ans += X.size([x[i]]) * Y.size([y[i]]);
        //cerr << i << " "<< X.size(mpx[x[i]]) << " "<< Y.size(mpy[y[i]]) << endl;
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:9: error: 'xs' was not declared in this scope; did you mean 'x'?
   82 |         xs.push_back(x[i]);
      |         ^~
      |         x
a.cc:83:9: error: 'ys' was not declared in this scope; did you mean 'yn'?
   83 |         ys.push_back(y[i]);
      |         ^~
      |         yn
a.cc:102:24: warning: capture of variable 'x' with non-automatic storage duration
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                        ^
a.cc:73:4: note: 'll x [100500]' declared here
   73 | ll x[100500], y[100050];
      |    ^
a.cc:102:25: error: expected ',' before '[' token
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                         ^
      |                         ,
a.cc:102:25: error: expected identifier before '[' token
a.cc: In lambda function:
a.cc:102:29: error: expected '{' before ')' token
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                             ^
a.cc: In function 'int main()':
a.cc:102:23: error: invalid user-defined conversion from 'main()::<lambda()>' to 'int' [-fpermissive]
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                       ^~~~~~
a.cc:102:23: note: candidate is: 'constexpr main()::<lambda()>::operator void (*)()() const' (near match)
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                       ^
a.cc:102:23: note:   no known conversion from 'void (*)()' to 'int'
a.cc:67:17: note:   initializing argument 1 of 'll UnionFind::size(int)'
   67 |     ll size(int x){
      |             ~~~~^
a.cc:102:41: warning: capture of variable 'y' with non-automatic storage duration
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                                         ^
a.cc:73:15: note: 'll y [100050]' declared here
   73 | ll x[100500], y[100050];
      |               ^
a.cc:102:42: error: expected ',' before '[' token
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                                          ^
      |                                          ,
a.cc:102:42: error: expected identifier before '[' token
a.cc: In lambda function:
a.cc:102:46: error: expected '{' before ')' token
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                                              ^
a.cc: In function 'int main()':
a.cc:102:40: error: invalid user-defined conversion from 'main()::<lambda()>' to 'int' [-fpermissive]
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                                        ^~~~~~
a.cc:102:40: note: candidate is: 'constexpr main()::<lambda()>::operator void (*)()() const' (near match)
  102 |         ans += X.size([x[i]]) * Y.size([y[i]]);
      |                                        ^
a.cc:102:40: note:   no known conversion from 'void (*)()' to 'int'
a.cc:67:17: note:   initializing argument 1 of 'll UnionFind::size(int)'
   67 |     ll size(int x){
      |             ~~~~^