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

#include<stdio.h>

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

main(){
  int n, i, j, e, sum;
  /*

    your code


   */
  int M[MAX][MAX];
  int d[MAX];
  int k[max];pi[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;
    }
  }

  /*

   your code

  */
  for(i=0;i<n;i++){
    pi[i]=-1;
    k[i]=INFTY;
    d[i]=0:
  }
  k[0]=0;

  while(1){
    u=-1;
    m=INFTY;

    for(i=0;i<n;i++){
      if((d[i]==0&&k[i]>M[u][i]){
	  pi[i]=u;
	  k[i]=M[u][i];
	}
	}

  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:16:9: error: 'max' undeclared (first use in this function)
   16 |   int k[max];pi[MAX];
      |         ^~~
main.c:16:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:16:14: error: 'pi' undeclared (first use in this function); did you mean 'i'?
   16 |   int k[max];pi[MAX];
      |              ^~
      |              i
main.c:35:11: error: expected ';' before ':' token
   35 |     d[i]=0:
      |           ^
      |           ;
main.c:40:5: error: 'u' undeclared (first use in this function)
   40 |     u=-1;
      |     ^
main.c:41:5: error: 'm' undeclared (first use in this function)
   41 |     m=INFTY;
      |     ^
main.c:44:33: error: expected ')' before '{' token
   44 |       if((d[i]==0&&k[i]>M[u][i]){
      |         ~                       ^
      |                                 )
main.c:48:9: error: expected expression before '}' token
   48 |         }
      |         ^
main.c:53:10: error: 'p' undeclared (first use in this function)
   53 |     if ( p[i] != -1 ) sum += M[i][p[i]];
      |          ^
main.c:59:1: error: expected declaration or statement at end of input
   59 | }
      | ^
Language: C

#include<stdio.h>

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

int main(){
  int n, i, j, e, sum,u,m;
  /*
    
    your code
    

  */
  int M[MAX][MAX];
  int d[MAX];
  int k[MAX],p[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;
    }
  }
  
  /*

    your code
    
  */
  for(i=0;i<n;i++){
    p[i]=-1;
    k[i]=INFTY;
    d[i]=0;
  }
  k[0]=0;
  
  while(1){
    u=-1;
    m=INFTY;
    
    for(i=0;i<n;i++){
      if( d[i]==0 && m>key[i] ){
	p[i]=u;
	k[i]=M[u][i];
      }
    }
  }
    
    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: In function 'main':
main.c:44:24: error: 'key' undeclared (first use in this function)
   44 |       if( d[i]==0 && m>key[i] ){
      |                        ^~~
main.c:44:24: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>

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

int main(){
  int n, i, j, e, sum,u,m;
  /*
    
    your code
    

  */
  int M[MAX][MAX];
  int d[MAX];
  int k[MAX],p[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;
    }
  }
  
  /*

    your code
    
  */
  for(i=0;i<n;i++){
    p[i]=-1;
    k[i]=INFTY;
    d[i]=0;
  }
  k[0]=0;
  
  while(1){
    u=-1;
    m=INFTY;
    
    for(i=0;i<n;i++){
      if( d[i]==0 && m>k[i] ){
	u=i;
	m=key[i];
      }
    }
    if(u==-1)break;
    d[u]=1;
    for(i=0;i<n;i++){
      if(k[i]>=M[u][i]&&d[i]==0){
	p[i]=u;
	k[i]=M[U][i];
      }
    }
  }
    
    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: In function 'main':
main.c:46:11: error: 'key' undeclared (first use in this function)
   46 |         m=key[i];
      |           ^~~
main.c:46:11: note: each undeclared identifier is reported only once for each function it appears in
main.c:54:16: error: 'U' undeclared (first use in this function)
   54 |         k[i]=M[U][i];
      |                ^
Language: C

#include<stdio.h>
void generic(int);
int minSearch(int, int);

static const int MAX = 500;
static const int INFTY = (1<<21);
int p[100][100];
int M[100][100];

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

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

  generic(n);

  sum = 0;

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

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

  return 0;
}

void generic(int n){
  int i, j;
  i = 1;
  while (i < n){
    minSearch(i, n);
    i++;
  }
}

int minSearch(int c, int n){
  int i, j, v, min;
  p[c][1] = 2001;
  for(i = 0; i < c; i++){
    for(j = 0; j < n; j++){
      v = p[i][0];
	if (M[v][j] < p[c][1]) {
	  p[c][0] = j;
	  p[c][1] = M[v][j];
	  min = v;
	}
    }
  }

Compiler output:
main.c:10:1: error: return type defaults to 'int' [-Wimplicit-int]
   10 | main(){
      | ^~~~
main.c: In function 'minSearch':
main.c:59:3: error: expected declaration or statement at end of input
   59 |   }
      |   ^
Language: C

#include<stdio.h>

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

int main(){
  int n,i,j,e,sum,u,v,min;
  int use[MAX],pi[MAX],key[MAX], 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]=-1;
  }

  key[0]=0;

  for(i=0;i<n;i++){
    use[i]=-1;
  }

  while(1){
    u=-1;
    minv=INFTY;
    for(i=0;i<n;i++){
      if(key[i]<minv && use[i]==-1){
	u=i;
	minv=key[i];
      }
    }

    if(u==-1){
      break;
    }
    use[u]=1;
    for(v=0;v<n;v++){
      if(M[u][v]<key[v] && use[v]==-1){
	key[v]=M[u][v];
	pi[v]=u;
      }
    }
  }

  sum=0;

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

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

Compiler output:
main.c: In function 'main':
main.c:31:5: error: 'minv' undeclared (first use in this function); did you mean 'min'?
   31 |     minv=INFTY;
      |     ^~~~
      |     min
main.c:31:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
 
static const int MAX = 500;

static const int INFTY = (1<<21);
  
  int sum2;

int  printer(int d){

  sum2 = sum2 + d;
  
return sum2;
}
 

int main(){
  int n;
  int j;
  int i;
  int e;
  int sum1;
  int M[MAX][MAX];
  int d[MAX];
  int isA[MAX];
  int u;
   
  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);
    }   
    d[i]=INFTY;
    isA[i]=0;
   }
   
  d[0]=0;
 
  while(1){
    int u;
int v=INFTY;
     
    for(i=0;i<n;i++){
      if(isA[i]==1){
continue;
      }      
if(v>d[i])
{
    v=d[i];
    u=i;
      }
    }
 
    if(v==INFTY)break;
    isA[u]=1;
    for(j=0;j<n;j++)
{
      if(isA[j]==1)continue;
      if(d[j]>=M[u][j])
{
    d[j]=M[u][j];
      }
    }
  } 
  sum1 = 0;
 sum2 = 0;
  for ( u = 0; u < n; u++ )
{
    printer(d[u]);
  
  sum1 = sum2;
  printf("%d\n", sum1);
   
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:78:1: error: expected declaration or statement at end of input
   78 | }
      | ^
