Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
#define MAX 100001
struct edge{int u,v,cost;};
pair<int,int>a[MAX];
int par[MAX];
int rank[MAX];
void init(int n){
  r(i,n){
    par[i]=i;
    rank[i]=0;
  }
}
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}
void unit(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[x]++;
  }
}
bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}
bool same(int x,int y){
  return find(x)==find(y);
}
vector<edge> es;
int V,E;
int prim(){
  sort(es.begin(),es.end(),comp);
  init(V);
  int res=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unit(e.u,e.v);
      res+=e.cost;
    }
  }
  return res;
}
main(){
  cin>>V;
  r(i,V){
    cin>>a[i].first>>a[i].second;
  }
  r(i,V)r(j,V){
    edge e;
    e.u=i;
    e.v=j;E++;
    e.cost=min(abs(a[i].first-a[j].first),abs(a[i].second-a[j].second));
  }
  cout<<prim()<<endl;
}

Compiler output:
a.cc: In function 'void init(long long int)':
a.cc:13:5: error: reference to 'rank' is ambiguous
   13 |     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:9:5: note:                 'long long int rank [100001]'
    9 | int rank[MAX];
      |     ^~~~
a.cc: In function 'void unit(long long int, long long int)':
a.cc:27:6: error: reference to 'rank' is ambiguous
   27 |   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:9:5: note:                 'long long int rank [100001]'
    9 | int rank[MAX];
      |     ^~~~
a.cc:27:14: error: reference to 'rank' is ambiguous
   27 |   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:9:5: note:                 'long long int rank [100001]'
    9 | int rank[MAX];
      |     ^~~~
a.cc:31:8: error: reference to 'rank' is ambiguous
   31 |     if(rank[x]==rank[y])rank[x]++;
      |        ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:9:5: note:                 'long long int rank [100001]'
    9 | int rank[MAX];
      |     ^~~~
a.cc:31:17: error: reference to 'rank' is ambiguous
   31 |     if(rank[x]==rank[y])rank[x]++;
      |                 ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:9:5: note:                 'long long int rank [100001]'
    9 | int rank[MAX];
      |     ^~~~
a.cc:31:25: error: reference to 'rank' is ambiguous
   31 |     if(rank[x]==rank[y])rank[x]++;
      |                         ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:9:5: note:                 'long long int rank [100001]'
    9 | int rank[MAX];
      |     ^~~~
a.cc: At global scope:
a.cc:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main(){
      | ^~~~