criyle/codenet-compile-errors huggingface dataset:
Language: C++

#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <set>
#include <list>

using namespace std;

typedef struct {
    int x, y;
} pos_t;

typedef struct {
    pos_t *a, *b;
} path_t;

path_t make_path(pos_t *a, pos_t *b) {
    path_t t;
    t.a = a;
    t.b = b;
    return t;
}


int main() {
    int n = 0;
    scanf("%d", &n);
    pos_t *p = (pos_t *) malloc(sizeof(pos_t) * n);
    pos_t **px = (pos_t **) malloc(sizeof(pos_t *) * n);
    pos_t **py = (pos_t **) malloc(sizeof(pos_t *) * n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &p[i].x, &p[i].y);
        px[i] = py[i] = &p[i];
    }
    auto cpx = [](pos_t *a, pos_t *b) { return a->x < b->x; };
    auto cpy = [](pos_t *a, pos_t *b) { return a->y < b->y; };
    sort(px, px + n, cpx);
    sort(py, py + n, cpy);
    auto dist = [](path_t &a) {
        return min(abs(a.a->x - a.b->x), abs(a.a->y - a.b->y));
    };
    auto comp = [&dist](path_t &a, path_t &b) {
        return dist(a) > dist(b);
    };
    priority_queue<path_t, deque<path_t>, typeof(comp)> q(comp);
    set<pos_t *> t;
    int r = 0;
    t.insert(&p[0]);
    
    auto rx = lower_bound(px, px + n, p.b, cpx);
    auto ry = lower_bound(py, py + n, p.b, cpy);
    if (rx != px) q.push(make_path(*rx, *(rx - 1)));
    if (rx + 1 != px + n) q.push(make_path(*rx, *(rx + 1)));
    if (ry != py) q.push(make_path(*ry, *(ry - 1)));
    if (ry + 1 != py + n) q.push(make_path(*ry, *(ry + 1)));
    
    while (t.size() != n) {
        auto p = q.top();
        q.pop();
        if (t.find(p.b) != t.end()) {
            continue;
        }
        r += dist(p);
        t.insert(p.b);
        auto rx = lower_bound(px, px + n, p.b, cpx);
        auto ry = lower_bound(py, py + n, p.b, cpy);
        if (rx != px) q.push(make_path(*rx, *(rx - 1)));
        if (rx + 1 != px + n) q.push(make_path(*rx, *(rx + 1)));
        if (ry != py) q.push(make_path(*ry, *(ry - 1)));
        if (ry + 1 != py + n) q.push(make_path(*ry, *(ry + 1)));
    }
    printf("%d\n", r);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:41: error: request for member 'b' in 'p', which is of pointer type 'pos_t*' (maybe you meant to use '->' ?)
   62 |     auto rx = lower_bound(px, px + n, p.b, cpx);
      |                                         ^
a.cc:63:41: error: request for member 'b' in 'p', which is of pointer type 'pos_t*' (maybe you meant to use '->' ?)
   63 |     auto ry = lower_bound(py, py + n, p.b, cpy);
      |                                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long;
const int N = 200000+5;
struct Edge{
    int x,y;
    int dis;
    Edge(int x,int y,int dis):x(x),y(y),dis(dis){}
    bool operator <(const Edge &rhs)const{
        return dis<rhs.dis;
    }
}edge[N];
int tot;
struct Node{
    int x,y;
}node[N];
int father[N];
 
bool cmpX(int a,int b){
    return node[a].x<node[b].x;
}
bool cmpY(int a,int b){
    return node[a].y<node[b].y;
}
int Find(int x){
    if(father[x]!=x)
        return father[x]=Find(father[x]);
    return x;
}
int n;
int Kruskal(){
    for(int i=1;i<=n;i++)
        father[i]=i;
 
    int mst=0;
    sort(edge+1,edge+1+tot);
    for(int i=1;i<=tot;i++){
        int x=Find(edge[i].x);
        int y=Find(edge[i].y);
        if(x!=y){
            mst+=edge[i].dis;
            father[x]=y;
        }
    }
    return mst;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&node[i].x,&node[i].y);
 
    for(int i=1;i<=n;i++)
        father[i]=i;
    sort(father+1,father+1+n,cmpX);
    for(int i=1;i<n;i++){
        int x=father[i];
        int y=father[i+1];
        int dis=node[y].x-node[x].x;
        edge[++tot]=Edge(x,y,dis);
    }
    for(int i=1;i<=n;i++)
        father[i]=i;
    sort(father+1,father+1+n,cmpY);
    for(int i=1;i<n;i++){
        int x=father[i];
        int y=father[i+1];
        int dis=node[y].y-node[x].y;
        edge[++tot]=Edge(x,y,dis);
    }
 
    int mst=Kruskal();
    printf("%d\n",mst);
    return 0;
}

Compiler output:
a.cc:3:14: error: declaration does not declare anything [-fpermissive]
    3 | typedef long long;
      |              ^~~~
a.cc:12:8: error: no matching function for call to 'Edge::Edge()'
   12 | }edge[N];
      |        ^
a.cc:8:5: note: candidate: 'Edge::Edge(int, int, int)'
    8 |     Edge(int x,int y,int dis):x(x),y(y),dis(dis){}
      |     ^~~~
