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

#include <iostream>

using namespace std;
#define MAX 100
int n,k,u,v,w;
int D[MAX+10][MAX+10],W[MAX+10][MAX+10];

int Fkoyd()
{
    for(int k=0;k<n;k++)
    {
        for(int i=0;i<n;i++)
        {
            if(W[i][k]==INT_MAX) continue;
            for(int j=0;j<n;j++)
            {
               if(W[k][j]==INT_MAX) continue;
               W[i][j]=min(W[i][j],W[i][k]+W[k][j]);
            }
        }
    }
}

int main()
{
    int negative=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
     for(int j=0;j<n;j++)
    {

        W[i][j]=(i==j)?0:INT_MAX;
    }
    for(int i=0;i<k;i++)
    {
        cin>>u>>v>>w;
        W[u][v]=w;
    }
    Fkoyd();
    for(int i=0;i<n;i++)
      if(W[i][i]<0) negative=1;


    if(negative) cout<<"NEGATIVE CYCLE"<<endl;
    else
    {
        for(int i=0;i<n;i++)
        {
          for(int j=0;j<n;j++)
          {
            if(j) cout<<" ";
            if(W[i][j]==INT_MAX) cout<<"INF";
            else cout<<W[i][j];
          }
          cout<<endl;
        }
    }
    return 0;
}



Compiler output:
a.cc: In function 'int Fkoyd()':
a.cc:14:25: error: 'INT_MAX' was not declared in this scope
   14 |             if(W[i][k]==INT_MAX) continue;
      |                         ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | 
a.cc:17:28: error: 'INT_MAX' was not declared in this scope
   17 |                if(W[k][j]==INT_MAX) continue;
      |                            ^~~~~~~
a.cc:17:28: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:22:1: warning: no return statement in function returning non-void [-Wreturn-type]
   22 | }
      | ^
a.cc: In function 'int main()':
a.cc:32:26: error: 'INT_MAX' was not declared in this scope
   32 |         W[i][j]=(i==j)?0:INT_MAX;
      |                          ^~~~~~~
a.cc:32:26: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:52:25: error: 'INT_MAX' was not declared in this scope
   52 |             if(W[i][j]==INT_MAX) cout<<"INF";
      |                         ^~~~~~~
a.cc:52:25: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

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

static const int MAX = 100;
static const int long long INNFTY = (1LL<<32);

int n;
long long d[MAX][MAX];

