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

#include <iostream>
#include <vector>
#include <queue>

#define INF 2000000000

using namespace std;

int main(){
  int n; cin >> n;
  vector<pair<int,int> > px,py;
  //adjacent list
  vector<pair<int,int> > G[n+1];
  for(int i=1;i<=n;i++){
    int x,y; cin >> x >> y;
    px.push_back(make_pair(x,i));
    py.push_back(make_pair(y,i));
  }
  sort(px.begin(),px.end());
  sort(py.begin(),py.end());
  for(int i=0;i<n-1;i++){
    G[px[i].second].push_back(make_pair(px[i+1].second,px[i+1].first-px[i].first));
    G[px[i+1].second].push_back(make_pair(px[i].second,px[i+1].first-px[i].first));
    G[py[i].second].push_back(make_pair(py[i+1].second,py[i+1].first-py[i].first));
    G[py[i+1].second].push_back(make_pair(py[i].second,py[i+1].first-py[i].first));
  }
  /*for(int i=1;i<=n;i++){
    for(int j=0;j<G[i].size();j++){
      cout << i << " " << G[i][j].first << " " << G[i][j].second << endl;
    }
  }*/
  //minimum spanning tree
  //PQ has make_pair(d[id],id)
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > PQ;
  int visited[n+1],d[n+1];
  for(int i=1;i<=n;i++){
    visited[i]=0;
    d[i]=INF;
  }
  d[1]=0;
  PQ.push(make_pair(0,1));
  int sum=0;
  while(PQ.empty()==false){
    int u=PQ.top().second;
    int u_cost=PQ.top().first;
    PQ.pop();
    if(u_cost>d[u]) continue;
    visited[u]=1;
    sum=sum+d[u];
    for(int i=0;i<G[u].size();i++){
      if(visited[G[u][i].first]==0){
        if(G[u][i].second<d[G[u][i].first]){
          d[G[u][i].first]=G[u][i].second;
          PQ.push(make_pair(d[G[u][i].first],G[u][i].first));
        }
      }
    }
  }
  cout << sum << endl;
}

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

#include <iostream>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define mp make_pair

const int maxn = 100005;

int px[maxn],py[maxn],f[maxn];

pair<int,int> sx[maxn],sy[maxn];

int fnd(int x){
	if (f[x]==x)return x;
	return f[x]=fnd(f[x]);
}

int n;

int dist(int u,int v){
	return min(abs(px[u]-px[v]),abs(py[u]-py[v]));
}

int unit(int x,int y){
	x=fnd(x);
	y=fnd(y);
	if (x==y)return 0;
	f[x]=y;
	return 1;
}