a.cc:8:5: note:   candidate expects 3 arguments, 0 provided
a.cc:5:8: note: candidate: 'constexpr Edge::Edge(const Edge&)'
    5 | struct Edge{
      |        ^~~~
a.cc:5:8: note:   candidate expects 1 argument, 0 provided
a.cc:5:8: note: candidate: 'constexpr Edge::Edge(Edge&&)'
a.cc:5:8: note:   candidate expects 1 argument, 0 provided
Language: C++

///....DH....///
#include <bits/stdc++.h>
#define task                "Built"
#define fi(a)               freopen(a, "r", stdin)
#define fo(a)               freopen(a, "w", stdout)

#define pii                 pair<int, int>
#define ft                  first
#define sd                  second
#define mp                  make_pair

#define pb                  push_back
#define pf                  push_front
#define popb                pop_back
#define popf                pop_front

#define reset(a, x)         memset(a, x, sizeof(a))
#define For(i, s, n, m)     for(int i = s; i <= n; i += m)
#define Ford(i, s, n, m)    for(int i = s; i >= n; i -= m)

using namespace std;

template <typename R, typename D> inline void Min(R &a, D b) {
    if(a>b)
        a=b;
}
template <typename D, typename R> inline void Max(D &a, R b) {
    if(a<b)
        a=b;
}

/** MOD **/                 const long long mod = 1e9 + 7;
/** size of array **/       const int maxn = 200005;
/** PI **/                  const double M_PI = 3.14159265358979323846;

struct edge {
    int x, y, w;
    bool operator < (const edge &P) {
        return w < P.w;
    }
} a[maxn], b[maxn];
int cnt, n, res, p[maxn];

bool cmpx (edge P, edge Q) {
    return P.x < Q.x;
}

bool cmpy (edge P, edge Q) {
    return P.y < Q.y;
}

int Find(int u) {
    if(u == p[u])
        return u;
    return p[u] = Find(p[u]);
}

int dsu(edge e) {
    int x = Find(e.x);
    int y = Find(e.y);
    if(x == y)
        return 0;
    p[x] = y;
    return e.w;
}

main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    fi(task".inp");
    fo(task".out");
#endif
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].x >> a[i].y;
        a[i].w = i;
    }
    sort(a + 1, a + n + 1, cmpx);
    for(int i = 1; i < n; i++) {
        b[++cnt].x = a[i].w;
        b[cnt].y = a[i + 1].w;
        b[cnt].w = min(abs(a[i].x - a[i + 1].x), abs(a[i].y - a[i + 1].y));
    }
    sort(a + 1, a + n + 1, cmpy);
    for(int i = 1; i < n; i++) {
        b[++cnt].x = a[i].w;
        b[cnt].y = a[i + 1].w;
        b[cnt].w = min(abs(a[i].x - a[i + 1].x), abs(a[i].y - a[i + 1].y));
    }
    sort(b + 1, b + cnt + 1);
    for(int i = 1; i <= n; i++)
        p[i] = i;
    for(int i = 1; i <= cnt; i++) {
        res += dsu(b[i]);
    }
    cout << res;
}
//6 8 3 4 9 12 19 18 1 13 5 7 6 -> 8


Compiler output:
In file included from /usr/include/c++/14/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:114,
                 from a.cc:2:
a.cc:34:42: error: expected unqualified-id before numeric constant
   34 | /** PI **/                  const double M_PI = 3.14159265358979323846;
      |                                          ^~~~
