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

#include<stdio.h>
 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
Language: C

#include<stdio.h>
#define 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:2:26: error: redefinition of 'MAX'
    2 | #define static const int MAX = 100;
      |                          ^~~
main.c:4:1: note: in expansion of macro 'static'
    4 | static const int WHITE = 0;
      | ^~~~~~
main.c:2:26: note: previous definition of 'MAX' with type 'int'
    2 | #define static const int MAX = 100;
      |                          ^~~
main.c:3:1: note: in expansion of macro 'static'
    3 | static const int INFTY = (1<<21);
      | ^~~~~~
main.c:2:26: error: redefinition of 'MAX'
    2 | #define static const int MAX = 100;
      |                          ^~~
main.c:5:1: note: in expansion of macro 'static'
    5 | static const int GRAY = 1;
      | ^~~~~~
main.c:2:26: note: previous definition of 'MAX' with type 'int'
    2 | #define static const int MAX = 100;
      |                          ^~~
main.c:3:1: note: in expansion of macro 'static'
    3 | static const int INFTY = (1<<21);
      | ^~~~~~
main.c:2:26: error: redefinition of 'MAX'
    2 | #define static const int MAX = 100;
      |                          ^~~
main.c:6:1: note: in expansion of macro 'static'
    6 | static const int BLACK = 2;
      | ^~~~~~
main.c:2:26: note: previous definition of 'MAX' with type 'int'
    2 | #define static const int MAX = 100;
      |                          ^~~
main.c:3:1: note: in expansion of macro 'static'
    3 | static const int INFTY = (1<<21);
      | ^~~~~~
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
Language: C

#include<stdio.h>
#define 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:2:13: error: expected expression before '=' token
    2 | #define MAX = 100;
      |             ^
main.c:8:11: note: in expansion of macro 'MAX'
    8 | int n , M[MAX][MAX];
      |           ^~~
main.c:8:19: error: expected identifier or '(' before ']' token
    8 | int n , M[MAX][MAX];
      |                   ^
main.c: In function 'prim':
main.c:2:13: error: expected expression before '=' token
    2 | #define MAX = 100;
      |             ^
main.c:12:9: note: in expansion of macro 'MAX'
   12 |   int d[MAX],p[MAX],color[MAX];
      |         ^~~
main.c:12:19: error: expected statement before ']' token
   12 |   int d[MAX],p[MAX],color[MAX];
      |                   ^
main.c:12:20: error: expected expression before ',' token
   12 |   int d[MAX],p[MAX],color[MAX];
      |                    ^
main.c:12:21: error: 'color' undeclared (first use in this function)
   12 |   int d[MAX],p[MAX],color[MAX];
      |                     ^~~~~
main.c:12:21: note: each undeclared identifier is reported only once for each function it appears in
main.c:15:5: error: 'd' undeclared (first use in this function)
   15 |     d[i] = INFTY;
      |     ^
main.c:16:5: error: 'p' undeclared (first use in this function)
   16 |     p[i] = -1;
      |     ^
main.c:34:31: error: 'M' undeclared (first use in this function)
   34 |       if(color[v] != BLACK && M[u][v] != INFTY) {
      |                               ^
main.c: In function 'main':
main.c:59:7: error: 'M' undeclared (first use in this function)
   59 |       M[i][j] = (e == -1) ? INFTY:e;
      |       ^
Language: C

include<stdio.h>
#define N 101
int main(){
  int G[N][N],a[N],f[N];
  int 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){
    num=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",sum);
  return 0;
}

Compiler output:
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include<stdio.h>
      |        ^
Language: C

#include<stdio.h>
#define N 101
#define W 2001
 
int main(){
  int A[N][N],B[N],key[N],p[N];
  int i,j,n,count=0,o,u=0;
 
  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++){
    A[i] = 0;
    p[i] = -1;    
    if(i==0)key[i] = 0;
    else key[i] = W  
	   }  
  
  while(o != W){
    o = W;
    for(i=0 ; i<n ; i++){
      if(B[i]!=2 && key[i]<o){	
	o = key[i];
	u = i;
      }
    }
    
    B[u]=2;
    for(i=0 ; i<n ; i++){
      if(A[u][i] != -1 && B[i] != 2 && A[u][i]<key[i]){
	p[i] = u;
	key[i] = A[u][i];
	B[i] = 1;
      }
    }
  }
  
  for(i=0 ; i<n ; i++)
    if(p[i] != -1) count += A[i][p[i]];    
   
  printf("%d\n",count);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:10: error: assignment to expression with array type
   18 |     A[i] = 0;
      |          ^
main.c:22:12: error: expected ';' before '}' token
   22 |            }
      |            ^