Language: C

#include<stdio.h>
int A[100][100];
int visit[100];
void MinimumSpanningTree(int);
 
main(){
  int n, i, j;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &A[i][j]);
    }
  }
  MinimumSpanningTree(n);
  return 0;
}
 
void MinimumSpanningTree(int n){
  int i, j, k=1, X[100], minCost, min, sum=0;
   
  X[0] = 0;
  visit[0] = 1;
  for(i = 1; i < n; i++){
    visit[i] = 0;
  }
  while(1){
    minCost = 2001;
    for(i = 0; i < k; i++){
      for(j = 0; j < n; j++){
    if(A[X[i]][j] < minCost && A[X[i]][j] != -1 && visit[j] != 1){
      minCost = A[X[i]][j];
      min = j;
    }
      }
    }
    if(k != n){
      X[k] = min;
      visit[min] = 1;
      sum += minCost;
      k++;
    }
    else break;
  }
  printf("%d\n", sum);

Compiler output:
main.c:6:1: error: return type defaults to 'int' [-Wimplicit-int]
    6 | main(){
      | ^~~~
main.c: In function 'MinimumSpanningTree':
main.c:44:3: error: expected declaration or statement at end of input
   44 |   printf("%d\n", sum);
      |   ^~~~~~
Language: C

#include<stdio.h>
#define A 100
#define N 2000

int a[A][A],v[A]; 

void MnimumSpanningTree(int);

/*void MnimumSpanningTree(){

  int i,j,k=1,sum=0,min,min2,b[A];

  b[0] = 0;
  v[0] = 0;
  for( i = 1 ; i < n ; i++ ){
    v[i] = 0;
  }

  while(1){
    min2 = N;
    for( i = 0 ; i < k ; i++ ){
      for( j = 0 ; j < n ; j++ ){
	if( a[b[i]][j] < min2 && a[b[i]][j] != -1 && v[j] != 1 ){
	  min2 = a[b[i]][j];
	  min = j;
	}
      }
    }
    if(k != n){
      b[k] = min;
      v[min] = 1;
      sum += min2;
      k++;
    }
    else break;
  }
  printf("%d\n", sum);

}
*/

main(){

  int i,j,n,a[A];

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      scanf("%d",a[i][j]);
	}
  }
 
  MnimumSpanningTree(n);

  return 0;

}

void MnimumSpanningTree(int n){

  int i,j,k=1,sum=0,min,min2,b[A];

  b[0] = 0;
  v[0] = 0;
  for( i = 1 ; i < n ; i++ ){
    v[i] = 0;
  }

  while(1){
    min2 = N;
    for( i = 0 ; i < k ; i++ ){
      for( j = 0 ; j < n ; j++ ){
	if( a[b[i]][j] < min2 && a[b[i]][j] != -1 && v[j] != 1 ){
	  min2 = a[b[i]][j];
	  min = j;
	}
      }
    }
    if(k != n){
      b[k] = min;
      v[min] = 1;
      sum += min2;
      k++;
    }
    else break;
  }
  printf("%d\n", sum);

}

Compiler output:
main.c:42:1: error: return type defaults to 'int' [-Wimplicit-int]
   42 | main(){
      | ^~~~
main.c: In function 'main':
main.c:50:22: error: subscripted value is neither array nor pointer nor vector
   50 |       scanf("%d",a[i][j]);
      |                      ^
Language: C

#include <stdio.h>
#include <limits.h>
#define A 100
#define WHITE 1
#define BLACK 2
#define NIL -2
 
int a[A][A], p[A], w[A][A], n;
 
prim(){
  int mincost, u, v, i,color[n], d[n];
 
  for( u = 0 ; u < n ; u++ ){
    d[u] = INT_MAX;
    p[u] = NIL;
    color[u] = WHITE;
  }
 
  d[0] = 0;
 
  while(1){
    mincost = INT_MAX;
    for( i = 0 ; i < n ; i++ ){
      if( color[i] != BLACK && d[i] < mincost ){
    mincost = d[i];
    u = i;
      }
    }
     
    if(mincost == INT_MAX){
      break;
    }
 
    color[u] = BLACK;
     
    for( v =  0; v < n ; v++ ){
      if( color[v] != BLACK && w[u][v] < d[v] && w[u][v] != -1 ){
    p[v] = u;
    d[v] = w[u][v];
      }
    }
 
  }
 
} 
 
   
int main(){
  int i, j, sum=0;
 
  scanf("%d",&n);
 
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n; j++ ){
      scanf("%d", &a[i][j]);
      w[i][j] = a[i][j];
    }
  }
 
  prim();
 
  for( i = 0 ; i < n ; i++ ){
    if( w[i][pi[i]] != -1 ){
      sum += w[i][p[i]];
    }
  }
 
  printf("%d\n",sum);
 
  return 0;
}