a.cc:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main() {
      | ^~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

class UnionFind {
public:
    vector<int> parent;  //親ノード
    vector<int> Siz;  //集合の大きさ

    // コンストラクタ
    UnionFind(int n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(int n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    int root(int x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {

        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }

    // xとyが同じ集合に属するかどうか
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    int size(int x) {
        return Siz[root(x)];
    }
};

int main() {
    int n;
    cin >> n;

    vector<ll> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    // Kruskal法で使用する枝
    using Edge = pair<ll, pair<int, int>>;
    vector<Edge> edges;

    // x軸方向にソートして隣接している部分のみ
    vector<int> ids(n);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) { return x[i] < x[j]; });
    for(int i = 0; i+1 < ids.size(), i++) {
        int u = ids[i];
        int v = ids[i+1];
        edges.push_back(Edge(x[v] - x[u], make_pair(u, v)));
    }

    // y軸方向にソートして隣接している部分のみ
    sort(ids.begin(), ids.end(), [&](int i, int j) { return y[i] < y[j]; });
    for(int i = 0; i+1 < ids.size(), i++) {
        int u = ids[i];
        int v = ids[i+1];
        edges.push_back(Edge(y[v] - y[u], make_pair(u, v)));
    }

    // Kruskal法
    sort(edges.begin(), edges.end());
    UnionFind Uni(n);
    ll ans = 0;
    for(auto e : edges) {

        int u = e.second.first;
        int v = e.second.second;
        ll cost = e.first;

        if(Uni.same(u, v)) {
            continue;
        }

        Uni.unite(u, v);
        ans += cost;
    }

    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:41: error: expected ';' before ')' token
   93 |     for(int i = 0; i+1 < ids.size(), i++) {
      |                                         ^
      |                                         ;
a.cc:101:41: error: expected ';' before ')' token
  101 |     for(int i = 0; i+1 < ids.size(), i++) {
      |                                         ^
      |                                         ;
Language: C++

# include <iostream>
# include <vector>

typedef long long ll;
using namespace std;

struct UnionFind {
    vector<int> parent;
    UnionFind(int n) : parent(n) {
        for (int i = 0; i < n; i++) parent[i] = i;
    }

    int root(int n) {
        if (parent[n] == n) return n;
        return parent[n] = root(parent[n]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        parent[rx] = ry;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<pair<int, int>> xBased(n), yBased(n);
    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        xBased[i] = { x, i };
        yBased[i] = { y, i };
    }
    sort(xBased.begin(), xBased.end());
    sort(yBased.begin(), yBased.end());
    vector<tuple<int, int, int>> costs;
    for (int i = 1; i < n; i++) {
        int xdiff = xBased[i].first - xBased[i-1].first;
        int ydiff = yBased[i].first - yBased[i-1].first;
        costs.push_back({ xdiff, xBased[i].second, xBased[i-1].second });
        costs.push_back({ ydiff, yBased[i].second, yBased[i-1].second });
    }
    sort(costs.begin(), costs.end());
    UnionFind tree(n);
    ll ans = 0;
    for (auto& cost : costs) {
        int c = get<0>(cost);
        int f = get<1>(cost);
        int s = get<2>(cost);
        if (tree.root(f) != tree.root(s)) {
            tree.unite(f, s);
            ans += c;
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   36 |     sort(xBased.begin(), xBased.end());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

// union-find
const int MAX_N = 1e5+1;

int parent[MAX_N];
int root(int x) {
  if (parent[x] == x)
    return x;
  return parent[x] = root(parent[x]);
}
void unite(int x, int y) {
  if (root(x) == root(y))
    return;
  x = root(x);
  y = root(y);
  parent[x] = y;
  return;
}
bool same(int x, int y) {
  return root(x) == root(y);
}
// end

int main() {
  cin.tie(0); ios::sync_with_stdio(false);

  int N; in(N);

  pii x[N], y[N];
  rep(i, N) {
    in(x[i].first); in(y[i].first);
    x[i].second = y[i].second = i;
    parent[i] = i;
  }
  sort(x, x+N); sort(y, y+N);
  pair<int, pii> diff_x[N-1], diff_y[N-1];

  rep(i, N-1) {
    diff_x[i].first = x[i+1].first - x[i].first;
    diff_y[i].first = y[i+1].first - y[i].first;
    diff_x[i].second = pii(x[i].second, x[i+1].second);
    diff_y[i].second = pii(y[i].second, y[i+1].second);
  }
  sort(diff_x, diff_x+N-1); sort(diff_y, diff_y+N-1);
  ll ans = 0;
  rep(i, N-1) {
    int cost1 = diff_x[i].first;
    int cost2 = diff_y[i].first;
    int x1 = diff_x[i].second.first,
        x2 = diff_x[i].second.second;
    int y1 = diff_y[i].second.first,
        y2 = diff_y[i].second.second;
    if (cost1 < cost2) {
      if (!same(x1, x2)) {
        unite(x1, x2);
        ans += cost1;
      }
    } else {
      if (!same(y1, y2)) {
        unite(y1, y2);
        ans += cost2;
      }
    }
    if (!same(x1, x2)) {
      unite(x1, x2);
      ans += cost1;
    }
    if (!same(y1, y2)) {
      unite(y1, y2);
      ans += cost2;
    }
  }
  out(ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:3: error: 'll' was not declared in this scope
   53 |   ll ans = 0;
      |   ^~
a.cc:64:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   64 |         ans += cost1;
      |         ^~~
      |         abs
a.cc:69:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   69 |         ans += cost2;
      |         ^~~
      |         abs
a.cc:74:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   74 |       ans += cost1;
      |       ^~~
      |       abs
a.cc:78:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   78 |       ans += cost2;
      |       ^~~
      |       abs
a.cc:81:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   81 |   out(ans);
      |       ^~~
a.cc:8:22: note: in definition of macro 'out'
    8 | #define out(v) cout<<v<<"\n"
      |                      ^
Language: C++

#include<iostream>

using namespace std;

int main(
{
return 0;
}

Compiler output:
a.cc:5:5: error: cannot declare '::main' to be a global variable
    5 | int main(
      |     ^~~~
a.cc:7:1: error: expected primary-expression before 'return'
    7 | return 0;
      | ^~~~~~
a.cc:7:1: error: expected '}' before 'return'
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
a.cc:6:2: error: expected ')' before 'return'
    6 | {
      |  ^
      |  )
    7 | return 0;
      | ~~~~~~
a.cc:5:9: note: to match this '('
    5 | int main(
      |         ^
a.cc:8:1: error: expected declaration before '}' token
    8 | }
      | ^
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }
 
   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

struct edge{int u,v,cost;};
bool comp(const edge& e1, const edge& e2){
  return e1.cost<e2.cost;
}
edge es[100010];
int V;
ll E;

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

int main(){
  cin >> V;
  E=2*(V-1);
  pint x[V],y[V];
  rep(i,V){
    cin >> x[i].first >> y[i].first;
    x[i].second=i;
    y[i].second=i;
    y[i].first--,x[i].first--;
  }
  sort(x,x+V);
  sort(y,y+V);
  rep(i,V-1){
    es[2*i]={x[i].second,x[i+1].second,x[i+1].first-x[i].first};
    es[2*i+1]={y[i].second,y[i+1].second,y[i+1].first-y[i].first};
  }
  int ans=0;
//  ans=kruskal();
  cout << ans << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:94:23: error: expected '}' at end of input
   94 |   cout << ans << endl;
      |                       ^
a.cc:76:11: note: to match this '{'
   76 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }
 
   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

struct edge{int u,v,cost;};
bool comp(const edge& e1, const edge& e2){
  return e1.cost<e2.cost;
}
edge es[100010];
int V;
ll E;

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

int main(){
  cin >> V;
  E=2*(V-1);
  pint x[V],y[V];
  rep(i,V){
    cin >> x[i].first >> y[i].first;
    x[i].second=i;
    y[i].second=i;
    y[i].first--,x[i].first--;
  }
  sort(x,x+V);
  sort(y,y+V);
  rep(i,V-1){
    es[2*i]={x[i].second,x[i+1].second,x[i+1].first-x[i].first};
    es[2*i+1]={y[i].second,y[i+1].second,y[i+1].first-y[i].first};
  }
//  int ans=kruskal();
  cout << ans << endl;
return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   93 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

struct UnionFind() {
    vector<int> par;
    UnionFind(itn n) : par(n, -1) {}
    int root(int x) {
        if(par[x] < 0)
            return 0;
        else
            return par[x] = root(par[x]);
    }
    int issame(int x, int y) { return root(x) == root(y); }
    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y)
            return;
        if(-par[x] < -par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
};
// http://drken1215.hatenablog.com/entry/2019/02/14/124300
int main() {
    int N;
    cin >> N;
    vector<long long> x(N), y(N);
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }
    using pint = pair<int, int>;
    using Edge = pair<long long, pint>;
    vecto<Edge> edges;
    // x軸にソートして隣接している部分のみ
    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) { return x[i] < x[k]; });
    for(int i = 0; i < ids.size() - 1; i++) {
        int u = ids[i];
        int v = ids[i + 1];
        edges.push_back(Edge(x[v] - x[u], pint(u, v)));
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) { return y[i] < y[j]; });
    for(int i = 0; i + 1 < ids.size(); ++i) {
        int u = ids[i], v = ids[i + 1];
        edges.push_back(Edge(y[v] - y[u], pint(u, v)));
    }
    //ここまでで辺を作る
    sort(edges.begin(), edge.end());
    UnionFind uf(N);
    long long res = 0;
    for(auto e : edges) {
        int u = e.second.first;
        int v = e.second.second;
        long long cost = e.first;
        if(uf.issame(u, v))
            continue;
        uf.merge(u, v);
        res += cost;
    }
    cout << res << endl;
}

Compiler output:
a.cc:7:18: error: expected unqualified-id before ')' token
    7 | struct UnionFind() {
      |                  ^
a.cc: In function 'int main()':
a.cc:38:5: error: 'vecto' was not declared in this scope
   38 |     vecto<Edge> edges;
      |     ^~~~~
a.cc:38:15: error: expected primary-expression before '>' token
   38 |     vecto<Edge> edges;
      |               ^
a.cc:38:17: error: 'edges' was not declared in this scope
   38 |     vecto<Edge> edges;
      |                 ^~~~~
a.cc: In lambda function:
a.cc:42:70: error: 'k' was not declared in this scope
   42 |     sort(ids.begin(), ids.end(), [&](int i, int j) { return x[i] < x[k]; });
      |                                                                      ^
a.cc: In function 'int main()':
a.cc:54:25: error: 'edge' was not declared in this scope; did you mean 'Edge'?
   54 |     sort(edges.begin(), edge.end());
      |                         ^~~~
      |                         Edge
a.cc:55:19: error: variable 'UnionFind uf' has initializer but incomplete type
   55 |     UnionFind uf(N);
      |                   ^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;		// 要素数
	cin >> n;
	int* x = new int[n];
	int* y = new int[n];
	int* q = new int[n] {0};	// 道が出来たか
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
	}

	int money = 0;
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		if (q[i] <= 0)
		{
			long min = -1;
			int another;
			for (int j = 0; j < n; j++)
			{
				if (i != j)
				{
					long road = fminl(fabsl(x[i] - x[j]), fabsl(y[i] - y[j]));
					if (min < 0 || min > road)
					{
						min = road;
						another = j;
						if (min == 0)
							break;
					}
				}
			}

			if (q[another] > 0)
			{
				q[i] = q[another];
			}
			else
			{
				index++;
				q[i] = index;
				q[another] = index;
			}
			money += min;
		}
	}
	while (index > 1)
	{
		index = 1;
		int one = q[0];
		long min = -1;
		int another;
		for (int i = 0; i < n; i++)
		{
			if (q[i] != one) continue;
			for (int j = 0; j < n; j++)
			{
				if (one == q[j]) continue;
				long road = fminl(fabsl(x[i] - x[j]), fabsl(y[i] - y[j]));
				if (min < 0 || min > road)
				{
					min = road;
					another = j;
					if (min == 0)
						break;
				}
			}
			if (min == 0)
				break;
		}

		if (min >= 0)
		{
			index = q[another];
			int index2 = 1;
			for (int j = 0; j < n; j++)
			{
				if (q[j] == index)
					q[j] = one;
				else if (q[j] != one)
					index2 = q[j];
			}
			index = index2;
			money += min;
		}
	}

	cout << money << '\n';

	delete[] x;
	delete[] y;
	return 0;
}


/*
6
1	8 3
1	4 9
2	12 19
1	18 1
2	13 5
1	7 6


N 3
x y
1 5
3 9
7 8
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:33:59: error: 'fabsl' was not declared in this scope
   33 |                                         long road = fminl(fabsl(x[i] - x[j]), fabsl(y[i] - y[j]));
      |                                                           ^~~~~
a.cc:33:53: error: 'fminl' was not declared in this scope; did you mean 'min'?
   33 |                                         long road = fminl(fabsl(x[i] - x[j]), fabsl(y[i] - y[j]));
      |                                                     ^~~~~
      |                                                     min
a.cc:69:51: error: 'fabsl' was not declared in this scope
   69 |                                 long road = fminl(fabsl(x[i] - x[j]), fabsl(y[i] - y[j]));
      |                                                   ^~~~~
a.cc:69:45: error: 'fminl' was not declared in this scope; did you mean 'min'?
   69 |                                 long road = fminl(fabsl(x[i] - x[j]), fabsl(y[i] - y[j]));
      |                                             ^~~~~
      |                                             min
Language: C++

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

class union_find{
  int n_; 
  vector<int> par, rank, size;
public:
  union_find(int n): n_{n} {
    par.resize(n_);
    rank.resize(n_);
    size.resize(n_);

    REP(i, n_){
      par[i] = i;
      rank[i] = 1;
      size[i] = 1;
    }
  } 

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

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

    if(x == y) return;

    if(rank[x] > rank[y]){
      par[y] = x;
      size[x] += size[y];
    } else {
      par[x] = y;
      size[y] += size[x];
      if(rank[x] == rank[y]) rank[y]++;
    }
  }

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

  vector<int> get_par(){ return par; }
};

struct edge{ int u, v; ll w; };

ll kruskal(int n, vector<edge> edges) {
  sort(edges.begin(), edges.end(), [](const edge& e1, const edge& e2){
    return e1.w < e2.w;
  });

  union_find uf(n);
  ll ret = 0;

  for(const auto& edge: edges){
    if(!uf.same(edge.u, edge.v)){
      uf.unite(edge.u, edge.v);
      ret += edge.w;
    }
  }

  return ret;
}

struct node{ int v; ll x, y; };

int main() {
  int n; cin >> n  vector<node> p(n), q(n);
  REP(i, n){
    ll x, y; cin >> x >> y;
    p[i] = {i, x, y};
    q[i] = {i, y, x};
  }

  vector<edge> edges;

  function<void(vector<node>&)> addEdge = [&](vector<node>& v){
    sort(v.begin(), v.end(), [](node& a, node& b){
      return a.x < b.x;
    });

    REP(i, n-1){
      ll dx = abs(v[i].x - v[i+1].x), dy = abs(v[i].y - v[i+1].y);
      edges.push_back({v[i].v, v[i+1].v, min(dx, dy)});
    }
  };

  addEdge(p);
  addEdge(q);
    
  cout << kruskal(n, edges) << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:84:18: error: expected ';' before 'vector'
   84 |   int n; cin >> n  vector<node> p(n), q(n);
      |                  ^ ~~~~~~
      |                  ;
a.cc:87:5: error: 'p' was not declared in this scope
   87 |     p[i] = {i, x, y};
      |     ^
a.cc:88:5: error: 'q' was not declared in this scope
   88 |     q[i] = {i, y, x};
      |     ^
a.cc:104:11: error: 'p' was not declared in this scope
  104 |   addEdge(p);
      |           ^
a.cc:105:11: error: 'q' was not declared in this scope
  105 |   addEdge(q);
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    void merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return;
        if (-par[x] < -par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
};
    
int main() {
    int N; cin >> N;
    vector<long long> x(N), y(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];

    // Kruskal 法に使う枝 (絞られたもの)
    using pint = pair<int,int>;
    using Edge = pair<long long, pint>;
    vector<Edge> edges;

    // x 軸方向について隣接二点のみ
    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) { return x[i] < x[j]; });
    for (int i = 0; i+1 < ids.size(); ++i) {
        int u = ids[i], v = ids[i+1];
        edges.push_back(Edge(x[v] - x[u], pint(u, v)));
    }

    // y 軸方向について隣接二点のみ
    sort(ids.begin(), ids.end(), [&](int i, int j) { return y[i] < y[j]; });
    for (int i = 0; i+1 < ids.size(); ++i) {
        int u = ids[i], v = ids[i+1];
        edges.push_back(Edge(y[v] - y[u], pint(u, v)));
    }

    // Kruskal 法
    sort(edges.begin(), edges.end());
    UnionFind uf(N);
    long long res = 0;
    for (auto e : edges) {
        int u = e.second.first, v = e.second.second;
        long long cost = e.first;
        if (uf.issame(u, v)) continue;
        uf.merge(u, v);
        res += cost;
    }
    cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   38 |     sort(ids.begin(), ids.end(), [&](int i, int j) { return x[i] < x[j]; });
      |     ^~~~
      |     short
Language: C

N = input()

data = [map(int,raw_input().split()) for i in range(N)]

def hoge(x,y):
    return x[1]-y[1]

data.sort()

for i in range(1,N-1):
    data[i].append(min(data[i+1][0]-data[i][0],data[i][0]-data[i-1][0]))
data[0].append(data[1][0]-data[0][0])
data[N-1].append(data[N-1][0]-data[N-2][0])


data.sort(hoge)
for i in range(1,N-1):
    data[i].append(min(data[i+1][1]-data[i][1],data[i][1]-data[i-1][1]))
data[0].append(data[1][1]-data[0][1])
data[N-1].append(data[N-1][1]-data[N-2][1])

ans = 0
minimam = 10000000000
for i in range(N):
    ans += min(data[i][2],data[i][3])
    minimam = min(minimam,min(data[i][2],data[i][3]))

print ans-minimam

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | N = input()
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'N' [-Wimplicit-int]
main.c:1:5: error: implicit declaration of function 'input' [-Wimplicit-function-declaration]
    1 | N = input()
      |     ^~~~~
main.c:1:5: error: initializer element is not constant
main.c:3:1: error: expected ',' or ';' before 'data'
    3 | data = [map(int,raw_input().split()) for i in range(N)]
      | ^~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

const int MAX_V = 1e5;
const int MAX_N = 1e5;
const int MAX_E = 1e5 * (1e5 - 1) / 2;
struct edge {int u, v, cost; };
vector<pair<int, int> > coo;

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

edge es[MAX_E];
int V, E;

int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ

// n要素で初期化
void init(int n) {
	rep(i, 0, n) {
		par[i] = i;
		depth[i] = 0;
	}
}

// 木の根を求める
int find(int x) {
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(depth[x] < depth[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if(depth[x] == depth[y]) depth[x]++;
	}
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> V;
	E = V * (V - 1) / 2;
	rep(i, 0, V) {
		int x, y;
		cin >> x >> y;
		coo.push_back(make_pair(x, y));
	}

	int cnt = 0;
	rep(i, 0, V) {
		rep(j, i + 1, V) {
			int a, b, c, d;
			a = coo[i].first;
			b = coo[i].second;
			c = coo[j].first;
			d = coo[j].second;

			edge e;
			e.u = i;
			e.v = j;
			e.cost = min(abs(a - c), abs(b - d));
			es[cnt++] = e;
		}
	}
	cout << kruskal() << endl;
}


Compiler output:
a.cc:32:35: warning: overflow in conversion from 'double' to 'int' changes value from '4.99995e+9' to '2147483647' [-Woverflow]
   32 | const int MAX_E = 1e5 * (1e5 - 1) / 2;
      |                   ~~~~~~~~~~~~~~~~^~~
a.cc:40:9: error: size of array 'es' exceeds maximum object size '9223372036854775807'
   40 | edge es[MAX_E];
      |         ^~~~~
Language: C++

//
//  abc065d.cpp
//
//
//  Created by Yoshida Satoshi on 2018/11/09.
//

#include <stdio.h>
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>

#define MAX 100005

using namespace std;

typedef long long ll;

struct Path
{
    int from,to,cost;
    
    bool operator<(const Path& rhs)const
    {
        return cost<rhs.cost;
    }
};

struct UF
{
    vector<int> par;
    
    UF(int n):par(n)
    {
        for(int i=0;i<n;i++) par[i]=i;
    }
    
    int root(int x)
    {
        if(par[x]==x) return x;
        else          return par[x]=root(par[x]);
    }
    
    void unite(int x,int y)
    {
        int rx=root(x);
        int ry=root(y);
        
        par[rx]=ry;
    }
    
    bool same(int x,int y)
    {
        int rx=root(x);
        int ry=root(y);
        
        return rx==ry;
    }
};

struct V
{
    int pos,index;
    bool operator<(const V& rhs)const
    {
        return pos<rhs.pos;
    }
}

int main()
{
    int n;
    cin>>n;
    vector<Path> p;
    int x[MAX],y[MAX];
    V vx[MAX],vy[MAX];
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        vx[i]={x[i],i};
        vy[i]={y[i],i};
    }
    sort(vx,vx+n);
    sort(vy,vy+n);
    for(int i=0;i<n-1;i++)
    {
        p.push_back({vx[i].index,vx[i+1].index,vx[i+1].pos-vx[i].pos});
        p.push_back({vy[i].index,vy[i+1].index,vy[i+1].pos-vy[i].pos});
    }
    UF uf(n);
    
    ll ans=0;
    for(int i=0;i<p.size();i++)
    {
        int from=p[i].from;
        int to=p[i].to;
        int cost=p[i].cost;
        
        if(!uf.same(from,to))
        {
            uf.unite(from,to);
            ans+=cost;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:70:2: error: expected ';' after struct definition
   70 | }
      |  ^
      |  ;
Language: C++

//
//  abc065d.cpp
//
//
//  Created by Yoshida Satoshi on 2018/11/09.
//

#include <stdio.h>
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>

#define MAX 100005

using namespace std;

typedef long long ll;

struct Path
{
    int from,to,cost;
    
    bool operator<(const Path& rhs)const
    {
        return cost<rhs.cost;
    }
};

struct UF
{
    vector<int> par;
    
    UF(int n):par(n)
    {
        for(int i=0;i<n;i++) par[i]=i;
    }
    
    int root(int x)
    {
        if(par[x]==x) return x;
        else          return par[x]=root(par[x]);
    }
    
    void unite(int x,int y)
    {
        int rx=root(x);
        int ry=root(y);
        
        par[rx]=ry;
    }
    
    bool same(int x,int y)
    {
        int rx=root(x);
        int ry=root(y);
        
        return rx==ry;
    }
};

struct V
{
    int pos,index;
    bool operator<(const V& rhs)const
    {
        return pos<rhs.pos;
    }
}

int main()
{
    int n;
    cin>>n;
    vector<Path> p;
    int x[MAX],y[MAX];
    V vx[MAX],vy[MAX];
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        vx[i]={x[i],i};
        vy[i]={y[i],i};
    }
    sort(vx,vx+n);
    sort(vy,vy+n);
    for(int i=0;i<n-1;i++)
    {
        p.push_back({vx[i].index,vx[i+1].index,vx[i+1].pos-vx[i].pos});
        p.push_back({vy[i].index,vy[i+1].index,vy[i+1].pos-vy[i].pos});
    }
    UF uf(n);
    
    ll ans=0;
    for(int i=0;i<p.size();i++)
    {
        int from=p[i].from;
        int to=p[i].to;
        int cost=p[i].cost;
        
        if(!uf.same(from,to))
        {
            cnt++;
            uf.unite(from,to);
            ans+=cost;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:70:2: error: expected ';' after struct definition
   70 | }
      |  ^
      |  ;
a.cc: In function 'int main()':
a.cc:103:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
  103 |             cnt++;
      |             ^~~
      |             int
Language: C++

//
//  abc065d.cpp
//
//
//  Created by Yoshida Satoshi on 2018/11/09.
//

#include <stdio.h>
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>

#define MAX 100005

using namespace std;

typedef long long ll;

struct Path
{
    int from,to,cost;
    
    bool operator<(const Path& rhs)const
    {
        return cost<rhs.cost;
    }
};

struct UF
{
    vector<int> par;
    
    UF(int n):par(n)
    {
        for(int i=0;i<n;i++) par[i]=i;
    }
    
    int root(int x)
    {
        if(par[x]==x) return x;
        else          return par[x]=root(par[x]);
    }
    
    void unite(int x,int y)
    {
        int rx=root(x);
        int ry=root(y);
        
        par[rx]=ry;
    }
    
    bool same(int x,int y)
    {
        int rx=root(x);
        int ry=root(y);
        
        return rx==ry;
    }
};

int main()
{
    int n;
    cin>>n;
    vector<Path> p;
    int x[MAX],y[MAX];
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        for(int j=0;j<i;j++)
        {
            p.push_back({j,i,min(abs(x[i]-x[j]),abs(y[i]-y[j]))});
        }
    }
    sort(p.begin(),p.end());
    UF uf(n);
    
    ll ans=0;
    int cnt=0;
    for(int i=0;i<p.size();i++)
    {
        if(cnt==v-1) break;
        int from=p[i].from;
        int to=p[i].to;
        int cost=p[i].cost;
        
        if(!uf.same(from,to))
        {
            cnt++;
            uf.unite(from,to);
            ans+=cost;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:84:17: error: 'v' was not declared in this scope
   84 |         if(cnt==v-1) break;
      |                 ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;

int *par, *ranks;
int N;
struct P {int n, x, y;};
struct PATH {int v1, v2, cost;};

void init()
{
  for (int i = 0; i < N; i++) {
    par[i] = i;
    ranks[i] = 0;
  }
}

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

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

  if (ranks[x] < ranks[y]) par[x] = par[y];
  else {
    par[y] = par[x];
    if (ranks[x] == ranks[y]) ranks[x]++;
  }
}

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

bool comp_x(P p1, P p2)
{
  return p1.x < p2.x;
}
bool comp_y(P p1, P p2)
{
  return p1.y < p2.y;
}

bool comp_cost(PATH path1, PATH path2)
{
  return path1.cost < path2.cost;
}

int main()
{
  cin >> N;
  P p[N];
  par = new int[N];
  ranks = new int[N];
  for (int i = 0; i < N; i++) {
    p[i].n = i;
    cin >> p[i].x >> p[i].y;
  }
  init();
  vector<PATH> pathes;
  sort(p, p + N, comp_x);
  for (int i = 0; i < N-1; i++) {
    PATH tmp;
    tmp.v1 = p[i].n; tmp.v2 = p[i+1].n;
    tmp.cost = p[i+1].x - p[i].x;
    pathes.push_back(tmp);
  }
  sort(p, p + N, comp_y);
  for (int i = 0; i < N-1; i++) {
    PATH tmp;
    tmp.v1 = p[i].n; tmp.v2 = p[i+1].n;
    tmp.cost = p[i+1].y - p[i].y;
    pathes.push_back(tmp);
  }

  sort(pathes.begin(), pathes.end(), comp_cost);
  int lim = pathes.size(), ans = 0;
  for (int i = 0; i < lim; i++) {
    PATH path = pathes[i];
    if (same(path.v1, path.v2)) continue;
    unite(path.v1, path.v2);
    ans += path.cost;
  }

  cout << ans << endl;
  delete [] par;
  delete [] ranks;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:67:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   67 |   sort(p, p + N, comp_x);
      |   ^~~~
      |   short
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define met(a,0) memset(a,0,sizeof(a))
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
const int N=1e5+10;
int book[N];
void init()
{
    for(int i=1; i<=n; i++)
        book[i]=i;
}
int getfa(int x)
{
    if(book[x]!=x)
        book[x]=getfa(book[x]);
    return book[x];
}
void mergexy(int x,int y)
{
    book[y]=x;
}
struct node{
int x,y,cnt;}s[N];
struct nodee{
int u,v,w;}f[2*N];
bool cmp(node a,node b){
return a.x<b.x;}
bool cmpp(node a,node b){
return a.y<b.y;}
bool cmppp(nodee a,nodee b){
return a.w<b.w;}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i,j,k,m,n;
    int cnt=0,sum=0,ans=0,num;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s[i].x>>s[i].y;
        s[i].cnt=i;
    }
    sort(s+1,s+1+n,cmp);
    for(i=1;i<n;i++)
    {
        f[++cnt].u=s[i].cnt;
        f[cnt].v=s[i+1].cnt;
        f[cnt].w=min(s[i+1].x-s[i].x,abs(s[i+1].y-s[i].y));
    }
    sort(s+1,s+1+n,cmpp)
    for(i=1;i<n;i++)
    {
        f[++cnt].u=s[i].cnt;
        f[cnt].v=s[i+1].cnt;
        f[cnt].w=min(s[i+1].y-s[i].y,abs(s[i+1].x-s[i].x));
    }
    sort(f+1,f+1+n,cmppp)
    init();
    for(i=1;i<=cnt;++i)
    {
        k=getfa(f[i].u);
        m=getfa(f[i].v);
        if(k!=m)
        {
            mergexy(k,m);
            num++;
            sum+=f[i].w;
        }
        if(num==n)
            break;
    }
    cout<<sum<<endl;
    return 0;
}


Compiler output:
a.cc:3:15: error: expected parameter name, found "0"
    3 | #define met(a,0) memset(a,0,sizeof(a))
      |               ^
a.cc: In function 'void init()':
a.cc:11:21: error: 'n' was not declared in this scope
   11 |     for(int i=1; i<=n; i++)
      |                     ^
a.cc: In function 'int main()':
a.cc:53:25: error: expected ';' before 'for'
   53 |     sort(s+1,s+1+n,cmpp)
      |                         ^
      |                         ;
   54 |     for(i=1;i<n;i++)
      |     ~~~                  
a.cc:54:20: error: expected ';' before ')' token
   54 |     for(i=1;i<n;i++)
      |                    ^
      |                    ;
a.cc:60:26: error: expected ';' before 'init'
   60 |     sort(f+1,f+1+n,cmppp)
      |                          ^
      |                          ;
   61 |     init();
      |     ~~~~
Language: Java

 static ArrayList<Edge> edges = new ArrayList<>();

    public static void addEdge(int f, int t, long c)
    {
        edges.add(new Edge(f, t, c));
    }


    static class Edge implements Comparable<Edge>
    {
        int f;
        int t;
        long toCost;

        Edge(int f, int to, long cost)
        {
            this.f = f;
            t = to;
            toCost = cost;
        }

        @Override
        public int compareTo(Edge e)
        {
            return toCost == e.toCost ? 0 : toCost > e.toCost ? 1 : -1;
        }

    }


Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
 static ArrayList<Edge> edges = new ArrayList<>();
        ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: C++

#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

ll min(ll a, ll b){
	if(a<b){return a;}
	else{return b;}
}

ll x[100005];
ll y[100005];

typedef pair<ll,int> pii;
bool used[100005];
int N;

ll prim() {
    priority_queue<pii, vector<pii>, greater<pii> > que;
    memset(used, 0, sizeof(used));
    que.push(pii(0ll,0));
    ll ret = 0ll;
    while(!que.empty()) {
        ll cst = que.top().first; 
		int v = que.top().second;
        que.pop();
		if(used[v]) {continue;}
        used[v] = 1;
        ret += cst;
        for(int i = 0; i < N; i++){
			que.push(pii(min(llabs(x[i]-x[v]),llabs(y[i]-y[v])),i));
		}
    }
    return ret;
}

int main(){

	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
	scanf("%lld %lld",&x[i],&y[i]);
	}

	printf("%lld\n",prim());

	return 0;
}

Compiler output:
a.cc: In function 'll prim()':
a.cc:27:5: error: 'memset' was not declared in this scope
   27 |     memset(used, 0, sizeof(used));
      |     ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <functional>
  +++ |+#include <cstring>
    8 |
Language: C++

#include<iostream>
#include<queue>
using namespace std;

using pii = pair<int, int>;

const int mxn = 100010;

struct edge{int from, to, cost;};

bool comp(edge a, edge b) {
    return a.cost < b.cost;
}

vector<edge> es;

int par[mxn];
void init_unionfind(int n){
    fill(par, par + n, -1);
}

int root(int x) {
    return par[x] < 0 ? x : par[x] = root(par[x]);
}

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

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(par[y] < par[x]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
}

int main() {
    int N;
    cin >> N;
    vector<pii> xs, ys;
    for(int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        xs.push_back({x, i});
        ys.push_back({y, i});
    }

    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    // xについての辺をはる
    for(int i = 1; i < N; i++) {
        int x = xs[i].first, idx = xs[i].second;
        int px = xs[i-1].first, pidx = xs[i-1].second;
        es.push_back({idx, pidx, abs(x - px)});
        es.push_back({pidx, idx, abs(x - px)});
    }

    // yについての辺をはる
    for(int i = 1; i < N; i++) {
        int y = ys[i].first, idx = ys[i].second;
        int py = ys[i-1].first, pidx = ys[i-1].second;
        es.push_back({idx, pidx, abs(y - py)});
        es.push_back({pidx, idx, abs(y - py)});
    }

    sort(es.begin(), es.end(), comp);

    init_unionfind(N+1);

    int ans = 0;
    for(int i = 0; i < es.size() ;i++) {
        if(!same(es[i].from, es[i].to)){
            unite(es[i].from, es[i].to);
            ans += es[i].cost;
        }
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   49 |     sort(xs.begin(), xs.end());
      |     ^~~~
      |     short