Language: C

#include <stdio.h>
#define INFTY 1000000
#define M -1
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define N 100
int prim(void);
int n,A[N][N];

int main()
{
  int i,j,k;

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

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

int prim()
{
  int d[N],p[N],color[N];
  int i,v,u,mincost,sum=0;

  for(i=0;i<n;i++)
    {
      d[i]=INFTY;
      p[i]=M;
      color[i]=WHITE;
    }
  d[0]=0;
while(1)
    {
      mincost=INFTY;
      u=M;
      for(i=0;i<n;i++)
        {
          if(color[i]!=BLACK&&d[i]<mincost)
            {
              u=i;
              mincost=d[i];
            }
        }
      if(u==M) 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]!=M) sum+=A[i][p[i]];
    }
  return sum;

Compiler output:
main.c: In function 'prim':
main.c:72:3: error: expected declaration or statement at end of input
   72 |   return sum;
      |   ^~~~~~
Language: C

#include <stdio.h>
#define INFTY 1000000
#define M -1
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define N 100
int prim(void);
int n,A[N][N];

int main()
{
  int i,j,k;

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

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

int prim()
{
  int d[N],p[N],color[N];
  int i,v,u,mincost,sum=0;

  for(i=0;i<n;i++)
    {
      d[i]=INFTY;
      p[i]=M;
      color[i]=WHITE;
    }
  d[0]=0;
while(1)
    {
      mincost=INFTY;
      u=M;
      for(i=0;i<n;i++)
        {
          if(mincost>d[I]&&color[i]!=BLACK)
            {
              u=i;
              mincost=d[i];
            }
        }
      if(u==M) 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]!=M) sum+=A[i][p[i]];
    }
  return sum;

Compiler output:
main.c: In function 'prim':
main.c:47:24: error: 'I' undeclared (first use in this function)
   47 |           if(mincost>d[I]&&color[i]!=BLACK)
      |                        ^
main.c:47:24: note: each undeclared identifier is reported only once for each function it appears in
main.c:72:3: error: expected declaration or statement at end of input
   72 |   return sum;
      |   ^~~~~~
Language: C

#include <stdio.h>
#define INFTY 1000000
#define M -1
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define N 100
int prim(void);
int n,A[N][N];

int main()
{
  int i,j,k;

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

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

int prim()
{
  int d[N],p[N],color[N];
  int i,v,u,mincost,sum=0;

  for(i=0;i<n;i++)
    {
      d[i]=INFTY;
      p[i]=M;
      color[i]=WHITE;
    }
  d[0]=0;
while(1)
    {
      mincost=INFTY;
      u=M;
      for(i=0;i<n;i++)
        {
          if(mincost>d[i]&&color[i]!=BLACK)
            {
              u=i;
              mincost=d[i];
            }
        }
      if(u==M) 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]!=M) sum+=A[i][p[i]];
    }
  return sum;

Compiler output:
main.c: In function 'prim':
main.c:72:3: error: expected declaration or statement at end of input
   72 |   return sum;
      |   ^~~~~~
Language: C

#include<stdio.h>

#define N 2000
#define A 101
#define NIL -1
void Prim();

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

int M[A][A], p[A], n, s;

main(){
  int i, j, e;
  
  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;
    }
  
  s=0;
  Prim();
  printf("%d\n", s);
  return 0;
}

void Prim(){
  int i, v, u, k[A];

  for(u=0;u<n;u++){
    y[u]=INFTY;
    p[u]=NIL;
  }

  y[0]=0;

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

    for(i=0;i<n;i++)
      if(key[i] < minv && p[i]==NIL ){
	u=i;
	minv=y[i];
      }
    
    if(u==NIL) break;
    p[u]=1;
    s+=y[u];
    
    for(v=0;v<n;v++)
      if(M[u][v]<y[v]){
	y[v]=M[u][v];
      }    
  }
}