Compiler output:
main.c:10:1: error: return type defaults to 'int' [-Wimplicit-int]
   10 | prim(){
      | ^~~~
main.c: In function 'main':
main.c:63:14: error: 'pi' undeclared (first use in this function); did you mean 'i'?
   63 |     if( w[i][pi[i]] != -1 ){
      |              ^~
      |              i
main.c:63:14: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define NIL -1
#define MAX 100
#define INF 100000

void prime(void);

int n;
int d[MAX], w[MAX], pi[MAX];

main()
{
  int i, j, sum=0;

  scanf("%d", &n);

  for(i=0; i<n; i++){
	for(j=0; j<n; j++){
	  acanf("%d", &w[i][j]);
	}
  }

  prime();
  for(i=0; i<n; i++) sum+=d[i];

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

  return 0;
}


void prime()
{
  int u, v, min;
  int color[MAX];
  int i, j;

  for(u=0; u<n; u++){
	d[u] = INF;
	pi[u] = NIL;
	color[u] = 0;
  }

  d[0] = 0;

  for(i=0; i<n; i++){
	min = INF;
	for(j=0; j<n; j++){
	  if(color[j] == 1) continue;
	  if(d[j] <= min){
		u=j;
		min = d[j];
	  }
	}

	for(v=0; v<n; v++){
	  if(w[u][v] == -1) continue;
	  if(color[v] == 1) continue;
	  if(w[u][v] < d[v]){
		pi[v] = u;
		d[v] = w[u][v];
	  }
	}
	color[u] = 1;
  }
}

Compiler output:
main.c:11:1: error: return type defaults to 'int' [-Wimplicit-int]
   11 | main()
      | ^~~~
main.c: In function 'main':
main.c:19:11: error: implicit declaration of function 'acanf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   19 |           acanf("%d", &w[i][j]);
      |           ^~~~~
      |           scanf
main.c:19:28: error: subscripted value is neither array nor pointer nor vector
   19 |           acanf("%d", &w[i][j]);
      |                            ^
main.c: In function 'prime':
main.c:57:18: error: subscripted value is neither array nor pointer nor vector
   57 |           if(w[u][v] == -1) continue;
      |                  ^
main.c:59:18: error: subscripted value is neither array nor pointer nor vector
   59 |           if(w[u][v] < d[v]){
      |                  ^
main.c:61:28: error: subscripted value is neither array nor pointer nor vector
   61 |                 d[v] = w[u][v];
      |                            ^
Language: C

#include<stdio.h>
a=101
int A[a][a];
int G[a];
void Tree(int);
 

void Tree(int n){
   int i, j, k=1;
   int X[100], co, mi, res=0;
   
  
  G[0] = 1;
X[0] = 0;
  for(i = 1; i < n; i++){
    G[i] = 0;
  }
  while(1){
    co = 2001;
     
    for(i = 0; i <k; i++){
      for(j = 0; j < n; j++){
    if(A[X[i]][j] < co && A[X[i]][j] != -1 && G[j] != 1){
      co = A[X[i]][j];
      mi = j;
    }
      }
    }
    if(k != n){
         res += co;   
      k++;
      X[k] = mi;
      G[mi] = 1;
    
    }
 
    else  break;
 
  }
 
  printf("%d\n", res);
 
  return;
}
int main(){
  int n, i, j;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++){
     for(j = 0; j < n; j++){
       scanf("%d", &A[i][j]);
    }
  }
   Tree(n);
   return 0;
}
 

Compiler output:
main.c:2:1: warning: data definition has no type or storage class
    2 | a=101
      | ^
main.c:2:1: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:3:1: error: expected ',' or ';' before 'int'
    3 | int A[a][a];
      | ^~~
main.c:4:5: error: variably modified 'G' at file scope
    4 | int G[a];
      |     ^
main.c: In function 'Tree':
main.c:23:8: error: 'A' undeclared (first use in this function)
   23 |     if(A[X[i]][j] < co && A[X[i]][j] != -1 && G[j] != 1){
      |        ^
main.c:23:8: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:51:21: error: 'A' undeclared (first use in this function)
   51 |        scanf("%d", &A[i][j]);
      |                     ^
Language: C

#include<stdio.h>

void tree(int n){
int i, j, k=1, A[100], cost, min, sum=0;
     
  A[0] = 0;
  V[0] = 1;
  for(i = 1; i < n; i++){
    V[i] = 0;
  }
  while(1){
    cost = 9999;
    for(i = 0; i < k; i++){
      for(j = 0; j < n; j++){
    if(G[A[i]][j] < cost && G[A[i]][j] != -1 && V[j] != 1){
      cost = G[A[i]][j];
      min = j;
    }
      }
    }
    if(k != n){
      A[k] = min;
      V[min] = 1;
      sum += cost;
      k++;
    }
    else break;
  }
  printf("%d\n", sum);
}

int G101][101];
int V[101];

   
main(){
  int n, i, j;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &G[i][j]);
    }
  }
     tree(n);
  return 0;
}
   

Compiler output:
main.c: In function 'tree':
main.c:7:3: error: 'V' undeclared (first use in this function)
    7 |   V[0] = 1;
      |   ^
