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

#include <iostream>
#include <stack>
#define N 100005


using namespace std;
int M[N][N];
int color[N];
int m, n;
int s, t, q;
int i, j;
int nt[N];
int next(int u){
	for(int v = nt[n]; v < n; v++){
		nt[u] = v + 1;
		if(M[u][v] && color[v] == 0) return v;
	}
	return -1;
}
int dfs(int s, int t){
	stack <int> S;
	S.push(s);
	color[s] = 1;
	while( !S.empty() ){
		int u = S.top();
		int v = next(u);
		if(v == t){
			return 1;
		}
		if(v != -1){
			if(color[v] == 0){
				color[v] = 1;
				S.push(v);
			}
		}
		else{
			S.pop();
			//color[u] = 1;
		}
	} 
	return 0; 
}
int main(){
	cin >> n >> m;
	for(i = 0; i < n; i++){
		color[i] = 0;
		for(j = 0; j < n; j++){
			M[i][j] = 0;
		}
	}
	for(i = 0; i < m; i++){
			cin >> s >> t;
			M[s][t] = M[t][s] = 1;
		
	}
	/*for(i = 0; i < n; i++){
		for(j = 0; j < n; j++){
			cout << M[i][j] << " ";
		}
		cout << endl;
	}*/
	cin >> q;
	for(i = 0; i < q; i++){
		cin >> s >> t;
		if(dfs(s, t)) 
			cout << "yes" << endl;
		else 
			cout << "no" << endl;
		for(j = 0; j < n; j++){
			color[j] = 0;
		}
	}
	
}