Compiler output:
main.c:13:1: error: return type defaults to 'int' [-Wimplicit-int]
   13 | main(){
      | ^~~~
main.c: In function 'Prim':
main.c:34:5: error: 'y' undeclared (first use in this function)
   34 |     y[u]=INFTY;
      |     ^
main.c:34:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:45:10: error: 'key' undeclared (first use in this function)
   45 |       if(key[i] < minv && p[i]==NIL ){
      |          ^~~
Language: C

#include<stdio.h>

#define N 2000
#define A 101
#define NIL -1

void Prim();

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

int M[A][A], p[A], n, s;

main(){
  int i, j, e;
  
  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;
    }
  
  s=0;
  Prim();
  printf("%d\n", s);
  return 0;
}

void Prim(){
  int i, v, u, k[A];

  for(u=0;u<n;u++){
    k[u]=INFTY;
    p[u]=NIL;
  }

  k[0]=0;

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

    for(i=0;i<n;i++)
      if(k[i] < minv && p[i]==NIL ){
	u=i;
	minv=k[i];
      }
    
    if(u==NIL) break;
    p[u]=1;
    s+=k[u];
    
    for(v=0;v<n;v++)
      if(M[u][v]<y[v]){
	k[v]=M[u][v];
      }    
  }
}

Compiler output:
main.c:14:1: error: return type defaults to 'int' [-Wimplicit-int]
   14 | main(){
      | ^~~~
main.c: In function 'Prim':
main.c:56:18: error: 'y' undeclared (first use in this function)
   56 |       if(M[u][v]<y[v]){
      |                  ^
main.c:56:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>

#define WHITE 0
#define BLACK 1
#define INF 100000

void prim(void);

int n, d[100], color[100], pi[100], w[100][100];

int main(int argc, char const *argv[]) {
  int i,j;

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

  prim();

  return 0;
}

void prim(){
  int i,j,v,u,mincost,r=0,sum=0;

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

  d[r] = 0;

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

    if(mincost == INF) break;

    color[u] = BLACK;

    for(v=0;v<n;v++){
      if(color[v] != BLACK && w[u][v] < d[v] && w[u][v] > -1){
        pi[v] = u;
        d[v] = w[u][v];
      }
    }
    sum += d[k];
  }
  for(i=0;i<n;i++) if(pi[i]!=-1) sum+=w[i][pi[i]];
  printf("%d\n",sum);
}

Compiler output:
main.c: In function 'prim':
main.c:56:14: error: 'k' undeclared (first use in this function)
   56 |     sum += d[k];
      |              ^
main.c:56:14: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define INF 1000000000
#define BLACK 1
#define WHITE 0
#define NIL -1

int G[101][101],d[101],pi[101],n,color[101],sum=0;

void prim(int);
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  prim(1);

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

  return 0;
  
}

void prim(int r){
  int mincost,u,i,v;

  for(u=1;u<=n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]=WHITE;
  }
  d[r]=0;
  while(1){
    mincost=INF;
    for(i=1;i<=n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INF) break;
    color[u]=BLACK;
    for(v=1;v<=n;v++){
      if(color[v]!=BLACK && G[u][v]<d[v] && G[u][v]!=-1){
	pi[v]=u;
	d[v]=G[u][v];
      }
    }

  }

  for(i=1;i<=n;i++){
    if(pi[i]!=NIL) sum=sum+G[i][pi[i]];
      
  

}

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

#include <stdio.h>
#define M 5
#define BLACK 1
#define inf 10000
int main()
{
  int i,j,n,minicost=0,u,v;
  int G[M][M];
  int color[2];
  int d[1000];
  int p[1000];

  scanf("%d",&n);

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

  while(0)
    {
      minicost = inf;

      for(i=0;i<n-1;i++)
	{
	  if(color[i] != BLACK && d[i] < minicost)
	    {
	      minicost = d[i];
	      u = i;
	    }

	  if(minicost == inf) break;

	  color[u] = BLACK;
	}

      for(v=0;v<n-1;v++)
	{
	  if(color[v] != BLACK && d[v] != -1)
	    {
	      if (G[u][v] < d[v])
		    {
		      d[v] = G[u][v];
		      p[v] = u;
		    }
	      color[u] = BLACK;
	    }
	}
    }
  printf("%d\n",);
    
  return 0;
}  

Compiler output:
main.c: In function 'main':
main.c:53:17: error: expected expression before ')' token
   53 |   printf("%d\n",);
      |                 ^
Language: C

#include <stdio.h>
int prim(void);
#define N 101
#define INF 200000
#define W 0
#define B 2
#define G 1

int n, A[N][N], e;
int i, j, u, minv;
int d[N], p[N], color[N];

int main(){

        scanf("%d", &n);
        for(i = 0; i<n; i++) {
                for(j = 0; j<n; j++) {
                        scanf("%d", &e);
                        if(e == -1) A[i][j] = INF;
????????????????????????            else A[i][j] = e;
                }
        }
        prim();
//printf("%d\n", sum);
        return 0;
}