int main(){
	scanf("%d",&n);
	for (int i=0;i<n;++i){
		scanf("%d%d",&px[i],&py[i]);
		f[i]=i;
		sx[i]=mp(px[i],i);
		sy[i]=mp(py[i],i);
	}
	sort(sx,sx+n);
	sort(sy,sy+n);
	set < pair < int , pair < int , int > > >st;
	for (int i=0;i<n-1;++i){
		st.insert(mp(dist(sx[i].second,sx[i+1].second),mp(sx[i].second,sx[i+1].second)));
		st.insert(mp(dist(sy[i].second,sy[i+1].second),mp(sy[i].second,sy[i+1].second)));
	}
	long long res=0;
	while ((int)st.size()){
		auto pair<int,pair<int,int> > cur= *(st.begin());
		st.erase(cur);
		int u=cur.second.first,v=cur.second.second;
		res += unit(u,v) * dist(u,v);
	}
	printf("%lld\n",res);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:47: error: invalid declarator before 'cur'
   54 |                 auto pair<int,pair<int,int> > cur= *(st.begin());
      |                                               ^~~
a.cc:55:26: error: 'cur' was not declared in this scope
   55 |                 st.erase(cur);
      |                          ^~~
a.cc:57:31: error: 'v' was not declared in this scope
   57 |                 res += unit(u,v) * dist(u,v);
      |                               ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair

const int maxn = 100005;

int px[maxn],py[maxn],f[maxn];

pair<int,int> sx[maxn],sy[maxn];

int fnd(int x){
	if (f[x]==x)return x;
	return f[x]=fnd(f[x]);
}

int n;

int dist(int u,int v){
	return min(abs(px[u]-px[v]),abs(py[u]-py[v]));
}

int unit(int x,int y){
	x=fnd(x);
	y=fnd(y);
	if (x==y)return 0;
	f[x]=y;
	return 1;
}

int main(){
	scanf("%d",&n);
	for (int i=0;i<n;++i){
		scanf("%d%d",&px[i],&py[i]);
		f[i]=i;
		sx[i]=mp(px[i],i);
		sy[i]=mp(py[i],i);
	}
	sort(sx,sx+n);
	sort(sy,sy+n);
	set < pair < int , pair < int , int > > >st;
	for (int i=0;i<n-1;++i){
		st.insert(mp(dist(sx[i].second,sx[i+1].second),mp(sx[i].second,sx[i+1].second)));
		st.insert(mp(dist(sy[i].second,sy[i+1].second),mp(sy[i].second,sy[i+1].second)));
	}
	long long res=0;
	while ((int)st.size()){
		auto pair<int,pair<int,int> > cur= *(st.begin());
		st.erase(cur);
		int u=cur.second.first,v=cur.second.second;
		res += unit(u,v) * dist(u,v);
	}
	printf("%lld\n",res);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:47: error: invalid declarator before 'cur'
   49 |                 auto pair<int,pair<int,int> > cur= *(st.begin());
      |                                               ^~~
a.cc:50:26: error: 'cur' was not declared in this scope
   50 |                 st.erase(cur);
      |                          ^~~
a.cc:52:31: error: 'v' was not declared in this scope
   52 |                 res += unit(u,v) * dist(u,v);
      |                               ^
Language: C++


asdadadasdasdasdasdadadasdasdasd
asdadadasdasdasd
asdadadasdasdasd
asdadadasdasdasd

Compiler output:
a.cc:2:1: error: 'asdadadasdasdasdasdadadasdasdasd' does not name a type
    2 | asdadadasdasdasdasdadadasdasdasd
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 100005
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll cost[MAX][MAX];
ll mincost[MAX];
priority_queue<Pll, vector<Pll>, greater<Pll> > que;
bool used[MAX];
int V;

ll prim(){
  fill(mincost, mincost+V, INF);
  fill(used, used+V, false);
  que.push(make_pair(0, 0));
  int res = 0;

  while(true){
	Pll v;
	while(!que.empty()){
	  if(!used[que.top().second]){
		v = que.top();
		break;
	  }
	  que.pop();
	}

	if(que.empty()) break;
	used[v.second] = true;
	res += v.first;

	rep(V){
	  mincost[i] = min(mincost[i], cost[v.second][i]);
	  que.push(make_pair(mincost[i], i));
	}
  }
  
  return res;
}

signed main(){
    //scanf("%d", &V);
    cin >> V;
    vector<ll> x(V), y(V);
    rep(V){
        //scanf("%lld %lld", &x[i], &y[i]);
        cin >> x[i] >> y[i];
        repp(j, i){
            cost[i][j] = cost[j][i] = min(abs(x[i] - x[j]), abs(y[i] - y[j]));
        }
    }
    printf("%lld\n", prim());
    return 0;
}

Compiler output:
/tmp/ccH7p88f.o: in function `prim()':
a.cc:(.text+0x11): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0xdd): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccH7p88f.o
a.cc:(.text+0x125): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 100005
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll cost[MAX][MAX];
ll mincost[MAX];
priority_queue<Pll, vector<Pll>, greater<Pll> > que;
bool used[MAX];
int V;

ll prim(){
  fill(mincost, mincost+V, INF);
  fill(used, used+V, false);
  que.push(make_pair(0, 0));
  int res = 0;

  while(true){
	Pll v;
	while(!que.empty()){
	  if(!used[que.top().second]){
		v = que.top();
		break;
	  }
	  que.pop();
	}

	if(que.empty()) break;
	used[v.second] = true;
	res += v.first;

	rep(V){
	  mincost[i] = min(mincost[i], cost[v.second][i]);
	  que.push(make_pair(mincost[i], i));
	}
  }
  
  return res;
}

signed main(){
    scanf("%d", &V);
    vector<ll> x(V), y(V);
    rep(V){
        scanf("%lld %lld", &x[i], &y[i]);
        repp(j, i){
            cost[i][j] = cost[j][i] = min(abs(x[i] - x[j]), abs(y[i] - y[j]));
        }
    }
    printf("%lld\n", prim());
    return 0;
}

Compiler output:
/tmp/ccPnO4lF.o: in function `prim()':
a.cc:(.text+0x11): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0xdd): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccPnO4lF.o
a.cc:(.text+0x125): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 100005
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll cost[MAX][MAX];
ll mincost[MAX];
priority_queue<Pll, vector<Pll>, greater<Pll> > que;
bool used[MAX];
int V;

ll prim(){
  fill(mincost, mincost+V, INF);
  fill(used, used+V, false);
  que.push(make_pair(0, 0));
  int res = 0;

  while(true){
	Pll v;
	while(!que.empty()){
	  if(!used[que.top().second]){
		v = que.top();
		break;
	  }
	  que.pop();
	}

	if(que.empty()) break;
	used[v.second] = true;
	res += v.first;

	rep(V){
	  mincost[i] = min(mincost[i], cost[v.second][i]);
	  que.push(make_pair(mincost[i], i));
	}
  }
  
  return res;
}

signed main(){
    scanf("%d", &V);
    vector<ll> x(V), y(V);
    rep(V){
        scanf("%lld %lld", &x[i], &y[i]);
        repp(j, i){
            cost[i][j] = cost[j][i] = min(abs(x[i] - x[j]), abs(y[i] - y[j]));
        }
    }
    printf("%lld\n", prim());
}

Compiler output:
/tmp/ccarWuqy.o: in function `prim()':
a.cc:(.text+0x11): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0xdd): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `que' defined in .bss section in /tmp/ccarWuqy.o
a.cc:(.text+0x125): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;

public class Main {
  static ArrayList<Edge>[] graph;
  static int vNum;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    vNum = sc.nextInt();
    Vertice[] V = new Vertice[vNum];
    graph = new ArrayList[vNum];
    for(int i = 0; i < vNum; i++) {
      graph[i] = new ArrayList<Edge>();
    }
    for(int i = 0; i < vNum; i++) {
      int x = sc.nextInt();
      int y = sc.nextInt();
      V[i] = new Vertice(i, x, y);
    }
    Arrays.sort(V, new Comparator<Vertice>() {
      public int compare(Vertice vertice1, Vertice vertice2) {
	return vertice1.x - vertice2.x;
      }
    });
    for(int i = 0; i < vNum - 1; i++) {
      Vertice v1 = V[i];
      Vertice v2 = V[i + 1];
      graph[v1.id].add(new Edge(v2.id, v2.x - v1.x));
      graph[v2.id].add(new Edge(v1.id, v2.x - v1.x));
    }

    Arrays.sort(V, new Comparator<Vertice>() {
      public int compare(Vertice vertice1, Vertice vertice2) {
	return vertice1.y - vertice2.y;
      }
    });
    for(int i = 0; i < vNum - 1; i++) {
      Vertice v1 = V[i];
      Vertice v2 = V[i + 1];
      graph[v1.id].add(new Edge(v2.id, v2.y - v1.y));
      graph[v2.id].add(new Edge(v1.id, v2.y - v1.y));
    }
    int ans = prim();
    System.out.println(ans);
  }

  public static int prim() {
    int total = 0;
    Queue<Edge> que = new PriorityQueue<Edge>();
    que.add(new Edge(0,0));
    boolean[] use = new boolean[vNum];
    while(!que.isEmpty()) {
      Edge e = que.poll();
      if(use[e.to]) {
        continue;
      }
      use[e.to] = true;
      total += e.cost;
      for(Edge e2 : graph[e.to]) {
        que.add(e2);
      }
    }
    return total;
  }

  static class Edge implements Comparable {
    int to;
    int cost;

    public Edge(int to, int cost) {
      this.to = to;
      this.cost = cost;
    }
    @Override
    public int compareTo(Edge o) {
      return this.cost - o.cost;
    }
  }

  static class Vertice {
    int id;
    int x;
    int y;

    public Vertice(int id, int x, int y) {
      this.id = id;
      this.x = x;
      this.y = y;
    }
  }
}

