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]
int y[10010];
int par[11010]
int 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:17:1: error: expected initializer before 'int'
   17 | int y[10010];
      | ^~~
a.cc:19:1: error: expected initializer before 'int'
   19 | int rank[10010];
      | ^~~
a.cc: In function 'void init_union_find(int)':
a.cc:27:17: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   27 |                 par[i] = i;
      |                 ^~~
      |                 __pstl::execution::v1::par
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from a.cc:5:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:28:22: error: redeclaration of 'auto i'
   28 |                 rank[i] = 0;
      |                      ^
a.cc:25:17: note: 'int i' previously declared here
   25 |         for(int i = 0;i < n;i++)
      |                 ^
a.cc:28:27: error: class template argument deduction failed:
   28 |                 rank[i] = 0;
      |                           ^
a.cc:28:27: error: no matching function for call to 'rank(int)'
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: candidate: 'template<class> rank()-> std::rank< <template-parameter-1-1> >'
 1437 |     struct rank
      |            ^~~~
/usr/include/c++/14/type_traits:1437:12: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/type_traits:1437:12: note: candidate: 'template<class> rank(std::rank< <template-parameter-1-1> >)-> std::rank< <template-parameter-1-1> >'
/usr/include/c++/14/type_traits:1437:12: note:   template argument deduction/substitution failed:
a.cc:28:27: note:   mismatched types 'std::rank< <template-parameter-1-1> >' and 'int'
   28 |                 rank[i] = 0;
      |                           ^
a.cc: In function 'int find(int)':
a.cc:34:12: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   34 |         if(par[x] == x)
      |            ^~~
      |            __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc: In function 'void unite(int, int)':
a.cc:50:16: error: expected unqualified-id before '[' token
   50 |         if(rank[x] < rank[y]){
      |                ^
a.cc:51:17: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   51 |                 par[x] = y;
      |                 ^~~
      |                 __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:53:17: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   53 |                 par[y] = x;
      |                 ^~~
      |                 __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:54:24: error: expected unqualified-id before '[' token
   54 |                 if(rank[x] == rank[y])rank[y]++;
      |                        ^
a.cc:54:46: error: expected initializer before '++' token
   54 |                 if(rank[x] == rank[y])rank[y]++;
      |                                              ^~
a.cc:54:46: error: expected ';' before '++' token
a.cc: In function 'int main()':
a.cc:93:24: error: 'x' was not declared in this scope
   93 |                 cin >> x[i] >> y[i];
      |                        ^
a.cc:93:32: error: 'y' was not declared in this scope
   93 |                 cin >> x[i] >> y[i];
      |                                ^
a.cc:101:42: error: 'x' was not declared in this scope
  101 |                         k.cost = min(abs(x[i]-x[j]),abs(y[i]-y[j]));
      |                                          ^
a.cc:101:57: error: 'y' was not declared in this scope
  101 |                         k.cost = min(abs(x[i]-x[j]),abs(y[i]-y[j]));
      |                                                         ^