int prim(){
        for(i = 0; i<n; i++) {
                d[i] = INF;
                p[i] = -1;
                color[i] = W;
        }
        d[0] = 0;
        p[0] = -1;
        while(1) {
                minv = INF;
                u = -1;
                for(i = 0; i<n; i++) {
                        if(minv>d[i]&&color[i] != B) {
                                u=i;
                                minv= d[i];
                        }
                }
                if(u == -1) break;
                color[u] = B;
                for(j = 0; j<n; j++) {
                        if(color[j] != j && A[u][j] != INF) {
                                if(d[j]>A[u][j]) {
                                        d[j]=A[u][j];
                                        p[j]=u;
                                        color[j]=G;
                                }
                        }
                }
        }
        int sum = 0;
        for(i = 0; i<n; i++) {
                if(p[i] != -1) sum += A[i][p[i]];
        }
        printf("%d\n", sum);
        return 0;
//return sum;
}

Compiler output:
main.c: In function 'main':
main.c:20:1: error: expected expression before '?' token
   20 | ????????????????????????            else A[i][j] = e;
      | ^
Language: C

#include???<stdio.h>

#define MAX 101
#define WHITE 0
#define BLACK 1
#define INF 2001

int n,a[N][N],d[N];

void MST()
{
  int i,j;
  int u,v;
  int pi[N],c[MAX];
  int mincost;
  for(u=1;u<=n;u++)
  {
    d[u]=INF;
    pi[u]=NULL;
    c[u]=W;
  }

  d[1]=0;

  for(i = 0;i < n;i++)
  {
    mincost = INF;
    for(j=1;j<=n;j++)
    {
      if(c[j]!=B&&d[j]<=mincost)
      {
        u = j;
        mincost = d[j];
      }
    }

    for(v=1;v<=n;v++)
    {
      if(a[u][v]!=-1&&c[v]!=B &&a[u][v]<d[v])
      {
        pi[v] = u;
        d[v] = a[u][v];
      }
    }
    c[u]=B;
  }
}

int main()
{
  int i,j;
  int sum = 0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=n;j++)
    {
      scanf("%d",&a[i][j]);
    }
  }

  MST();

  for(i=1;i<=n;i++) sum += d[i];
    printf("%d\n",sum); 
  return 0;
}

Compiler output:
main.c:1:10: warning: trigraph ??< ignored, use -trigraphs to enable [-Wtrigraphs]
    1 | #include???<stdio.h>
main.c:1:9: error: #include expects "FILENAME" or <FILENAME>
    1 | #include???<stdio.h>
      |         ^
main.c:8:9: error: 'N' undeclared here (not in a function)
    8 | int n,a[N][N],d[N];
      |         ^
main.c: In function 'MST':
main.c:19:11: error: 'NULL' undeclared (first use in this function)
   19 |     pi[u]=NULL;
      |           ^~~~
main.c:1:1: note: 'NULL' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
  +++ |+#include <stddef.h>
    1 | #include???<stdio.h>
main.c:19:11: note: each undeclared identifier is reported only once for each function it appears in
   19 |     pi[u]=NULL;
      |           ^~~~
main.c:20:10: error: 'W' undeclared (first use in this function)
   20 |     c[u]=W;
      |          ^
main.c:30:16: error: 'B' undeclared (first use in this function)
   30 |       if(c[j]!=B&&d[j]<=mincost)
      |                ^
main.c: In function 'main':
main.c:53:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   53 |   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:53:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   53 |   scanf("%d",&n);
      |   ^~~~~
main.c:53:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:65:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   65 |     printf("%d\n",sum);
      |     ^~~~~~
main.c:65:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:65:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:65:5: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C

#include???<stdio.h>

#define MAX 101
#define WHITE 0
#define BLACK 1
#define INF 2001

void MST(void);

int n,a[N][N],d[N];

void MST()
{
  int i,j;
  int u,v;
  int pi[N],c[MAX];
  int mincost;
  for(u=1;u<=n;u++)
  {
    d[u]=INF;
    pi[u]=NULL;
    c[u]=W;
  }

  d[1]=0;

  for(i = 0;i < n;i++)
  {
    mincost = INF;
    for(j=1;j<=n;j++)
    {
      if(c[j]!=B&&d[j]<=mincost)
      {
        u = j;
        mincost = d[j];
      }
    }

    for(v=1;v<=n;v++)
    {
      if(a[u][v]!=-1&&c[v]!=B &&a[u][v]<d[v])
      {
        pi[v] = u;
        d[v] = a[u][v];
      }
    }
    c[u]=B;
  }
}