void floyd() {
  for ( int k = 0; k < n; k++ )
    for ( int i = 0; i < n; i++ ) {
      if ( d[i][k] == INFTY ) continue;
      for ( int j = 0; j < n; j++ ) {
        if ( d[k][j] == INFTY ) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
}

int main() {
  int e, u, v, c;
  cin >> n >> e;

  for ( int i = 0; i < n; i++ )
    for ( int j = 0; j < n; j++ )
      d[i][j] = ( (i == j) ? 0 : INFTY );

  for ( int i = 0; i < e; i++ ) {
    cin >> u >> v >> c;
    d[u][v] = c;
  }

  floyd();

  bool negative = false;
  for ( int i = 0; i < n; i++ ) if ( d[i][i] < 0 ) negative = true;

  if ( negative ) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for ( int i = 0; i < n; i++ ) {
      for ( int j = 0; j < n; j++ ) {
        if ( j ) cout << " ";
        if ( d[i][j] == INFTY ) cout << "INF";
        else cout << d[i][j];
      }
      cout << endl;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'void floyd()':
a.cc:16:23: error: 'INFTY' was not declared in this scope; did you mean 'INNFTY'?
   16 |       if ( d[i][k] == INFTY ) continue;
      |                       ^~~~~
      |                       INNFTY
a.cc:18:25: error: 'INFTY' was not declared in this scope; did you mean 'INNFTY'?
   18 |         if ( d[k][j] == INFTY ) continue;
      |                         ^~~~~
      |                         INNFTY
a.cc: In function 'int main()':
a.cc:30:34: error: 'INFTY' was not declared in this scope; did you mean 'INNFTY'?
   30 |       d[i][j] = ( (i == j) ? 0 : INFTY );
      |                                  ^~~~~
      |                                  INNFTY
a.cc:48:25: error: 'INFTY' was not declared in this scope; did you mean 'INNFTY'?
   48 |         if ( d[i][j] == INFTY ) cout << "INF";
      |                         ^~~~~
      |                         INNFTY
Language: C++

#include<cstdio>
#include<algorithm>
using namespace std;
#define INF (INT_MAX)
int main(){
  int v,e,s,t,d;
  int graph[100][100];
  fill_n(*graph,100*100,INF);
  
  scanf("%d %d",&v,&e);
  for(int i=0;i<v;i++) graph[i][i] = 0;
  for(int i=0;i<e;i++){
    scanf("%d %d %d",&s,&t,&d);
    graph[s][t] = d;
  }

  for(int i=0;i<v;i++){
    for(int j=0;j<v;j++){
      for(int k=0;k<v;k++){
	if(graph[j][i]!=INF && graph[i][k]!=INF){
	  graph[j][k] = min(graph[j][k],graph[j][i]+graph[i][k]);
	}
	if(graph[i][i]<0){
	  puts("NEGATIVE CYCLE");
	  return(0);
	}
      }
    }
  }

  for(int i=0;i<v;i++){
    for(int j=0;j<v;j++){
      printf(graph[i][j]==INF?"INF":"%d",graph[i][j]);
      putchar(j==v-1?'\n':' ');
    }
  }

  return(0);
}



Compiler output:
a.cc: In function 'int main()':
a.cc:4:14: error: 'INT_MAX' was not declared in this scope
    4 | #define INF (INT_MAX)
      |              ^~~~~~~
a.cc:8:25: note: in expansion of macro 'INF'
    8 |   fill_n(*graph,100*100,INF);
      |                         ^~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<algorithm>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include <iostream>
using namespace std ; 
long long  b[102][102]  , v , e ; 
int main() {
	cin >> v >> e ;  
	for(int i=1 ; i<=v ; i++) {
		for(int j=1 ; j<=v ; j++) {
			if(i==j) {
				b[i][j]=0;
			}
			else {
				b[i][j]=1e18 ;
			}
		}
	}
	for(int i= 0 ; i < e ; i++) {
		int x , y , z  ; 
		cin >> x >> y >> z ; 
		b[x][y]=z;
	}
	for(int x=1 ; x<=v ; x++) {
		for(int y=1 ; y<=v ; y++) {
			for(int z=1; z<=v ; z++) {
				b[y][z]=min(b[y][z],b[y][x]+b[x][z]);
				if(y==z) {
					if(b[y][z]<0) {
						cout << "NEGATIVE CYCLE" << endl ;
						return 0 ;  					
					}
				}
			}
		}
	}
	for(int i=1 ; i<=v ; i++) {
		for(int j=1 ; j<=v ; j++) {
			if(i!=1) {
				cout << " " << b[i][j] ; 
			}
			else {
				cout << b[i][j] ; 
			}
		}
		cout << endl ; 
	}
	
}#include <iostream>
using namespace std ; 
long long  b[102][102]  , v , e ; 
int main() {
	cin >> v >> e ;  
	for(int i=1 ; i<=v ; i++) {
		for(int j=1 ; j<=v ; j++) {
			if(i==j) {
				b[i][j]=0;
			}
			else {
				b[i][j]=1e18 ;
			}
		}
	}
	for(int i= 0 ; i < e ; i++) {
		int x , y , z  ; 
		cin >> x >> y >> z ; 
		b[x][y]=z;
	}
	for(int x=1 ; x<=v ; x++) {
		for(int y=1 ; y<=v ; y++) {
			for(int z=1; z<=v ; z++) {
				b[y][z]=min(b[y][z],b[y][x]+b[x][z]);
				if(y==z) {
					if(b[y][z]<0) {
						cout << "NEGATIVE CYCLE" << endl ;
						return 0 ;  					
					}
				}
			}
		}
	}
	for(int i=1 ; i<=v ; i++) {
		for(int j=1 ; j<=v ; j++) {
			if(i!=1) {
				cout << " " << b[i][j] ; 
			}
			else {
				cout << b[i][j] ; 
			}
		}
		cout << endl ; 
	}
	
}


Compiler output:
a.cc:46:2: error: stray '#' in program
   46 | }#include <iostream>
      |  ^
a.cc:46:3: error: 'include' does not name a type
   46 | }#include <iostream>
      |   ^~~~~~~
a.cc:48:12: error: redefinition of 'long long int b [102][102]'
   48 | long long  b[102][102]  , v , e ;
      |            ^
a.cc:3:12: note: 'long long int b [102][102]' previously declared here
    3 | long long  b[102][102]  , v , e ;
      |            ^
a.cc:48:27: error: redefinition of 'long long int v'
   48 | long long  b[102][102]  , v , e ;
      |                           ^
a.cc:3:27: note: 'long long int v' previously declared here
    3 | long long  b[102][102]  , v , e ;
      |                           ^
a.cc:48:31: error: redefinition of 'long long int e'
   48 | long long  b[102][102]  , v , e ;
      |                               ^
a.cc:3:31: note: 'long long int e' previously declared here
    3 | long long  b[102][102]  , v , e ;
      |                               ^
a.cc:49:5: error: redefinition of 'int main()'
   49 | int main() {
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main() {
      |     ^~~~
Language: C++

#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//ここから下
int v,e;
edge es[11451];
int d[114];
bool find_negative_loop(){
    memset(d,0,sizeof(d));
    rep(i,0,v){
        rep(j,0,e){
            edge e=es[j];
            if(d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                if(i==v-1)return true;
            }
        }
    }
    return false;
}

void shortest_path(int s){
    rep(i,0,v)d[i]=inf;
    d[s]=0;
    while(true){
        bool update=false;
        rep(i,0,e){
            edge e=es[i];
            if(d[e.from]!=inf&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;update=true;
            }
        }
        if(!update)break;
    }
}
signed main(){
    cin>>v>>e;
    if(v==1){
        cout<<0<<endl;
        return 0;
    }
    rep(i,0,e){
        int a,b,c;cin>>a>>b>>c;
        es[i]=edge{a,b,c};
    }
    if(find_negative_loop()){
            cout<<"NEGATIVE CYCLE"<<endl;
            return 0;
        }
    rep(i,0,v){
        shortest_path(i);
        rep(j,0,v-1){
            if(d[j]==inf)cout<<"INF"<<" ";
            else cout<<d[j]<<" ";
        }if(d[v-1]==inf)cout<<"INF"<<endl;
        else cout<<d[v-1]<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'bool find_negative_loop()':
a.cc:27:5: error: 'memset' was not declared in this scope
   27 |     memset(d,0,sizeof(d));
      |     ^~~~~~
a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   14 | #include<list>
  +++ |+#include <cstring>
   15 | using namespace std;
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];

void floyed() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (d[i][k] == INFTY) {
        continue;
      }
      for (int j = 0; j < n; j++) {
        if (d[k][j] == INFTY) {
          continue;
        }
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int e, u, v, c;
  cin >> n >> e;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = ((i == j) ? 0 : INFTY);
    }
  }

  for (int i = 0; i < e; i++) {
    cin >> u >> v >> c;
    d[u][v] = c;
  }

  floyd();

  bool negative = false;
  for (int i = 0; i < n; i++) {
    if (d[i][i] < 0) {
      negative = true;
    }
  }

  if (negative) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (j) {
          cout << " ";
        }
        if (d[i][j] == INFTY) {
          cout << "INF";
        } else {
          cout << d[i][j]
        }
      }
      cout << endl;
    }
  }

  return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:44:3: error: 'floyd' was not declared in this scope; did you mean 'floyed'?
   44 |   floyd();
      |   ^~~~~
      |   floyed
a.cc:64:26: error: expected ';' before '}' token
   64 |           cout << d[i][j]
      |                          ^
      |                          ;
   65 |         }
      |         ~