main.c:7:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:15:8: error: 'G' undeclared (first use in this function)
   15 |     if(G[A[i]][j] < cost && G[A[i]][j] != -1 && V[j] != 1){
      |        ^
main.c: At top level:
main.c:32:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before ']' token
   32 | int G101][101];
      |         ^
main.c:36:1: error: return type defaults to 'int' [-Wimplicit-int]
   36 | main(){
      | ^~~~
main.c: In function 'main':
main.c:41:20: error: 'G' undeclared (first use in this function)
   41 |       scanf("%d", &G[i][j]);
      |                    ^
Language: C

#include<stdio.h>
int G101][101];
int V[101];
void tree(int n){
int i, j, k=1, A[100], cost, min, sum=0;
     
  A[0] = 0;
  V[0] = 1;
  for(i = 1; i < n; i++){
    V[i] = 0;
  }
  while(1){
    cost = 9999;
    for(i = 0; i < k; i++){
      for(j = 0; j < n; j++){
    if(G[A[i]][j] < cost && G[A[i]][j] != -1 && V[j] != 1){
      cost = G[A[i]][j];
      min = j;
    }
      }
    }
    if(k != n){
      A[k] = min;
      V[min] = 1;
      sum += cost;
      k++;
    }
    else break;
  }
  printf("%d\n", sum);
}



   
main(){
  int n, i, j;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &G[i][j]);
    }
  }
     tree(n);
  return 0;
}
   

Compiler output:
main.c:2:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before ']' token
    2 | int G101][101];
      |         ^
main.c: In function 'tree':
main.c:16:8: error: 'G' undeclared (first use in this function)
   16 |     if(G[A[i]][j] < cost && G[A[i]][j] != -1 && V[j] != 1){
      |        ^
main.c:16:8: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:36:1: error: return type defaults to 'int' [-Wimplicit-int]
   36 | main(){
      | ^~~~
main.c: In function 'main':
main.c:41:20: error: 'G' undeclared (first use in this function)
   41 |       scanf("%d", &G[i][j]);
      |                    ^
Language: C

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


typedef struct edge {
    int w, f, t;
} edge;
edge E[(100*100)/2];
  
int A[100][100];
int group[100];
int comp(const void *x, const void *y)
{
    return ((edge*)x)->w - ((edge*)y)->w;
}
  
int kru(int n)
{
    int i, j, en, s, from, to;
    for(i=0; i<n; i++) group[i]=i;
    en=0;
    for(i=0; i<n; i++) {
        for(j=0; j<i; j++) {
            if(A[i][j]!=-1) {
                E[en].w=A[i][j];
                E[en].f=i;
                E[en].t=j;
                en++;
            }
        }
    }
    qsort(E, en, sizeof(edge), comp);
      
    s=0;
    for(i=0; i<en; i++) {
        from=group[E[i].f];
        to=group[E[i].t];
        if(from != to) {
            s+=E[i].w;
            for(j=0; j<n; j++) {
                if(group[j]==from) group[j]=to;
            }
            for(j=1; j<n && group[j-1]==group[j]; j++);
            if(j==n) break;
        }
    }
      return s;
}
int main(int argc,char * argv[])
{
    int i=0, j, n, s;
    scanf("%d", &n);
      
    while(i=>n){
      i++;
        for(j=0; j<n; j++) {
            scanf("%d", &A[i][j]);
        }
    }
      
    s=kru(n);
    printf("%d\n", s);
    return 0;
}
 

Compiler output:
main.c: In function 'main':
main.c:54:13: error: expected expression before '>' token
   54 |     while(i=>n){
      |             ^
Language: C

#include<stdio.h>
#define N 100
#define INF 1<<21
int G[N][N], n, labels[N], d[N], p[N];

/*
  labels:
  0 unvisited
  1 tmp
  2 included
 */

void prim(){
    int i,u, mincost;
    for(i=0; i<n; i++) {
	labels[i]=0;
	d[i]=INF;
    }
    d[0]=0;
    p[0]= -1;
    
    while (true) {
	/*find the vertex with the minimum weight and return u*/
	mincost = INF;
	for(i=0; i<n; i++) {
	    if(labels[i]!=2 && d[i]<mincost) {
		mincost= d[i];
		u=i;
		    }
	}
	
	if (mincost == INF)break;
	
	labels[u]=2;
	
	/* */
	for(i=0; i<n; i++){
	    if(labels[i]!=2 && G[u][i] != -1){
		if(G[u][i] < d[i]){
		    d[i]=G[u][i];
		    p[i]=u;
		    labels[i]=1;
		}
	    }
	}

	
    }
}

int min(int x, int y){
    return (x>=y) ? y: x;
}

int mincost[N];
int prim2() {
    int i;
    for(i=0; i<n; i++) {
	mincost[i]=INF;
	labels[i]=0;
    }
    mincost[0]=0;
    int res=0;
    while (true){
	int u,v=-1;
	for(u=0; u<n; u++){
	    if(labels[u]==0 && (v == -1 || mincost[u] < mincost[v])) v=u;
	}
	if (v==-1) break;
	labels[v]=1;
	res += mincost[v];
	for(u=0; u<n; u++){
	    if(G[v][u]!=-1)mincost[u] = min(mincost[u], G[v][u]);
	}
    }
    return res;

}

int main(){
    int i,j, sum;
    scanf("%d",&n);
    for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	    scanf("%d",&G[i][j]);
	}
    }
    
    printf("%d\n", prim2());
    return 0;
}

Compiler output:
main.c: In function 'prim':
main.c:22:12: error: 'true' undeclared (first use in this function)
   22 |     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 N 100
main.c:22:12: note: each undeclared identifier is reported only once for each function it appears in
   22 |     while (true) {
      |            ^~~~
main.c: In function 'prim2':
main.c:64:12: error: 'true' undeclared (first use in this function)
   64 |     while (true){
      |            ^~~~
main.c:64:12: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
Language: C

#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
using namespace std;
typedef pair<int,int> PII;

int P[100]; //union_find

int root(int i){
    if(P[i] == i) return i;
    else return P[i] = root(P[i]);
}

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

void unite(int x, int y){
    P[root(x)] = root(y);
}

int main(){
    int n;
    cin >> n;
    int g[n][n];
    vector<pair<int,PII> > V;
    REP(i,n){
        REP(j,n){
            cin >> g[i][j];
            if(i<j && g[i][j] >= 0) V.pb(mp(g[i][j],mp(i,j)));
        }
    }
    sort(all(V));
    REP(i,n){
        P[i] = i;
    }
    int wsum = 0, count = 0;
    REP(i,n*n){
        int x = V[i].snd.fst;
        int y = V[i].snd.snd;
        if(same(x,y)) continue;
        unite(x,y);
        wsum += V[i].fst;
        count++;
        if(count == n-1) break;
    }

    cout <<wsum<<endl;

    return 0;
}

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

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

int A[MAX][MAX],n,v;

int prim(){
  int u,mincost,sum=0;
  int d[MAX],p[MAX],color[MAX];
 
  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=NOTSIDE;
    color[i]=WHITE;
  }
 
  d[0]=0;
 
  while(1){
    mincost=INFTY;
    u=NOTSIDE;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=BLACK){
        u=i;
        mincost=d[i];
      }
    }
    if(u==NOTSIDE)  break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&A[u][v]!=INFTY){
        if(d[v]>A[u][v]){
          d[v]=A[u][v];
          p[v]=u;
          color[v]=GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=NOTSIDE)sum+=A[i][p[i]];
  }
  return sum;
}

