Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>


using namespace std;

struct edge
{
	int u,v,cost;
};

int n;
int x[10010],y[10010];
int par[11010],rank[10010];
vector<edge> ki;
long long ans;

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

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

void unite(int x,int y)
{
	x = find(x);
	y = find(y);
	if(x == y) return;
	
	if(rank[x] < rank[y]){
		par[x] = y;
	} else{
		par[y] = x;
		if(rank[x] == rank[y])rank[y]++;
	}
}

bool same(int x,int y)
{
	return find(x) == find(y);
}

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

int kruskal()
{
	sort(ki.begin(),ki.end(),comp);
	init_union_find(n);
	int res = 0;
	for(int i = 0;i < ki.size();i++)
	{
		edge e = ki[i];
		if(!same(e.u,e.v))
		{
			unite(e.u,e.v);
			res += e.cost;
		}
	}
	return res;
}




int main()
{
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		cin >> x[i] >> y[i];
	}
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < n;j++)
		{
			edge k;
			k.u = i;k.v = j;
			k.cost = min(abs(x[i]-x[j]),abs(y[i]-y[j]));
//			cout << k.cost << endl;
			ki.push_back(k);
		}
	}
	
	ans = kruskal();
	
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'void init_union_find(int)':
a.cc:26:17: error: reference to 'rank' is ambiguous
   26 |                 rank[i] = 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:17:16: note:                 'int rank [10010]'
   17 | int par[11010],rank[10010];
      |                ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:48:12: error: reference to 'rank' is ambiguous
   48 |         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:17:16: note:                 'int rank [10010]'
   17 | int par[11010],rank[10010];
      |                ^~~~
a.cc:48:22: error: reference to 'rank' is ambiguous
   48 |         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:17:16: note:                 'int rank [10010]'
   17 | int par[11010],rank[10010];
      |                ^~~~
a.cc:52:20: error: reference to 'rank' is ambiguous
   52 |                 if(rank[x] == rank[y])rank[y]++;
      |                    ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:17:16: note:                 'int rank [10010]'
   17 | int par[11010],rank[10010];
      |                ^~~~
a.cc:52:31: error: reference to 'rank' is ambiguous
   52 |                 if(rank[x] == rank[y])rank[y]++;
      |                               ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:17:16: note:                 'int rank [10010]'
   17 | int par[11010],rank[10010];
      |                ^~~~
a.cc:52:39: error: reference to 'rank' is ambiguous
   52 |                 if(rank[x] == rank[y])rank[y]++;
      |                                       ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:17:16: note:                 'int rank [10010]'
   17 | int par[11010],rank[10010];
      |                ^~~~