Language: C++

#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

const int maxn = 1e4+10;
const int maxe = 1e8;
int pa[maxn],rank[maxn];

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

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

void unite(int x,int y){
	x = find(x); y = find(y);

	if(x==y) return ;
	if(rank[x] < rank[y]){
		pa[x] = y;
	}else{
		pa[y] = x;
		if(rank[x] == rank[y])
			++rank[x];
	}
}

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

struct edge{
	int u,v;
	double cost;
	edge(int u=0,int v=0,double cost=0) : u(u),v(v),cost(cost){}
	bool operator<(const edge& rhs) const{
		return cost > rhs.cost;
	}
};
edge es[maxe];
int V,E;

pair<int,int> pile[maxn];

double kruskal(){
	sort(es,es+E);
	init(V);
	double res = 0;
	for(int i=0; i<E; i++){
		edge e = es[i];
		if(!same(e.u,e.v))
			unite(e.u,e.v);
		else
			res += e.cost;
	}

	return res;
}


int main(){
	scanf("%d%d",&V,&E);
	for(int i=0; i<V; i++)
		scanf("%d%d",&pile[i].first,&pile[i].second);

	for(int i=0; i<E; i++){
		scanf("%d%d",&es[i].u,&es[i].v);
		--es[i].u,--es[i].v;
		int dx = pile[es[i].u].first - pile[es[i].v].first;
		int dy = pile[es[i].u].second - pile[es[i].v].second;
		es[i].cost = sqrt(dx*dx+dy*dy);	
	}

	printf("%.3lf\n",kruskal());
}

Compiler output:
a.cc: In function 'void init(int)':
a.cc:17:17: error: reference to 'rank' is ambiguous
   17 |                 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/vector:62,
                 from a.cc:3:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:12:14: note:                 'int rank [10010]'
   12 | int pa[maxn],rank[maxn];
      |              ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:30:12: error: reference to 'rank' is ambiguous
   30 |         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:12:14: note:                 'int rank [10010]'
   12 | int pa[maxn],rank[maxn];
      |              ^~~~
a.cc:30:22: error: reference to 'rank' is ambiguous
   30 |         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:12:14: note:                 'int rank [10010]'
   12 | int pa[maxn],rank[maxn];
      |              ^~~~
a.cc:34:20: error: reference to 'rank' is ambiguous
   34 |                 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:12:14: note:                 'int rank [10010]'
   12 | int pa[maxn],rank[maxn];
      |              ^~~~
a.cc:34:31: error: reference to 'rank' is ambiguous
   34 |                 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:12:14: note:                 'int rank [10010]'
   12 | int pa[maxn],rank[maxn];
      |              ^~~~
a.cc:35:27: error: reference to 'rank' is ambiguous
   35 |                         ++rank[x];
      |                           ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:12:14: note:                 'int rank [10010]'
   12 | int pa[maxn],rank[maxn];
      |              ^~~~
a.cc: In function 'int find(int)':
a.cc:23:20: warning: control reaches end of non-void function [-Wreturn-type]
   23 |         else pa[x] = find(pa[x]);
      |              ~~~~~~^~~~~~~~~~~~~