Compiler output:
/tmp/cc9MwXdS.o: in function `next(int)':
a.cc:(.text+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc9MwXdS.o
a.cc:(.text+0x1a): relocation truncated to fit: R_X86_64_PC32 against symbol `nt' defined in .bss section in /tmp/cc9MwXdS.o
a.cc:(.text+0x3c): relocation truncated to fit: R_X86_64_PC32 against symbol `nt' defined in .bss section in /tmp/cc9MwXdS.o
a.cc:(.text+0x7e): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cc9MwXdS.o
a.cc:(.text+0x94): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc9MwXdS.o
/tmp/cc9MwXdS.o: in function `dfs(int, int)':
a.cc:(.text+0xf1): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cc9MwXdS.o
a.cc:(.text+0x149): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cc9MwXdS.o
a.cc:(.text+0x164): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cc9MwXdS.o
/tmp/cc9MwXdS.o: in function `main':
a.cc:(.text+0x1e3): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc9MwXdS.o
a.cc:(.text+0x1ff): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc9MwXdS.o
a.cc:(.text+0x210): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;
vector<int> neighbors[100005];
//why choose vector, not matrix
int root[100005];

void dfs(int i, int start){
	root[i] = start;
	//visut all i's neighbors
	//c++ 11
	for(int j : neighbors[i]){
		if(root[j]==-1){
			dfs(j,start);
		}
	}
}

int main(){
	int n,m,x,y;
	memset(root, -1, sizeof(root));
	scanf("%d %d",&n,&m);
	for(int i = 0; i<m; i++){
		scanf("%d %d",&x,&y)
		neighbors[x].push_back(y);
		neighbors[y].push_back(x);
	}
	for(int i = 0; i<n; i++){
		if(root[x]= -1){
			dfs(i,i);
		}
	}
	scanf("%d", &q);
	for(int i = 0; i<q; i++){
		scanf("%d %d",&x, &y);
		if(root[x] = root[y]){
			printf("Yes\n");
		}else printf("no\n");
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:37: error: expected ';' before 'neighbors'
   26 |                 scanf("%d %d",&x,&y)
      |                                     ^
      |                                     ;
   27 |                 neighbors[x].push_back(y);
      |                 ~~~~~~~~~            
a.cc:35:22: error: 'q' was not declared in this scope
   35 |         scanf("%d", &q);
      |                      ^
Language: C++

#include <iostream>
#include <climits>
#include <stack>
#include <vector>

using namespace std;
static const int MAX=100;
static const int NIL=-1;
int n;
vector <int> G[MAX];
int color [MAX];

void dfs(int r,int c)
{
    stack<int> S;
    S.push(r);
    color[r]=c;
    while(!S.empty())
    {
        int u=S.top();
        S.pop();
        for(int i=0;i<G[u].size();i++)
        {
            int v=G[u][i];
            if(color[i]==NIL)
            {
                color[v]=c;
                S.push(v);
            }
        }
    }
}

void assign_color()
{
    int id=1;
    for(int i=0;i<n;i++) color[i]=NIL;
    for(int u=0;u<n;u++)
    {
        if(color[u]==NIL) dfs(u,id++);
    }
}

int main()
{
    int s,t,m,q;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assign_color();
    
    for(int i=0;i<n;i++)
    {
        cin>>s>>t;
        if(color[s]==color[r])
        {
            cout<<"yes"<<endl;
        }
        else
        {
            cout<<"no"<<endl;
        }
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:59:28: error: 'r' was not declared in this scope
   59 |         if(color[s]==color[r])
      |                            ^
Language: C++

#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector <int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while ( !S.empty() ) {
    int u = S.top(); S.pop();
    for ( int i = 0; i < G[u].size(); i++ ) {
      int v = G[u][i];
      if ( color[v] == NIL ) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for ( int i = 0; i < n; i++ ) color[i] = NIL:
  for ( int u = 0; u < n; u++ )
    if ( color[u] == NIL ) dfs(u, id++);
}

int main() {
  int s, t, m, q;

  cin >> n >> m;

  for ( int i = 0; i < m; i++ ) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for ( int i = 0; i < q; i++ ) {
    cin >> s >> t;
    if ( color[s] == color[t] )
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'void assignColor()':
a.cc:30:47: error: expected ';' before ':' token
   30 |   for ( int i = 0; i < n; i++ ) color[i] = NIL:
      |                                               ^
      |                                               ;
a.cc:31:20: error: 'u' was not declared in this scope
   31 |   for ( int u = 0; u < n; u++ )
      |                    ^
Language: C++

#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>

#include <queue>
#include <map>
#include <utility>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG

/*
   Memory limitaion; 64 MiB
   # of users: 2 <= n <= 100 K
   # of relations: 0 <= m <= 100 K

   Data size:
    1) for relations (maybe hash table):
      100K * 4Byte * 2 (bi-direction) = 800K

    2) for visited flag:
      100K * 1Byte = 100K
*/

const int kMaxUsers = 100 * 1000;

bool g_isVisited[kMaxUsers]; // 100 KiB
multimap<int, int> g_relations; // 800 KiB at least
multimap<int, int> g_reachable; // 800 KiB at least


void setRelations(int id0, int id1)
{
  g_relations.insert(make_pair(id0, id1));
  g_relations.insert(make_pair(id1, id0));
}


void setReachable(int start, int end)
{
  g_reachable.insert(make_pair(start, end));
}


bool checkReachableFromStatic(int start, int end)
{
  g_reachable.insert(make_pair(start, end));

  std::multimap<int, int>::iterator it;
  for (it = g_reachable.equal_range(start).first; it != g_relations.equal_range(start).second; it++)
  {
    if (it->second == end)
      return true;
  }

  return false;
}


string isReachable(int num, int start, int end)
{

  // init
  memset(g_isVisited, 0, num);

  queue<int> que;
  que.push(start);

  while (!que.empty())
  {
    int id = que.front();

    if (checkReachableFromStatic(id, end))
      return string("yes");

    que.pop();
    g_isVisited[id] = true;

    // if no path from "id", try next
    if (g_relations.count(id) == 0)
      continue;

    // check all pathes connected from "id"
    std::multimap<int, int>::iterator it;
    for (it = g_relations.equal_range(id).first; it != g_relations.equal_range(id).second; it++)
    {
      int &dst = it->second;

      if (dst == end)
      {
        setReachable(start, end);
        return string("yes");
      }

      if (!g_isVisited[dst])
        que.push(dst);

    }
  }

  return string("no");
}


void printAllRelations()
{
#if DEBUG
  for (auto& m: g_relations)
    DPRINTF("%d %d\n", m.first, m.second);
#endif // DEBUG
}


int main()
{
  int n, m;
  cin >> n >> m; cin.ignore();

  DPRINTF("number of users %d\n", n);
  DPRINTF("number of relations %d\n", m);

  for (int i = 0; i < m; i++)
  {
    int s, t;
    cin >> s >> t; cin.ignore();

    setRelations(s, t);
  }

  printAllRelations();

  int q;
  cin >> q; cin.ignore();

  for (int i = 0; i < q; i++)
  {
    int s, t;
    cin >> s >> t; cin.ignore();

    DPRINTF("src %d  dst %d\n", s, t);

    cout << isReachable(n, s, t) << endl;
  }

  return 0;

}



Compiler output:
a.cc: In function 'std::string isReachable(int, int, int)':
a.cc:76:3: error: 'memset' was not declared in this scope
   76 |   memset(g_isVisited, 0, num);
      |   ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   10 | #include <utility>
  +++ |+#include <cstring>
   11 | using namespace std;
Language: C++

#include <cstdio>
#include <vector>
#include <cstring>

bool isFriend(std::vector<int> *a, int s, int t, int *checked, int c){
    int tmp;
    checked[s] = c;
    if(s==t)return true;
    for(int i=0;i<a[s].size();i++){
        tmp = a[s][i];
        if(checked[tmp]>=c)continue;
        if(isFriend(a,tmp,t,checked,c))return true;
    }
    return false;
}

int main(){
    int i, n, m, q, s, t;
    int *checked;
    scanf("%d %d",&n,&m);
    checked = (int *)malloc(sizeof(int)*n);
    memset(checked, 0, sizeof(int)*n);
    std::vector<int> a[n];
    for(i=0;i<m;i++){
        scanf("%d %d",&s,&t);
        a[s].push_back(t);
        a[t].push_back(s);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d %d",&s,&t);
        if(isFriend(a,s,t,checked,i+1))printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:21:22: error: 'malloc' was not declared in this scope
   21 |     checked = (int *)malloc(sizeof(int)*n);
      |                      ^~~~~~
a.cc:4:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    3 | #include <cstring>
  +++ |+#include <cstdlib>
    4 |
Language: C++

#include<iostream>
#include<vector>
#include<stack>

using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX]
int color[N];

void dfs(int r, int c) {
  stack<int> S;
  S.push(s);
  color[r] = c;

  while (!S.empty()) {
    int u = S.top(); S.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (color[v] == NIL) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for (int i = 0; i < n; i++) {
    color[i] = NIL;
  }
  for (int u = 0; u < n; u++) {
    if (color[u] == NIL) {
      dfs(u, id++);
    }
  }
}

int main() {
  int m, s, t;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  int q;
  cin >> q;

  for (int i =0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}


Compiler output:
a.cc:12:1: error: expected initializer before 'int'
   12 | int color[N];
      | ^~~
a.cc: In function 'void dfs(int, int)':
a.cc:16:10: error: 's' was not declared in this scope
   16 |   S.push(s);
      |          ^
a.cc:17:3: error: 'color' was not declared in this scope; did you mean 'tolower'?
   17 |   color[r] = c;
      |   ^~~~~
      |   tolower
a.cc:21:25: error: 'G' was not declared in this scope
   21 |     for (int i = 0; i < G[u].size(); i++) {
      |                         ^
a.cc: In function 'void assignColor()':
a.cc:34:5: error: 'color' was not declared in this scope; did you mean 'tolower'?
   34 |     color[i] = NIL;
      |     ^~~~~
      |     tolower
a.cc:37:9: error: 'color' was not declared in this scope; did you mean 'tolower'?
   37 |     if (color[u] == NIL) {
      |         ^~~~~
      |         tolower
a.cc: In function 'int main()':
a.cc:50:5: error: 'G' was not declared in this scope
   50 |     G[s].push_back(t);
      |     ^
a.cc:61:9: error: 'color' was not declared in this scope; did you mean 'tolower'?
   61 |     if (color[s] == color[t]) {
      |         ^~~~~
      |         tolower
Language: C++

#include<iostream>
#include<vector>
#include<stack>

using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[N];

void dfs(int r, int c) {
  stack<int> S;
  S.push(s);
  color[r] = c;

  while (!S.empty()) {
    int u = S.top(); S.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (color[v] == NIL) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for (int i = 0; i < n; i++) {
    color[i] = NIL;
  }
  for (int u = 0; u < n; u++) {
    if (color[u] == NIL) {
      dfs(u, id++);
    }
  }
}

int main() {
  int m, s, t;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  int q;
  cin >> q;

  for (int i =0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}


Compiler output:
a.cc:12:11: error: 'N' was not declared in this scope
   12 | int color[N];
      |           ^
a.cc: In function 'void dfs(int, int)':
a.cc:16:10: error: 's' was not declared in this scope
   16 |   S.push(s);
      |          ^
a.cc:17:3: error: 'color' was not declared in this scope; did you mean 'tolower'?
   17 |   color[r] = c;
      |   ^~~~~
      |   tolower
a.cc: In function 'void assignColor()':
a.cc:34:5: error: 'color' was not declared in this scope; did you mean 'tolower'?
   34 |     color[i] = NIL;
      |     ^~~~~
      |     tolower
a.cc:37:9: error: 'color' was not declared in this scope; did you mean 'tolower'?
   37 |     if (color[u] == NIL) {
      |         ^~~~~
      |         tolower
a.cc: In function 'int main()':
a.cc:61:9: error: 'color' was not declared in this scope; did you mean 'tolower'?
   61 |     if (color[s] == color[t]) {
      |         ^~~~~
      |         tolower
Language: C++


#include<iostream>
#include<vector>
#include<stack>

using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
  stack<int> S;
  S.push(s);
  color[r] = c;

  while (!S.empty()) {
    int u = S.top(); S.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (color[v] == NIL) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for (int i = 0; i < n; i++) {
    color[i] = NIL;
  }
  for (int u = 0; u < n; u++) {
    if (color[u] == NIL) {
      dfs(u, id++);
    }
  }
}

int main() {
  int m, s, t;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  int q;
  cin >> q;

  for (int i =0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}




Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:17:10: error: 's' was not declared in this scope
   17 |   S.push(s);
      |          ^
Language: C++

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

static const int MAX =100000;
static const int NIL=-1;

int n;
vector<int> G[MAX];
int color[MAX];

void dsf(int r,int c){
  stack<int> S;
  S.push(r);
  color[r]=c;
  while(!S.empty()){
    int u=S.top();S.pop();
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      if(color[v]==NIL){
        color[v]=c;
        S.push(v);
      }
  }
}

void assignColor(){
  int id=1;
  for(int i=0;i<n;i++) color[i]=NIL;
  for(int u=0;u<n;u++){
    if(color[u]==NIL)dfs(u,id++);
  }
}

int main (){
  int s,t,m,q;
  cin >> n >>m;
  for(int i=0;i<m;i++){
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();
  cin >>q;
  for(int i=0;i<q;i++){
    if(color[s]==color[t]){
      cout <<"yes"<< endl;
    }else{
      cout << "no" <<endl;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'void dsf(int, int)':
a.cc:29:19: error: a function-definition is not allowed here before '{' token
   29 | void assignColor(){
      |                   ^
a.cc:37:10: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   37 | int main (){
      |          ^~
a.cc:37:10: note: remove parentheses to default-initialize a variable
   37 | int main (){
      |          ^~
      |          --
a.cc:37:10: note: or replace parentheses with braces to value-initialize a variable
a.cc:37:12: error: a function-definition is not allowed here before '{' token
   37 | int main (){
      |            ^
a.cc:57:2: error: expected '}' at end of input
   57 | }
      |  ^
a.cc:14:22: note: to match this '{'
   14 | void dsf(int r,int c){
      |                      ^
Language: C++

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

static const int MAX =100000;
static const int NIL=-1;

int n;
vector<int> G[MAX];
int color[MAX];

void dsf(int r,int c){
  stack<int> S;
  S.push(r);
  color[r]=c;
  while(!S.empty()){
    int u=S.top();S.pop();
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      if(color[v]==NIL){
        color[v]=c;
        S.push(v);
      }
    }
  }
}

void assignColor(){
  int id=1;
  for(int i=0;i<n;i++) color[i]=NIL;
  for(int u=0;u<n;u++){
    if(color[u]==NIL)dfs(u,id++);
  }
}

int main (){
  int s,t,m,q;
  cin >> n >>m;
  for(int i=0;i<m;i++){
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();
  cin >>q;
  for(int i=0;i<q;i++){
    if(color[s]==color[t]){
      cout <<"yes"<< endl;
    }else{
      cout << "no" <<endl;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'void assignColor()':
a.cc:34:22: error: 'dfs' was not declared in this scope; did you mean 'dsf'?
   34 |     if(color[u]==NIL)dfs(u,id++);
      |                      ^~~
      |                      dsf
Language: C++

#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(c);
    color[r] = c;
    while(!S.empty()) {
        int u=S.top(); S.pop();
        for (int i=0; i<G[u].size(); i++) {
            int v = G[u][i]; 
            if(color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i=0; i<n; i++) color[i] = NIL;
    for (int u=0; u<n; u++) {
        if(color[i] == NIL) dfs(u, id++);
    }
}

int main() {
    int s, t, m, q;
    
    cin >> n >> m;
    
    for (int i=0; i<m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    
    assignColor();
    
    cin >> q;
    
    for (int i=0; i<q; i++) {
        cin >> s >> t;
        if(color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'void assignColor()':
a.cc:32:18: error: 'i' was not declared in this scope
   32 |         if(color[i] == NIL) dfs(u, id++);
      |                  ^
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

public class MST {
	public static void main(String[] wjy) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		Graph g = new Graph(num);
		for (int i=0;i<num;i++) {
			for (int m =0;m<num;m++) {
				int we = sc.nextInt();
				g.setEdge(i,m,we);
			}
		}
		//for (int i =0;i<g.getV();i++) {
		//	System.out.println(g.getAdj(i));
		//}
		System.out.println(g.getMst());
	}
	static class Graph{
		public Vertice[] ver;
		public int[][] matrix;
		public Graph(int n) {
			this.ver= new Vertice[n];
			for (int i=0;i<n;i++) {
				this.ver[i] = new Vertice(i);
			}
			this.matrix=new int[n][n];
		}
		
		public int getV() {
			return this.ver.length;
		}
		
		public void setEdge(int n,int m,int we) {
			this.matrix[n][m] = we;
		}
		
		public ArrayList<ArrayList<Integer>> getAdj(int n){
			ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>();
			int m = this.getV();
			for (int i=0;i<m;i++) {
				if (this.matrix[n][i] !=-1) {
					ArrayList<Integer> arr = new ArrayList<Integer>();
					arr.add(i);
					arr.add(this.matrix[n][i]);
					a.add(arr);
				}
			}
			return a;
		}
		
		public int getMinVe(ArrayList<Integer> arr) {
			int index = -1;
			int m=Integer.MAX_VALUE;
			for (int i=0;i<arr.size();i++) {
				if (this.ver[arr.get(i)].value<=m) {
					index = i;
					m = this.ver[arr.get(i)].value;
				}
			}
			return index;
		}
		
		public int getMst(){
			//ArrayList<int[]> al= new ArrayList<int[]>();
			int mindis =0;
			ArrayList<Integer> q = new ArrayList<Integer>();
			for (int i=0;i<this.getV();i++) {
				q.add(i);
			}
			this.ver[0].setValue(0);
			while (!q.isEmpty()) {
				//for (int i=0;i<this.getV();i++) {
				//	System.out.println(this.ver[i]);
				//}
				//System.out.println();
				int index = this.getMinVe(q);
				//System.out.println(index);
				int m = q.remove(index);
				this.ver[m].setVisit();
				if (this.ver[m].parent != -20) {
					int k =this.ver[m].parent;
					int l =this.ver[m].key;
					mindis = mindis + this.matrix[k][l];
				} 
				ArrayList<ArrayList<Integer>> arr = this.getAdj(m);
				for (int i=0;i<arr.size();i++) {
					int ve = arr.get(i).get(0);
					if (this.ver[ve].visit == 0) {
						int we = arr.get(i).get(1);
						if ((this.ver[m].value+we)<this.ver[ve].value) {
							this.ver[ve].setValue(we+this.ver[m].value);
							this.ver[ve].setParent(m);
						}
					}
				}
				
			}
			return mindis;
			
		}
	}
	
	static class Vertice{
		public int key;
		public int value;
		public int parent;
		public int visit;
		//@SuppressWarnings("null")
		public String toString() {
			return this.value +" "+ this.parent+" "+this.visit; 
		}
		public Vertice(int num) {
			this.key = num;
			this.value = Integer.MAX_VALUE;
			this.parent = -20;
			this.visit=0;
		}
		
		public void setValue(int k) {
			this.value =k;
		}
		
		public void setParent(int n) {
			this.parent =n;
		}
		
		public int getParent() {
			return this.parent;
		}
		public void setVisit() {
			this.visit = 1;
		}
	}
}


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

import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

@SuppressWarnings("unchecked")
class MinCostTree{

    int N;
    class Edge{
        int from,to;
        long w;
        Edge(int from,int to,long w){this.from=from;this.to=to;this.w=w;}
    }
    List<Edge> edges[];
    List<Edge> minedge[];
    void add_edge(int u,int v,long w){
        edges[u].add(new Edge(u,v,w));
        edges[v].add(new Edge(v,u,w));
    }
    MinCostTree(int N){
        this.N=N;
        edges = new ArrayList[N];
        minedge = new ArrayList[N];
        for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
        for(int i=0;i<N;++i)minedge[i]=new ArrayList<>();
    }
    long mincost(){
        PriorityQueue<Edge> que = new PriorityQueue<>((a,b)->a.w<b.w ? -1:1);
        boolean used[] = new boolean[N];
        used[0]=true;
        long res = 0;
        for(Edge e : edges[0])que.add(e);
        while(!que.isEmpty()){
            Edge e = que.poll();
            if(used[e.to])continue;
            used[e.to]=true;
            minedge[e.from].add(e);
            res += e.w;
            for(Edge ed : edges[e.to])que.add(ed);
        }
        return res;
    }
}

Class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        MinCostTree mct = new MinCostTree(n);
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                long a = scan.nextLong();
                if(i>j && a>0)mct.add_edge(i, j, a);
            }
        }
        System.out.println(mct.mincost());
    }
}


Compiler output:
Main.java:46: error: class, interface, enum, or record expected
Class Main{
^
Main.java:47: error: unnamed classes are a preview feature and are disabled by default.
    public static void main(String[] args){
                  ^
  (use --enable-preview to enable unnamed classes)
Main.java:59: error: class, interface, enum, or record expected
}
^
3 errors
Language: Java

import java.util.Scanner;

public class MST {
    public static final int WHITE = 0;
    public static final int GRAY = 1;
    public static final int BLACK = 2;
    public static final int INF = Integer.MAX_VALUE;


    public MST() {

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] G = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int w = sc.nextInt();
                G[i][j] = (w == -1) ? INF : w;
            }
        }
        int res = prim(n, G);
        System.out.println(res);


    }

    private static int prim(int n, int[][] G) {
        int u;
        int minv;
        int[] d = new int[n];
        int[] p = new int[n];
        int[] color = new int[n];

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

        d[0] = 0;

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

            for(int v=0;v<n;v++){
                if(color[v] != BLACK && G[u][v] != INF){
                    if(d[v] > G[u][v]) {
                        d[v] = G[u][v];
                        p[v] = u;
                        color[v] = GRAY;
                    }
                }
            }
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            if(p[i] != -1){
                sum += G[i][p[i]];
            }
        }
        return sum;
    }
}



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

#include<stdio.h>
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n M[MAX][MAX];

int prim(){
  int i,v,u,minv;
  int d[MAX],p[MAX],color[MAX];

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

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0; i<n; i++){
      if(minv>d[i] && color[i]!=BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > m[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(i = 0; i<n; i++;){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j;
  scanf("%d",&n);

  for(i = 0; i<n;i++){
    for(j = 0; j<n; j++){
      int e;
      scanf("%d",&e);
      M[i][j] = (e==-1)>INFTY:e;
    }
  }

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

  return 0;
}



Compiler output:
main.c:8:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'M'
    8 | int n M[MAX][MAX];
      |       ^
main.c: In function 'prim':
main.c:14:15: error: 'n' undeclared (first use in this function)
   14 |   for(i = 0;i<n;i++){
      |               ^
main.c:14:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:34:31: error: 'M' undeclared (first use in this function)
   34 |       if(color[v] != BLACK && M[u][v] != INFTY){
      |                               ^
main.c:35:19: error: 'm' undeclared (first use in this function)
   35 |         if(d[v] > m[u][v]){
      |                   ^
main.c:44:22: error: expected ')' before ';' token
   44 |   for(i = 0; i<n; i++;){
      |      ~               ^
      |                      )
main.c: In function 'main':
main.c:52:15: error: 'n' undeclared (first use in this function)
   52 |   scanf("%d",&n);
      |               ^
main.c:58:7: error: 'M' undeclared (first use in this function)
   58 |       M[i][j] = (e==-1)>INFTY:e;
      |       ^
main.c:58:30: error: expected ';' before ':' token
   58 |       M[i][j] = (e==-1)>INFTY:e;
      |                              ^
      |                              ;
Language: C

#include<stdio.h>
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

int prim(){
  int i,v,u,minv;
  int d[MAX],p[MAX],color[MAX];

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

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0; i<n; i++){
      if(minv>d[i] && color[i]!=BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > m[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(i = 0; i<n; i++;){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j;
  scanf("%d",&n);

  for(i = 0; i<n;i++){
    for(j = 0; j<n; j++){
      int e;
      scanf("%d",&e);
      M[i][j] = (e==-1)>INFTY:e;
    }
  }

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

  return 0;
}



Compiler output:
main.c:8:7: error: variably modified 'M' at file scope
    8 | int n,M[MAX][MAX];
      |       ^
main.c:8:7: error: variably modified 'M' at file scope
main.c: In function 'prim':
main.c:35:19: error: 'm' undeclared (first use in this function)
   35 |         if(d[v] > m[u][v]){
      |                   ^
main.c:35:19: note: each undeclared identifier is reported only once for each function it appears in
main.c:44:22: error: expected ')' before ';' token
   44 |   for(i = 0; i<n; i++;){
      |      ~               ^
      |                      )
main.c: In function 'main':
main.c:58:30: error: expected ';' before ':' token
   58 |       M[i][j] = (e==-1)>INFTY:e;
      |                              ^
      |                              ;
Language: C

#include<stdio.h>
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

int prim(){
  int i,v,u,minv;
  int d[MAX],p[MAX],color[MAX];

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

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0; i<n; i++){
      if(minv>d[i] && color[i]!=BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > m[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(i = 0; i<n; i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j;
  scanf("%d",&n);

  for(i = 0; i<n;i++){
    for(j = 0; j<n; j++){
      int e;
      scanf("%d",&e);
      M[i][j] = (e==-1)>INFTY:e;
    }
  }

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

  return 0;
}



Compiler output:
main.c:8:7: error: variably modified 'M' at file scope
    8 | int n,M[MAX][MAX];
      |       ^
main.c:8:7: error: variably modified 'M' at file scope
main.c: In function 'prim':
main.c:35:19: error: 'm' undeclared (first use in this function)
   35 |         if(d[v] > m[u][v]){
      |                   ^
main.c:35:19: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:58:30: error: expected ';' before ':' token
   58 |       M[i][j] = (e==-1)>INFTY:e;
      |                              ^
      |                              ;
Language: C

#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

int prim(){
  int i,v,u,minv;
  int d[MAX],p[MAX],color[MAX];

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

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0; i<n; i++){
      if(minv>d[i] && color[i]!=BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > m[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(i = 0; i<n; i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j;
  scanf("%d",&n);

  for(i = 0; i<n;i++){
    for(j = 0; j<n; j++){
      int e;
      scanf("%d",&e);
      M[i][j] = (e==-1)>INFTY:e;
    }
  }

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

  return 0;
}




Compiler output:
main.c: In function 'prim':
main.c:35:19: error: 'm' undeclared (first use in this function)
   35 |         if(d[v] > m[u][v]){
      |                   ^
main.c:35:19: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:58:30: error: expected ';' before ':' token
   58 |       M[i][j] = (e==-1)>INFTY:e;
      |                              ^
Language: C

#include <stdio.h>
#define MAX 1 << 22
int map[100][100];
int n, minval = 999999;

int prim()
{
    int sum = 0;
    int d[100], fathernode[100], color[100];;
    for(int i = 0; i < n; i ++)
        d[i] = fathernode[i] = MAX;
    d[0] = 0;
    while(true)
    {
        int ch = -1, min = MAX;
        for(int i = 0; i < n; i ++)
        {
            if(min > d[i] && color[i] == 0) //选取未被染色的点
            {
                ch = i;
                min = d[i];
            }
        }
        if(ch == -1) //选完了，跳出
            break;
        color[ch] = 1;//选取这个点后染色
        for(int j = 0; j < n; j ++)//选取V-T中与T距离最近的节点
        {
            if(d[j] > map[ch][j] && color[j] == 0)
            {
                d[j] = map[ch][j];
                fathernode[j] = ch;//j节点的父节点是ch
            }
        }
    }
    //选取完毕，开始加起来
    for(int k = 0; k < n; k ++)//只加被染色（即被选中的）节点
    {
        if(fathernode[k] != MAX)//只加上有父节点的点
            sum += map[k][fathernode[k]];
    }
    return sum;
}

int main(void)
{
    scanf("%d", &n);
    for(int i = 0; i < n; i ++)
        for(int j = 0; j < n; j ++)
        {
            int t;
            scanf("%d", &t);
            map[i][j] = (t == -1 ? MAX : t);
        }
    printf("%d\n", prim() );
    return 0;
}


Compiler output:
main.c: In function 'prim':
main.c:13:11: error: 'true' undeclared (first use in this function)
   13 |     while(true)
      |           ^~~~
main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdbool.h>
    2 | #define MAX 1 << 22
main.c:13:11: note: each undeclared identifier is reported only once for each function it appears in
   13 |     while(true)
      |           ^~~~
Language: C

#include <stdio.h>
#define MAX 1 << 22
int map[1000][1000];
int n, minval = 999999;

int prim()
{
    int sum = 0;
    int d[1000], fathernode[1000], color[1000];;
    for(int i = 0; i < n; i ++)
        d[i] = fathernode[i] = MAX;
    d[0] = 0;
    while(true)
    {
        int ch = -1, min = MAX;
        for(int i = 0; i < n; i ++)
        {
            if(min > d[i] && color[i] == 0) //选取未被染色的点
            {
                ch = i;
                min = d[i];
            }
        }
        if(ch == -1) //选完了，跳出
            break;
        color[ch] = 1;//选取这个点后染色
        for(int j = 0; j < n; j ++)//选取V-T中与T距离最近的节点
        {
            if(d[j] > map[ch][j] && color[j] == 0)
            {
                d[j] = map[ch][j];
                fathernode[j] = ch;//j节点的父节点是ch
            }
        }
    }
    //选取完毕，开始加起来
    for(int k = 0; k < n; k ++)//只加被染色（即被选中的）节点
    {
        if(fathernode[k] != MAX)//只加上有父节点的点
            sum += map[k][fathernode[k]];
    }
    return sum;
}

int main(void)
{
    scanf("%d", &n);
    for(int i = 0; i < n; i ++)
        for(int j = 0; j < n; j ++)
        {
            int t;
            scanf("%d", &t);
            map[i][j] = (t == -1 ? MAX : t);
        }
    printf("%d\n", prim() );
    return 0;
}


Compiler output:
main.c: In function 'prim':
main.c:13:11: error: 'true' undeclared (first use in this function)
   13 |     while(true)
      |           ^~~~
main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdbool.h>
    2 | #define MAX 1 << 22
main.c:13:11: note: each undeclared identifier is reported only once for each function it appears in
   13 |     while(true)
      |           ^~~~
Language: C

include <stdio.h> 


static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum;
  int M[MAX][MAX];
  int d[MAX],pi[MAX],G[MAX],v[MAX];
  int MIN;
  int length=0,c=1,f=0,count=0;

  
  v[0] = 0;
  MIN = INFTY;
  sum = 0;

  for(i = 2; i <= MAX; i++){
    v[i] = -1;
  }
  

  scanf("%d", &n);
  
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }


  for(i = 1; i <= n; i++){
    MIN = INFTY;
    
    for(count = 1; count <= c; count++){
      for(j = 1; j <= n; j++){
	if(MIN > M[v[count]][j] && mst(j,v,c)){
	  MIN = M[v[count]][j];
	  
	  f = j;
	}
      }
    }
    
    v[c] = f;
    pi[v[i]] = v[c];
    c++;
    
    sum = sum + MIN;
  }
  
  
  printf("%d\n",sum);
  
  return 0;
}

int mst(int a,int b[], int c)
{
  
  int i;
  
  for(i = 1; i <= c; i++){
    if(b[i] == a){
      return ;
    }
    
    else {
      return 1;
    }
  }
}

Compiler output:
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include <stdio.h>
      |         ^
main.c:7:1: error: return type defaults to 'int' [-Wimplicit-int]
    7 | main(){
      | ^~~~
main.c: In function 'main':
main.c:9:9: error: 'MAX' undeclared (first use in this function)
    9 |   int M[MAX][MAX];
      |         ^~~
main.c:9:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:24:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   24 |   scanf("%d", &n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | include <stdio.h>
main.c:24:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   24 |   scanf("%d", &n);
      |   ^~~~~
main.c:24:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:39:36: error: implicit declaration of function 'mst' [-Wimplicit-function-declaration]
   39 |         if(MIN > M[v[count]][j] && mst(j,v,c)){
      |                                    ^~~
main.c:55:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   55 |   printf("%d\n",sum);
      |   ^~~~~~
main.c:55:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:55:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:55:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: In function 'mst':
main.c:67:7: error: 'return' with no value, in function returning non-void [-Wreturn-mismatch]
   67 |       return ;
      |       ^~~~~~
main.c:60:5: note: declared here
   60 | int mst(int a,int b[], int c)
      |     ^~~
Language: C

#include<stdio.h>
#define ENP 100000
#define END 200000
#define N 1000000
#define MAX 1000

int main(){
  int y=0, i,n,p,c,M[MAX][MAX],grab[MAX][3],belongA[MAX],minimum=N,sum =0,minimumC,minimumP;
  
  scanf("%d", &n);
  
  for ( p = 0; p< n; p++ ){
    belongA[p] = 0;
    for ( c = 0; c < n; c++ ){
      scanf("%d", &M[p][c]);
    }
  }
  for ( y = 0; y < MAX; y++ ){
    grab[y][0] = ENP;
    grab[y][1] = ENP;
    grab[y][2] = ENP;
  }
  
  p = 0;
  for(i = 0; i < n-1; i++ ){
    belongA[p] = 1;
    for ( c = 0; c< n; c++ ){
      if(M[p][c] != -1 && belongA[c] != 1){
        grab[y][0] = M[p][c];
        grab[y][1] = c;
	grab[y][2] = p;
	y++;
      }
      for ( y = 0; grab[y][0] != ENP; y++ ){
        if(grab[y][0] < minimum){
          minimum = grab[y][0];
          minimumC = grab[y][1];
	  minimumP = grab[y][2];
        }
      } 
    }
    for ( y = 0; grab[y][0] != ENP; y++ ){
      if(minimum == grab[y][0] && minimumC == grab[y][1]){
	grab[y][0] = END;
      }
    }
    sum += M[minimumP][minimumC];
    p = minimumC;
    minimum = N;
  }
  
  printf("%d\n", sum);

Compiler output:
main.c: In function 'main':
main.c:52:3: error: expected declaration or statement at end of input
   52 |   printf("%d\n", sum);
      |   ^~~~~~
Language: C

#include<stdio.h>
#define ENP 100000
#define END 200000
#define N 1000000
#define MAX 1000

int main(){
  int y=0, i,n,p,c,M[MAX][MAX],grab[MAX][3],belongA[MAX],minimum=N,sum =0,minimumC,minimumP;
  
  scanf("%d", &n);
  
  for ( p = 0; p< n; p++ ){
    belongA[p] = 0;
    for ( c = 0; c < n; c++ ){
      scanf("%d", &M[p][c]);
    }
  }
  for ( y = 0; y < MAX; y++ ){
    grab[y][0] = ENP;
    grab[y][1] = ENP;
    grab[y][2] = ENP;
  }
  
  p = 0;
  for(i = 0; i < n-1; i++){
    belongA[p] = 1;
    for ( c = 0,; c < n ; c++ ){
      if(M[p][c] != -1 && belongA[c] != 1){
        grab[y][0] = M[p][c];
        grab[y][1] = c;
	grab[y][2] = p;
	y++;
      }
      for ( y = 0; grab[y][0] != ENP; y++ ){
        if(grab[y][0] < minimum && belongA[grab[y][1]] != 1){
          minimum = grab[y][0];
          minimumC = grab[y][1];
	  minimumP = grab[y][2];
        }
      } 
    }
    /*for ( y = 0; grab[y][0] != ENP; y++ ){
      if(minimum == grab[y][0] && minimumC == grab[y][1]){
	grab[y][0] = END;
      }
      }*/
    sum += M[minimumP][minimumC];
    M[minimumC][minimumP] = END;
    p = minimumC;
    minimum = N;
  }
  
  printf("%d\n", sum);
 
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:27:17: error: expected expression before ';' token
   27 |     for ( c = 0,; c < n ; c++ ){
      |                 ^
Language: C

#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum;
  int M[MAX][MAX];

  scanf("%d", &n);
  
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for(i=0; i<n; i++){
    key[i]=INFTY;
    pi[i]=NIL;
    vis[i]=0;
  }
  key[0]=0;

  while(1){
    u=NIL;
    minv=INFTY;

    for(i=0; i<n; i++){
      if(key[i] < minv && !vis[i]){
	u=i;
	minv = key[i];
      }
    }

    if(u==NIL)
      break;

    vis[u]=1;

    for(i=0; i<n; i++){
      if(M[u][i] < key[i] && !vis[i]){
	key[i] = M[u][i];
	pi[i]=u;
      }
    }
  }



  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

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

  return 0;
}

Compiler output:
main.c:6:1: error: return type defaults to 'int' [-Wimplicit-int]
    6 | main(){
      | ^~~~
main.c: In function 'main':
main.c:20:5: error: 'key' undeclared (first use in this function)
   20 |     key[i]=INFTY;
      |     ^~~
main.c:20:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:21:5: error: 'pi' undeclared (first use in this function); did you mean 'i'?
   21 |     pi[i]=NIL;
      |     ^~
      |     i
main.c:21:11: error: 'NIL' undeclared (first use in this function)
   21 |     pi[i]=NIL;
      |           ^~~
main.c:22:5: error: 'vis' undeclared (first use in this function)
   22 |     vis[i]=0;
      |     ^~~
main.c:27:5: error: 'u' undeclared (first use in this function)
   27 |     u=NIL;
      |     ^
main.c:28:5: error: 'minv' undeclared (first use in this function)
   28 |     minv=INFTY;
      |     ^~~~
main.c:55:10: error: 'p' undeclared (first use in this function)
   55 |     if ( p[i] != -1 ) sum += M[i][p[i]];
      |          ^
Language: C

#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum,M[MAX][MAX]={0};
  int u,minV,INT_MAX,A[MAX]={INFTY},key[MAX]={INFTY};
  /*

    your code


   */

  scanf("%d", &n);
  
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
  
  
  while(1){
    minV = 
      for(i=1;i<=n;i++){
        if((i < minV) && 

  






















  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

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

  return 0;
}

Compiler output:
main.c:6:1: error: return type defaults to 'int' [-Wimplicit-int]
    6 | main(){
      | ^~~~
main.c: In function 'main':
main.c:7:35: error: variable-sized object may not be initialized except with an empty initializer
    7 |   int n, i, j, e, sum,M[MAX][MAX]={0};
      |                                   ^
main.c:8:29: error: variable-sized object may not be initialized except with an empty initializer
    8 |   int u,minV,INT_MAX,A[MAX]={INFTY},key[MAX]={INFTY};
      |                             ^
main.c:8:46: error: variable-sized object may not be initialized except with an empty initializer
    8 |   int u,minV,INT_MAX,A[MAX]={INFTY},key[MAX]={INFTY};
      |                                              ^
main.c:28:7: error: expected expression before 'for'
   28 |       for(i=1;i<=n;i++){
      |       ^~~
main.c:63:1: error: expected declaration or statement at end of input
   63 | }
      | ^
main.c:63:1: error: expected declaration or statement at end of input