Language: C++


#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];

void floyd() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (d[i][k] == INFTY) {
        continue;
      }
      for (int j = 0; j < n; j++) {
        if (d[k][j] == INFTY) {
          continue;
        }
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int e, u, v, c;
  cin >> n >> e;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = ((i == j) ? 0 : INFTY);
    }
  }

  for (int i = 0; i < e; i++) {
    cin >> u >> v >> c;
    d[u][v] = c;
  }

  floyd();

  bool negative = false;
  for (int i = 0; i < n; i++) {
    if (d[i][i] < 0) {
      negative = true;
    }
  }

  if (negative) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (j) {
          cout << " ";
        }
        if (d[i][j] == INFTY) {
          cout << "INF";
        } else {
          cout << d[i][j]
        }
      }
      cout << endl;
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:65:26: error: expected ';' before '}' token
   65 |           cout << d[i][j]
      |                          ^
      |                          ;
   66 |         }
      |         ~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
//
bool negative=true;
struct edge{int from;int to;int cost;};
struct bellman{
	//
	int v,e;
	vector<edge> G;
	vector<int> D;
	//
	bellman(int n,int m){
		v=n;e=m;
		D.resize(v);
		fill(D.begin(),D.end(),1e9+7);
	}
	//
	void add_edge(int from,int to,int cost){
		G.push_back((edge){from,to,cost});
	}
	//
	vector<int> dist(int s){
		D[s]=0;
		for(int i=0;i<v;i++){
			bool f=false;
			for(int j=0;j<e;j++){
				edge &e=G[j];
				if(D[e.from]!=1e9+7&&D[e.to]>D[e.from]+e.cost){
					D[e.to]=D[e.from]+e.cost;
					f=true;
					if(i==v-1){
						negative=false;
						break;
					}
				}
			}
			if(!negative){
				break;
			}
			if(!f){
				break;
			}
		}
		return D;
	}
	//
};
//
ll co[100][100];
int main(){
	int V,E;
	cin>>V>>E;
	bellman be(V,E);
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			co[i][j]=1e18+7;
			if(i==j){
				co[i][j]=0;
			}
		}
	}
	for(int i=0;i<E;i++){
		int s,t,d;
		cin>>s>>t>>d;
		co[s][t]=d;
		be.add_edge(s,t,d);
	}
	vector<int> ans=be.dist(0);
	if(!negative){
		cout<<"NEGATIVE CYCLE"<<endl;
		return 0;
	}
	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				co[i][j]=min(co[i][j],co[i][k]+co[k][j]);
			}
		}
	}
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			if(j!=0){
				cout<<" ";
			}
			if(co[i][j]==1e9+7){
				cout<<"INF";
			}else{
				cout<<co[i][j];
			}
		}
		cout<<endl;
	}
	return 0;
}


Compiler output:
a.cc:50:1: error: 'll' does not name a type
   50 | ll co[100][100];
      | ^~
a.cc: In function 'int main()':
a.cc:57:25: error: 'co' was not declared in this scope
   57 |                         co[i][j]=1e18+7;
      |                         ^~
a.cc:66:17: error: 'co' was not declared in this scope
   66 |                 co[s][t]=d;
      |                 ^~
a.cc:77:33: error: 'co' was not declared in this scope
   77 |                                 co[i][j]=min(co[i][j],co[i][k]+co[k][j]);
      |                                 ^~
a.cc:86:28: error: 'co' was not declared in this scope
   86 |                         if(co[i][j]==1e9+7){
      |                            ^~
Language: C++

#include <iostream>
#include <vector>
#definne ll long long
using namespace std;
//
bool negative=true;
struct edge{int from;int to;int cost;};
struct bellman{
	//
	int v,e;
	vector<edge> G;
	vector<int> D;
	//
	bellman(int n,int m){
		v=n;e=m;
		D.resize(v);
		fill(D.begin(),D.end(),1e9+7);
	}
	//
	void add_edge(int from,int to,int cost){
		G.push_back((edge){from,to,cost});
	}
	//
	vector<int> dist(int s){
		D[s]=0;
		for(int i=0;i<v;i++){
			bool f=false;
			for(int j=0;j<e;j++){
				edge &e=G[j];
				if(D[e.from]!=1e9+7&&D[e.to]>D[e.from]+e.cost){
					D[e.to]=D[e.from]+e.cost;
					f=true;
					if(i==v-1){
						negative=false;
						break;
					}
				}
			}
			if(!negative){
				break;
			}
			if(!f){
				break;
			}
		}
		return D;
	}
	//
};
//
ll co[100][100];
int main(){
	int V,E;
	cin>>V>>E;
	bellman be(V,E);
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			co[i][j]=1e18+7;
			if(i==j){
				co[i][j]=0;
			}
		}
	}
	for(int i=0;i<E;i++){
		int s,t,d;
		cin>>s>>t>>d;
		co[s][t]=d;
		be.add_edge(s,t,d);
	}
	vector<int> ans=be.dist(0);
	if(!negative){
		cout<<"NEGATIVE CYCLE"<<endl;
		return 0;
	}
	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				co[i][j]=min(co[i][j],co[i][k]+co[k][j]);
			}
		}
	}
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			if(j!=0){
				cout<<" ";
			}
			if(co[i][j]==1e9+7){
				cout<<"INF";
			}else{
				cout<<co[i][j];
			}
		}
		cout<<endl;
	}
	return 0;
}


