Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;
#define ARRAY_MAX 100005

vector<int> par(ARRAY_MAX);//親
vector<int> rank(ARRAY_MAX);//木の深さ

typedef struct edge{

    int u;
    int v;
    int cost;
}EDGE;

bool comp(const EDGE& e1,const EDGE& e2){
    return e1.cost < e2.cost;
}


//n要素で初期化
void init(int n){
    for(int i = 0;i < n;i++){
        par[i] = i;/*各ノードに番号を振る,この時par[x]=xとなる時は木の根となる*/
        rank[i] = 0;/*各ノード自体の高さは0*/
    }
}
//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;/*根ならそのノードの番号を返す*/
    }else{
        return par[x] = find(par[x]);/*根でないならさらにノードの根を探す*/
    }
}

//xとyの属する集合を併合する
void unite(int x,int y){
    x = find(x);//xの根の番号を探す
    y = find(y);//yの根の番号を探す
    if(x == y){//一致すればつながっている
        return;
    }
    if(rank[x] < rank[y]){//xの高さが低いなら高いほうにつなぐ、そして高さは大きい方(y)になる
        par[x] = y;
    }else{
        par[y] = x;//yの高さが低いなら高いほうにつなぐ、そして高さは大きいほう(x)になる
        if(rank[x] == rank[y]){//高さが一致しているなら併合の高さは1増える
            rank[x]++;
        }
    }
}

//xとyが同じ集合に属するか判定
bool same(int x,int y){
    return find(x) == find(y);//同じ集合なら1、違うなら0が返る
}

int kruskal(int n,int count,vector<EDGE>& es){

    sort(es.begin(),es.end(),comp);
    init(n);
    int res = 0;
    for(int i = 0;i < count;i++){
        EDGE e = es[i];
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res += e.cost;
        }
    }
    return res;
}



int main(){

    int n;
    cin >> n;
    vector<EDGE> es;
    vector<int> x(n),y(n);
    int count = 0;

    REP(i,n){
        cin >> x[i] >> y[i];
    }

    for(int i = 0;i < n-1;i++){
        for(int j = i+1;j < n;j++){
            EDGE e;
            e.u = i;
            e.v = j;
            e.cost = min(abs(x[j]-x[i]),abs(y[j]-y[i]));
            es.push_back(e);
            count++;
        }
    }
    int ans = kruskal(n,count,es);
    cout << ans << endl;



    return 0;
}

Compiler output:
a.cc: In function 'void init(int)':
a.cc:48:9: error: reference to 'rank' is ambiguous
   48 |         rank[i] = 0;/*各ノード自体の高さは0*/
      |         ^~~~
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:30:13: note:                 'std::vector<int> rank'
   30 | vector<int> rank(ARRAY_MAX);//木の深さ
      |             ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:67:8: error: reference to 'rank' is ambiguous
   67 |     if(rank[x] < rank[y]){//xの高さが低いなら高いほうにつなぐ、そして高さは大きい方(y)になる
      |        ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:30:13: note:                 'std::vector<int> rank'
   30 | vector<int> rank(ARRAY_MAX);//木の深さ
      |             ^~~~
a.cc:67:18: error: reference to 'rank' is ambiguous
   67 |     if(rank[x] < rank[y]){//xの高さが低いなら高いほうにつなぐ、そして高さは大きい方(y)になる
      |                  ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:30:13: note:                 'std::vector<int> rank'
   30 | vector<int> rank(ARRAY_MAX);//木の深さ
      |             ^~~~
a.cc:71:12: error: reference to 'rank' is ambiguous
   71 |         if(rank[x] == rank[y]){//高さが一致しているなら併合の高さは1増える
      |            ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:30:13: note:                 'std::vector<int> rank'
   30 | vector<int> rank(ARRAY_MAX);//木の深さ
      |             ^~~~
a.cc:71:23: error: reference to 'rank' is ambiguous
   71 |         if(rank[x] == rank[y]){//高さが一致しているなら併合の高さは1増える
      |                       ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:30:13: note:                 'std::vector<int> rank'
   30 | vector<int> rank(ARRAY_MAX);//木の深さ
      |             ^~~~
a.cc:72:13: error: reference to 'rank' is ambiguous
   72 |             rank[x]++;
      |             ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:30:13: note:                 'std::vector<int> rank'
   30 | vector<int> rank(ARRAY_MAX);//木の深さ
      |             ^~~~