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

#include <stdio.h>
#define N 10000

int main(){
	
	int a, b;
	int ans = 0;
	int A[N][N], x[N], y[N], z[N];
	int i, j, n;
	
	scanf("%d", &n);
	
	for(i=0; i<n-1; i++){
		a = 2000;
		for(j=0; j<n; j++){
			if(x[j] == 0 && y[j] < a){
				a = y[j];
				b = j;
			}
		}
	x[b] = 1;
	}
		
	for(j=0; j<n; j++){
		if(A[b][j] != -1 && x[j] == 0 && A[b][j] < y[j]){
			y[j] = A[b][j];
		}
	}
	
	for(i=0; i<n; i++){
		x[i] = 0;
		y[i] = 2000;
	}
	
	y[0] = 0;
	
	for(i=0; i<n; i++){
		for(j=0; j<n; j++){
			scanf("%d",&A[i][j]);
		}
	}
	
	for(i=0; i<n; i++){
		ans += y[i];
		}
	
	printf("%d\n",ans);
	
	return 0;
	

Compiler output:
main.c: In function 'main':
main.c:49:9: error: expected declaration or statement at end of input
   49 |         return 0;
      |         ^~~~~~
Language: C

#include <stdio.h>
#define MAX 200000000
#define white 0
#define black 1
 
int n, c[100][100];
 
int prim() {
  int i, d[100], p[100], cl[100], sum, minc, u;
  for (i = 0; i < n; ++i) {
    cl[i] = white;
    d[i] = MAX
  }
     
  d[0] = 0;
     
  while(1){
    minc = MAX;
    for (i = 0; i < n; ++i){
      if (cl[i] != black && d[i] < minc){
        minc = d[i];
        u = i;
      }
    }
         
  if (minc == MAX) break;
         
    cl[u] = black;
         
    for (i = 0; i < n; ++i) {
      if (cl[i] != black && c[u][i] != MAX) {
        if (c[u][i] < d[i]){
          d[i] = c[u][i];
          p[i] = u;
        }
      }
    }
  }
     
  sum = 0;
  for (i = 1; i < n ; ++i) {
    sum += c[i][p[i]];
  }
  return sum;
}
 
int main() {
  int i, j;
  scanf("%d", &n);
     
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      scanf("%d", &c[i][j]);
        if (c[i][j] == -1) c[i][j] = MAX;
    }
  }
     
    printf("%d\n", prim());
    return 0;
}

Compiler output:
main.c: In function 'prim':
main.c:13:3: error: expected ';' before '}' token
   13 |   }
      |   ^
Language: C

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

int n, M[MAX][MAX];

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

   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)
         dreak;
      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;
            }
         }
      }
   }

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

   return sum;
}

int main()
{
   int i, j;

   scanf("%d", &n);

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

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

   return 0;
}

Compiler output:
main.c:2:18: error: expected ']' before ';' token
    2 | #define   MAX 100;
      |                  ^
main.c:8:10: note: in expansion of macro 'MAX'
    8 | int n, M[MAX][MAX];
      |          ^~~
main.c:8:18: error: expected identifier or '(' before ']' token
    8 | int n, M[MAX][MAX];
      |                  ^
main.c: In function 'prim':
main.c:2:18: error: expected ']' before ';' token
    2 | #define   MAX 100;
      |                  ^
main.c:12:10: note: in expansion of macro 'MAX'
   12 |    int d[MAX], p[MAX], color[MAX];
      |          ^~~
main.c:12:21: error: expected statement before ']' token
   12 |    int d[MAX], p[MAX], color[MAX];
      |                     ^
main.c:12:22: error: expected expression before ',' token
   12 |    int d[MAX], p[MAX], color[MAX];
      |                      ^
main.c:12:24: error: 'color' undeclared (first use in this function)
   12 |    int d[MAX], p[MAX], color[MAX];
      |                        ^~~~~
main.c:12:24: note: each undeclared identifier is reported only once for each function it appears in
main.c:16:7: error: 'd' undeclared (first use in this function)
   16 |       d[i] = INFTY;
      |       ^
main.c:17:7: error: 'p' undeclared (first use in this function)
   17 |       p[i] = -1;
      |       ^
main.c:33:10: error: 'dreak' undeclared (first use in this function)
   33 |          dreak;
      |          ^~~~~
main.c:36:33: error: 'M' undeclared (first use in this function)
   36 |          if (color[v]!=BLACK && M[u][v]!=INFTY){
      |                                 ^
main.c: In function 'main':
main.c:62:23: error: 'M' undeclared (first use in this function)
   62 |          scanf("%d", &M[i][j]);
      |                       ^
Language: C

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

int n, M[MAX][MAX];

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

   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)
         dreak;
      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;
            }
         }
      }
   }

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

   return sum;
}

int main()
{
   int i, j;

   scanf("%d", &n);

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

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

   return 0;
}