Compiler output:
a.cc:3:2: error: invalid preprocessing directive #definne; did you mean #define?
    3 | #definne ll long long
      |  ^~~~~~~
      |  define
a.cc:51:1: error: 'll' does not name a type
   51 | ll co[100][100];
      | ^~
a.cc: In function 'int main()':
a.cc:58:25: error: 'co' was not declared in this scope
   58 |                         co[i][j]=1e18+7;
      |                         ^~
a.cc:67:17: error: 'co' was not declared in this scope
   67 |                 co[s][t]=d;
      |                 ^~
a.cc:78:33: error: 'co' was not declared in this scope
   78 |                                 co[i][j]=min(co[i][j],co[i][k]+co[k][j]);
      |                                 ^~
a.cc:87:28: error: 'co' was not declared in this scope
   87 |                         if(co[i][j]==1e9+7){
      |                            ^~
Language: C++

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

int N, E;
int a[101][101];

void warshalfloyd() {
    for (int k = 0; i < N; ++i) {
        for (int i = 0; j < N; ++j) {
            for (int j = 0; k < N; ++k) {
                a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
            }
        }
    }
}

int INF = INT_MAX / 2;
int main() {
    cin >> N >> E;

    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            a[k][i] = INF;
        }
    }
    for (int j = 0; j < N; ++j) {
        a[j][j] = 0;
    }
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        a[s][t] = d;
    }

    warshalfloyd();
    for (int m = 0; m < N; ++m) {
        if(a[m][m] < 0) {
            cout << "NEGATIVE CYCLE"<< endl;
            return 0;
        }

    }
    for (int l = 0; l < N; ++l) {
        for (int i = 0; i < N; ++i) {
            if(i) cout << " ";
            if(a[l][i] == INF) {
                cout << "INF" ;
            } else
            cout << a[l][i] ;
        }
        cout << endl;
    }


    return 0;
}



