Language: C++

#include <bits/stdc++.h>
using namespace std;
struct union_find
{
    vector<long long> par;  //親の番号　
    vector<long long> rank; //木の深さ(根のランクは0)
    vector<long long> siz;  //要素xが根なら木の頂点数を格納する
    //初期化子リストを用いた初期化
    union_find(long long N) : par(N), rank(N), siz(N)
    {
        for (long long i = 0; i < N; i++)
        {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    //要素xが所属する木の根を再帰的に発見する
    long long root(long long x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]); //経路圧縮
    }
    //要素xが属する木と要素yが属する木の併合
    void unite(long long x, long long y)
    {
        long long rx = root(x);
        long long ry = root(y);
        if (rx == ry)
            return; //同じ木に属してたらそのまま
        if (rank[rx] < rank[ry])
        {
            par[rx] = ry; //根がryの木に併合
            siz[ry] = siz[rx] + siz[ry];
        }
        else
        {
            par[ry] = rx; //根がrxの木に併合
            siz[rx] = siz[rx] + siz[ry];
            if (rank[rx] == rank[ry])
                rank[rx]++;
        }
    }
    //要素xが属する木と要素yが属する木が同じならtrueを返す
    bool same(long long x, long long y)
    {
        return root(x) == root(y);
    }
    //要素xが属する木の頂点数を返す
    long long size(long long x)
    {
        return siz[root(x)];
    }
};
/*
クラスカル法
kruskal(V,E):無向グラフから最小全域木を作り使われる辺のコストを返す
使用するためにはunion_findが必要
計算量O(ElogV)
*/
struct kruskal_edge
{
    long long u;
    long long v;
    long long cost;
};
//辺のコストの大小を比較
bool kruskal_comp(const kruskal_edge &e1, const kruskal_edge &e2)
{
    return e1.cost < e2.cost;
}
vector<kruskal_edge> kruskal_side;
long long kruskal(long long V, long long E) //V:頂点数,E:辺数
{
    sort(kruskal_side.begin(), kruskal_side.end(), kruskal_comp); //辺のコストが小さい順にソート
    union_find kruskal_tree(V);
    long long kruskal_res = 0;
    for (long long i = 0; i < E; i++)
    {
        kruskal_edge ks = kruskal_side[i];
        if (!kruskal_tree.same(ks.u, ks.v))
        {
            kruskal_tree.unite(ks.u, ks.v);
            kruskal_res += ks.cost;
        }
    }
    return kruskal_res;
}
typedef ll long long;
int main()
{
    ll N;
    cin >> N;
    kruskal_side.resize(2 * (N - 1)); //edgeの本数だけ確保
    map<pair<ll, ll>, ll> field(N);   //ソート後に座標から頂点の番号を特定するのに必要
    vector<pair<ll, ll>> xpairs(N);   //x座標でソート用
    vector<pair<ll, ll>> ypairs(N);   //y座標でソート用
    for (ll i = 0; i < N; i++)
    {
        ll a, b;
        cin >> a >> b;
        pair<ll, ll> P = make_pair(a, b), Q = make_pair(b, a);
        field[P] = i;
        xpairs[i] = P;
        ypairs[i] = Q;
    }
    sort(xpairs.begin(), xpairs.end());
    sort(ypairs.begin(), ypairs.end());
    ll now = 0;
    for (ll i = 0; i < N - 1; i++)
    {
        //xpairs
        kruskal_side[now].u = field[xpairs[i]];
        kruskal_side[now].v = field[xpairs[i + 1]];
        kruskal_side[now].cost = xpairs[i + 1].first - xpairs[i].first;
        now++;
        //ypairs
        kruskal_side[now].u = field[ypairs[i]];
        kruskal_side[now].v = field[ypairs[i + 1]];
        kruskal_side[now].cost = ypairs[i + 1].first - ypairs[i].first;
        now++;
    }
    cout << kruskal(N, 2 * (N - 1)) << endl;
    return 0;
}

Compiler output:
a.cc:90:9: error: 'll' does not name a type
   90 | typedef ll long long;
      |         ^~
a.cc: In function 'int main()':
a.cc:93:5: error: 'll' was not declared in this scope
   93 |     ll N;
      |     ^~
a.cc:94:12: error: 'N' was not declared in this scope
   94 |     cin >> N;
      |            ^
a.cc:96:25: error: template argument 1 is invalid
   96 |     map<pair<ll, ll>, ll> field(N);   //ソート後に座標から頂点の番号を特定するのに必要
      |                         ^
a.cc:96:25: error: template argument 3 is invalid
a.cc:96:25: error: template argument 4 is invalid
a.cc:97:23: error: template argument 1 is invalid
   97 |     vector<pair<ll, ll>> xpairs(N);   //x座標でソート用
      |                       ^~
a.cc:97:23: error: template argument 2 is invalid
a.cc:98:23: error: template argument 1 is invalid
   98 |     vector<pair<ll, ll>> ypairs(N);   //y座標でソート用
      |                       ^~
a.cc:98:23: error: template argument 2 is invalid
a.cc:99:12: error: expected ';' before 'i'
   99 |     for (ll i = 0; i < N; i++)
      |            ^~
      |            ;
a.cc:99:20: error: 'i' was not declared in this scope
   99 |     for (ll i = 0; i < N; i++)
      |                    ^
a.cc:101:11: error: expected ';' before 'a'
  101 |         ll a, b;
      |           ^~
      |           ;
a.cc:102:16: error: 'a' was not declared in this scope
  102 |         cin >> a >> b;
      |                ^
a.cc:102:21: error: 'b' was not declared in this scope
  102 |         cin >> a >> b;
      |                     ^
a.cc:104:14: error: invalid types 'int[int]' for array subscript
  104 |         field[P] = i;
      |              ^
a.cc:106:21: error: 'Q' was not declared in this scope
  106 |         ypairs[i] = Q;
      |                     ^
a.cc:108:17: error: request for member 'begin' in 'xpairs', which is of non-class type 'int'
  108 |     sort(xpairs.begin(), xpairs.end());
      |                 ^~~~~
a.cc:108:33: error: request for member 'end' in 'xpairs', which is of non-class type 'int'
  108 |     sort(xpairs.begin(), xpairs.end());
      |                                 ^~~
a.cc:109:17: error: request for member 'begin' in 'ypairs', which is of non-class type 'int'
  109 |     sort(ypairs.begin(), ypairs.end());
      |                 ^~~~~
a.cc:109:33: error: request for member 'end' in 'ypairs', which is of non-class type 'int'
  109 |     sort(ypairs.begin(), ypairs.end());
      |                                 ^~~
a.cc:110:7: error: expected ';' before 'now'
  110 |     ll now = 0;
      |       ^~~~
      |       ;
a.cc:111:12: error: expected ';' before 'i'
  111 |     for (ll i = 0; i < N - 1; i++)
      |            ^~
      |            ;
a.cc:111:20: error: 'i' was not declared in this scope
  111 |     for (ll i = 0; i < N - 1; i++)
      |                    ^
a.cc:114:22: error: 'now' was not declared in this scope; did you mean 'pow'?
  114 |         kruskal_side[now].u = field[xpairs[i]];
      |                      ^~~
      |                      pow