Compiler output:
Main.java:66: error: Edge is not abstract and does not override abstract method compareTo(Object) in Comparable
  static class Edge implements Comparable {
         ^
Main.java:74: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Language: C++

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

struct union_find {
  const int root_v = -1;
  vector<int> d;
  union_find(int n) : d(n, root_v) {}

  int root(int i) {
    return d[i] == root_v ? i : root(d[i]);
  }

  bool is_connect(int i, int j) {
    return root(i) == root(j);
  }

  void connect(int i, int j) {
    d[i] = j;
  }
};

struct city {
  int index;
  int x;
  int y;
};

struct path {
  int s, g;
  int cost;
};

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

  long n;
  cin >> n;

  vector<city> cs(n);

  for (int i = 0; i < n; i++) {
    cs[i].index = i;
    cin >> cs[i].x >> cs[i].y;
  }
  
  vector<path> e;

  sort(cs.begin(), cs.end(), [](city r, city l){ return r.x < l.x;});
  for (int i = 0; i < cs.size() - 1; i++) {
    e.push_back(path {cs[i].index, cs[i+1].index, cs[i+1].x - cs[i].x});
  }

  sort(cs.begin(), cs.end(), [](city r, city l){ return r.y < l.y;});
  for (int i = 0; i < cs.size() - 1; i++) {
    e.push_back(path {cs[i].index, cs[i+1].index, cs[i+1].y - cs[i].y});
  }

  sort(e.begin(), e.end(), [](path r, path l){return r.cost < l.cost;});

  int cost = 0;
  union_find uf(n);
  for (path p : e) {
    if (!uf.is_connect(p.s, p.g)) {
      uf.connect(p.s, p.g);
      cost += p.cost;
    }
  }

  cout << cost << endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:52:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   52 |   sort(cs.begin(), cs.end(), [](city r, city l){ return r.x < l.x;});
      |   ^~~~
      |   sqrt
Language: C

#include<bits/stdc++.h>
using namespace std;
#define m make_pair
#define I int
#define t first
#define u second
pair<I,I>x[1<<17],y[1<<17];I i,n,p[1<<17],s;
pair<I,pair<I,I> > G[2<<17];
I f(I a){return p[a]-a?p[a]=f(p[a]):a;}
main()
{
	for(cin>>n;i++<n;x[i].u=y[i].u=p[i]=i)cin>>x[i].t>>y[i].t;
	sort(x+1,x+n+1),sort(y+1,y+n+1);
	for(i=0;++i<n;)
	{
		G[i*2] = m(abs(x[i].t-x[i+1].t),m(x[i].u,x[i+1].u));
		G[i*2+1] = m(abs(y[i].t-y[i+1].t),m(y[i].u,y[i+1].u));
	}
	sort(G,G+n*2);
	for(i=0;i<2*n-2;i++)
	{
		I x=G[i].u.t,y=G[i].u.u;
		if(f(x)-f(y))
		{
			s+=G[i].t;
			p[f(x)]=f(y);
		}
	}
	cout<<s<<endl;
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#include <climits>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ull N;

struct UnionFind {
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    for(int i=0;i<n;++i) par[i] = i;
  }

  int find(int x) {
    if (x == par[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 (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
    sizes[y] = 0;
  }

  void unite(pair<int,int> p) {
    unite(p.first,p.second);
  }

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

  bool same(pair<int,int> p) {
    return same(p.first,p.second);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};

void fillmap(vector<pair<int,int>> xs, map<pair<int,int>,int> &m){
  for(auto it=xs.begin();it+1!=xs.end();++it) {
    int diff = abs(it->first-(it+1)->first);
    int t = it->second, n = (it+1)->second;
    auto key = t<n ? make_pair(t,n) : make_pair(n,t);
    m[key] = m.count(key) ? min(diff, m[key]) : diff;
  }
}

int main (int argc, char const *argv[])
{
  cin >> N;
  vector< pair<int,int> > xs,ys;
  for(int i=1;i<=N;++i) {
    int x,y;cin >> x >> y;
    xs.push_back(make_pair(x,i));
    ys.push_back(make_pair(y,i));
  }

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

  map< pair<int,int>,int > m;
  fillmap(xs,m);
  fillmap(ys,m);

  priority_queue< pair< int, pair<int,int> > > pq;

  for(auto &&kv:m) pq.push(make_pair(-kv.second,kv.first));

  auto uf = UnionFind(N+1);
  ll ans=0;
  while(pq.size()) {
    auto t = pq.top(); pq.pop();
    // cout << t.first << " : " << t.second.first << "," << t.second.second << endl;
    if(uf.same(t.second)) continue;
    uf.unite(t.second);
    ans += -t.first;
  }

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


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

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

using namespace std;
const int maxn=100000+5;
typedef long long ll;
struct point{int x,y,id;};
point p[maxn];
int n;
struct edge{int from,to,cost;};
vector<edge> pool;
int myabs(int x){return x<0?-x:x;}
bool cmppp(edge a,edge b){
	return a.cost<b.cost;
}
bool cmp1(point a,point b){
	if(a.x==b.x) return a.y<b.y;
	return a.x<b.x;
}
bool cmp2(point a,point b){
	if(a.y==b.y) return a.x<b.x;
	return a.y<b.y;
}
struct ge{int to,cost;};
struct cmpp{
	bool operator()(edge a,edge b){
		return a.cost>b.cost;
	}
};
vector<ge> g[maxn];
int f[maxn],rnk[maxn];
int getf(int x){
	return f[x]==x?f[x]:f[x]=getf(f[x]);
}
void merge(int u,int v)
{
	int fu=getf(u),fv=getf(v);
	if(fu==fv) return;
	else{
		if(rnk[fu]>rnk[fv]){
			rnk[fu]+=rnk[fv];rnk[fv]=0;
			f[fv]=fu;
		}else{
			rnk[fv]+=rnk[fu];rnk[fu]=0;
			f[fu]=fv;
		}
	}
}
vector<edge> egs;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {p[i].id=i;scanf("%d%d",&p[i].x,&p[i].y);}
	sort(p+1,p+1+n,cmp1);
	for(int i=1;i<n;i++){
		egs.push_back((edge){p[i].id,p[i+1].id,min(myabs(p[i].x-p[i+1].x),myabs(p[i].y-p[i+1].y))});
	}
	sort(p+1,p+1+n,cmp2);
	for(int i=1;i<n;i++){
		egs.push_back((edge){p[i].id,p[i+1].id,min(myabs(p[i].x-p[i+1].x),myabs(p[i].y-p[i+1].y))});
	}
	bool has=true;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=n;i++) rnk[i]=1;
	ll ans=0;
	sort(egs.begin(),egs.end(),cmppp);
	memset(vis,0,sizeof(vis));
	int lev=n-1;
	for(int i=0;i<egs.size();i++)
	{
		edge now=egs[i];
		if(getf(now.from)!=getf(now.to))
		{lev--;vis[i]=true;merge(now.from,now.to);ans+=now.cost;}
		if(lev==0) break;
	}
	printf("%lld\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:75:16: error: 'vis' was not declared in this scope
   75 |         memset(vis,0,sizeof(vis));
      |                ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define M 1000000007
#define N 100005
int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0;

struct zb{
    int x, y,id,prx,pry;
}a[N];
int cmp(const int i, const int j){return w[i]<w[j];}
int cmp1(struct zb i, struct zb j){return i.x<j.x;}
int cmp2(struct zb i, struct zb j){return i.y<j.y;}
int fin(int x){return p[x]==x?x:p[x]=fin(p[x]);}
LL kru()
{
    LL ans=0;
    for(int i=0;i<n;i++)
        p[i]=i;
    for(int i=0;i<m;i++)
        r[i]=i;
    sort(r,r+m,cmp);
    for(int i=0;i<m;i++)
    {
        int e=r[i];
        int x=fin(u[e]);
        int y=fin(v[e]);
        if(x!=y){ans+=w[e];p[x]=y;}
    }
    return ans;
}

int main()
{
    scanf("%d",&n);
    m=(n-1)*2;
    for(i=0;i<n;i++)
        {scanf("%d%d",&a[i].x,&a[i].y);a[i].id=i;}
    sort(a,a+n,cmp1);
    for(i=n-1;i>0;i--)
        {a[i].x=a[i].x-a[i-1].x;a[i].prx=a[i-1].id;}
    for(i=1;i<=n-1;i++)
    {
        u[k]=a[i].id;v[k]=a[i].prx;w[k++]=a[i].x;
    }
    sort(a,a+n,cmp2);
    for(i=n-1;i>0;i--)
        {a[i].y=a[i].y-a[i-1].y; a[i].pry=a[i-1].id;}
    for(i=1;i<=n-1;i++)
    {
        u[k]=a[i].id;v[k]=a[i].pry;w[k++]=a[i].y;
    }
    printf("%lld",kru());
    return 0;
}


Compiler output:
a.cc:6:8: warning: integer overflow in expression of type 'int' results in '1411065433' [-Woverflow]
    6 | int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0;
      |        ^
a.cc:6:8: error: size of array 'u' exceeds maximum object size '9223372036854775807'
a.cc:6:15: warning: integer overflow in expression of type 'int' results in '1411065433' [-Woverflow]
    6 | int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0;
      |               ^
a.cc:6:15: error: size of array 'v' exceeds maximum object size '9223372036854775807'
a.cc:6:27: warning: integer overflow in expression of type 'int' results in '1411065433' [-Woverflow]
    6 | int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0;
      |                           ^
a.cc:6:27: error: size of array 'r' exceeds maximum object size '9223372036854775807'
a.cc:6:34: warning: integer overflow in expression of type 'int' results in '1411065433' [-Woverflow]
    6 | int u[N*N],v[N*N],p[N],r[N*N],w[N*N],n,m,i,j,k=0;
      |                                  ^
a.cc:6:34: error: size of array 'w' exceeds maximum object size '9223372036854775807'
Language: C++

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif
using namespace std;

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
typedef unsigned char byte;
typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

const int MAXN = 100100;
int N;
pii pos[MAXN];
bool in[MAXN];
vector<int> edge[MAXN];
unordered_map<int, unordered_set<int>> has;

int dist(int a, int b)
{
    return min(abs(pos[a].fi - pos[b].fi), abs(pos[a].se - pos[b].se));
}

int main()
{
    while (cin >> N)
    {
        has.clear();
        memset(in, 0, sizeof(in));
        xs.clear();
        ys.clear();
        FO (i, N)
        {
            int x, y;
            cin >> x >> y;
            if (has[x].count(y))
                in[i] = true;
            has[x].insert(y);
        }
        priority_queue<pii, vector<pii>, greater<pii>> que;
        in[0] = true;
        FO (i, N)
            if (!in[i])
                que.push(pii(dist(0, i), i));
        llong res = 0;
        while (!que.empty())
        {
            pii d_u = que.top();
            que.pop();
            int d = d_u.fi;
            int u = d_u.se;
            if (in[u])
                continue;
            res += d;
            in[u] = true;
            FO (i, N)
                if (!in[i])
                    que.push(pii(dist(u, i), i));
        }
        cout << res << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:9: error: 'xs' was not declared in this scope
   65 |         xs.clear();
      |         ^~
a.cc:66:9: error: 'ys' was not declared in this scope; did you mean 'yn'?
   66 |         ys.clear();
      |         ^~
      |         yn
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;

const int MAXV = 100010;
const int INF = 1e8;

int cost[MAXV][MAXV];
int mincost[MAXV];
bool used[MAXV];
int V;

ll prim() {
    for (int i=0; i<V; ++i) {
        mincost[i] = INF;
        used[i] = false;
    }
    mincost[0] = 0;
    ll res = 0;
    while (true) {
        int v = -1;
        for (int u=0;u<V;++u) {
            if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
        }
        if (v == -1) break;
        used[v] = true;
        res += mincost[v];
        for (int u=0; u<V; ++u) {
            mincost[u] = min(mincost[u], cost[v][u]);
        }
    }
    return res;
}

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> V;

    using P = pair<int, int>;
    vector< P > v(V);

    rep(i, V) {
        P a; int x, y;
        cin >> x >> y;
        a = { x, y };
        v[i] = a;
    }

    rep(i, V) {
        for (int j=i+1; j<V; ++j) {
            cost[i][j] = min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) );
            cost[j][i] = min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) );
        }
    }

    cout << prim() << endl;

}


Compiler output:
/tmp/ccTzEEHY.o: in function `prim()':
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0x9a): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0xc8): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0xe3): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccTzEEHY.o
a.cc:(.text+0x148): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;

const int MAXV = 100010;
const int INF = 1e8;

int cost[MAXV][MAXV];
int mincost[MAXV];
bool used[MAXV];
int V;

ll prim() {
    for (int i=0; i<V; ++i) {
        mincost[i] = INF;
        used[i] = false;
    }
    mincost[0] = 0;
    ll res = 0;
    while (true) {
        int v = -1;
        for (int u=0;u<V;++u) {
            if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
        }
        if (v == -1) break;
        used[v] = true;
        res += mincost[v];
        for (int u=0; u<V; ++u) {
            mincost[u] = min(mincost[u], cost[v][u]);
        }
    }
    return res;
}

int main() {

    scanf("%d", &V);

    using P = pair<int, int>;
    vector< P > v(V);

    rep(i, V) {
        P a; int x, y;
        scanf("%d %d", &x, &y);
        a = { x, y };
        v[i] = a;
    }

    rep(i, V) {
        for (int j=i+1; j<V; ++j) {
            cost[i][j] = min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) );
            cost[j][i] = min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) );
        }
    }

    cout << prim() << endl;

}


Compiler output:
/tmp/cccN8ir6.o: in function `prim()':
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0x9a): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0xc8): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0xe3): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cccN8ir6.o
a.cc:(.text+0x148): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