Compiler output:
main.c: In function 'prim':
main.c:33:10: error: 'dreak' undeclared (first use in this function)
   33 |          dreak;
      |          ^~~~~
main.c:33:10: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>

#define N 100

int main(){
int A[N][N];
int B[N]={},C[N];
int i,j,c,n;
int m1,m2,min;
int sum=0;

for(i=0;i<100;i++)
C[i]=10000;

scanf("%d",&n);

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

B[0]=0;
m2=1;

while(1){
c=0;
for(i=0;i<n;i++)
    if(B[i]==1)c++;
    if(c==n)break;

m1=10000

for(i=0;i<n;i++){
if(C[i]>A[m2][i]&& B[i]!=1&&A[m2][i]!=-1)
B[i]=A[m2][i];
if(B[i]!=1&&m1>C[i]){
min=i;
m1=C[i];
}
sum=sum+m1;
C[min]=m1;
B[min]=1;
m2=min;
}
printf("%d\n",sum);
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:30:9: error: expected ';' before 'for'
   30 | m1=10000
      |         ^
      |         ;
   31 | 
   32 | for(i=0;i<n;i++){
      | ~~~      
main.c:46:1: error: expected declaration or statement at end of input
   46 | }
      | ^
Language: C

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

struct node {
  int id;
  int weight;
  struct node *next;
};
struct node **list;
int *key, *prev, *visit, *heap, *heap_index, heapsize;

void Insert(int, int, int);
void downheap(int);
void upheap(int);
void PQ_init(int);
void PrimPQ(int, int);
int main(void)
{
  int i, j, n, w, cost = 0;
  scanf("%d", &n);
  list = (struct node**)malloc(sizeof (struct node*) * n);
  key = (int*)malloc(sizeof (int) * n);
  prev = (int*)malloc(sizeof (int) * n);
  visit = (int*)malloc(sizeof (int) * n);
  for (i = 0; i < n; i++) list[i] = NULL;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf(" %d", &w);
      if (w != -1) {
        Insert(i, j, w);
      }
    }
  }
  PrimPQ(0, n);
  for (i = 0; i < n; i++) {
    cost += key[i];
    free(list[i]);
  }
  printf("%d\n", cost);
  free(list);
  free(key);
  free(prev);
  free(visit);
  free(heap);
  free(heap_index);
}
void Insert(int a, int b, int weight)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->weight = weight;
  p->id = b;
  p->next = list[a];
  list[a] = p;
  p = (struct node*)malloc(sizeof(struct node));
  p->weight = weight;
  p->id = a;
  p->next = list[b];
  list[b] = p;
}
void downheap(int k)
{
  int j, v = heap[k];
  while (k < heapsize / 2) {
    j = 2 * k + 1;
    if (j < heapsize - 1 && key[heap[j]] > key[heap[j+1]]) j++;
    if (key[v] <= key[heap[j]]) break;
    heap[k] = heap[j];
    heap_index[heap[j]] = k;
    k = j;
  }
  heap[k] = v;
  heap_index[v] = k;
}
void upheap(int j)
{
  int k, v = heap[j];
  while (j > 0) {
    k = (j + 1) / 2 - 1;
    if (key[v] >= key[heap[k]]) break;
    heap[j] = heap[k];
    heap_index[heap[k]] = j;
    j = k;
  }
  heap[j] = v;
  heap_index[v] = j;
}
void PQ_init(int size)
{
  int i;
  heapsize = size;
  heap = (int*)malloc(sizeof(int) * size);
  heap_index = (int*)malloc(sizeof(int) * size);
  for (i = 0; i < size; i++) {
    heap[i] = heap_index[i] = i;
  }
  for (i = size / 2 - 1; i >= 0; i--) {
    downheap(i);
  }
}
void PrimPQ(int p, int size)
{
  int i;
  for (i = 0; i < size; i++) {
    key[i] = INT_MAX;
    prev[i] = -1;
    visit[i] = 0;
  }
  key[p] = 0;
  PQ_init(size);
  while (heapsize > 0) {
    struct node *n;
    int u = heap[0];
    heap[0] = heap[heapsize - 1];
    heap_index[heap[heapsize - 1]] = 0;
    heapsize--;
    downheap(0);
    for (n = list[u]; n != NULL; n = n->next) {
      int v = n->id, w = n->weight;
      if (visit[v] == 0 && w < key[v]) {
        key[v] = w;
        prev[v] = w;
        upheap(heap_index[v]);
      }
    }



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

#include<stdio.h>
#include<stdlib.h>
#define N 100
#define LARGE 10000

typedef struct edge{
	int cost;
	int u;
	int v;
}edge;

/*qsort用*/
int cmp(const void *p,const void *q){
	return ((edge*)p)->cost - ((edge*)q)->cost;
}


int find(int u,int par[]){
	if(par[u]==u){
		return u;
	}else {
		return par[u]=find(par[u],par);
	}
}

void merge(int u,int v,int par[]){
	if(par[u] < par[v]){
		if(v!=par[v])
			merge(u,par[par[v]],par);
		par[v]=par[u];
	}
	else {
		if(u!=par[u])
			merge(v,par[par[u]],par);
		par[u]=par[v];
	}
	return;
}



int main(){
	int i,j;
	int num=0;/*edgeの個数*/
	int ans=0;
	int a[N][N];
	edge E[LARGE];/*edge*/
	int par[MAX];/*親の配列*/
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)par[i]=i;
	
	
	/*隣接行列の読み込み*/
	for(i=0;i<n;i++){
	
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
			if(a[i][j]!=-1 && j>=i+1){
				E[num].cost=a[i][j];
				E[num].u=i;
				E[num++].v=j;
			}
		}
		
	}
	
	/*edgeのソート*/
	qsort(E,num,sizeof(edge),cmp);
	
	for(i=0;i<num;i++){
		if(find(E[i].u,par) != find(E[i].v,par)){
			merge(E[i].u,E[i].v,par);
			ans+=E[i].cost;
		}
	}
	
	printf("%d\n",ans);
	
	return 0;
	
}