int main()
{
  int i,j;
  int sum = 0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=n;j++)
    {
      scanf("%d",&a[i][j]);
    }
  }

  MST();

  for(i=1;i<=n;i++) sum += d[i];
    printf("%d\n",sum); 
  return 0;
}

Compiler output:
main.c:1:10: warning: trigraph ??< ignored, use -trigraphs to enable [-Wtrigraphs]
    1 | #include???<stdio.h>
main.c:1:9: error: #include expects "FILENAME" or <FILENAME>
    1 | #include???<stdio.h>
      |         ^
main.c:10:9: error: 'N' undeclared here (not in a function)
   10 | int n,a[N][N],d[N];
      |         ^
main.c: In function 'MST':
main.c:21:11: error: 'NULL' undeclared (first use in this function)
   21 |     pi[u]=NULL;
      |           ^~~~
main.c:1:1: note: 'NULL' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
  +++ |+#include <stddef.h>
    1 | #include???<stdio.h>
main.c:21:11: note: each undeclared identifier is reported only once for each function it appears in
   21 |     pi[u]=NULL;
      |           ^~~~
main.c:22:10: error: 'W' undeclared (first use in this function)
   22 |     c[u]=W;
      |          ^
main.c:32:16: error: 'B' undeclared (first use in this function)
   32 |       if(c[j]!=B&&d[j]<=mincost)
      |                ^
main.c: In function 'main':
main.c:55:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   55 |   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:55:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   55 |   scanf("%d",&n);
      |   ^~~~~
main.c:55:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:67:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   67 |     printf("%d\n",sum);
      |     ^~~~~~
main.c:67:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:67:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:67:5: note: include '<stdio.h>' or provide a declaration of 'printf'
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 u, minv;
  int d[MAX], p[MAX], color[MAX];

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

  d[0] = 0;

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

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

  for(int i=0; i<n; i++){
    for(int 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:9:8: error: variably modified 'M' at file scope
    9 | int n, M[MAX][MAX];
      |        ^
main.c:9:8: 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 u, minv;
  int d[MAX], p[MAX], color[MAX];

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

  d[0] = 0;

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

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

  for(int i=0; i<n; i++){
    for(int 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:9:8: error: variably modified 'M' at file scope
    9 | int n, M[MAX][MAX];
      |        ^
main.c:9:8: 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 prim();

int n, M[MAX][MAX];

int prim(){
  int u, minv, i=0, v=0;
  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(){
  scanf("%d",&n);

  for(int i=0; i<n; i++){
    for(int 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:11:8: error: variably modified 'M' at file scope
   11 | int n, M[MAX][MAX];
      |        ^
main.c:11:8: 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 prim();

int n, M[MAX][MAX];

int prim(){
  int u, minv, i=0, v=0;
  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=0, j=0;

  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:11:8: error: variably modified 'M' at file scope
   11 | int n, M[MAX][MAX];
      |        ^
main.c:11:8: error: variably modified 'M' at file scope
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 sum,i,u,min;
  int d[MAX],p[MAX],c[MAX];

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

  d[0]=0;

  while(1){
    min=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(min>d[i] && c[i]!=BLACK){
	u=i;
	min=d[i];
      }
    }

    if(u==-1) break;
    c[u]=BLACK;
    
    for(i=0;i<n;i++){
      if(c[i]!=BLACK && M[u][i]!=INFTY){
	if(d[i]>M[u][i]){
	      d[v]=M[u][i];
	      p[i]=u;
	      c[i]=GRAY;
	    }
      }
    }
  }

  sum=0;

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

  return sum;
}

int main(){

  int i,j,e;
  
  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;
    }
  }

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

  return 0;
}

Compiler output:
main.c: In function 'prim':
main.c:40:17: error: 'v' undeclared (first use in this function)
   40 |               d[v]=M[u][i];
      |                 ^
main.c:40:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define N 100
#define INFTY 20000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int M[N][N];
int n;
int prim(){
  int color[N],d[N],p[N];
  int v,i,mincost,sum,u;

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

int main(){
  int i,j,e;
  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;
    }
  }
  printf("%d\n",prim());
}
  

Compiler output:
main.c: In function 'prim':
main.c:20:9: error: expected ';' before 'mincost'
   20 |     u=-1
      |         ^
      |         ;
   21 |     mincost=INFTY;
      |     ~~~~~~~
Language: C

#include<stdio.h>

void prim();  
int main(){
  int g[100][100],a[100],f[100];
  int 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]);
    }
  }
prim();
    return 0;
}