int main(){
  int e,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
      A[i][j]=(e==NOTSIDE)?INFTY:e;
    }
  }
  printf("%d\n",prim());
  return 0;
}

Compiler output:
main.c: In function 'prim':
main.c:15:7: error: 'i' undeclared (first use in this function)
   15 |   for(i=0;i<n;i++){
      |       ^
main.c:15:7: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:53:7: error: 'i' undeclared (first use in this function)
   53 |   for(i=0;i<n;i++){
      |       ^
Language: C

#include<stdio.h>
#define MAX 100
static const int  INFTY = 10000000000;

int i,j,M[MAX][MAX],e,minv,d[MAX],p[MAX],color[MAX],u,v,n,sum=0;
int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];

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

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

int main(){
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e == -1)M[i][j] = INFTY;
      else if(e != -1)M[i][j] = e;
    }
  }
  printf("%d\n",prim());

  return 0;
}

Compiler output:
main.c:3:27: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
    3 | static const int  INFTY = 10000000000;
      |                           ^~~~~~~~~~~
main.c: In function 'prim':
main.c:29:34: error: expected ')' before '!' token
   29 |       if(color[v] != 2 && M[u][v] ! = INFTY){
      |         ~                        ^~
      |                                  )
Language: C

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

int n, M[MAX][MAX];

int prim(void);

int main()
{
  int i, j;

  scanf("%d", &n);

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

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

  return 0;
}

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

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

  d[0] = 0;

  while(1) {
    minv = 2001;
    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]!=2001) {
        if(d[v]>M[u][v]) {
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }

Compiler output:
main.c: In function 'prim':
main.c:61:7: error: expected declaration or statement at end of input
   61 |       }
      |       ^
main.c:61:7: error: expected declaration or statement at end of input
main.c:61:7: error: expected declaration or statement at end of input
Language: C

#include <stdio.h>
#define N 100
  
int main(){
  
  int    i, j, n, min, minj, total=0;
  int A[N][N], flag[N], t[N];
  
  scanf("%d", &n)

    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++){
	scanf("%d", &A[i][j]);
      }
    }
  for(i = 0; i < n ; i++){
    flag[i] = 0;
    t[i] = 2001;
  }

  t[0] = 0;
  
  for(i = 0; i < n - 1; i++){
    min = 2001;
    for(j = 0; j < n; j++){
      if(t[j] < min && flag[j] == 0){
	min = t[j];
	minj = j;
      }
    }

    flag[minj] = 1;
  
    for(j = 0; j < n; j++){
      if(A[minj][j] != -1 && A[minj][j] < t[j] && flag[j]==0){
	t[j] = A[minj][j];
      }
    }
  }
  
  for(i = 0; i < n; i++){
    total += t[i];
  }
  printf("%d\n", total);

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:18: error: expected ';' before 'for'
    9 |   scanf("%d", &n)
      |                  ^
      |                  ;
   10 | 
   11 |     for(i = 0; i < n; i++){
      |     ~~~
Language: C

#include<stdio.h>

int main(){
  int g[102][102],a[N],f[102],n,i,j,k=1,m=0,num,sum=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&g[i][j]);
    }
  }
  
  a[0]=0;
  f[0]=1;
  
  for(i=1;i<n;i++) f[i]=0;
  
  while(1){
    value=2001;
    
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
	if(g[a[i]][j]<num && g[a[i]][j]!=-1 && f[j]!=1){
	  num=g[a[i]][j];
	  m=j;
	}
      }
    }
    
    if(k!=n){
      a[k]=m;
      f[m]=1;
      sum+=num;
      k++;
    }
    else break;
  }
  printf("%d\n",num);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:21: error: 'N' undeclared (first use in this function)
    4 |   int g[102][102],a[N],f[102],n,i,j,k=1,m=0,num,sum=0;
      |                     ^
main.c:4:21: note: each undeclared identifier is reported only once for each function it appears in
main.c:20:5: error: 'value' undeclared (first use in this function)
   20 |     value=2001;
      |     ^~~~~