Compiler output:
main.c: In function 'main':
main.c:48:17: error: 'MAX' undeclared (first use in this function)
   48 |         int par[MAX];/*親の配列*/
      |                 ^~~
main.c:48:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:50:21: error: 'n' undeclared (first use in this function)
   50 |         scanf("%d",&n);
      |                     ^
Language: C

#include <stdio.h>

static const int MAX = 100;
static const int INFINITY = 1 << 21;
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;

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

static int prim()
{
    int d[MAX], p[MAX], color[MAX];

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

    d[0] = 0;

    while (1) {
        int minv = INFINITY;
        int 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] != INFINITY) {
                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) ? INFINITY : e;
        }
    }

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


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

include<stdio.h>

int main(void){
  int n,i,j,x=0,a=10000;
  int key[101][101];

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

  for(i=2;i<=n;i++){
    for(j=1;j<=n;j++){
      if(key[i][j]!=-1&&key[i][j]<a)a=key[i][j];
    }
    x=a+x;
    a=10000;
  }

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


  return 0;
}

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

include<stdio.h>

int main(void){
  int n,i,j,x=0,a=5000;
  int key[101][101];

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

  for(i=2;i<=n;i++){
    for(j=1;j<=n;j++){
      if(key[i][j]!=-1&&key[i][j]<a)a=key[i][j];
    }
    x=a+x;
    a=5000;
  }

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


  return 0;
}

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

#include<stdio.h>

int main(void){
  int n,i,j,x=0,a=1001;
  int key[101][101];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&key[i][j]);
    }
  }
  for(i=2;i<=n;i++){
a=1001
    for(j=1;j<=n;j++){
      if(key[i][j]!=-1&&key[i][j]<a)a=key[i][j];
    }
   x=x+a;
  }

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


  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:13:7: error: expected ';' before 'for'
   13 | a=1001
      |       ^
      |       ;
   14 |     for(j=1;j<=n;j++){
      |     ~~~
Language: C++

import heapq

n = int(input())
#A = [[int(i) for i in input().split()] for i in range(n)]
h = []
DP = {}
heapq.heappush(h,(0,0))
c = 0
while(len(DP)<n):
    tmp = heapq.heappop(h)
    if tmp[1] in DP:
        continue
    c += tmp[0]
    DP[tmp[1]] = 1
    for i,j in enumerate(A[tmp[1]]):
        if j > 0 and not i in DP:
            heapq.heappush(h,(j,i))
print(c)


Compiler output:
a.cc:4:2: error: invalid preprocessing directive #A
    4 | #A = [[int(i) for i in input().split()] for i in range(n)]
      |  ^
a.cc:1:1: error: 'import' does not name a type
    1 | import heapq
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'heapq' does not name a type
    7 | heapq.heappush(h,(0,0))
      | ^~~~~
Language: C++

#include<stdio.h>

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

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

    your code


   */

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

  






















  sum = 0;

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

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

  retur
}