void prim(){
  a[0]=0;
  f[0]=1;
    
  for(i=1;i<n;i++) f[i]=0;
    
  while(1){
    num=2000;
      
    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",sum);
}

Compiler output:
main.c: In function 'prim':
main.c:20:3: error: 'a' undeclared (first use in this function)
   20 |   a[0]=0;
      |   ^
main.c:20:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:21:3: error: 'f' undeclared (first use in this function)
   21 |   f[0]=1;
      |   ^
main.c:23:7: error: 'i' undeclared (first use in this function)
   23 |   for(i=1;i<n;i++) f[i]=0;
      |       ^
main.c:23:13: error: 'n' undeclared (first use in this function)
   23 |   for(i=1;i<n;i++) f[i]=0;
      |             ^
main.c:26:5: error: 'num' undeclared (first use in this function)
   26 |     num=2000;
      |     ^~~
main.c:28:15: error: 'k' undeclared (first use in this function)
   28 |     for(i=0;i<k;i++){
      |               ^
main.c:29:11: error: 'j' undeclared (first use in this function)
   29 |       for(j=0;j<n;j++){
      |           ^
main.c:30:8: error: 'g' undeclared (first use in this function)
   30 |     if(g[a[i]][j]<num && g[a[i]][j]!=-1 && f[j]!=1){
      |        ^
main.c:32:7: error: 'm' undeclared (first use in this function)
   32 |       m=j;
      |       ^
main.c:40:7: error: 'sum' undeclared (first use in this function)
   40 |       sum+=num;
      |       ^~~
Language: C

#include <stdio.h>

int i,j,n,e,M[100][100];

int prim(int n){
  int u,sum,mincost,d[100].p[100],color[100];
  
  for(i=0;i<n;i++){
    d[i]=(1<<21);
    p[i]=-1;
    color[i]=0;
  }
  
  d[0]=0;
  while(1){
    mincost=(1<<21);
    u=-1;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=2){
        u=i;
        mincost=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=2;
    for(j=0;j<n;j++){
      if(color[j]!=2&&M[u][j]!=(1<<21)){
        if(d[j]>M[u][j]){
          d[j]=M[u][j];
          p[j][j]=u;
          color[j]=1;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  
  return sum;
}

int main(void)
{
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)? (1<<21);
    }
  }
  pritf("%d\n",prin(n));
  return 0;
}

Compiler output:
main.c: In function 'prim':
main.c:6:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    6 |   int u,sum,mincost,d[100].p[100],color[100];
      |                           ^
main.c:9:5: error: 'd' undeclared (first use in this function)
    9 |     d[i]=(1<<21);
      |     ^
main.c:9:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:10:5: error: 'p' undeclared (first use in this function)
   10 |     p[i]=-1;
      |     ^
main.c:11:5: error: 'color' undeclared (first use in this function)
   11 |     color[i]=0;
      |     ^~~~~
main.c: In function 'main':
main.c:54:31: error: expected ':' before ';' token
   54 |       M[i][j]=(e==-1)? (1<<21);
      |                               ^
      |                               :
main.c:57:3: error: implicit declaration of function 'pritf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |   ^~~~~
      |   printf
main.c:57:16: error: implicit declaration of function 'prin'; did you mean 'prim'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |                ^~~~
      |                prim
Language: C

#include <stdio.h>

int i,j,n,e,M[100][100];

int prim(int n){
  int u,sum,mincost,d[100],p[100],color[100];
 
  for(i=0;i<n;i++){
    d[i]=(1<<21);
    p[i]=-1;
    color[i]=0;
  }
  
  d[0]=0;
  while(1){
    mincost=(1<<21);
    u=-1;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=2){
        u=i;
        mincost=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=2;
    for(j=0;j<n;j++){
      if(color[j]!=2&&M[u][j]!=(1<<21)){
        if(d[j]>M[u][j]){
          d[j]=M[u][j];
          p[j][j]=u;
          color[j]=1;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  
  return sum;
}

int main(void)
{
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)? (1<<21);
    }
  }
  pritf("%d\n",prin(n));
  return 0;
}

Compiler output:
main.c: In function 'prim':
main.c:32:15: error: subscripted value is neither array nor pointer nor vector
   32 |           p[j][j]=u;
      |               ^
main.c: In function 'main':
main.c:54:31: error: expected ':' before ';' token
   54 |       M[i][j]=(e==-1)? (1<<21);
      |                               ^
      |                               :
main.c:57:3: error: implicit declaration of function 'pritf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |   ^~~~~
      |   printf
main.c:57:16: error: implicit declaration of function 'prin'; did you mean 'prim'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |                ^~~~
      |                prim
Language: C

#include <stdio.h>

int i,j,n,e,M[100][100];

int prim(int n){
  int u,sum,mincost,d[100],p[100],color[100];
 
  for(i=0;i<n;i++){
    d[i]=(1<<21);
    p[i]=-1;
    color[i]=0;
  }
  
  d[0]=0;
  while(1){
    mincost=(1<<21);
    u=-1;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=2){
        u=i;
        mincost=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=2;
    for(j=0;j<n;j++){
      if(color[j]!=2&&M[u][j]!=(1<<21)){
        if(d[j]>M[u][j]){
          d[j]=M[u][j];
          p[j]=u;
          color[j]=1;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  
  return sum;
}

int main(void)
{
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)? (1<<21);
    }
  }
  pritf("%d\n",prin(n));
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:54:31: error: expected ':' before ';' token
   54 |       M[i][j]=(e==-1)? (1<<21);
      |                               ^
      |                               :
main.c:57:3: error: implicit declaration of function 'pritf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |   ^~~~~
      |   printf
main.c:57:16: error: implicit declaration of function 'prin'; did you mean 'prim'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |                ^~~~
      |                prim
Language: C

#include <stdio.h>

int i,j,n,e,M[100][100];

int prim(int n){
  int u,sum,mincost,d[100],p[100],color[100];
 
  for(i=0;i<n;i++){
    d[i]=(1<<21);
    p[i]=-1;
    color[i]=0;
  }
  
  d[0]=0;
  while(1){
    mincost=(1<<21);
    u=-1;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=2){
        u=i;
        mincost=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=2;
    for(j=0;j<n;j++){
      if(color[j]!=2&&M[u][j]!=(1<<21)){
        if(d[j]>M[u][j]){
          d[j]=M[u][j];
          p[j]=u;
          color[j]=1;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  
  return sum;
}

int main(void)
{
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1) ? (1<<21);
    }
  }
  pritf("%d\n",prin(n));
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:54:32: error: expected ':' before ';' token
   54 |       M[i][j]=(e==-1) ? (1<<21);
      |                                ^
      |                                :
main.c:57:3: error: implicit declaration of function 'pritf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |   ^~~~~
      |   printf
main.c:57:16: error: implicit declaration of function 'prin'; did you mean 'prim'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |                ^~~~
      |                prim
Language: C

#include <stdio.h>

int i,j,n,e,M[100][100];

int prim(int n){
  int u,sum,mincost,d[100],p[100],color[100];
 
  for(i=0;i<n;i++){
    d[i]=(1<<21);
    p[i]=-1;
    color[i]=0;
  }
  
  d[0]=0;
  while(1){
    mincost=(1<<21);
    u=-1;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=2){
        u=i;
        mincost=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=2;
    for(j=0;j<n;j++){
      if(color[j]!=2&&M[u][j]!=(1<<21)){
        if(d[j]>M[u][j]){
          d[j]=M[u][j];
          p[j]=u;
          color[j]=1;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  
  return sum;
}

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

Compiler output:
main.c: In function 'main':
main.c:57:3: error: implicit declaration of function 'pritf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |   ^~~~~
      |   printf
main.c:57:16: error: implicit declaration of function 'prin'; did you mean 'prim'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(n));
      |                ^~~~
      |                prim
Language: C

#include <stdio.h>

int i,j,n,e,M[100][100];

int prim(int n){
  int u,sum,mincost,d[100],p[100],color[100];
 
  for(i=0;i<n;i++){
    d[i]=(1<<21);
    p[i]=-1;
    color[i]=0;
  }
  
  d[0]=0;
  while(1){
    mincost=(1<<21);
    u=-1;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=2){
        u=i;
        mincost=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=2;
    for(j=0;j<n;j++){
      if(color[j]!=2&&M[u][j]!=(1<<21)){
        if(d[j]>M[u][j]){
          d[j]=M[u][j];
          p[j]=u;
          color[j]=1;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  
  return sum;
}

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

Compiler output:
main.c: In function 'main':
main.c:57:3: error: implicit declaration of function 'pritf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(e));
      |   ^~~~~
      |   printf
main.c:57:16: error: implicit declaration of function 'prin'; did you mean 'prim'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prin(e));
      |                ^~~~
      |                prim
Language: C

#include <stdio.h>

int i,j,n,e,M[100][100];

int prim(int n){
  int u,sum,mincost,d[100],p[100],color[100];
 
  for(i=0;i<n;i++){
    d[i]=(1<<21);
    p[i]=-1;
    color[i]=0;
  }
  
  d[0]=0;
  while(1){
    mincost=(1<<21);
    u=-1;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=2){
        u=i;
        mincost=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=2;
    for(j=0;j<n;j++){
      if(color[j]!=2&&M[u][j]!=(1<<21)){
        if(d[j]>M[u][j]){
          d[j]=M[u][j];
          p[j]=u;
          color[j]=1;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  
  return sum;
}

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

Compiler output:
main.c: In function 'main':
main.c:57:3: error: implicit declaration of function 'pritf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   57 |   pritf("%d\n",prim(e));
      |   ^~~~~
      |   printf
Language: C

#include <stdio.h>

int main()
{
   int n, i, j, min, d, e;
   int a[1000], b[1000], A[1000][1000];

   scanf("%d", &n);

   for ( i = 0; i < n; i++ ) {
      a[ i ] = 0;
      b[ i ] = 1000;
      for ( j = 0; j < n; j++ ) {
         scanf("%d", &A[ i ][ j ]);
      }
   }
   b[0] = 0;
   for ( i = 1; i < n; i++ ) {
      min = 1000;
      for ( j = 0; j < n; j++ ) {
         if ( b[ j ] < min && a[ j ] == 0 ) {
            min = b[ j ];
            d = j;
         }
      }
      a[ d ] = 1;
      for ( e = 0; e < n; e++ ) {
         if ( A[ d ][ e ] < b[ e ] && A[ d ][ e ] != -1 && a[ d ] == 0 ) {
            b[ e ] = A[ d ][ e ];
         }
      }
   }
   for ( i = 0; i < n; i++ ) {
      wa = wa + b[ i ];
   }
   printf("%d\n", wa);
   return 0;
}

Compiler output:
main.c: In function 'main':
main.c:34:7: error: 'wa' undeclared (first use in this function); did you mean 'a'?
   34 |       wa = wa + b[ i ];
      |       ^~
      |       a
main.c:34:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C

 #include<stdio.h>
int main(void)
{
	int n,i,j,k,l;
	int minv
	int d[1000],s[1000],P[1000][1000];
	int c=0;
	s[0]=0;
	
	
scanf("%d",&n);
	
	for(i=0;i<n;i++){
	d[i]=0;
	s[i]=1000;
	for(j=0;j<n;j++){
		scanf("%d",&P[i][j]);
		
	}
	
	}
	for(i=1;i<n;i++){
minv=1000;
	for(j=0;j<n;j++){
		if(s[j]<minv&&d[j]==0)
		minv=s[j];
		k=j;
	}
	
	d[k]=1;
	for(l=0;l<n;l++){
		if(P[k][l]<s[l]&&P[k][l]!=-1&&d[l]==0)
		s[l]=P[k][l];
	}
	
	}
	for(i=0;i<n;i++){
		c=c+s[i];
	}
	printf("%d\n",c);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:17: error: expected ';' before 'int'
    5 |         int minv
      |                 ^
      |                 ;
    6 |         int d[1000],s[1000],P[1000][1000];
      |         ~~~      
main.c:23:1: error: 'minv' undeclared (first use in this function)
   23 | minv=1000;
      | ^~~~
main.c:23:1: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define INFTY 1000000000

int a[100][100];
int prim(int n) {
  int u,i,v,minconst,d[n],p[n],M[n][n],color[n];
  d[0]=0;
  p[0]=-1;
	
	while (true){
		minconst=INFTY;
		for(i=0;i<n;i++){
		  if(color[i] != BLACK && d[i] < minconst){
		    minconst = d[i];
		    u=i;
	     }
	   }
	   if(minconst == INFTY)
	      break;
	   color[u] = BLACK;
	   for(v=0;v<n;v++){
		  if(color[v] != BLACK && )
		  if(M[u][v]<d[v]){
			d[v]=M[u][v];
			p[v]=u;
			color[v]=GRAY;
		  }
	  }
   }
}

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

Compiler output:
main.c: In function 'prim':
main.c:13:16: 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 WHITE 0
main.c:13:16: note: each undeclared identifier is reported only once for each function it appears in
   13 |         while (true){
      |                ^~~~
main.c:25:43: error: expected expression before ')' token
   25 |                   if(color[v] != BLACK && )
      |                                           ^