const LL maxn=100500,inf=LONG_LONG_MAX;
LL x[maxn],y[maxn],Map[maxn][maxn],vis[maxn],ans,n,d[maxn];
struct node
{
    LL v,len;//v代表当前顶点，w代表v到答案集合的最小距离
    friend bool operator <(node a,node b)
    {
        return a.len>b.len;
    }
};
LL prim()
{
    priority_queue<node>q;
    node t;
    t.v=1;t.len=0;
    q.push(t);//初始化顶点1到答案集合的距离为0，以保证第一次一定选入顶点1到答案集合中去
    ans=0;
    fill(vis,vis+maxn,0);
    fill(d,d+maxn,inf);
    while(q.size())
    {
        t=q.top();q.pop();//取离答案集合距离最小的顶点
        if(vis[t.v]) continue;//如果已经在答案集合中则进行下一次的循环
        vis[t.v]=1;//否则取顶点t.v加入到答案集合中
        ans+=t.len;
        for(int i=1;i<=n;i++)//更新未加入答案集合的顶点到答案集合 的距离
        {
            if(!vis[i]&&Map[t.v][i]<d[i])//可以更新则入队
            {
                node next;
                next.v=i;
                next.len=Map[t.v][i];
                d[i]=Map[t.v][i];
                q.push(next);
            }
        }
    }
    return ans;
}
int main()
{
    cin.sync_with_stdio(0);
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
                cin>>x[i]>>y[i];
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                Map[i][j]=min(abs(x[i]-x[j]),abs(y[i]-y[j]));
        cout<<prim()<<endl;
    }
    return 0;
}



