Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> PLI;
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int parent[123456];
int rank[123456];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		parent[i] = i;
		rank[i] = 0;
	}
}

int ufind(int x){
	int ans;
	if(parent[x] == x){
		return x;
	}else{
		ans = ufind(parent[x]);
		parent[x] = ans;
		return ans;
	}
}

void unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(rank[x] > rank[y]){
		parent[y] = x;
	}else{
		parent[x] = y;
	}
	if(rank[x] == rank[y]){
		rank[y]++;
	}
}

int main(void){
	int n,i;
	ll xi,yi,ans=0ll;
	E e;
	vector<PLI> x,y;
	priority_queue< E, vector<E>, greater<E> > pq;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> xi >> yi;
		x.push_back(PLI(xi,i));
		y.push_back(PLI(yi,i));
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	for(i=1; i<n; ++i){
		pq.push(E(x[i].first-x[i-1].first,P(x[i-1].second,x[i].second)));
		pq.push(E(y[i].first-y[i-1].first,P(y[i-1].second,y[i].second)));
	}
	ufinit(n);
	while(!pq.empty()){
		e = pq.top();
		pq.pop();
		if(ufind(e.from) == ufind(e.to)){
			continue;
		}
		unionf(e.from,e.to);
		ans += e.cost;
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'void ufinit(int)':
a.cc:27:17: error: reference to 'rank' is ambiguous
   27 |                 rank[i] = 0;
      |                 ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:21:5: note:                 'int rank [123456]'
   21 | int rank[123456];
      |     ^~~~
a.cc: In function 'void unionf(int, int)':
a.cc:45:12: error: reference to 'rank' is ambiguous
   45 |         if(rank[x] > rank[y]){
      |            ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:21:5: note:                 'int rank [123456]'
   21 | int rank[123456];
      |     ^~~~
a.cc:45:22: error: reference to 'rank' is ambiguous
   45 |         if(rank[x] > rank[y]){
      |                      ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:21:5: note:                 'int rank [123456]'
   21 | int rank[123456];
      |     ^~~~
a.cc:50:12: error: reference to 'rank' is ambiguous
   50 |         if(rank[x] == rank[y]){
      |            ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:21:5: note:                 'int rank [123456]'
   21 | int rank[123456];
      |     ^~~~
a.cc:50:23: error: reference to 'rank' is ambiguous
   50 |         if(rank[x] == rank[y]){
      |                       ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:21:5: note:                 'int rank [123456]'
   21 | int rank[123456];
      |     ^~~~
a.cc:51:17: error: reference to 'rank' is ambiguous
   51 |                 rank[y]++;
      |                 ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:21:5: note:                 'int rank [123456]'
   21 | int rank[123456];
      |     ^~~~