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

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

#define N 100000
#define INF (1 << 21)

struct POINT {
    int x;
    int y;
};

int n;
POINT p[N];
int cost[N + 1][N + 1];
long long d[N + 1][N + 1];

int main() {
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> p[i].x >> p[i].y;
    }
    
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < n; j++ ) {
            cost[i][j] = INF;
        }
    }
    
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < n; j++ ) {
            if ( i == j ) continue;
            cost[i][j] = min(abs(p[i].x - p[j].x), abs(p[i].y - p[j].y));
        }
    }
    
    for ( int k = 0; k < n; k++ ) {
        for ( int i = 0; i < n; i++ ) {
            if ( d[i][k] == INF ) continue;
            for ( int j = 0; j < n; j++ ) {
                if ( d[k][j] == INF ) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    
    long long ans = 0;
    long long minc = INF;
    for ( int i = 0; i < n; i++ ) {
        for ( int  j = 0; j < n; j++ ) {
            long long tmp = d[i][j];
            minc = min(tmp, minc);
        }
        ans += minc;
    }
    
    cout << ans << endl;
    
    return 0;
}

Compiler output:
/tmp/ccDJJrwA.o: in function `main':
a.cc:(.text+0x21e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o
a.cc:(.text+0x25e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o
a.cc:(.text+0x292): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o
a.cc:(.text+0x2ba): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o
a.cc:(.text+0x2e9): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o
a.cc:(.text+0x323): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o
a.cc:(.text+0x3ac): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
using namespace std;

long long int kaizyou(long long int n){
  return n*kaizyou(n-1)%1000000007
}

main(){
  long long int n,m,ans;
  cin >> n >> m;
  if(n>m+1 || m>n+1){
    cout << "0" <<endl;
  }else{
    ans=kaizyou(n);
    ans*=kaizyou(m);
    if(n!=m){
      ans*=2;
    }
    ans%=1000000007;
    cout << ans << endl;
  }
}


Compiler output:
a.cc: In function 'long long int kaizyou(long long int)':
a.cc:5:35: error: expected ';' before '}' token
    5 |   return n*kaizyou(n-1)%1000000007
      |                                   ^
      |                                   ;
    6 | }
      | ~                                  
a.cc: At global scope:
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
Language: C++

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <functional>
#include <map>
#include <ios>
#include <iosfwd>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <complex.h>
#include <fenv.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <tgmath.h>
#include <conio.h>
#include <numeric>
#include <list>
#include <windows.h>
#include <cfloat>
#include <climits>
using namespace std;

const long long Mod=1e9+7;

inline long long All(int x)
{
	long long res=1;
	for(int i=2;i<=x;i++) res=res*i%Mod;
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	
	int n,m;
	cin>>n>>m;
	
	if(abs(n-m)>1) {cout<<0;return 0;}
	
	long long ans=All(n)*All(m);
	if(n==m) ans*=2;
	
	ans%=Mod;
	
	cout<<ans;
	
	return 0;
}

Compiler output:
a.cc:53:10: fatal error: conio.h: No such file or directory
   53 | #include <conio.h>
      |          ^~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {

    int n, m;
    long long res = 1;
    cin >> n >> m;
    int base = 1e9 + 7;

    if ( abs (n - m) > 1) {
            cout << 0 << '\n;
    }
        else
    {
        if (n == m) {
            res = 2;
        }

        for (int i = 1; i <= n; ++i) {
            res *= i;
            res = res % base;

        }
        for (int j = 1; j <= m; ++j) {
            res *= j;
            res = res % base;
        }

        cout << res << '\n';
    }
    return 0;
}



Compiler output:
a.cc:13:26: warning: missing terminating ' character
   13 |             cout << 0 << '\n;
      |                          ^
a.cc:13:26: error: missing terminating ' character
   13 |             cout << 0 << '\n;
      |                          ^~~~
a.cc: In function 'int main()':
a.cc:14:5: error: expected primary-expression before '}' token
   14 |     }
      |     ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {

    int n, m;
    long long res = 1;
    cin >> n >> m;
    int base = 1e9 + 7;

    if ( abs (n - m) > 1) {
            cout << 0;
        else
    {
        if (n == m) {
            res = 2;
        }

        for (int i = 1; i <= n; ++i) {
            res *= i;
            res = res % base;

        }
        for (int j = 1; j <= m; ++j) {
            res *= j;
            res = res % base;
        }

        cout << res << '\n';
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: expected '}' before 'else'
   14 |         else
      |         ^~~~
a.cc:12:27: note: to match this '{'
   12 |     if ( abs (n - m) > 1) {
      |                           ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {

    int n, m;
    long long res = 1;
    cin >> n >> m;
    int base = 1e9 + 7;

    if ( abs (n - m) > 1) {
            cout << 0;
        else
    {
        if (n == m) {
            res = 2;
        }

        for (int i = 1; i <= n; ++i) {
            res *= i;
            res = res % base;

        }
        for (int j = 1; j <= m; ++j) {
            res *= j;
            res = res % base;
        }

        cout << res << '\n';
    }
    return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: expected '}' before 'else'
   14 |         else
      |         ^~~~
a.cc:12:27: note: to match this '{'
   12 |     if ( abs (n - m) > 1) {
      |                           ^
Language: C++

#include <iostream>
#include <algorithm>
#define _ %1000000007

typedef long long LL;
using namespace std;

int compute(int M, int D) {
    if (abs(M-D) > 1) return 0;
    int tiny = min(M, D);
    LL ret = 1;
    for (LL item = tiny; item >= 2; item--) {
        ret = (item*ret)_;
    }
    ret = (ret*ret)_;
    if(M == D) {
        ret = (ret<<1)_;
    }
    else {
        int big = max(M, D);
        ret = (ret*big)_;
    }
    return ret;


}

int main() {
    int m,d;
    cin >> m >> d;
    int ret = compute(m, d);
    cout << ret << endl;100000 100000

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:31: error: expected ';' before numeric constant
   32 |     cout << ret << endl;100000 100000
      |                               ^~~~~~~
      |                               ;
Language: Java

/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class TaskC {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    long MOD = 1_000_000_007;
    String[] s = br.readLine().split(" ");
    long n = Long.parseLong(s[0]);
    long m = Long.parseLong(s[1]);

    if (m>n+1 || m<n-1) {
      System.out.println(0);
      System.exit(0);
    }
    long fact1 = 1;
    long fact2 = 1;
    for (int i=0; i<m; i++) {
      fact1*=(i+1);
      fact1%=MOD;
    }
    for (int i=0; i<n; i++) {
      fact2*=(i+1);
      fact2%=MOD;
    }
    long ans = (fact1*fact2)%MOD;
    if (m==n)
      ans*=2;
    ans%=MOD;
    System.out.println(ans);
  }
}


Compiler output:
Main.java:8: error: class TaskC is public, should be declared in a file named TaskC.java
public class TaskC {
       ^
1 error
Language: C++

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

int main() {
    long long n, m, ans = 1;
	cin >> n >> m;
	if (n > m) swap(n,m);
	if (n + 1 < m) cout << 0;
	else {
        rep(i,1,n+1) ans = ans * i % MOD * i % MOD;
        if (n == m) cout << ans * 2 % MOD;
        else cout << ans * m % MOD;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:13: error: 'i' was not declared in this scope
   10 |         rep(i,1,n+1) ans = ans * i % MOD * i % MOD;
      |             ^
a.cc:10:9: error: 'rep' was not declared in this scope
   10 |         rep(i,1,n+1) ans = ans * i % MOD * i % MOD;
      |         ^~~
a.cc:11:39: error: 'MOD' was not declared in this scope
   11 |         if (n == m) cout << ans * 2 % MOD;
      |                                       ^~~
a.cc:12:32: error: 'MOD' was not declared in this scope
   12 |         else cout << ans * m % MOD;
      |                                ^~~
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;

bool comp(vll a,vll b){
    return a[0]<b[0];
}





int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vvll x(N,vll(2)),y(N,vll(2));
    for(ll i=0;i<N;i++){
        cin>>x[i][0]>>y[i][0];
        x[i][1]=i;y[i][1]=i;
    }
    
    sort(ALL(x),comp);sort(ALL(y),comp);
    
    vvll cost(N,vll(N,LLMAX));
    for(ll i=0;i<N-1;i++){
        cost[x[i][1]][x[i+1][1]]=x[i+1][0]-x[i][0];
        cost[x[i+1][1]][x[i][1]]=x[i+1][0]-x[i][0];
    }
    for(ll i=0;i<N-1;i++){
        cost[y[i][1]][y[i+1][1]]=y[i+1][0]-y[i][0];
        cost[y[i+1][1]][y[i][1]]=y[i+1][0]-y[i][0];
    }
    
    vll s(2*N-2),t(2*N-2),c(2*N-2);
    for(ll i=0;i<N-1;i++){
        s[i]=x[i][1];
        t[i]=x[i+1][1];
        c[i]=x[i+1][0]-x[i][0];
    }
    for(ll i=0;i<N-1;i++){
        s[i+N-1]=y[i][1];
        t[i+N-1]=y[i+1][1];
        c[i+N-1]=y[i+1][0]-y[i][0];
    }
    
    cout<<kruskal(s,t,c,N)<<endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:68:11: error: 'kruskal' was not declared in this scope
   68 |     cout<<kruskal(s,t,c,N)<<endl;
      |           ^~~~~~~
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

struct edge
{
    int x,y,cost;
};

struct pct
{
    int x,y,ind;
};

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

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

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

pct P[100005];
vector<edge> Edg;
int Pa[100005],Sz[100005];

int parent(int x)
{
    int cx=x;
    while(Pa[x]!=0)
        x=Pa[x];

    while(Pa[cx]!=0)
    {
        int aux=Pa[cx];
        Pa[cx]=x;
        cx=aux;
    }
    return x;
}

bool unite(int x, int y)
{
    x=parent(x);
    y=parent(y);

    if(x==y)
        return 0;

    if(Sz[x]>=Sz[y])
    {
        Sz[x]+=Sz[y];
        Pa[y]=x;
    }
    else
    {
        Sz[y]+=Sz[x];
        Pa[x]=y;
    }
    return 1;
}

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

    int n;
    cin>>n;

    for(int i=1; i<=n; i++)
    {
        cin>>P[i].x>>P[i].y;
        P[i].ind=i;
        Sz[i]=1;
    }

    sort(P+1,P+n+1,cmp1);
    for(int i=2; i<=n; i++)
        Edg.push_back({P[i].ind,P[i-1].ind,P[i].x-P[i-1].x});

    sort(P+1,P+n+1,cmp2);
    for(int i=2; i<=n; i++)
        Edg.push_back({P[i].ind,P[i-1].ind,P[i].y-P[i-1].y});

    sort(Edg.begin(),Edg.end(),cmp);

    long long rez=0;
    for(auto edg:Edg)
    {
        if(unite(edg.x,edg.y))
            rez+=edg.cost;
    }

    cout<<rez<<"\n";
    return 0;
}


Compiler output:
a.cc:32:1: error: 'vector' does not name a type
   32 | vector<edge> Edg;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:89:9: error: 'Edg' was not declared in this scope
   89 |         Edg.push_back({P[i].ind,P[i-1].ind,P[i].x-P[i-1].x});
      |         ^~~
a.cc:93:9: error: 'Edg' was not declared in this scope
   93 |         Edg.push_back({P[i].ind,P[i-1].ind,P[i].y-P[i-1].y});
      |         ^~~
a.cc:95:10: error: 'Edg' was not declared in this scope
   95 |     sort(Edg.begin(),Edg.end(),cmp);
      |          ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

struct point {
    int x, y, id;
} a[N];

bool cmp1(const point& a, const point& b) {
    if (a.x != b.x) {
        return a.x < b.x;
    }
    return a.y < b.y;
}

bool cmp2(const point& a, const point& b) {
    if (a.y != b.y) {
        return a.y < b.y;
    }
    return a.x < b.x;
}

int n;
bool visited[N];
vector<pair<long long, int> > g[N];

long long prim(int x) {
    priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > pq;
    long long ans = 0;
    pq.push({0, x});
    while(!pq.empty()) {
        pair<long long, int> p = pq.top();
        pq.pop();
        x = p.second;
        if (visited[x]) {
        	continue;
		}
        ans += p.first;
        visited[x] = true;
        for(int i = 0; i < g[x].size(); i++) {
            int y = g[x][i].second;
            if (!visited[y]) {
            	pq.push(g[x][i]);
            }
        }
    }
    return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].y;
		a[i].id = i + 1;
	}
	sort(p, p + n, cmp1);
	for (int i = 1; i < n; i++) {
		g[a[i].id].push_back({abs(a[i].x - a[i - 1].x), a[i - 1].id});
		g[a[i - 1].id].push_back({abs(a[i].x - a[i - 1].x), a[i].id});
	}
	sort(p, p + n, cmp2);
	for (int i = 1; i < n; i++) {
		g[a[i].id].push_back({abs(a[i].y - a[i - 1].y), a[i - 1].id});
		g[a[i - 1].id].push_back({abs(a[i].y - a[i - 1].y), a[i].id});
	}
	cout << prim(1) << '\n';
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:14: error: 'p' was not declared in this scope
   60 |         sort(p, p + n, cmp1);
      |              ^
Language: C++

typedef long long ll;
int N;

void _main() {
    cin >> N;
    vector<pair<int, int>> va, vb;
    rep(i, 0, N) {
        int x, y; cin >> x >> y;
        va.push_back({ x, i });
        vb.push_back({ y, i });
    }
 
    vector<tuple<int, int, int>> edges;
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    rep(i, 0, N - 1) {
        edges.push_back(make_tuple( va[i + 1].first - va[i].first, va[i].second, va[i + 1].second ));
        edges.push_back(make_tuple( vb[i + 1].first - vb[i].first, vb[i].second, vb[i + 1].second));
    }
    sort(edges.begin(), edges.end());
    
    UnionFind uf(N);
    ll ans = 0;
    for (auto p : edges) {
        int x, y, c;
        tie(c, x, y) = p;
 
        if (uf[x] != uf[y]) {
            uf(x, y);
            ans += c;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'void _main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> N;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<pair<int, int>> va, vb;
      |     ^~~~~~
a.cc:6:12: error: 'pair' was not declared in this scope
    6 |     vector<pair<int, int>> va, vb;
      |            ^~~~
a.cc:6:17: error: expected primary-expression before 'int'
    6 |     vector<pair<int, int>> va, vb;
      |                 ^~~
a.cc:7:9: error: 'i' was not declared in this scope
    7 |     rep(i, 0, N) {
      |         ^
a.cc:7:5: error: 'rep' was not declared in this scope
    7 |     rep(i, 0, N) {
      |     ^~~
a.cc:13:12: error: 'tuple' was not declared in this scope
   13 |     vector<tuple<int, int, int>> edges;
      |            ^~~~~
a.cc:13:18: error: expected primary-expression before 'int'
   13 |     vector<tuple<int, int, int>> edges;
      |                  ^~~
a.cc:14:10: error: 'va' was not declared in this scope
   14 |     sort(va.begin(), va.end());
      |          ^~
a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |     sort(va.begin(), va.end());
      |     ^~~~
      |     short
a.cc:15:10: error: 'vb' was not declared in this scope
   15 |     sort(vb.begin(), vb.end());
      |          ^~
a.cc:20:10: error: 'edges' was not declared in this scope
   20 |     sort(edges.begin(), edges.end());
      |          ^~~~~
a.cc:22:5: error: 'UnionFind' was not declared in this scope
   22 |     UnionFind uf(N);
      |     ^~~~~~~~~
a.cc:26:9: error: 'tie' was not declared in this scope
   26 |         tie(c, x, y) = p;
      |         ^~~
a.cc:28:13: error: 'uf' was not declared in this scope
   28 |         if (uf[x] != uf[y]) {
      |             ^~
a.cc:33:5: error: 'cout' was not declared in this scope
   33 |     cout << ans << endl;
      |     ^~~~
a.cc:33:20: error: 'endl' was not declared in this scope
   33 |     cout << ans << endl;
      |                    ^~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

// 全局变量
const int N = 100010 , M = N + N;
int x[N],y[N],id[N],n;

typedef struct ufset *UFset;
struct ufset
{
  int *parent;
  int *root;
};
UFset UFinit(int size)
{
  int e;
  UFset U=(UFset)malloc(sizeof *U);
  U->parent=(int*)malloc((size+1)*sizeof(int));
  U->root=(int*)malloc((size+1)*sizeof(int));
  for(e=1; e<=size; e++)
  {
    U->parent[e]=1;
    U->root[e]=1;
  }
  return U;
}
int UFfind(int e,UFset U)
{
  int i,j = e;
  while(!U->root[j]) j = U->parent[j];
  while(j!=e){
    i = U->parent[e];
    U->parent[e]=j;
    e=i;
  }
  return j;
}
int UFunion(int i,int j,UFset U)
{
  if(U->parent[i]<U->parent[j])
  {
    U->parent[j]+=U->parent[i];
    U->root[i]=0;
    U->parent[i]=j;
    return j;
  }
  else
  {
    U->parent[i]+=U->parent[j];
    U->root[j]=0;
    U->parent[j]=i;
    return i;
  }
}

// 记录优化后的边集数
struct Edge
{
  int u, v, cost;
  bool operator <(const Edge&b) const
  {
    return cost < b.cost;
  }
} edge[M];
int tot;
// 按照X轴排序
bool cmpX(int a, int b)
{
  return x[a] < x[b];
}
// 按照Y轴排序
bool cmpY(int a, int b)
{
  return y[a] < y[b];
}
void add(int c, int a, int b)
{
  edge[tot].cost = c;
  edge[tot].u = a;
  edge[tot++].v = b;
}
int main()
{
  scanf("%d", &n);
  int i
  for (i = 1; i <= n; ++i)
  {
    scanf("%d%d", x + i, y + i);
    id[i] = i;
  }
  std::sort(id + 1 , id + n + 1, cmpX);
  for (i = 2; i <= n; ++i)
    add(x[id[i]] - x[id[i - 1]], id[i], id[i - 1]);
  std::sort(id + 1 , id + n + 1, cmpY);
  for (i = 2; i <= n; ++i)
    add(y[id[i]] - y[id[i - 1]], id[i], id[i - 1]);
  UFset UFS = UFinit(n);

  // 按照花费排序
  std::sort(edge, edge + tot);
  long long totcost = 0;
  for (i = 0; i < tot; ++i)
  {
    int u = edge[i].u, v = edge[i].v;
    u = UFfind(u,UFS), v = UFfind(v,UFS);
    if (u != v)
    {
      UFunion(u,v,UFS);
      totcost += edge[i].cost;
    }
  }
  printf("%lld\n", totcost);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:87:3: error: expected initializer before 'for'
   87 |   for (i = 1; i <= n; ++i)
      |   ^~~
a.cc:87:15: error: 'i' was not declared in this scope
   87 |   for (i = 1; i <= n; ++i)
      |               ^
a.cc:106:24: error: 'v' was not declared in this scope
  106 |     u = UFfind(u,UFS), v = UFfind(v,UFS);
      |                        ^
Language: Java

import sys
import heapq
def getn():
    return int(sys.stdin.readline())
def getnums():
    return list(map(int,(sys.stdin.readline().split())))

INF=10000000000
n = getn()
pos = []
edge = [[] for i in range(n)]
for i in range(n):
    x,y = getnums()
    pos.append([x,y,i])

pos.sort(key=lambda x:x[0])
for i,j in zip(pos, pos[1:]):
    x1,y1,i1 = i
    x2,y2,i2 = j
    cost = min(abs(x1-x2), abs(y1-y2))
    edge[i1].append([cost,i2])
    edge[i2].append([cost,i1])

pos.sort(key=lambda x:x[1])
for i,j in zip(pos, pos[1:]):
    x1,y1,i1 = i
    x2,y2,i2 = j
    cost = min(abs(x1-x2), abs(y1-y2))
    edge[i1].append([cost,i2])
    edge[i2].append([cost,i1])

def prim(start, n):
    ans = 0
    n_set = 1
    group = set([start])
    q = edge[start]
    heapq.heapify(q)
    while(q):
        next_e = heapq.heappop(q)
        if next_e[1] in group:
            pass
        else:
            ans += next_e[0]
            group.add(next_e[1])
            for ne in edge[next_e[1]]:
                heapq.heappush(q, ne)
            n_set += 1
            #print("union: ", next_e[1], group)
            #print(q)
        if n_set == n:
            return ans

ans  = prim(0, n)
print(ans)
#print(edge)





Compiler output:
Main.java:1: error: '.' expected
import sys
          ^
Main.java:2: error: '.' expected
import heapq
            ^
Main.java:3: error: ';' expected
def getn():
   ^
Main.java:48: error: illegal character: '#'
            #print("union: ", next_e[1], group)
            ^
Main.java:49: error: illegal character: '#'
            #print(q)
            ^
Main.java:55: error: illegal character: '#'
#print(edge)
^
6 errors
Language: C++

/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)
struct part{
LL v;
int id;
};
struct part1{
int x,y;
LL v;
};
bool cmp(struct part a, struct part b)
{
    return(a.v<b.v);
}
int f[100010];
int find1(int x)
{
    if (f[x]==x) return(x); else f[x]=find1(f[x]);
    retufn(f[x]);
}
bool cmp1(struct part1 a, struct part1 b)
{
    return(a.v<b.v);
}
struct part x[100010],y[100010];
struct part1 a[200010];
int n;
int main()
{
scanf("%d",&n);
for (int i=1;i<=n;i++)
{
    LL xx,yy;
    scanf("%lld%lld",&xx,&yy);
    x[i].v=xx;
    x[i].id=i;
    y[i].v=yy;
    y[i].id=i;
}
sort(x+1,x+1+n,cmp);
sort(y+1,y+1+n,cmp);
int o=0;
for (int i=1;i<=n-1;i++)
{
    o++;
    a[o].x=x[i].id;
    a[o].y=x[i+1].id;
    a[o].v=x[i+1].v-x[i].v;
}
for (int i=1;i<=n-1;i++)
{
    o++;
    a[o].x=y[i].id;
    a[o].y=y[i+1].id;
    a[o].v=y[i+1].v-y[i].v;
}
sort(a+1,a+1+o,cmp1);
for (int i=1;i<=n;i++)
    f[i]=i;
int k=0;
LL ans=0;
for (int i=1;i<=o;i++)
{
    int fa=find1(a[i].x);
    int fb=find1(a[i].y);
    if (fa!=fb)
    {
        f[fa]=fb;
        ans+=a[i].v;
        k++;
    }
    if (k==n-1) break;
}
printf("%lld\n",ans);
    return(0);
}


Compiler output:
a.cc: In function 'int find1(int)':
a.cc:46:5: error: 'retufn' was not declared in this scope
   46 |     retufn(f[x]);
      |     ^~~~~~
a.cc:45:38: warning: control reaches end of non-void function [-Wreturn-type]
   45 |     if (f[x]==x) return(x); else f[x]=find1(f[x]);
      |                                  ~~~~^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int > vi;
typedef pair<int ,int > pii;
typedef vector<pii> vii;
const int inf=0x3f3f3f3f, maxn=100007, mod=1e9+7;
const ll linf=0x3f3f3f3f3f3f3f3fLL;
const ll P=19260817;
int fa[100007];
int n;
register int find(int x){
	return x==fa[x]? x: fa[x]=find(fa[x]);
}
struct node{
	int x,y,id;
}a[100007];
inline bool cmp1(const node& a,const node& b){
	return a.x<b.x;
}
inline bool cmp2(const node& a,const node& b){
	return a.y<b.y;
}
struct edge{
	int x,y,val;
}e[100005<<2];
inline bool cmp3(const edge& a,const edge &b){
	return a.val<b.val;
}
int cnt;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y),a[i].id=i;
	sort(a+1,a+n+1,cmp1);
	for(int i=1;i<n;i++){
		e[++cnt].x=a[i].id;
		e[cnt].y=a[i+1].id;
		e[cnt].val=abs(a[i].x-a[i+1].x);
	}
	sort(a+1,a+n+1,cmp2);
	for(int i=1;i<n;i++){
		e[++cnt].x=a[i].id;
		e[cnt].y=a[i+1].id;
		e[cnt].val=abs(a[i].y-a[i+1].y);
	}
	sort(e+1,e+cnt+1,cmp3);
	int p=0;
	ll ans=0;
	for(int i=1;i<=cnt;i++){
		int fx=find(e[i].x);
		int fy=find(e[i].y);
		if(fx==fy)continue;
		fa[fx]=fy;
		ans+=e[i].val;
		p++;
		if(p==n-1)break;
	}
	printf("%lld",ans);
    return 0;
}


Compiler output:
a.cc:15:1: error: storage class 'register' invalid for function 'find'
   15 | register int find(int x){
      | ^~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=1e5+10;
int pre[N];

struct Node{
    int x,y,ind;
}v1[N],v[4*N];

int cmp1(Node a,Node b)
{
    if(a.x==b.x)
        return a.y<b.y;
    return a.x<b.x;
}
int cmp2(Node a,Node b)
{
    if(a.y==b.y)
        return a.x<b.x;
    return a.y<b.y;
}
int cmp(Node a,Node b)
{
    return a.ind<b.ind;
}
int find(int x){    return pre[x]==x?x:find(pre[x]);}
int vind=0;
int main()
{
    int n,x,y;
    vind=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        pre[i]=i;
        scanf("%d%d",&v1[i].x,&v1[i].y);
        v1[i].ind=i;
    }
    sort(v1,v1+v1ind,cmp1);
    for(int i=0;i<n-1;i++)
    {
        v[vind].x=v1[i].ind;v[vind].y=v1[i+1].ind;v[vind++].ind=min(abs(v1[i].x-v1[i+1].x),abs(v1[i].y-v1[i+1].y));
    }
    sort(v1,v1+v1ind,cmp2);
    for(int i=0;i<v1ind-1;i++)
    {
        v[vind].x=v1[i].ind;v[vind].y=v1[i+1].ind;v[vind++].ind=min(abs(v1[i].x-v1[i+1].x),abs(v1[i].y-v1[i+1].y));
    }
    sort(v,v+vind,cmp);
    int m=n-1,i=0;
    ll ans=0;
    while(i<vind)
    {
        if(m==0)    break;
        int prex=find(v[i].x),prey=find(v[i].y);
        if(prex!=prey)
        {
            pre[prex]=prey;
            m--;
            ans+=(ll)v[i].ind;
        }
        i++;
    }
    printf("%lld\n",ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:16: error: 'v1ind' was not declared in this scope; did you mean 'vind'?
   41 |     sort(v1,v1+v1ind,cmp1);
      |                ^~~~~
      |                vind
Language: C++

#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define lim 100001
using namespace std;
struct point
{
	int x,y,id;
} c[lim];
struct edge
{
	int u,v,cost;
} e[2*lim];
bool cmp1(point a,point b)
{
	return a.x < b.x;
}
bool cmp2(point a,point b)
{
	return a.y < b.y;
}
bool cmp_edge(edge a,edge b)
{
	return a.cost < b.cost;
}
int parent[lim];
int find(int x){return p[x] == x ? x : p[x] = find(p[x]);}
int n,tot;
signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  cin >> n;
  for(int i = 0; i <= n; i++) p[i] = i;
  for(int i = 1; i <= n; i++){
   cin >> dx[i] >> dy[i];
  }
  for(int i = 1; i <= n; i++)
  {
    c[i].x = dx[i]; c[i].y = dy[i];c[i].id = i;
  }
  sort(c+1,c+1+n,cmp1);
  for(int i = 2; i <= n; i++){
    e[tot].u = c[i].id;
    e[tot].v = c[i-1].id;
    e[tot].cost = c[i].x - c[i-1].x;
    tot++;
  }
  sort(c+1,c+1+n,cmp2);
  for(int i = 2; i <= n; i++){
    e[tot].u = c[i].id;
    e[tot].v = c[i-1].id;
    e[tot].cost = c[i].y - c[i-1].y;
    tot++;
  }
  sort(e,e+tot,cmp);
  ll ans = 0;
  int cnt = 0;
  for(int i = 0; i < tot; i++){
    int f = find(e[i].u);
    int t = find(e[i].v);
    if(f!=t){ans+=e[i].cost;p[f] = t;cnt++;}
    if(cnt == n-1)break;
  }
  printf("%lld\n", ans);
  return 0;
}

Compiler output:
a.cc: In function 'long long int find(long long int)':
a.cc:27:24: error: 'p' was not declared in this scope
   27 | int find(int x){return p[x] == x ? x : p[x] = find(p[x]);}
      |                        ^
a.cc: In function 'int main()':
a.cc:34:31: error: 'p' was not declared in this scope
   34 |   for(int i = 0; i <= n; i++) p[i] = i;
      |                               ^
a.cc:36:11: error: 'dx' was not declared in this scope
   36 |    cin >> dx[i] >> dy[i];
      |           ^~
a.cc:36:20: error: 'dy' was not declared in this scope
   36 |    cin >> dx[i] >> dy[i];
      |                    ^~
a.cc:40:14: error: 'dx' was not declared in this scope
   40 |     c[i].x = dx[i]; c[i].y = dy[i];c[i].id = i;
      |              ^~
a.cc:40:30: error: 'dy' was not declared in this scope
   40 |     c[i].x = dx[i]; c[i].y = dy[i];c[i].id = i;
      |                              ^~
a.cc:56:16: error: 'cmp' was not declared in this scope; did you mean 'cmp2'?
   56 |   sort(e,e+tot,cmp);
      |                ^~~
      |                cmp2
a.cc:57:3: error: 'll' was not declared in this scope
   57 |   ll ans = 0;
      |   ^~
a.cc:62:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
   62 |     if(f!=t){ans+=e[i].cost;p[f] = t;cnt++;}
      |              ^~~
      |              abs
a.cc:62:29: error: 'p' was not declared in this scope
   62 |     if(f!=t){ans+=e[i].cost;p[f] = t;cnt++;}
      |                             ^
a.cc:65:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   65 |   printf("%lld\n", ans);
      |                    ^~~
      |                    abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector< pair < int , pair < ii , ii > > > viiiii;
map <ii,int> r;
map<ii,ii> p;
viiiii edge;
int numset;
ii a[100005];
void init(int N)
{
	numset=N;
	for(int i=0 ; i<N ; i++)
	{
		p[a[i]] = a[i];
	}
}
ii find(ii i)
{
	if(p[i].fi == i.fi && p[i].se == i.se)
	return p[i];
	else return find(p[i]); 
}
bool same(ii i, ii j)
{
	ii u = find(i);
	ii v = find(j);
	if(u .fi == v .fi && u .se == v .se) return 1;
	return 0;
}
void joint(ii i, ii j)
{
	if(same(i,j)==0)
	{
		numset--;
		r[find(j)]+=r[find(i)];
		p[find(i)]=find(j);
	}
}
int size(ii i)
{
	return r[find(i)];
}
int kruskal(int V)
{
	sort(edge.begin(),edge.end());
	init(V);
	int cost = 0;
	for(int i=0 ; i < edge.size(); i++)
	{
		pair < int , pair < ii , ii > > front = edge[i];
		if(same(front.se.fi,front.se.se) == 0)
		{	
			cost += front.fi;
			joint(front.se.fi,front.se.se);
		}
	}
	return cost;
}

bool cmp(ii a , ii b)
{
	return a . se < b .se;
}
signed main(){
	int n;
	cin >> n;
	for(int i = 1 ; i <= n ; ++i)
	{
		int x, y;
		cin >> x >> y;
		r[a[i]] = 1;
		a[i].fi = x;
		a[i].se = y;
	}
	sort(a + 1, a + n + 1);
	for(int i = 1 ; i < n ; ++i)
	{
		for(int j = i + 1 ; j <= i + 50 && j <= n ; ++j)
		{
			edge.pb(mp(a[j].fi - a[i].fi,mp(a[i],a[j])));
		}
	}
	sort(a + 1, a + n + 1, cmp);
	for(int i = 1 ; i < n ; ++i)
	{
		for(int j = i + 1 ;j <= i + 50 && j <= n; ++j)
		{
			edge.pb(mp(a[j].se - a[i].se,mp(a[i],a[j])));
		}
	}
	co

Compiler output:
a.cc: In function 'int main()':
a.cc:99:9: error: 'co' was not declared in this scope; did you mean 'cos'?
   99 |         co
      |         ^~
      |         cos
a.cc:99:11: error: expected '}' at end of input
   99 |         co
      |           ^
a.cc:72:14: note: to match this '{'
   72 | signed main(){
      |              ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;
const int N=1e5+100;
int u[N],n,ans;
class edge
{
    public:
    int f,t,w;
    edge(int f,int t,int w):f(f),t(t),w(w){}
};
class ufind
{
    vector<int> f,r;
    public:
    ufind(int n)
    {
        f.reserve(N);
        r.assign(N,1);
        for(int i=1;i<=n;++i) f[i]=i;
    }
    int find(int x)
    {
        if (x==f[x]) return x;
        else x=f[x];
    }
    bool unite(int x,int y)
    {
        x=find(x);y=find(y);
        if (x==y) return false;
        if (r[x]<r[y]) swap(x,y);
        f[y]=x;
        if (r[x]==r[y]) r[x]++;
        return true;
    }
};
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    vector<pair<int,int>> x,y;
    for(int i=1;i<=n;++i)
    {
        int xx,yy;
        cin>>xx>>yy;
        x.push_back(make_pair(xx,i));
        y.push_back(make_pair(yy,i));
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    vector<edge> e;
    for(int i=1;i<n;++i) 
    {
        e.push_back(edge(x[i-1].second,x[i].second,x[i].first-x[i-1].first)); 
        e.push_back(edge(y[i-1].second,y[i].second,y[i].first-y[i-1].first)); 
        e.push_back(edge(x[i].second,x[i-1].second,x[i].first-x[i-1].first)); 
        e.push_back(edge(y[i].second,y[i-1].second,y[i].first-y[i-1].first)); 
    }
    sort(e.begin(),e.end(),[](const edge &a,const edge &b){return a.w<b.w;});
    ufind s(n);
    cout<<e.size()<<endl;
    for(auto i:e)
        if(s.unite(i.f,i.t)) ans+=i.w;
    cout<<ans<<endl;
    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In member function 'long long int ufind::find(long long int)':
a.cc:27:15: warning: control reaches end of non-void function [-Wreturn-type]
   27 |         else x=f[x];
Language: C++

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

using namespace std;
using ll = long long;

const int MAX = 1e5+1;
ll G[MAX][MAX];
int N;

ll prim(){
    ll ans = 0ll;
    vector<bool> used(N,false);
    priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > Q;

    Q.push(make_pair(0,0));
    while(!Q.empty()){
        int u;
        ll cost_u;
        tie(cost_u, u) = Q.top(); Q.pop();

        if(used[u]) continue;
        used[u] = true;
        ans += cost_u;
        for(int j=0;j<N;j++){
            Q.push(make_pair(G[u][j], j));
        }
    }
    return ans;
}

int main(){
    cin >> N;
    vector<pair<int,int> > towns(N);
    int x,y;
    for(int i=0;i<N;i++){
        scanf("%d%d", &x,&y);
        towns[i] = make_pair(x,y);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            ll cost = min(abs(towns[i].first - towns[j].first), abs(towns[i].second-towns[j].second));
            G[i][j] = cost;
        }
    }
    cout << prim() << endl;
    return 0;
}

Compiler output:
/tmp/cc5UKB2c.o: in function `prim()':
a.cc:(.text+0x2a): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o
a.cc:(.text+0x203): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o
/tmp/cc5UKB2c.o: in function `main':
a.cc:(.text+0x2af): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o
a.cc:(.text+0x2d1): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o
a.cc:(.text+0x364): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o
a.cc:(.text+0x44c): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o
a.cc:(.text+0x45f): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5UKB2c.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <cstdio>
#include <cstdlib>

using namespace std;
using ll = long long;

const int MAX = 1e5+1;
ll G[MAX][MAX];
int N;

ll prim(){
    ll ans = 0ll;
    vector<bool> used(N,false);
    priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > Q;

    Q.push(make_pair(0,0));
    while(!Q.empty()){
        int u;
        ll cost_u;
        tie(cost_u, u) = Q.top(); Q.pop();

        if(used[u]) continue;
        used[u] = true;
        ans += cost_u;
        for(int j=0;j<N;j++){
            Q.push(make_pair(G[u][j], j));
        }
    }
    return ans;
}

int main(){
    cin >> N;
    vector<pair<int,int> > towns(N);
    int x,y;
    for(int i=0;i<N;i++){
        scanf("%d%d", &x,&y);
        towns[i] = make_pair(x,y);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            ll cost = min(abs(towns[i].first - towns[j].first), abs(towns[i].second-towns[j].second));
            G[i][j] = cost;
        }
    }
    cout << prim() << endl;
    return 0;
}

Compiler output:
/tmp/cckzbRIK.o: in function `prim()':
a.cc:(.text+0x2a): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o
a.cc:(.text+0x203): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o
/tmp/cckzbRIK.o: in function `main':
a.cc:(.text+0x2af): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o
a.cc:(.text+0x2d1): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o
a.cc:(.text+0x364): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o
a.cc:(.text+0x44c): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o
a.cc:(.text+0x45f): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cckzbRIK.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MAX 100001
int x[MAX], y[MAX];

int main(void) {
    int N, xmin = int(1e9), xmax = 0, ymin = int(1e9), ymax = 0;
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        scanf("%d%d", x+i, y+i);
        xmin = min(xmin, x[i]);
        xmax = max(xmax, x[i]);
        ymin = min(ymin, y[i]);
        ymax = man(ymax, y[i]);
    }

    return !printf("%d\n", min(xmax - xmin, ymax - ymin));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: 'man' was not declared in this scope; did you mean 'tan'?
   17 |         ymax = man(ymax, y[i]);
      |                ^~~
      |                tan
Language: C++

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

using namespace std;

const int MAX = 100000;
const int WHITE = 0;
const int BLACK = 1;
const int GRAY = 2;
const int INFTY = (int) 1 << 21;

typedef pair<int,int> t_pi;

int n;
int list[MAX][MAX];
int d[MAX], color[MAX], p[MAX];
t_pi pos[MAX];

int cost_func(t_pi a, t_pi b){
    int A = abs(a.first-b.first);
    int B = abs(a.second-b.second);
    return min(A,B);
}

int prim(){
    for(int i=0;i<n;i++){
        color[i] = WHITE;
        p[i] = -1;
        d[i] = INFTY;
    }

    d[0] = 0;

    while(true){
        int mincost = INFTY;
        int u = -1;
        for(int i=0;i<n;i++){
            if(color[i] != BLACK && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }

        if(u == -1) break;
        color[u] = BLACK;
        for(int v=0;v<n;v++){
            if(color[v] != BLACK ){
                if(d[v] > list[u][v]){
                    d[v] = list[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    int total = 0;
    for(int i=0;i<n;i++){
        if(p[i] != -1){
            total += list[i][p[i]];
        }
    }

    return total;
}

int main(void){
    cin >> n;

    int x, y;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        pos[i] = make_pair(x,y);
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int tmp = cost_func(pos[i],pos[j]);
            list[i][j] = tmp;
        }
    }

    cout << prim() << endl;

    return 0;
}



Compiler output:
/tmp/ccvgGfCX.o: in function `prim()':
a.cc:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0x83): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0x9e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0xba): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0x105): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0x121): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0x15a): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0x181): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0x1a1): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvgGfCX.o
a.cc:(.text+0x20b): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll = long long;