Compiler output:
/tmp/ccTmBal4.o: in function `prim()':
a.cc:(.text+0x3b): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0x5e): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0x6d): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0x7e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0xf9): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0x103): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0x123): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccTmBal4.o
a.cc:(.text+0x16a): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;

struct UnionFind {
    static const int Max = 100010;
    int par[Max];
    int rank[Max];

    void init(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[x]++;
        }
    }

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

const ll MAXE = (1e5 * (1e5 - 1) / 2) + 1;
struct edge { int u, v; ll cost; };

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

edge es[MAXE];
int V, E;

ll kruskal() {
    sort(es, es+E, comp);
    UnionFind uf;
    uf.init(V);
    ll 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;
    using P = pair<int, int>;
    vector< P > v(V);
    rep(i, V) {
        P a; int x, y;
        cin >> x >> y;
        a = { x, y };
        v[i] = a;
    }

    rep(i, V) {
        for (int j=i+1; j<V; ++j) {
            edge e = {i, j, min( (int)abs(v[i].first - v[j].first), (int)abs(v[i].second - v[j].second) ) };
            es[E++] = e;
        }
    }

    cout << kruskal() << endl;
}


Compiler output:
/tmp/ccK28nWJ.o: in function `kruskal()':
a.cc:(.text+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccK28nWJ.o
a.cc:(.text+0x63): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o
a.cc:(.text+0x107): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccK28nWJ.o
/tmp/ccK28nWJ.o: in function `main':
a.cc:(.text+0x126): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o
a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o
a.cc:(.text+0x202): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o
a.cc:(.text+0x2cc): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccK28nWJ.o
a.cc:(.text+0x2d5): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccK28nWJ.o
a.cc:(.text+0x300): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o
a.cc:(.text+0x313): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccK28nWJ.o
collect2: error: ld returned 1 exit status
Language: C++

#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long ll;
const int MAXN = 100010;
int n, en, fa[MAXN];
struct Point {
	int x, y, id;
}P[MAXN];
struct Edge {
	int from, to, w;
	Edge(int from = 0, int to = 0, int w = 0) : from(from), to(to), w(w) {}
	bool operator < (const Edge &rhs) const {
		return w < rhs.w;
	}
}E[MAXN<<1];
ll ans;

bool cmp1(Point a, Point b) {
	return a.x < b.x;
}

bool cmp2(Point a, Point b) {
	return a.y < b.y;
}

inline int dis(int a, int b) {
	return min(abs(P[a].x-P[b].x), abs(P[a].y-P[b].y));
}

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x * f;
}

int find(int x) {
	return fa[x] = fa[x] == x ? x : find(fa[x]);
}

int main() {
	int i;
	n = read();
	for(i = 1; i <= n; i++) 
		P[i].x = read(), P[i].y = read(), P[i].id = i;
	sort(P+1, P+n+1, cmp1);
	for(i = 1; i < n; i++) E[++en] = Edge(P[i].id, P[i+1].id, dis(i, i+1));
	sort(P+1, P+n+1, cmp2);
	for(i = 1; i < n; i++) E[++en] = Edge(P[i].id, P[i+1].id, dis(i, i+1));
	sort(E+1, E+en+1);
	for(i = 1; i <= n; i++) fa[i] = i;
	for(i = 1; i <= en; i++) {
		int a = E[i].from, b = E[i].to;
		int x = find(a), y = find(b);
		if(x == y) continue;
		fa[x] = y, ans += E[i].w;
	}
	printf("%lld\n", ans);
	return 0;
}


Compiler output:
a.cc: In function 'int read()':
a.cc:36:16: error: 'isdigit' was not declared in this scope
   36 |         for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
      |                ^~~~~~~
a.cc:37:15: error: 'isdigit' was not declared in this scope
   37 |         for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
      |               ^~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include<queue>
#include <string>
#define N 250000
#define MOD 1000000007
using namespace std;
int cas;
int n,m;
struct ds{int x,y,i;}d[N];
bool cmpx(ds d1,ds d2){return d1.x<d2.x;}
bool cmpy(ds d1,ds d2){return d1.y<d2.y;}
struct es{int i,j,c;}e[N];
bool cmp(es d1,es d2){return d1.c<d2.c;}
int p[N];
int getf(int x)
{
    int i=x,j;
    while(p[i]!=i)i=p[i];
    while(p[x]!=i){j=p[x];p[x]=i;x=j;}
    return i;
}
void merge(int a,int b)
{
    a=getf(a);b=getf(b);
    p[a]=b;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        d[i].i=i;
        p[i]=i;
        scanf("%d%d",&d[i].x,&d[i].y);
    }
    sort(d+1,d+n+1,cmpx);
    for(int i=1;i<n;i++)
    {
        e[i].i=d[i].i;
        e[i].j=d[i+1].i;
        e[i].c=d[i+1].x-d[i].x;
    }
    sort(d+1,d+n+1,cmpy);
    for(int i=1;i<n;i++)
    {
        e[i+n-1].i=d[i].i;
        e[i+n-1].j=d[i+1].i;
        e[i+n-1].c=d[i+1].y-d[i].y;
    }
    sort(e+1,e+2*n-1,cmp);
    long long ans=0,cnt=0;
    for(int i=1;i<=2*n-2;i++)
    {
        if(getf(e[i].i)!=getf(e[i].j))
        {
            merge(e[i].i,e[i].j);
            ans+=e[i].c;
            cnt++;
            if(cnt==n-1){cout<<ans;return 0;}
        }
    }
}




Compiler output:
a.cc: In function 'int main()':
a.cc:40:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   40 |     sort(d+1,d+n+1,cmpx);
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <stack>
using namespace std;
int main(){
	int R, C, N;
	cin >> R >> C >> N;
	vector<int> x1(N), y1(N), x2(N), y2(N);
	for (int i = 0; i < N; i++){
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	}
	vector<pair<int, int>> pos;
	for (int i = 0; i < N; i++){
		int p = -1;
		if (x1[i] == 0){
			p = y1[i];
		} else if (y1[i] == R){
			p = R + x1[i];
		} else if (x1[i] == C){
			p = R + C + R - y1[i];
		} else if (y1[i] == 0){
			p = R + C + R + C - x1[i];
		}
		int q = -1;
		if (x2[i] == 0){
			q = y2[i];
		} else if (y2[i] == R){
			q = R + x2[i];
		} else if (x2[i] == C){
			q = R + C + R - y2[i];
		} else if (y2[i] == 0){
			q = R + C + R + C - x2[i];
		}
		if (p != -1 && q != -1){
			pos.push_back(make_pair(p, i + 1));
			pos.push_back(make_pair(q, i + 1));
		}
	}
	sort(pos.begin(), pos.end());
	stack<int> st;
	st.push(-1);
	for (auto P : pos){
		if (st.top() == P.second){
			st.pop();
		} else {
			st.push(P.second);
		}
	}
	if (st.size() == 1){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

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

#include <iostream>
#include <vector>
#include <map>
#include <stack>
using namespace std;
int main(){
	int R, C, N;
	cin >> R >> C >> N;
	vector<int> x1(N), y1(N), x2(N), y2(N);
	for (int i = 0; i < N; i++){
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	}
	map<int, int> pos;
	for (int i = 0; i < N; i++){
		int p = -1;
		if (x1[i] == 0){
			p = y1[i];
		} else if (y1[i] == R){
			p = R + x1[i];
		} else if (x1[i] == C){
			p = R + C + R - y1[i];
		} else if (y1[i] == 0){
			p = R + C + R + C - x1[i];
		}
		int q = -1;
		if (x2[i] == 0){
			q = y2[i];
		} else if (y2[i] == R){
			q = R + x2[i];
		} else if (x2[i] == C){
			q = R + C + R - y2[i];
		} else if (y2[i] == 0){
			q = R + C + R + C - x2[i];
		}
		if (p != -1 && q != -1){
			if (p > q){
				swap(p, q);
			}
			assert(!pos.count(p));
			assert(!pos.count(q));
			pos[p] = i + 1;
			pos[q] = - (i + 1);
		}
	}
	stack<int> st;
	for (auto P : pos){
		if (!st.empty()){
			if (st.top() == - P.second){
				st.pop();
            } else {
				st.push(P.second);
            }
        } else {
			st.push(P.second);
		}
    }
	if (st.empty()){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:25: error: 'assert' was not declared in this scope
   39 |                         assert(!pos.count(p));
      |                         ^~~~~~
a.cc:5:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    4 | #include <stack>
  +++ |+#include <cassert>
    5 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <cassert>
using namespace std;
int main(){
	int R, C, N;
	cin >> R >> C >> N;
	vector<int> x1(N), y1(N), x2(N), y2(N);
	for (int i = 0; i < N; i++){
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	}
	map<int, int> pos;
	for (int i = 0; i < N; i++){
		int p = -1;
		if (x1[i] == 0){
			p = y1[i];
		} else if (y1[i] == R){
			p = R + x1[i];
		} else if (x1[i] == C){
			p = R + C + R - y1[i];
		} else if (y1[i] == 0){
			p = R + C + R + C - x1[i];
		}
		int q = -1;
		if (x2[i] == 0){
			q = y2[i];
		} else if (y2[i] == R){
			q = R + x2[i];
		} else if (x2[i] == C){
			q = R + C + R - y2[i];
		} else if (y2[i] == 0){
			q = R + C + R + C - x2[i];
		}
		if (p != -1 && q != -1){
			if (p > q){
				swap(p, q);
			}
			assert(!pos.count(p));
			assert(!pos.count(q));
			pos[p] = i + 1;
			pos[q] = - (i + 1);
		}
	}
	vector<int> P;
	for (int x : pos){
		P.push_back(x.second);
	}
	bool ok = true;
	stack<int> st;
	for (auto x : P){
		if (x > 0){
			st.push(x);
		} else {
			if (st.top() + x == 0){
				st.pop();
			} else {
				ok = false;
				break;
			}
		}
	}
	if (ok){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:22: error: cannot convert 'std::pair<const int, int>' to 'int' in initialization
   47 |         for (int x : pos){
      |                      ^~~
a.cc:48:31: error: request for member 'second' in 'x', which is of non-class type 'int'
   48 |                 P.push_back(x.second);
      |                               ^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <stack>
using namespace std;
int main(){
	int R, C, N;
	cin >> R >> C >> N;
	vector<int> x1(N), y1(N), x2(N), y2(N);
	for (int i = 0; i < N; i++){
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	}
	map<int, int> pos;
	for (int i = 0; i < N; i++){
		int p = -1;
		if (x1[i] == 0){
			p = y1[i];
		} else if (y1[i] == R){
			p = R + x1[i];
		} else if (x1[i] == C){
			p = R + C + R - y1[i];
		} else if (y1[i] == 0){
			p = R + C + R + C - x1[i];
		}
		int q = -1;
		if (x2[i] == 0){
			q = y2[i];
		} else if (y2[i] == R){
			q = R + x2[i];
		} else if (x2[i] == C){
			q = R + C + R - y2[i];
		} else if (y2[i] == 0){
			q = R + C + R + C - x1[i];
		}
		if (p != -1 && q != -1){
			if (p > q){
				swap(p, q);
			}
			pos[p] = i + 1;
			pos[q] = - (i + 1);
		}
	}
	bool ok = true;
	stack<int> st;
	for (auto P : pos){
		if (P.second > 0){
			st.push(P.second);
		} else {
			if (st.top() == - P.second){
				st.pop();
			} else {
				ok = false;
				break;
			}
		}
	}
	if (ok){
		cout << "YES" << endl;
	} else {
		assert(false);
		cout << "NO" << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:17: error: 'assert' was not declared in this scope
   60 |                 assert(false);
      |                 ^~~~~~
a.cc:5:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    4 | #include <stack>
  +++ |+#include <cassert>
    5 | using namespace std;