Language: C

#include<stdio.h>

static const int N=500;
  static const int INF = (1<<21);


#define NIL = -1

int p[100],k[100],n;

int main(){
  int i,j,a,b,c,sum;
  int y[100][100];
  int z [100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a);
      y[i][j] = (a ==1)? INF:a ;   
 }
  }

  for(c=0;c<n;c++){
    k[c] = 100000;

    p[c]=NIL;
    z[c]=NIL;

  }
  k[0]=0;

  while(1){
    int c =NIL;
    int b = 100000;

    for(i=0;i<n;i++){
      if(k[i]<b && z[i]==NIL){
	b=k[i];
	c=i;
      }
    }

    if(c = NIL){ break; }

    for(b = 0;b<n;b++){
      if(y[c][b]<k[b] && z[b]==NIL){
	k[b]=y[c][b];
	p[b]=c;
      }
    }
    sum = 0;

    for(i=0;i<n;i++){
      if(p[i] ! = -1 ) 	sum += y[i][p[i]];
    }
    printf("%d",sum);

    return 0;
  }

}

Compiler output:
main.c: In function 'main':
main.c:7:13: error: expected expression before '=' token
    7 | #define NIL = -1
      |             ^
main.c:28:10: note: in expansion of macro 'NIL'
   28 |     p[c]=NIL;
      |          ^~~
main.c:7:13: error: expected expression before '=' token
    7 | #define NIL = -1
      |             ^
main.c:29:10: note: in expansion of macro 'NIL'
   29 |     z[c]=NIL;
      |          ^~~
main.c:7:13: error: expected expression before '=' token
    7 | #define NIL = -1
      |             ^
main.c:35:12: note: in expansion of macro 'NIL'
   35 |     int c =NIL;
      |            ^~~
main.c:7:13: error: expected expression before '=' token
    7 | #define NIL = -1
      |             ^
main.c:39:26: note: in expansion of macro 'NIL'
   39 |       if(k[i]<b && z[i]==NIL){
      |                          ^~~
main.c:7:13: error: expected expression before '=' token
    7 | #define NIL = -1
      |             ^
main.c:45:12: note: in expansion of macro 'NIL'
   45 |     if(c = NIL){ break; }
      |            ^~~
main.c:7:13: error: expected expression before '=' token
    7 | #define NIL = -1
      |             ^
main.c:48:32: note: in expansion of macro 'NIL'
   48 |       if(y[c][b]<k[b] && z[b]==NIL){
      |                                ^~~
main.c:56:14: error: expected ')' before '!' token
   56 |       if(p[i] ! = -1 )  sum += y[i][p[i]];
      |         ~    ^~
      |              )
Language: C

#include<stdio.h>

#define NIL -1

int p[100],key[100],n;

int main(){
  int a,b,c,sum,i,j;
  int M[100][100];
  int L[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a);
      M[i][j]=(a==-1)

    }
  }

  for(c=0;c<n;c++){
    key[c]=100000000;
    p[c]=NIL;
    l[c]=NIL;
  }
  
  key[0]=0;

  while(1){
    int c=NIL;
    int b=100000000;

    for(i=0;i<n;i++){
     
      if(key[i]<b && l[i]==NIL){
	b=key[i];
	c=i;
      }
    }
	
      if(c==NIL){
      break;
    }

    for(b=0;b<n;b++){
      if(M[c][b]<key[b] && l[b]==NIL){
	key[b]=M[c][b];
	p[b]=c;
      }
    }
    l[c]=0;
  }
  
  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: In function 'main':
main.c:17:22: error: expected ';' before '}' token
   17 |       M[i][j]=(a==-1)
      |                      ^
      |                      ;
   18 | 
   19 |     }
      |     ~                 
main.c:25:5: error: 'l' undeclared (first use in this function)
   25 |     l[c]=NIL;
      |     ^
main.c:25:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
int main(){

  int n,i,j,E[100][100]


   scanf("%d",&n);

   for(i=0;i<n;i++){
     for(j=0;j<n;J++){
       scanf("%d",&E[i][j]);
     }
   }

       min[]=E[0][1];

for(i=0;i<n;i++){
     for(j=0;j<n;J++){
 
       if(E[i][j]<=min)
	min[i]=E[i][j];

     }

 min[]=E[i][j];

 }

Compiler output:
main.c: In function 'main':
main.c:7:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'scanf'
    7 |    scanf("%d",&n);
      |    ^~~~~
main.c:10:18: error: 'J' undeclared (first use in this function)
   10 |      for(j=0;j<n;J++){
      |                  ^
main.c:10:18: note: each undeclared identifier is reported only once for each function it appears in
main.c:11:20: error: 'E' undeclared (first use in this function)
   11 |        scanf("%d",&E[i][j]);
      |                    ^
main.c:15:8: error: 'min' undeclared (first use in this function); did you mean 'main'?
   15 |        min[]=E[0][1];
      |        ^~~
      |        main
main.c:15:12: error: expected expression before ']' token
   15 |        min[]=E[0][1];
      |            ^
main.c:25:6: error: expected expression before ']' token
   25 |  min[]=E[i][j];
      |      ^
main.c:27:2: error: expected declaration or statement at end of input
   27 |  }
      |  ^
Language: C

#include <stdio.h>
 
#define max 100
 
int main(){
  int i,j,n,min,minj,ans=0;
 
  int data[max][max]
  int flag[max],d[max];
 
  scanf("%d",&n);
 
  for(i = 0 ; i < n ; i++){
    flag[i] = 0;
    d[i] = 2001;
  }
  d[0] = 0;
 
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      scanf("%d",&data[i][j]);
    }
  }
 
  for(i = 0 ; i <= n ; i++){
    min = 2001;
     
    for(j = 0 ; j < n ; j++){
      if((d[j] < min) && (flag[j] == 0 )){
    min = d[j];
    minj = j;
      }
    }
    flag[minj] = 1;
    for(j = 0 ; j < n ; j++){
      if(data[minj][j] != -1 && data[minj][j] < d[j] && flag[j] ==0){
 
    d[j] = data[minj][j];
      }
    }
  }
  for(i = 0 ; i < n ; i++){
    ans += d[i];
  }
  printf("%d\n",ans);
 
  return 0;
 
}