Compiler output:
a.cc: In function 'void warshalfloyd()':
a.cc:9:21: error: 'i' was not declared in this scope
    9 |     for (int k = 0; i < N; ++i) {
      |                     ^
a.cc:10:25: error: 'j' was not declared in this scope
   10 |         for (int i = 0; j < N; ++j) {
      |                         ^
Language: Java

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Prim {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int V, E;
		
		String line;
		try{
			line = br.readLine();
			String[] data = line.split(" ");
			V = Integer.parseInt(data[0]);
			E = Integer.parseInt(data[1]);
			
			int[][] graph = new int[V][V];
			
			for(int i=0; i<E; i++){
				data = br.readLine().split(" ");
				int s = Integer.valueOf(data[0]);
				int t = Integer.valueOf(data[1]);
				int w = Integer.valueOf(data[2]);
				
				graph[s][t] = w;
				graph[t][s] = w;
			}
			
			int mst = solve(V,E,graph);
			System.out.println(mst);
			
		}catch(Exception ex){
			ex.printStackTrace();
		}  
	}
	
	private static int solve(int V, int E, int[][] graph){
		// create s set mstSet that keeps track of vertices already include in MST
		boolean[] mstSet = new boolean[V];
		
		
		// assign key values to all vertices in the graph, initial all key values as INFINITE
		int[] key = new int[V];
		for(int i=0; i<V; i++){
			key[i] = Integer.MAX_VALUE;
			mstSet[i] = false;
		}
		
		// assign 0 to the first vertex so that it will be picked first
		key[0] = 0;
		int[] parent = new int[V];
		parent[0] = -1;
		
		// while mstSet does not include all vertices
		/**
		 * 1. Pick a vertex u which is not there in the mstSet and has min key value
		 * 2. include u to the mstSet
		 * 3. update key values adjacent vertices of u
		 * **/
		
		
		int count = 0;
		int sum = 0;
		while(count < V){
			PairValue pair = minKey(key, mstSet);
			int u = pair.index;
			//System.out.println("u: "+u);
			sum += pair.weight;
			mstSet[u] = true;
			
			for(int i=0; i<V; i++){
				if(graph[u][i] != 0 && !mstSet[i] &&
						key[i] > graph[u][i]){
					key[i] = graph[u][i];
					parent[i]=u;
				}
			}
			count ++;
		}
		
				
		return sum;
	}
	
	// return min key index;
	private static PairValue minKey(int[] key, boolean[] mstSet){
		int min = Integer.MAX_VALUE;
		int index = -1;
		
		for(int i=0; i<key.length; i++){
			if(min > key[i] && !mstSet[i]){
				min = key[i];
				index = i;
			}
		}
		return new PairValue(index, min);
	}
}



class PairValue{
	int index, weight;
	public PairValue(int a, int b){
		index = a;
		weight = b;
	}
}

Compiler output:
Main.java:4: error: class Prim is public, should be declared in a file named Prim.java
public class Prim {
       ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class GRL_2_A {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int V, E;
		
		String line;
		try{
			line = br.readLine();
			String[] data = line.split(" ");
			V = Integer.parseInt(data[0]);
			E = Integer.parseInt(data[1]);
			
			int[][] graph = new int[V][V];
			
			for(int i=0; i<E; i++){
				data = br.readLine().split(" ");
				int s = Integer.valueOf(data[0]);
				int t = Integer.valueOf(data[1]);
				int w = Integer.valueOf(data[2]);
				
				graph[s][t] = w;
				graph[t][s] = w;
			}
			
			int mst = solve(V,E,graph);
			System.out.println(mst);
			
		}catch(Exception ex){
			ex.printStackTrace();
		}  
	}
	
	private static int solve(int V, int E, int[][] graph){
		// create s set mstSet that keeps track of vertices already include in MST
		boolean[] mstSet = new boolean[V];
		
		
		// assign key values to all vertices in the graph, initial all key values as INFINITE
		int[] key = new int[V];
		for(int i=0; i<V; i++){
			key[i] = Integer.MAX_VALUE;
			mstSet[i] = false;
		}
		
		// assign 0 to the first vertex so that it will be picked first
		key[0] = 0;
		int[] parent = new int[V];
		parent[0] = -1;
		
		// while mstSet does not include all vertices
		/**
		 * 1. Pick a vertex u which is not there in the mstSet and has min key value
		 * 2. include u to the mstSet
		 * 3. update key values adjacent vertices of u
		 * **/
		
		
		int count = 0;
		int sum = 0;
		while(count < V){
			PairValue pair = minKey(key, mstSet);
			int u = pair.index;
			//System.out.println("u: "+u);
			sum += pair.weight;
			mstSet[u] = true;
			
			for(int i=0; i<V; i++){
				if(graph[u][i] != 0 && !mstSet[i] &&
						key[i] > graph[u][i]){
					key[i] = graph[u][i];
					parent[i]=u;
				}
			}
			count ++;
		}
		
				
		return sum;
	}
	
	// return min key index;
	private static PairValue minKey(int[] key, boolean[] mstSet){
		int min = Integer.MAX_VALUE;
		int index = -1;
		
		for(int i=0; i<key.length; i++){
			if(min > key[i] && !mstSet[i]){
				min = key[i];
				index = i;
			}
		}
		return new PairValue(index, min);
	}
}



class PairValue{
	int index, weight;
	public PairValue(int a, int b){
		index = a;
		weight = b;
	}
}

Compiler output:
Main.java:4: error: class GRL_2_A is public, should be declared in a file named GRL_2_A.java
public class GRL_2_A {
       ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Solve {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int V, E;
		
		String line;
		try{
			line = br.readLine();
			String[] data = line.split(" ");
			V = Integer.parseInt(data[0]);
			E = Integer.parseInt(data[1]);
			
			int[][] graph = new int[V][V];
			
			for(int i=0; i<E; i++){
				data = br.readLine().split(" ");
				int s = Integer.valueOf(data[0]);
				int t = Integer.valueOf(data[1]);
				int w = Integer.valueOf(data[2]);
				
				graph[s][t] = w;
				graph[t][s] = w;
			}
			
			int mst = solve(V,E,graph);
			System.out.println(mst);
			
		}catch(Exception ex){
			ex.printStackTrace();
		}  
	}
	
	private static int solve(int V, int E, int[][] graph){
		// create s set mstSet that keeps track of vertices already include in MST
		boolean[] mstSet = new boolean[V];
		
		
		// assign key values to all vertices in the graph, initial all key values as INFINITE
		int[] key = new int[V];
		for(int i=0; i<V; i++){
			key[i] = Integer.MAX_VALUE;
			mstSet[i] = false;
		}
		
		// assign 0 to the first vertex so that it will be picked first
		key[0] = 0;
		int[] parent = new int[V];
		parent[0] = -1;
		
		// while mstSet does not include all vertices
		/**
		 * 1. Pick a vertex u which is not there in the mstSet and has min key value
		 * 2. include u to the mstSet
		 * 3. update key values adjacent vertices of u
		 * **/
		
		
		int count = 0;
		int sum = 0;
		while(count < V){
			PairValue pair = minKey(key, mstSet);
			int u = pair.index;
			//System.out.println("u: "+u);
			sum += pair.weight;
			mstSet[u] = true;
			
			for(int i=0; i<V; i++){
				if(graph[u][i] != 0 && !mstSet[i] &&
						key[i] > graph[u][i]){
					key[i] = graph[u][i];
					parent[i]=u;
				}
			}
			count ++;
		}
		
				
		return sum;
	}
	
	// return min key index;
	private static PairValue minKey(int[] key, boolean[] mstSet){
		int min = Integer.MAX_VALUE;
		int index = -1;
		
		for(int i=0; i<key.length; i++){
			if(min > key[i] && !mstSet[i]){
				min = key[i];
				index = i;
			}
		}
		return new PairValue(index, min);
	}
}



class PairValue{
	int index, weight;
	public PairValue(int a, int b){
		index = a;
		weight = b;
	}
}

Compiler output:
Main.java:4: error: class Solve is public, should be declared in a file named Solve.java
public class Solve {
       ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class PrimMatrix {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int vertex;
	static int edge;
	static int[][] graph;
	static int cost[];
	static int parent[];
	static boolean visited[];
	static final int INFINITY = Integer.MAX_VALUE;

	public static void main(String[] args) throws IOException {

		input();
		prim();
	}

	public static void prim() {
		int index = 1;
		for (int i = 1; i < vertex; i++) {
			for (int j = 1; j <= vertex; j++) {
				int weight = graph[index][j];
				if (cost[j] > weight && visited[j] == false && weight != 0) {
					cost[j] = weight;
					parent[j] = index;
				}
			}
			int min = INFINITY;
			for (int k = 1; k < cost.length; k++) {
				if (cost[k] < min && visited[k] == false) {
					min = cost[k];
					index = k;
				}
			}
			visited[index] = true;
		}
		int sum = 0;
		for (int m = 2; m < cost.length; m++) {
			sum += cost[m];
		}
		System.out.println(sum);
	}

	public static void input() throws IOException {
		StringTokenizer st = new StringTokenizer(br.readLine());

		vertex = Integer.parseInt(st.nextToken());
		edge = Integer.parseInt(st.nextToken());
		graph = new int[vertex + 1][vertex + 1];
		cost = new int[vertex + 1];
		parent = new int[vertex + 1];
		visited = new boolean[vertex + 1];
		for (int k = 1; k <= vertex; k++) {
			cost[k] = INFINITY;
		}
		for (int i = 1; i <= edge; i++) {
			st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			graph[a+1][b+1] = graph[b+1][a+1] = c;

		}
		cost[1] = 0;
		parent[1] = 1;
		visited[1] = true;

	}
}

Compiler output:
Main.java:6: error: class PrimMatrix is public, should be declared in a file named PrimMatrix.java
public class PrimMatrix {
       ^
1 error
Language: Java

import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
 
 
public class Main {
 
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   
  static class Edge implements Comparable <Edge> {
    int from, to, cost;
    public Edge(int from, int to, int cost) {
      this.from = from;
      this.to = to;
      this.cost = cost;
    }
    @Override public int compareTo(Edge other) {
      return cost - other.cost;
    }
  }
   
  // Graph must be undirected!
  public static Long prims(Map <Integer, List<Edge>> graph, int n) {
     
    if (graph == null) return null;
     
    long sum = 0, nodesVisited = 1;
    boolean[] visited = new boolean[n];
    PriorityQueue <Edge> pq = new PriorityQueue<>();
     
    // Add initial set of edges to the pq
    List <Edge> edges = graph.get(0);
    if (edges == null || edges.size() == 0) return null;
    for(Edge edge : edges) pq.offer(edge);
    visited[0] = true;
 
    // Loop while the MST is not complete
    while ( nodesVisited != n && !pq.isEmpty() ) {
      Edge edge = pq.poll();
      if (!visited[edge.to]) {
         
        // Add edges to nodes we have not yet visited
        edges = graph.get(edge.to);
        if (edges == null || edges.size() == 0) return null;
        for (Edge e : edges) 
          if (!visited[e.to])
            pq.offer(e);
 
        visited[edge.to] = true;
        sum += edge.cost;
        nodesVisited++;
 
      }
    }
     
    // Check if MST spans entire graph
    if (nodesVisited == n) return sum;
    return null;
 
  }
 
  // Example usage
  public static void main(String[] args) {
     
    // Contains tuples of (from, to, weight)
StringTokenizer st = new StringTokenizer(br.readLine());
 final int NUM_NODES = Integer.parseInt(st.nextToken());
final int edge = Integer.parseInt(st.nextToken());
 
int[][] edges= new int[edge][edge];
 
for (int i = 1; i <= edge; i++) {
            st = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            int c = Integer.parseInt(st.nextToken());
            graph[a][b]  = c-1;
 
        }
     
 
 
    
 
    // Setup graph as adjacency list
    Map <Integer, List<Edge>> graph = new HashMap<>();
    for (int i = 0; i < NUM_NODES; i++) graph.put(i, new ArrayList<>());
    for ( int[] tuple : edges ) {
      int from = tuple[0];
      int to = tuple[1];
      int cost = tuple[2];
      Edge edge = new Edge(from, to, cost);
      Edge revEdge = new Edge(to, from, cost);
      graph.get(from).add(edge);
      graph.get(to).add(revEdge);
    }
 
    Long mstCost = prims(graph, NUM_NODES);
    System.out.println("MST cost: " + mstCost);
 
  }
 
}

Compiler output:
Main.java:79: error: cannot find symbol
            graph[a][b]  = c-1;
            ^
  symbol:   variable graph
  location: class Main
Main.java:94: error: variable edge is already defined in method main(String[])
      Edge edge = new Edge(from, to, cost);
           ^
2 errors
Language: Java

import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
  
  
public class Main {
  
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
  static class Edge implements Comparable <Edge> {
    int from, to, cost;
    public Edge(int from, int to, int cost) {
      this.from = from;
      this.to = to;
      this.cost = cost;
    }
    @Override public int compareTo(Edge other) {
      return cost - other.cost;
    }
  }
    
  // Graph must be undirected!
  public static Long prims(Map <Integer, List<Edge>> graph, int n) {
      
    if (graph == null) return null;
      
    long sum = 0, nodesVisited = 1;
    boolean[] visited = new boolean[n];
    PriorityQueue <Edge> pq = new PriorityQueue<>();
      
    // Add initial set of edges to the pq
    List <Edge> edges = graph.get(0);
    if (edges == null || edges.size() == 0) return null;
    for(Edge edge : edges) pq.offer(edge);
    visited[0] = true;
  
    // Loop while the MST is not complete
    while ( nodesVisited != n && !pq.isEmpty() ) {
      Edge edge = pq.poll();
      if (!visited[edge.to]) {
          
        // Add edges to nodes we have not yet visited
        edges = graph.get(edge.to);
        if (edges == null || edges.size() == 0) return null;
        for (Edge e : edges) 
          if (!visited[e.to])
            pq.offer(e);
  
        visited[edge.to] = true;
        sum += edge.cost;
        nodesVisited++;
  
      }
    }
      
    // Check if MST spans entire graph
    if (nodesVisited == n) return sum;
    return null;
  
  }
  
  // Example usage
  public static void main(String[] args) {
      
    // Contains tuples of (from, to, weight)
StringTokenizer st = new StringTokenizer(br.readLine());
 final int NUM_NODES = Integer.parseInt(st.nextToken());
final int edge = Integer.parseInt(st.nextToken());
  
int[][] edges= new int[edge][edge];
  
for (int i = 1; i <= edge; i++) {
            st = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            int c = Integer.parseInt(st.nextToken());
            edges[a][b]  = c-1;
  
        }
      
  
  
     
  
    // Setup graph as adjacency list
    Map <Integer, List<Edge>> graph = new HashMap<>();
    for (int i = 0; i < NUM_NODES; i++) graph.put(i, new ArrayList<>());
    for ( int[] tuple : edges ) {
      int from = tuple[0];
      int to = tuple[1];
      int cost = tuple[2];
      Edge edge = new Edge(from, to, cost);
      Edge revEdge = new Edge(to, from, cost);
      graph.get(from).add(edge);
      graph.get(to).add(revEdge);
    }
  
    Long mstCost = prims(graph, NUM_NODES);
    System.out.println("MST cost: " + mstCost);
  
  }
  
}

Compiler output:
Main.java:94: error: variable edge is already defined in method main(String[])
      Edge edge = new Edge(from, to, cost);
           ^
1 error
Language: Java

import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
  
  
public class Main {
  
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
  static class Edge implements Comparable <Edge> {
    int from, to, cost;
    public Edge(int from, int to, int cost) {
      this.from = from;
      this.to = to;
      this.cost = cost;
    }
    @Override public int compareTo(Edge other) {
      return cost - other.cost;
    }
  }
    
  // Graph must be undirected!
  public static Long prims(Map <Integer, List<Edge>> graph, int n) {
      
    if (graph == null) return null;
      
    long sum = 0, nodesVisited = 1;
    boolean[] visited = new boolean[n];
    PriorityQueue <Edge> pq = new PriorityQueue<>();
      
    // Add initial set of edges to the pq
    List <Edge> edges = graph.get(0);
    if (edges == null || edges.size() == 0) return null;
    for(Edge edge : edges) pq.offer(edge);
    visited[0] = true;
  
    // Loop while the MST is not complete
    while ( nodesVisited != n && !pq.isEmpty() ) {
      Edge edge = pq.poll();
      if (!visited[edge.to]) {
          
        // Add edges to nodes we have not yet visited
        edges = graph.get(edge.to);
        if (edges == null || edges.size() == 0) return null;
        for (Edge e : edges) 
          if (!visited[e.to])
            pq.offer(e);
  
        visited[edge.to] = true;
        sum += edge.cost;
        nodesVisited++;
  
      }
    }
      
    // Check if MST spans entire graph
    if (nodesVisited == n) return sum;
    return null;
  
  }
  
  // Example usage
  public static void main(String[] args) {
      
    // Contains tuples of (from, to, weight)
StringTokenizer st = new StringTokenizer(br.readLine());
 final int NUM_NODES = Integer.parseInt(st.nextToken());
final int k = Integer.parseInt(st.nextToken());
  
int[][] edges= new int[edge][edge];
  
for (int i = 1; i <= k; i++) {
            st = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            int c = Integer.parseInt(st.nextToken());
            edges[a][b]  = c-1;
  
        }
      
  
  
     
  
    // Setup graph as adjacency list
    Map <Integer, List<Edge>> graph = new HashMap<>();
    for (int i = 0; i < NUM_NODES; i++) graph.put(i, new ArrayList<>());
    for ( int[] tuple : edges ) {
      int from = tuple[0];
      int to = tuple[1];
      int cost = tuple[2];
      Edge edge = new Edge(from, to, cost);
      Edge revEdge = new Edge(to, from, cost);
      graph.get(from).add(edge);
      graph.get(to).add(revEdge);
    }
  
    Long mstCost = prims(graph, NUM_NODES);
    System.out.println("MST cost: " + mstCost);
  
  }
  
}

Compiler output:
Main.java:72: error: cannot find symbol
int[][] edges= new int[edge][edge];
                       ^
  symbol:   variable edge
  location: class Main
Main.java:72: error: cannot find symbol
int[][] edges= new int[edge][edge];
                             ^
  symbol:   variable edge
  location: class Main
2 errors
Language: C

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

using namespace std;

bool vis[100001];
vector < pair < int, int > > v[100011];
priority_queue < pair < pair < int, int >, int > > q;

int main()
{
	long long n, m, w = 0;
	cin >> n >> m;
	for( int i = 1; i <= m; i++)
	{
		int u, o, p;
		cin >> u >> o >> p;
		v[u].push_back( make_pair( p, o ));
		v[o].push_back( make_pair( p, u ));
	}
	q.push(make_pair(make_pair(0, 1), 0));
	while(q.size())
	{
		int t = q.top().first.second;
		int r = q.top().first.first * -1;
		int root = q.top().second;
		q.pop();
		if( vis[t] == true ) continue;
		vis[t] = true;
		w = w + r;
		//cout << root << " " << t << endl;
		for(int i = 0; i < v[t].size(); i++)
			if( vis[v[t][i].second] == false ) q.push(make_pair(make_pair( -1*v[t][i].first, v[t][i].second ), t));
		while( !q.empty() && vis[q.top().first.second] == true ) q.pop();
	}
	cout << w;
	return 0;
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cassert>

using namespace std;

struct edge { int to, cost; };
typedef pair<int, int> P;

const int MAX_V = 10000;
const int INF = 1 << 28;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

int prim(){
	int res = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	d[0] = 0;
	que.push(P(0, 0));
	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		res += p.first;
		for(int i=0;i<G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost){
				d[e.to] = e.cost;
				que.push(P(e.cost, e.to));
			}
		}
	}
	return res;
}

int main(){
	int E;
	cin >> V >> E;
	for(int i=0;i<E;i++){
		int s, t, w;
		cin >> s >> t >> w;
		assert(0 <= s && s < V);
		assert(0 <= t && t < V);
		G[s].push_back((edge){t, w});
		G[t].push_back((edge){s, w});
	}
	cout << prim() << 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<iostream>

using namespace std;

#define VMAX 1000
#define NOT -1

int main(void){

	int V,E;
	int s,t,w;
	int ed[VMAX][VMAX];
	int min,mx,my;
	int cost;
	bool use[VMAX];

	cin>>V>>E;

	for(int i=0;i<V;i++) use[i]=false;
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			ed[i][j]=NOT;
		}
	}

	for(int i=0;i<E;i++){
		cin>>s>>t>>w;
		ed[s][t]=w;
		ed[t][s]=w;
	}

	use[0]=true;
	cost=0;
	while(1){
		min=NOT;
		for(int i=0;i<V;i++){
			if(use[i]==true){
				for(int j=0;j<V;j++){
					if(use[j]==false){
						if(ed[i][j]!=NOT){
							if(min==NOT||min>ed[i][j]) min=ed[i][j],mx=j,my=i;
						}
					}
				}
			}
		}
		if(min==NOT) break;
		use[my]=true,use[mx]=true;
		cost+=ed[my][mx];
	}
	cout<<cost<<endl;
}

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

#define _USE_MATH_DEFINES

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

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

using namespace std;

#define MAX_V 120000
#define MAX_E 220000

typedef pair<int, int> P;
long long int INF = 1e18;

int par[MAX_V];
int rnk[MAX_V];

// n要素で初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

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

// xとyの属する集合を併合
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
	}else{
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

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

struct edge{
	int u, v;
	long long int cost;
};

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

edge es[MAX_E];
int V, E;

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

int main(){
	
	int V, E;
	cin >> V >> E;
	
	for(int i = 0; i < E; i++){
		long long int u, v, cost;
		cin >> u >> v >> cost;
		
		edge e;
		e.cost = cost;
		e.v = v;
		e.u = u;
		es.push_back(e);
		e.v = u;
		e.u = v;
		es.push_back(e);
	}
	
	int ans = kruskal();
	
	cout << ans << endl;
	
	return 0;
}


Compiler output:
a.cc:25:24: error: conflicting declaration 'typedef struct std::pair<int, int> P'
   25 | typedef pair<int, int> P;
      |                        ^
a.cc:16:44: note: previous declaration as 'typedef struct std::pair<long long int, long long int> P'
   16 | typedef pair<long long int, long long int> P;
      |                                            ^
a.cc:26:15: error: redefinition of 'long long int INF'
   26 | long long int INF = 1e18;
      |               ^~~
a.cc:17:15: note: 'long long int INF' previously defined here
   17 | long long int INF = 1e18;
      |               ^~~
a.cc: In function 'int main()':
a.cc:113:20: error: request for member 'push_back' in 'es', which is of non-class type 'edge [220000]'
  113 |                 es.push_back(e);
      |                    ^~~~~~~~~
a.cc:116:20: error: request for member 'push_back' in 'es', which is of non-class type 'edge [220000]'
  116 |                 es.push_back(e);
      |                    ^~~~~~~~~
Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

#define V_MAX 10000
#define E_MAX 100000

#define NIL -1

int Node[V_MAX];

void init(){
    for(int i = 0; i < V_MAX; i++){
        Node[i] = NIL;
    }
}

int findSet(int x){
    vector<int> V;
    int index = x;
    while(Node[index] != NIL){
        V.push_back(index);
        index = Node[index];
    }
    for(int i = 0; i < V.size(); i++){
        Node[V[i]] = index;
    }
    return index;
}

void unite(int x, int y){
    int root_x = findSet(x);
    int root_y = findSet(y);
    if(root_x != root_y){
        Node[root_x] = root_y;
    }
}

bool same(int x, int y){
    if(findSet(x) == findSet(y)){
        return true;
    }else{
        return false;
    }
}

typedef struct Edge{
    int v1;
    int v2;
    int w;
}Edge;

vector<Edge> Es;

bool edgeSort(Edge a, Edge b){
    return a.w < b.w;
}

int main(void){
    init();

    int V, E;
    scanf("%d %d", &V, &E);

    for(int i = 0; i < E; i++){
        Edge e;
        scanf("%d %d %d", &e.v1, &e.v2, &e.w);
        Es.push_back(e);
    }

    sort(Es.begin(), Es.end(), edgeSort);

    int sum = 0;
    for(int i = 0; i < E; i++){
        if(!same(Es[i].v1, Es[i].v2)){
            sum += Es[i].w;
            unite(Es[i].v1, Es[i].v2);
        }
    }

    printf("%d\n", sum);
}



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

#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

#define V_MAX 10000
#define E_MAX 100000

#define NIL -1

int Node[V_MAX];

void init(){
    for(int i = 0; i < V_MAX; i++){
        Node[i] = NIL;
    }
}

int findSet(int x){
    vector<int> V;
    int index = x;
    while(Node[index] != NIL){
        V.push_back(index);
        index = Node[index];
    }
    for(int i = 0; i < V.size(); i++){
        Node[V[i]] = index;
    }
    return index;
}

void unite(int x, int y){
    int root_x = findSet(x);
    int root_y = findSet(y);
    if(root_x != root_y){
        Node[root_x] = root_y;
    }
}

bool same(int x, int y){
    if(findSet(x) == findSet(y)){
        return true;
    }else{
        return false;
    }
}

typedef struct Edge{
    int v1;
    int v2;
    int w;
}Edge;

vector<Edge> Es;

bool edgeSort(Edge a, Edge b){
    return a.w < b.w;
}

int main(void){
    init();

    int V, E;
    scanf("%d %d", &V, &E);

    for(int i = 0; i < E; i++){
        Edge e;
        scanf("%d %d %d", &e.v1, &e.v2, &e.w);
        Es.push_back(e);
    }

    std::sort(Es.begin(), Es.end(), edgeSort);

    int sum = 0;
    for(int i = 0; i < E; i++){
        if(!same(Es[i].v1, Es[i].v2)){
            sum += Es[i].w;
            unite(Es[i].v1, Es[i].v2);
        }
    }

    printf("%d\n", sum);
}



Compiler output:
a.cc: In function 'int main()':
a.cc:72:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   72 |     std::sort(Es.begin(), Es.end(), edgeSort);
      |          ^~~~
      |          qsort