Language: C++

#include<bits/stdc++.h>
using namespace std;

#define int long long

typedef  pair<int, int> iPair;
struct Graph
{
    int V, E;
    vector< pair<int, iPair> > edges;
    
    Graph(int V, int E)
    {
        this->V = V;
        this->E = E;
    }
    void addEdge(int u, int v, int w)
    {
        edges.push_back({w, {u, v}});
    }
    int kruskalMST();
};

struct data{
	int x, y, weight;
}edge2[100001];
bool cmp1(int a, int b){
	if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true;
	else return false;
}

bool cmp2(int a, int b){
	if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true;
	else return false;
}

struct DisjointSets
{
    int *parent, *rnk;
    int n;
    DisjointSets(int n)
    {
        this->n = n;
        parent = new int[n+1];
        rnk = new int[n+1];
        for (int i = 0; i <= n; i++)
        {
            rnk[i] = 0;
            parent[i] = i;
        }
    }
    int find(int u)
    {
        if (u != parent[u])
            parent[u] = find(parent[u]);
        return parent[u];
    }

    void merge(int x, int y)
    {
        x = find(x), y = find(y);
        if (rnk[x] > rnk[y])
            parent[y] = x;
        else
            parent[x] = y;

        if (rnk[x] == rnk[y])
            rnk[y]++;
    }
};

int Graph::kruskalMST()
{
    int mst_wt = 0;
    sort(edges.begin(), edges.end());
    DisjointSets ds(V);
    vector< pair<int, iPair> >::iterator it;
    for (it=edges.begin(); it!=edges.end(); it++)
    {
        int u = it->second.first;
        int v = it->second.second;

        int set_u = ds.find(u);
        int set_v = ds.find(v);
        if (set_u != set_v)
        {
            cout << u << " - " << v << endl;
            mst_wt += it->first;
            ds.merge(set_u, set_v);
        }
    }

    return mst_wt;
}

int main()
{
	int n, x, y;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x >> y;
		edges2.push_back(make_pair(x, y));
	} 
    Graph(n, 2*(n-1));
    sort(edges2, edges2 + n, cmp1);
    for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second));
    sort(edges2, edges2 + n, cmp2);
    for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second));
    int mst_wt = g.kruskalMST();
    cout << mst_wt;
    return 0;
}

Compiler output:
a.cc: In function 'bool cmp1(long long int, long long int)':
a.cc:28:12: error: 'edges2' was not declared in this scope; did you mean 'edge2'?
   28 |         if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true;
      |            ^~~~~~
      |            edge2
a.cc: In function 'bool cmp2(long long int, long long int)':
a.cc:33:12: error: 'edges2' was not declared in this scope; did you mean 'edge2'?
   33 |         if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true;
      |            ^~~~~~
      |            edge2
At global scope:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:102:17: error: 'edges2' was not declared in this scope; did you mean 'edge2'?
  102 |                 edges2.push_back(make_pair(x, y));
      |                 ^~~~~~
      |                 edge2
a.cc:105:10: error: 'edges2' was not declared in this scope; did you mean 'edge2'?
  105 |     sort(edges2, edges2 + n, cmp1);
      |          ^~~~~~
      |          edge2
a.cc:106:39: error: expected unqualified-id before '.' token
  106 |     for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second));
      |                                       ^
a.cc:108:39: error: expected unqualified-id before '.' token
  108 |     for(int i = 0; i < n-1; i++) Graph.push_back(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second));
      |                                       ^
a.cc:109:18: error: 'g' was not declared in this scope
  109 |     int mst_wt = g.kruskalMST();
      |                  ^
a.cc: In function 'bool cmp1(long long int, long long int)':
a.cc:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^
a.cc: In function 'bool cmp2(long long int, long long int)':
a.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^