Compiler output:
main.c: In function 'main':
main.c:8:21: error: expected ';' before 'int'
    8 |   int data[max][max]
      |                     ^
      |                     ;
    9 |   int flag[max],d[max];
      |   ~~~                
main.c:21:19: error: 'data' undeclared (first use in this function)
   21 |       scanf("%d",&data[i][j]);
      |                   ^~~~
main.c:21:19: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include "stdafx.h"
#include<stdio.h>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>

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 M[MAX][MAX];
int n;
int color[MAX];

int prim(){


	int min;
	int u;
	int array[MAX];
	int i,p;

	u = 0;

	for (int j = 0; j < n; j++){
		color[j] = 0;
		array[j] = 0;
	}

	i = 0;
	color[i] = 2;
	//printf("OK");

	while(1){
		min = INFTY;
		p = 0;
		//printf("COLOR %d\n", color[0]);
		for (int b = 0; b <= i; b++){
			//printf("OKOK1\n");
			for (int j = 0; j < n;j++){
				//printf("OKOK\n");
				if (color[j] == 0 && M[array[b]][j] != INFTY){
					if (min > M[array[b]][j]){
						min = M[array[b]][j];
						p = j;
						//printf("OK");
					}
				}
			}
		}

		if (p == 0){
			break;
		}

		u += min;
		color[p] = 2;
		array[i] = p;
		i++;
		//printf("OK");
	}

	return u;

}

int main(){
	scanf_s("%d", &n);
	int e;

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

			//printf("%d\n", M[i][j]);
		}
	}
	

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

}

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

#include<stdio.h>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>

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 M[MAX][MAX];
int n;
int color[MAX];

int prim(){


	int min;
	int u;
	int array[MAX];
	int i,p;

	u = 0;

	for (int j = 0; j < n; j++){
		color[j] = 0;
		array[j] = 0;
	}

	i = 0;
	color[i] = 2;
	//printf("OK");

	while(1){
		min = INFTY;
		p = 0;
		//printf("COLOR %d\n", color[0]);
		for (int b = 0; b <= i; b++){
			//printf("OKOK1\n");
			for (int j = 0; j < n;j++){
				//printf("OKOK\n");
				if (color[j] == 0 && M[array[b]][j] != INFTY){
					if (min > M[array[b]][j]){
						min = M[array[b]][j];
						p = j;
						//printf("OK");
					}
				}
			}
		}

		if (p == 0){
			break;
		}

		u += min;
		color[p] = 2;
		array[i] = p;
		i++;
		//printf("OK");
	}

	return u;

}

int main(){
	scanf_s("%d", &n);
	int e;

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

			//printf("%d\n", M[i][j]);
		}
	}
	

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

}

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

#include<stdio.h>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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 M[MAX][MAX];
int n;
int color[MAX];

int prim(){


	int min;
	int u;
	int array[MAX];
	int i,p;

	u = 0;

	for (int j = 0; j < n; j++){
		color[j] = 0;
		array[j] = 0;
	}

	i = 0;
	color[i] = 2;
	//printf("OK");

	while(1){
		min = INFTY;
		p = 0;
		//printf("COLOR %d\n", color[0]);
		for (int b = 0; b <= i; b++){
			//printf("OKOK1\n");
			for (int j = 0; j < n;j++){
				//printf("OKOK\n");
				if (color[j] == 0 && M[array[b]][j] != INFTY){
					if (min > M[array[b]][j]){
						min = M[array[b]][j];
						p = j;
						//printf("OK");
					}
				}
			}
		}

		if (p == 0){
			break;
		}

		u += min;
		color[p] = 2;
		array[i] = p;
		i++;
		//printf("OK");
	}

	return u;

}

int main(){
	scanf_s("%d", &n);
	int e;

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

			//printf("%d\n", M[i][j]);
		}
	}
	

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

}

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

#include<stdio.h>

using namespace std;

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 M[MAX][MAX];
int n;
int color[MAX];

int prim(){


	int min;
	int u;
	int array[MAX];
	int i,p;

	u = 0;

	for (int j = 0; j < n; j++){
		color[j] = 0;
		array[j] = 0;
	}

	i = 0;
	color[i] = 2;
	//printf("OK");

	while(1){
		min = INFTY;
		p = 0;
		//printf("COLOR %d\n", color[0]);
		for (int b = 0; b <= i; b++){
			//printf("OKOK1\n");
			for (int j = 0; j < n;j++){
				//printf("OKOK\n");
				if (color[j] == 0 && M[array[b]][j] != INFTY){
					if (min > M[array[b]][j]){
						min = M[array[b]][j];
						p = j;
						//printf("OK");
					}
				}
			}
		}

		if (p == 0){
			break;
		}

		u += min;
		color[p] = 2;
		array[i] = p;
		i++;
		//printf("OK");
	}

	return u;

}

int main(){
	scanf_s("%d", &n);
	int e;

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

			//printf("%d\n", M[i][j]);
		}
	}
	

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

}