Compiler output:
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:28:7: error: expected primary-expression before 'for'
   28 |       for(i=1;i<=n;i++){
      |       ^~~
a.cc:28:23: error: expected ';' before ')' token
   28 |       for(i=1;i<=n;i++){
      |                       ^
      |                       ;
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:26:11: note: to match this '{'
   26 |   while(1){
      |           ^
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:6:7: note: to match this '{'
    6 | main(){
      |       ^
Language: C++

#include<stdio.h>

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

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

    your code


   */

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

  






















  sum = 0;

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

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

  return 0;
}

Compiler output:
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:26:9: error: expected primary-expression before ')' token
   26 |   while(){
      |         ^
a.cc:28:7: error: expected primary-expression before 'for'
   28 |       for(i=1;i<=n;i++){
      |       ^~~
a.cc:28:23: error: expected ';' before ')' token
   28 |       for(i=1;i<=n;i++){
      |                       ^
      |                       ;
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:26:10: note: to match this '{'
   26 |   while(){
      |          ^
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:6:7: note: to match this '{'
    6 | main(){
      |       ^
Language: C++

#include<stdio.h>

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

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

    your code


   */

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

  






















  sum = 0;

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

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

  return 0;
}

Compiler output:
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:28:7: error: expected primary-expression before 'for'
   28 |       for(i=1;i<=n;i++){
      |       ^~~
a.cc:28:23: error: expected ';' before ')' token
   28 |       for(i=1;i<=n;i++){
      |                       ^
      |                       ;
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:26:11: note: to match this '{'
   26 |   while(1){
      |           ^
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:6:7: note: to match this '{'
    6 | main(){
      |       ^
Language: C++

#include<iostream>
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;

struct Node{
  int color, dist, parent;
};

int n, M[MAX][MAX];
Node node[MAX];

void Printnodes(){
  string col[3] = {"WHITE", "GRAY ", "BLACK"};
  for(int i = 0; i < n; i++){
    cout << "nodeID : " << i ;
    cout << " color : " << col[node[i].color];
    cout << " parent : " << node[i].parent;
    cout << " dist : " << node[i].dist << endl;
  }
  cout << endl;
}

int main(){
  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cin >> M[i][j];
    }
    node[i].color = WHITE;
    node[i].dist = INFTY;
    node[i].parent = -1;
  }

  int p = 0;
  node[p].color = BLACK;
  node[p].dist = 0;

  while(true){
    Printnodes();

    for(int i = 0; i < n; i++){
      if(M[p][i] > 0 && node[i].color != BLACK){
        node[i].dist = M[p][i];
        node[i].parent = p;
        node[i].color = GRAY;
      }
    }

    int min_d = INFTY;
    p = -1;
    for(int i = 0; i < n; i++){
      if(node[i].dist < min_d && node[i].color != BLACK){
        min_d = node[i].dist;
        p = i;
      }
    }

    if(p == -1)
      break;

    node[p].color = BLACK;
    cout << "node " << p << " turns to BLACK!" << endl;
    cout << "Total distance is " << totaldist << endl;
  }

  int sum = 0;

  for(int i = 0; i < n; i++){
    if(node[i].parent >= 0)
      sum += M[i][node[i].parent];
  }
  cout << sum << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:37: error: 'totaldist' was not declared in this scope
   68 |     cout << "Total distance is " << totaldist << endl;
      |                                     ^~~~~~~~~
Language: C++

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

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

int n;
vector<edge> G;

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

class UnionFind {
 public:
    int g_num;
    vector<int> rank, par;

    UnionFind() {}
    UnionFind(int size) {
        rank.resize(size, 0);
        par.resize(size, 0);
        for (int i = 0; i < size; i++) {
            par[i] = i;
            rank[i] = 0;
        }
        g_num = size;
    }

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        g_num--;
        if (rank[x] > rank[y]) {
            par[y] = x;
        } else {
            par[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    int group_num() {
        return g_num;
    }
};

int kruscal() {
    sort(G.begin(), G.end(), comp);
    UnionFind uf(n);
    int res = 0;
    for (auto e: G) {
        if (!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int cost;
            cin >> cost;
            if (cost == -1) continue;
            G.push_back(edge {i, j, cost});
        }
    }
    int ans = prim();
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:82:15: error: 'prim' was not declared in this scope
   82 |     int ans = prim();
      |               ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,a) for(i=0;i<a;i++)
using namespace std;
static const int W 0
static const int G 1
static const int B 2

void prim(int n, int *total, vector<vector<int> > &M) {
    int i,u,min;
    vector<int> d(n);
    vector<int> p(n);
    vector<int> color(n);

    rep(i,n){
        d[i] = INT_MAX;
        p[i] = -1;
        color[i] = INT_MAX;
    }
    d[0] = 0;
    while(true){
        min = INT_MAX;
        u = -1;
        rep(i,n){
            if(min > d[i] && color[i] != B) {
                u = i;
                min = d[i];
            }
        }
        if(u==-1) break;
        color[u] = B;
        rep(i,n){
            if(color[i] != B && M[u][i])
                if(d[i] > M[u][i]) {
                    d[i] = M[u][i];
                    p[i] = u;
                    color[u] = G;
                }
        }
    }
    rep(i,n){
        if(p[i] != -1) total += M[i][p[i]]
    }
}

int main(void) {
    int i,j,n,total = 0;
    vector<vector<int> > M;
    cin >> n;
    M.resize(n);

    rep(i,n){
        M[i].resize(n);
    }
    rep(i,n){
        rep(j,n){
            cin >> M[i][j];
            if(M[i][j] != -1) M[i][j] = INT_MAX;

        }
    }
    prim(n,&total,M);
    cout << total;
    return 0;
}

Compiler output:
a.cc:4:20: error: expected initializer before numeric constant
    4 | static const int W 0
      |                    ^
a.cc: In function 'int main()':
a.cc:61:5: error: 'prim' was not declared in this scope
   61 |     prim(n,&total,M);
      |     ^~~~
Language: C++

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_A

Compiler output:
a.cc:1:1: error: 'http' does not name a type
    1 | http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_A
      | ^~~~
Language: C++

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

using namespace std;

int P[10001];

void init(int n) {
	for (int i = 0; i <= n; i++)
		P[i] = i;
}

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

bool is_same_set(int a, int b) {
	return root(a) == root(b);
}

void unite(int a, int b) {
	P[root(a)] = root(b);
}

bool span(int n) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (!is_same_set(i, j))
				return false;
		}
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	init(n);
	vector<vector<int> > map(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> map[i][j];
		}
	}
	vector<pair<int, pair<int, int> > > edges;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (map[i][j] >= 0)
				edges.push_back(pair<int, pair<int, int> >(map[i][j], pair<int, int>(i, j)));
		}
	}
	sort(edges.begin(), edges.end());
	int result = 0;
	while (!span(n)) {
		pair<int, pair<int, int> > edge = edges.front();
		edges.erase(edges.begin());
		int a = edge.second.first;
		int b = edge.second.second;
		if (!is_same_set(a, b)){
			unite(a, b);
			result += edge.first;
		}
	}
	cout << result << endl;
}

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

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int x[10000][10000];
int MIN[10000];
int MINX = 0;
int MINZ = 10000000;

int main() {
	memset(MIN, 127, sizeof(MIN));
	int n, a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a;
			x[i][j] = a;
		}
	}
	for(int i=0;i<n;i++){
	    for(int j=0;j<n;j++){
	        if(x[i][j]!=-1){
	            MIN[i]=min(x[i][j],MIN[i]);
	        }
	    }
	}
	for(int i=0;i<n;i++){
	    MINX=0;
	    for(int j=0;j<n;j++){
	        MINX += min[j];
	    }
	    MINZ=min(MINZ,MINX);
	}
	cout<<MINZ<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   31 |                 MINX += min[j];
      |                            ^
Language: C++

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

#define INF 2000000000

int x[10000][10000];
int MIN[10000];
int p[10000];

int prim(){
    int v,MINX;
    int col[10000];
    for(int i=0;i<n;i++){
        MIN[i]=INF;
        p[i]=-1;
        col[i]=0;
    }
    MIN[0]=0;
    while(true){
        MINX=INF;
        v=-1;
        for(int i=0;i<n;i++){
            if(MINX > MIN[i] && col != 2){
                u=i;
                MINX = MIN[i];
            }
        }
        if(u==-1){
            break;
        }
        color[u]=black;
        for(int k=0;k<n;k++){
            if(color != 0 && x[u][k]!=-1 && MIN[k]>x[u][k]){
                MIN[k]=x[u][k];
                col[k]=1;
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum += x[i][MIN[i]];
    }
    return sum;
}

int main() {
	int n, a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a;
			x[i][j] = a;
		}
	}
    cout<<prim()<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int prim()':
a.cc:15:19: error: 'n' was not declared in this scope
   15 |     for(int i=0;i<n;i++){
      |                   ^
a.cc:24:23: error: 'n' was not declared in this scope
   24 |         for(int i=0;i<n;i++){
      |                       ^
a.cc:25:37: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   25 |             if(MINX > MIN[i] && col != 2){
      |                                 ~~~~^~~~
a.cc:26:17: error: 'u' was not declared in this scope
   26 |                 u=i;
      |                 ^
a.cc:30:12: error: 'u' was not declared in this scope
   30 |         if(u==-1){
      |            ^
a.cc:33:9: error: 'color' was not declared in this scope; did you mean 'col'?
   33 |         color[u]=black;
      |         ^~~~~
      |         col
a.cc:33:15: error: 'u' was not declared in this scope
   33 |         color[u]=black;
      |               ^
a.cc:33:18: error: 'black' was not declared in this scope
   33 |         color[u]=black;
      |                  ^~~~~
a.cc:34:23: error: 'n' was not declared in this scope
   34 |         for(int k=0;k<n;k++){
      |                       ^
a.cc:42:19: error: 'n' was not declared in this scope
   42 |     for(int i=0;i<n;i++){
      |                   ^
Language: C++

n = int(raw_input())
A = [0]
i = 0
long = 0
NY = range(1, n)
a = [[0 for i in xrange(n)] for j in xrange(n)]
while i <=n:
    a[i] = map(int,raw_input().split())
    i = i+1
while NY != []:
    amin = 2001
    for i in A:
        for j in NY:
            if 0 <= a[i][j] < amin:
                amin = a[i][j]
                addA = j
    A.append(addA)
    NY.remove(addA)
    long =long + amin
print long

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(raw_input())
      | ^
Language: C++

n = int( raw_input() )
A = [0]
p = range(1, n)
a = [ [ 0 for i in xrange(n) ] for j in xrange(n) ]
for i in xrange(n):
    a[i] = map( int,raw_input().split() )
l = 0
while p != []:
    a_min = 2001
    for i in A:
        for j in p:
            if 0 <= a[i][j] < a_min:
                a_min = a[i][j]
                add_A = j
    A.append( add_A )
    NY.remove( add_A )
    l += a_min
print l

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int( raw_input() )
      | ^
Language: C++


#include <iostream>
using namespace std;
const int MAX = 100;
const int INFTY = 2000000;
const int WHITE = 0;
const int GRAY = 1;
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(){
    cin >> n;

    for (int i = 0; i < n ; ++i) {
        for (int j = 0; j < n ; ++j) {
            int e; cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }
    
    cout << prim () << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int prim()':
a.cc:47:13: error: 'P' was not declared in this scope
   47 |         if( P[i] != -1) sum += M[i][p[i]];
      |             ^
Language: C++

#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;
    REP(i,n-1){
        int x = V[i].snd.fst;
        int y = V[i].snd.snd;
        if(!same(x,y)){
            unite(x,y);
            wsum += V[i].fst;
        }
    }

    cout <<wsum<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   40 |     sort(all(V));
      |     ^~~~
      |     short
Language: C++

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

int main(){
  int n;
  int a[100][100],b[100]={},c[100]={};
  cin>>n;
  for(int i=0;i<n;i++)
   for(int j=0;j<n;j++)cin>>a[i][j];
  c[0]=1;

  while(1){
   int k=0.min=10000,min1=0;
   if(k==n)break;
   for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
     if(a[b[i]][j]<min && a[b[i]][j]!=-1 &&c[j]!=1){
      min=a[b[i]][j];
      b[k]=j;
    }
   c[b[k]]=1
   ans+=min;
   k++;
  }
 cout<<ans<<endl;
 return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: no match for 'operator=' (operand types are 'std::chrono::duration<long double, std::ratio<60> >' and 'int')
   13 |    int k=0.min=10000,min1=0;
      |                ^~~~~
In file included from /usr/include/c++/14/chrono:41,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:172,
                 from a.cc:1:
/usr/include/c++/14/bits/chrono.h:585:19: note: candidate: 'constexpr std::chrono::duration<_Rep, _Period>& std::chrono::duration<_Rep, _Period>::operator=(const std::chrono::duration<_Rep, _Period>&) [with _Rep = long double; _Period = std::ratio<60>]'
  585 |         duration& operator=(const duration&) = default;
      |                   ^~~~~~~~
/usr/include/c++/14/bits/chrono.h:585:29: note:   no known conversion for argument 1 from 'int' to 'const std::chrono::duration<long double, std::ratio<60> >&'
  585 |         duration& operator=(const duration&) = default;
      |                             ^~~~~~~~~~~~~~~
a.cc:17:19: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<'
   17 |      if(a[b[i]][j]<min && a[b[i]][j]!=-1 &&c[j]!=1){
      |         ~~~~~~~~~~^~~~
a.cc:18:20: error: overloaded function with no contextual type information
   18 |       min=a[b[i]][j];
      |                    ^
a.cc:21:13: error: expected ';' before 'ans'
   21 |    c[b[k]]=1
      |             ^
      |             ;
   22 |    ans+=min;
      |    ~~~       
a.cc:25:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |  cout<<ans<<endl;
      |        ^~~
      |        abs
Language: C++

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

int main(){
  int n;
  int a[100][100],b[100]={},c[100]={};
  cin>>n;
  for(int i=0;i<n;i++)
   for(int j=0;j<n;j++)cin>>a[i][j];
  c[0]=1;

  int k=0.min=10000,min1=0,ans=0;
  while(1){
   if(k==n)break;
   for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
     if(a[b[i]][j]<min && a[b[i]][j]!=-1 &&c[j]!=1){
      min=a[b[i]][j];
      b[k]=j;
    }
   c[b[k]]=1
   ans+=min;
   k++;
  }
 cout<<ans<<endl;
 return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: no match for 'operator=' (operand types are 'std::chrono::duration<long double, std::ratio<60> >' and 'int')
   12 |   int k=0.min=10000,min1=0,ans=0;
      |               ^~~~~
In file included from /usr/include/c++/14/chrono:41,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:172,
                 from a.cc:1:
/usr/include/c++/14/bits/chrono.h:585:19: note: candidate: 'constexpr std::chrono::duration<_Rep, _Period>& std::chrono::duration<_Rep, _Period>::operator=(const std::chrono::duration<_Rep, _Period>&) [with _Rep = long double; _Period = std::ratio<60>]'
  585 |         duration& operator=(const duration&) = default;
      |                   ^~~~~~~~
/usr/include/c++/14/bits/chrono.h:585:29: note:   no known conversion for argument 1 from 'int' to 'const std::chrono::duration<long double, std::ratio<60> >&'
  585 |         duration& operator=(const duration&) = default;
      |                             ^~~~~~~~~~~~~~~
a.cc:17:19: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<'
   17 |      if(a[b[i]][j]<min && a[b[i]][j]!=-1 &&c[j]!=1){
      |         ~~~~~~~~~~^~~~
a.cc:18:20: error: overloaded function with no contextual type information
   18 |       min=a[b[i]][j];
      |                    ^
a.cc:21:13: error: expected ';' before 'ans'
   21 |    c[b[k]]=1
      |             ^
      |             ;
   22 |    ans+=min;
      |    ~~~       
a.cc:25:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |  cout<<ans<<endl;
      |        ^~~
      |        abs
Language: C++

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

int main(){
  int n;
  int a[100][100],b[100]={},c[100]={};
  c[0]=1;
  cin>>n;
  for(int i=0;i<n;i++)
   for(int j=0;j<n;j++)cin>>a[i][j];

  int k=1,min=10000,min1=0,ans=0;
  while(1){
   for(int i=0;i<k;i++)
    for(int j=0;j<n;j++)
     if(a[b[i]][j]<min && a[b[i]][j]!=-1 &&c[j]!=1){
      min=a[b[i]][j];
      min1=j;
    }
   if(k==n)break;
   b[k]=min1;
   c[min1]=1
   ans+=min;
   k++;
  }

 cout<<ans<<endl;
 return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: expected ';' before 'ans'
   22 |    c[min1]=1
      |             ^
      |             ;
   23 |    ans+=min;
      |    ~~~
Language: C++

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

int main(){
  int n,a[100][100],b[100]={},c[100]={};
  c[0]=1;
  cin>>n;
  for(int i=0;i<n;i++)
   for(int j=0;j<n;j++)cin>>a[i][j];

  int k=1,min1,ans=0;
  while(1){
   int min=10000;
   for(int i=0;i<k;i++)
    for(int j=0;j<n;j++)
     if(a[b[i]][j]<min && a[b[i]][j]!=-1 &&c[j]!=1){
      min=a[b[i]][j];
      min1=j;
    }
   if(k==n)break;
   b[k]=min1;
   c[min1]=1
   ans+=min;
   k++;
  }

 cout<<ans<<endl;
 return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: expected ';' before 'ans'
   22 |    c[min1]=1
      |             ^
      |             ;
   23 |    ans+=min;
      |    ~~~
Language: C++

#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
int matrix[100][100];
pair<int,int> edges[100];
int cost[100];
int src[100];
int dst[100];
int p[10010];
void init(int n)
{
    for(int i=0;i<=n;i++)
        p[i]=i;
};
int root(int a)
{
    if(p[a]==a)
        return a;
    return (p[a]=root(p[a]));
};
bool is_same_set(int a,int b)
{
    return root(a)==root(b);
};
void unite(int a,int b)
{
    p[root(a)]=root(b);
};

int main()
{
    int n,amount=0,sum=0;
    
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>matrix[i][j];
        }
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(matrix[i][j]!=-1)
            {
                cost[amount]=matrix[i][j];
                src[amount]=i;
                dst[amount]=j;
                amount++;
            }
        }
    }
    for(int i=0;i<amount;i++)
    {
        edges[i]=make_pair(cost[i],i);
    }

	init(n);
    
    sort(edges,edges+amount);
    
    for(int i=0;i<amount;i++)
    {
        if(is_same_set(src[edges[i].second()],dst[edges[i].second()]))
			continue;
		unite(src[edges[i].second()],dst[edges[i].second()]));
		sum+=edges[i].first();
    }
	cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:43: error: expression cannot be used as a function
   68 |         if(is_same_set(src[edges[i].second()],dst[edges[i].second()]))
      |                            ~~~~~~~~~~~~~~~^~
a.cc:68:66: error: expression cannot be used as a function
   68 |         if(is_same_set(src[edges[i].second()],dst[edges[i].second()]))
      |                                                   ~~~~~~~~~~~~~~~^~
a.cc:70:42: error: expression cannot be used as a function
   70 |                 unite(src[edges[i].second()],dst[edges[i].second()]));
      |                           ~~~~~~~~~~~~~~~^~
a.cc:70:65: error: expression cannot be used as a function
   70 |                 unite(src[edges[i].second()],dst[edges[i].second()]));
      |                                                  ~~~~~~~~~~~~~~~^~
a.cc:71:36: error: expression cannot be used as a function
   71 |                 sum+=edges[i].first();
      |                      ~~~~~~~~~~~~~~^~
Language: C++

#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
int matrix[100][100];
pair<int,int> edges[100];
int cost[100];
int src[100];
int dst[100];
int p[10010];
void init(int n)
{
    for(int i=0;i<=n;i++)
        p[i]=i;
};
int root(int a)
{
    if(p[a]==a)
        return a;
    return (p[a]=root(p[a]));
};
bool is_same_set(int a,int b)
{
    return root(a)==root(b);
};
void unite(int a,int b)
{
    p[root(a)]=root(b);
};

int main()
{
    int n,amount=0,sum=0;
    
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>matrix[i][j];
        }
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(matrix[i][j]!=-1)
            {
                cost[amount]=matrix[i][j];
                src[amount]=i;
                dst[amount]=j;
                amount++;
            }
        }
    }
    for(int i=0;i<amount;i++)
    {
        edges[i]=make_pair(cost[i],i);
    }

	init(n);
    
    sort(edges,edges+amount);
    
    for(int i=0;i<amount;i++)
    {
        if(is_same_set(src[edges[i].second()],dst[edges[i].second()]))
			continue;
		unite(src[edges[i].second()],dst[edges[i].second()]);
		sum+=edges[i].first();
    }
	cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:43: error: expression cannot be used as a function
   68 |         if(is_same_set(src[edges[i].second()],dst[edges[i].second()]))
      |                            ~~~~~~~~~~~~~~~^~
a.cc:68:66: error: expression cannot be used as a function
   68 |         if(is_same_set(src[edges[i].second()],dst[edges[i].second()]))
      |                                                   ~~~~~~~~~~~~~~~^~
a.cc:70:42: error: expression cannot be used as a function
   70 |                 unite(src[edges[i].second()],dst[edges[i].second()]);
      |                           ~~~~~~~~~~~~~~~^~
a.cc:70:65: error: expression cannot be used as a function
   70 |                 unite(src[edges[i].second()],dst[edges[i].second()]);
      |                                                  ~~~~~~~~~~~~~~~^~
a.cc:71:36: error: expression cannot be used as a function
   71 |                 sum+=edges[i].first();
      |                      ~~~~~~~~~~~~~~^~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <map>
#include <algorithm>

using namespace std;

#define FAR INT_MAX
#define N 100

static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;


int n, color[N], d[N], p[N];
int m[N][N];

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

	d[0] = 0;
	int dist = FAR;

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

		if (-1 == u) break;
		color[u] = BLACK;

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

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int val; cin >> val;
			m[i][j] = (val == -1) ? FAR : val;
		}
	}
 
	cout << prim() << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int prim()':
a.cc:11:13: error: 'INT_MAX' was not declared in this scope
   11 | #define FAR INT_MAX
      |             ^~~~~~~
a.cc:25:24: note: in expansion of macro 'FAR'
   25 |                 d[i] = FAR;
      |                        ^~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include <algorithm>
  +++ |+#include <climits>
    8 | 
a.cc:11:13: error: 'INT_MAX' was not declared in this scope
   11 | #define FAR INT_MAX
      |             ^~~~~~~
a.cc:30:20: note: in expansion of macro 'FAR'
   30 |         int dist = FAR;
      |                    ^~~
a.cc:11:13: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #define FAR INT_MAX
      |             ^~~~~~~
a.cc:30:20: note: in expansion of macro 'FAR'
   30 |         int dist = FAR;
      |                    ^~~
a.cc: In function 'int main()':
a.cc:11:13: error: 'INT_MAX' was not declared in this scope
   11 | #define FAR INT_MAX
      |             ^~~~~~~
a.cc:66:49: note: in expansion of macro 'FAR'
   66 |                         m[i][j] = (val == -1) ? FAR : val;
      |                                                 ^~~
a.cc:11:13: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #define FAR INT_MAX
      |             ^~~~~~~
a.cc:66:49: note: in expansion of macro 'FAR'
   66 |                         m[i][j] = (val == -1) ? FAR : val;
      |                                                 ^~~
Language: C++

#include<cstdio>
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define _USE_MATH_DEFINES // M_PI????????????????????????
#include<math.h>
#include<queue>
#pragma warning(disable:4996)
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 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;
		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(){
	cin >> n;

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			int e;
			cin >> e;
			M[i][j] = (e==-1) ? INFTY : e;
		}
	}
	cout << prim() << "\n";
}

Compiler output:
a.cc: In function 'int prim()':
a.cc:47:49: error: expected ';' before 'GRAY'
   47 |                                         color[v] GRAY;
      |                                                 ^~~~~
      |                                                 ;