struct V {
  int index;
  ll x, y;
};
struct E {
  int v, u;
  ll cost;
};
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
  int N;
  cin >> N;
  vector<V> vs;
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    vs.push_back(V{ i, x, y });
  }
  vector<E> es;
  sort(vs.begin(), vs.end(), [](const V &a, const V &b) {
    return a.x < b.x;
  });
  for (int i = 1; i < N; i++) {
    es.push_back(E{ vs[i-1].index, vs[i].index, vs[i].x - vs[i-1].x });
  }
  sort(vs.begin(), vs.end(), [](const V &a, const V &b) {
    return a.y < b.y;
  });
  for (int i = 1; i < N; i++) {
    es.push_back(E{ vs[i-1].index, vs[i].index, vs[i].y - vs[i-1].y });
  }
  sort(es.begin(), es.end(), [](const E &a, const E &b) {
    return a.cost < b.cost;
  });
  UnionFind uf(N);
  ll res = 0;
  for (const auto &e: es) {
    if (!uf.findSet(e.v, e.u)) {
      res += e.cost;
      uf.unionSet(e.v, e.u);
    }
  }
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   47 |   sort(vs.begin(), vs.end(), [](const V &a, const V &b) {
      |   ^~~~
      |   short
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
#define inf 1<<29
#define nu 1000005
#define maxnum 100005
#define num 30
int n;
struct Md
{
    int v,u,flag;

}M[maxnum],C[maxnum];
struct Node
{
    int x,y,z;

}dis[nu];
bool cmp(Md a,Md b){
   return a.v<b.v;
}
bool cmp0(Md a,Md b){
   return a.u<b.u;
}
bool cmp1(Node a,Node b){
   return a.z<b.z;
}
int book[maxnum];
void init()
{
    for(int i=1;i<=n;i++)
        book[i]=i;

}
int getx(int x)
{
    if(book[x]!=x)
        book[x]=getx(book[x]);
    return book[x];
}
void mergexy(int x,int y)
{
     book[y]=x;
}
void change(){
    for(int i=1;i<=n;i++)
        {
            C[i].v=M[i].v;
            C[i].u=M[i].u;
            C[i].flag=M[i].flag;
        }
}
int main()
{
    scanf("%d",&n);

    for(int i=1;i<=n;i++){
         scanf("%d%d",&M[i].v,&M[i].u);
         M[i].flag=i;
    }
  /*  int t=unique(M+1,M+n)-M;
    for(int i=1;i<=t;i++)
        cout<<M[i].v<<" "<<M[i].u<<endl;
      n=t;
      change();*/
      int fl=0;
      sort(C+1,C+n+1,cmp);
      for(int i=2;i<=n;i++)
      {
          dis[++fl].x=C[i].flag,dis[fl].y=C[i-1].flag,dis[fl].z=(min(fabs(C[i].v-C[i-1].v),fabs(C[i].u-C[i-1].u)));
      }
      change();
      sort(C+1,C+n+1,cmp0);
      for(int i=2;i<=n;i++)
      {
          dis[++fl].x=C[i].flag,dis[fl].y=C[i-1].flag,dis[fl].z=(min(fabs(C[i].v-C[i-1].v),fabs(C[i].u-C[i-1].u)));
      }
    sort(dis+1,dis+flag+1,cmp1);
   /*  cout<<flag<<endl;
    for(int i=1;i<=flag;i++)
        cout<<dis[i].z<<endl;*/
        init();
         int number=0;
        int sum=0;
       for(int i=1;i<=flag;i++)
        {
            int p=getx(dis[i].x),q=getx(dis[i].y);
            if(p!=q){
                mergexy(p,q);
                number++;
                sum+=dis[i].z;
        }
        if(number==n)  break;
    }
   cout<<sum<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:20: error: 'flag' was not declared in this scope; did you mean 'fl'?
   82 |     sort(dis+1,dis+flag+1,cmp1);
      |                    ^~~~
      |                    fl
Language: C++

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

typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

#define PREV(i, s) ((i - 1 + s) % s)
#define NEXT(i, s) ((i + 1) % s)

vector< iP > pp;
int prim(vector< vector< int > > &g) {
    int ret = 0;
    int s = g.size();
    priority_queue< iP, vector< iP >, greater< iP > > q;
    vector< int > v(s + 1, 0);
    q.push(iP(0, 0));
    while(!q.empty()) {
        iP p = q.top(); q.pop();
        if(v[p.second]++) continue;
        ret += p.first;
        int now = p.second;
        for(int i = 0; i < g[now].size(); i++) {
            q.push(iP(min(abs(pp[now].first - pp[g[now][i]].first), abs(pp[now].second - pp[g[now][i]].second)), g[now][i]));
        }
    }

    return ret;
}

int main() {

    int n;
    vector< iiP > g1, g2;
    vector< vector< int > > g0;

    cin >> n;
    g0.resize(n + 1);
    pp.resize(n);
    for(int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        pp[i] = iP(x, y);
        g1.push_back(iiP(iP(x, y), i));
        g2.push_back(iiP(iP(y, x), i));
    }
    sort(g1.begin(), g1.end());
    sort(g2.begin(), g2.end());
    for(int i = 0; i < n; i++) {
        g0[i].push_back(g1[PREV(i, n)].second), g0[i].push_back(g1[NEXT(i, n)].second);
        g0[i].push_back(g2[PREV(i, n)].second), g0[i].push_back(g2[NEXT(i, n)].second);
    }

    cout << prim(g0) << endl;
}


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