Compiler output:
main.c:3:1: error: unknown type name 'using'
    3 | using namespace std;
      | ^~~~~
main.c:3:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
    3 | using namespace std;
      |                 ^~~
main.c:11:5: error: variably modified 'M' at file scope
   11 | int M[MAX][MAX];
      |     ^
main.c:11:5: error: variably modified 'M' at file scope
main.c:13:5: error: variably modified 'color' at file scope
   13 | int color[MAX];
      |     ^~~~~
main.c: In function 'main':
main.c:68:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   68 |         scanf_s("%d", &n);
      |         ^~~~~~~
      |         scanf
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 M[MAX][MAX];
int n;
int color[MAX];

int prim(){


	int min;
	int u;
	int array[MAX];
	int i,p;

	u = 0;

	for (int j = 0; j < n; j++){
		color[j] = 0;
		array[j] = 0;
	}

	i = 0;
	color[i] = 2;
	//printf("OK");

	while(1){
		min = INFTY;
		p = 0;
		//printf("COLOR %d\n", color[0]);
		for (int b = 0; b <= i; b++){
			//printf("OKOK1\n");
			for (int j = 0; j < n;j++){
				//printf("OKOK\n");
				if (color[j] == 0 && M[array[b]][j] != INFTY){
					if (min > M[array[b]][j]){
						min = M[array[b]][j];
						p = j;
						//printf("OK");
					}
				}
			}
		}

		if (p == 0){
			break;
		}

		u += min;
		color[p] = 2;
		array[i] = p;
		i++;
		//printf("OK");
	}

	return u;

}

int main(){
	scanf_s("%d", &n);
	int e;

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

			//printf("%d\n", M[i][j]);
		}
	}
	

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

}

Compiler output:
main.c:8:5: error: variably modified 'M' at file scope
    8 | int M[MAX][MAX];
      |     ^
main.c:8:5: error: variably modified 'M' at file scope
main.c:10:5: error: variably modified 'color' at file scope
   10 | int color[MAX];
      |     ^~~~~
main.c: In function 'main':
main.c:65:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   65 |         scanf_s("%d", &n);
      |         ^~~~~~~
      |         scanf
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 M[MAX][MAX];
int n;
int color[MAX];

int prim(){


	int min;
	int u;
	int array[MAX];
	int i,p;

	u = 0;

	for (int j = 0; j < n; j++){
		color[j] = 0;
		array[j] = 0;
	}

	i = 0;
	color[i] = 2;
	//printf("OK");

	while(1){
		min = INFTY;
		p = 0;
		//printf("COLOR %d\n", color[0]);
		for (int b = 0; b <= i; b++){
			//printf("OKOK1\n");
			for (int j = 0; j < n;j++){
				//printf("OKOK\n");
				if (color[j] == 0 && M[array[b]][j] != INFTY){
					if (min > M[array[b]][j]){
						min = M[array[b]][j];
						p = j;
						//printf("OK");
					}
				}
			}
		}

		if (p == 0){
			break;
		}

		u += min;
		color[p] = 2;
		array[i] = p;
		i++;
		//printf("OK");
	}

	return u;

}

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

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

			//printf("%d\n", M[i][j]);
		}
	}
	

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

}

Compiler output:
main.c:8:5: error: variably modified 'M' at file scope
    8 | int M[MAX][MAX];
      |     ^
main.c:8:5: error: variably modified 'M' at file scope
main.c:10:5: error: variably modified 'color' at file scope
   10 | int color[MAX];
      |     ^~~~~
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;

static int M[MAX][MAX];
int n;
int color[MAX];

int prim(){


	int min;
	int u;
	int array[MAX];
	int i,p;

	u = 0;

	for (int j = 0; j < n; j++){
		color[j] = 0;
		array[j] = 0;
	}

	i = 0;
	color[i] = 2;
	//printf("OK");

	while(1){
		min = INFTY;
		p = 0;
		//printf("COLOR %d\n", color[0]);
		for (int b = 0; b <= i; b++){
			//printf("OKOK1\n");
			for (int j = 0; j < n;j++){
				//printf("OKOK\n");
				if (color[j] == 0 && M[array[b]][j] != INFTY){
					if (min > M[array[b]][j]){
						min = M[array[b]][j];
						p = j;
						//printf("OK");
					}
				}
			}
		}

		if (p == 0){
			break;
		}

		u += min;
		color[p] = 2;
		array[i] = p;
		i++;
		//printf("OK");
	}

	return u;

}

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

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

			//printf("%d\n", M[i][j]);
		}
	}
	

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

}

Compiler output:
main.c:8:12: error: variably modified 'M' at file scope
    8 | static int M[MAX][MAX];
      |            ^
main.c:8:12: error: variably modified 'M' at file scope
main.c:10:5: error: variably modified 'color' at file scope
   10 | int color[MAX];
      |     ^~~~~
Language: C

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

int n,M[MAX][MAX];

int prim(){
    int i,u,minv,sum;
    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(i=0;i<n;i++){
            if(color[i]!=BLACK && M[u][i]!=INFTY){
                if(d[i]>M[u][i]){
                    d[i]=M[u][i];
                    p[i]=u;
                    color[i]=GRAY;
                }
            }
        }
    }
        sum=0;
        for(i=0;i<n;i++)
            if(p[i]!=-1)
                sum+=M[i][p[i]];
    return sum;
}

int main(void){
    int i,o,e;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        for(o=0;o<n;o++){
            scanf("%d",&e);
            M[i][o]=(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
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", &n);

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

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

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
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", &n);

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

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

Compiler output:
main.c:8:9: error: variably modified 'M' at file scope
    8 | int n , M[MAX][MAX];
      |         ^
main.c:8:9: error: variably modified 'M' at file scope