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

#include<stdio.h>
#define N 100000
#define NIL -1

typedef struct{
  int par;
  int left;
  int right;
}node_tree;

node_tree T[N];
int deep;
int left_h,right_h;

int Deep(int u){
  int d;
  if(T[u].left!=NIL){
    d++;
    Deep(T[u].par);
  }
  return d;
}


  
int Degree(int u){
    if (T[u].left == NIL && T[u].right == NIL)return 0;
    else if(T[u].left != NIL && T[u].right != NIL)return 2;
    else  return 1;
}

//兄弟
int Sibling(int u){
  if(T[u].par == NIL) return NIL;//親がいなければNILをかえす。
  else if(T[T[u].par].left==u)return T[T[u].par].right;
  else return T[T[u].par].left;

}
  



int Hight(int u){
  int left_h = 0, right_h = 0;
  if(T[u].left!=NIL) {
    left_h = 1+Hight(T[u].left);//左側
  }
  if(T[u].right!=NIL){
    right_h =1+Hight(T[u].right);//右側
  }
  if(left_h < right_h) return right_h;
  else return left_h;//大小比較して大きいほうを返す
}
  
  
  
void print(int u){
  printf("node %d, parent = %d,sibling = %d,degree = %d, depth = %d, height = %d, ",u,T[u].par,Sbling(u),Degree(u),Deep(u),Hight(u));
  
  if(T[u].par == NIL)printf("root\n");
  else if(T[u].left==NIL&&T[u].right==NIL)printf("leaf\n");
  else if(T[u].left!=NIL||T[u].right!=NIL)printf("internal node\n");
}
  
  
main(){
  int i,j,deg,ver,ch,l,n,tmp;
      
    scanf("%d", &n);
      
    for ( i=0;i<n;i++) {
      T[i].par=NIL;
      T[i].left=NIL;
      T[i].right=NIL;
    }
    for (i=0;i<n;i++){
      scanf("%d %d %d",&ver,&deg,&ch);
             T[deg].par=ver;
	     T[ch].par=ver;
             T[ver].left=deg;
             T[ver].right=ch;
	     
    }
    for (i =0;i<n;i++){
      print(i);
    }

    return 0;
}

Compiler output:
main.c: In function 'print':
main.c:58:96: error: implicit declaration of function 'Sbling'; did you mean 'Sibling'? [-Wimplicit-function-declaration]
   58 |   printf("node %d, parent = %d,sibling = %d,degree = %d, depth = %d, height = %d, ",u,T[u].par,Sbling(u),Degree(u),Deep(u),Hight(u));
      |                                                                                                ^~~~~~
      |                                                                                                Sibling
main.c: At top level:
main.c:66:1: error: return type defaults to 'int' [-Wimplicit-int]
   66 | main(){
      | ^~~~
Language: C

#include<stdio.h>
#define N 100000
#define NIL -1

typedef struct{
  int par;
  int left;
  int right;
}node_tree;

node_tree T[N];
int deep;
int left_h,right_h;

int Deep(int u){
  int d;
  if(T[u].left!=NIL){
    d++;
    Deep(T[u].par);
  }
  return d;
}


  
int Degree(int u){
    if (T[u].left == NIL && T[u].right == NIL)return 0;
    else if(T[u].left != NIL && T[u].right != NIL)return 2;
    else  return 1;
}

//兄弟
int Sibling(int u){
  if(T[u].par == NIL) return NIL;//親がいなければNILをかえす。
  else if(T[T[u].par].left==u)return T[T[u].par].right;
  else return T[T[u].par].left;

}
  



int Hight(int u){
  int left_h = 0, right_h = 0;
  if(T[u].left!=NIL) {
    left_h = 1+Hight(T[u].left);//左側
  }
  if(T[u].right!=NIL){
    right_h =1+Hight(T[u].right);//右側
  }
  if(left_h < right_h) return riht_h;
  else return left_h;//大小比較して大きいほうを返す
}
  
  
  
void print(int u){
  printf("node %d, parent = %d,sibling = %d,degree = %d, depth = %d, height = %d, ",u,T[u].par,Sibling(u),Degree(u),Deep(u),Hight(u));
  
  if(T[u].par == NIL)printf("root\n");
  else if(T[u].left==NIL&&T[u].right==NIL)printf("leaf\n");
  else if(T[u].left!=NIL||T[u].right!=NIL)printf("internal node\n");
}
  
  
main(){
  int i,j,deg,ver,ch,l,n,tmp;
      
    scanf("%d", &n);
      
    for ( i=0;i<n;i++) {
      T[i].par=NIL;
      T[i].left=NIL;
      T[i].right=NIL;
    }
    for (i=0;i<n;i++){
      scanf("%d %d %d",&ver,&deg,&ch);
             T[deg].par=ver;
	     T[ch].par=ver;
             T[ver].left=deg;
             T[ver].right=ch;
	     
    }
    for (i =0;i<n;i++){
      print(i);
    }

    return 0;
}

Compiler output:
main.c: In function 'Hight':
main.c:51:31: error: 'riht_h' undeclared (first use in this function); did you mean 'right_h'?
   51 |   if(left_h < right_h) return riht_h;
      |                               ^~~~~~
      |                               right_h
main.c:51:31: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:66:1: error: return type defaults to 'int' [-Wimplicit-int]
   66 | main(){
      | ^~~~
Language: C

#include<stdio.h>
#define  NIL -1
#define N 100000

struct Node{
  int p;
  int l;
  int r;
  int s;
  int h;
  
}Node;

 struct Node T[N];

int getDepth(int u){
  int d=0;
   
  
 for(;T[u].p != NIL; d++) u=T[u].p;
  
  return d;
}
void setHeight(int n){
  int d,i,j;
  for(i=0;i<n;i++){
   
    if(T[i].r == NIL && T[i].l == NIL){
      T[i].h == 0;
      for(j = i,d = 1;j != NIL; d++){
	j = T[j].p;
	if(T[j].h < d) T[j].h = d;
	
      }
    }
  }
 
}

int main(){
  int i;
  int j;
  int n = 0;
  int v  =0;
  int d = 0;
  int c = 0;
  int l = 0;
  scanf("%d",&n);
 
 for(i=0;i<n;i++) {
   
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
    T[i].s=NIL;
  }
  
 for(i=0;i<n;i++){
   scanf("%d %d %d",&v,&d,&c);
   if( d!= NIL && c ==NIL){
     T[v].l = d;
     T[d].p = v;
   }
   if(c != NIL && d == NIL){
    T[v].r = c; 
    T[c].p = v;
   }
   if(d != NIL && c != NIL){
     T[v].l = d;
     T[d].p = v;
     T[v].r = c; 
     T[c].p = v;
     T[d].s = c;
     T[c].s = d;
   }
 }
 
 
 

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

#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node{int p,l,r,ls,rs;};
struct Node T[MAX];
int n,D[MAX],M=0;

int getDepth(int u){
  int d=0;
  while(T[u].p != -1){
    u = T[u].p;
    d++;
  }
  return d;
}


int getSibling(int s){
  int i; 
  for(i=0; i<n; i++){
    if(s == T[i].l)return T[i].ls;
    if(s == T[i].r)return T[i].rs;
  }
  return -1;
}

int height(struct Node p,int h){
  
  int l=0,r=0;
  if(p.r==-1 && p.l==-1){ return 0; }
  if(p.r!=-1)r = height(T[p.r],r);
  if(p.l!=-1)l = height(T[p.l],l); 
  
  if(l<r) M = r+1;
  
  else M =l+1;
  
  return M;
  
  
}


int getDegree(int d){
  if(T[d].l != -1  && T[d].r != -1) return 2;
  else if(T[d].l == -1 && T[d].r != -1)return 1;
  else if(T[d].l != -1 && T[d].r == -1)return 1;
  else return 0;
}

void print(int u){
  int i=0,count=0;
  printf("node %d: parent = %d, sibling = %d, degree = %d, ",u,  T[u].p,  getSibling(u), getDegree(u));
  printf("depth = %d, height = %d, ", D[u], height(T[u], 0));
  if(D[u] == 0)printf("root\n");
  else if(T[u].l != -1 || T[u].r != -1)
  else printf("leaf\n");
  M = 0;
}



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

  for (i=0; i<n; i++){
    T[i].p = T[i].l = T[i].r = T[i].ls = T[i].rs = NIL;
  }
  
  for (i=0; i<n; i++){
    scanf("%d",&v);
    for (j=0; j<2; j++){
      scanf("%d",&c);
      

      if(j == 0){
	T[v].l = c;
	T[c].p = v;
	T[v].rs = c; 
      }
      else if(j == 1){
	T[v].r = c;
	T[c].p = v;
	T[v].ls = c;
      }
    }
  }
  for (i=0; i<n; i++){
    D[i] = getDepth(i);
  }



   for (i=0; i<n; i++) print(i);
  return 0;
}

Compiler output:
main.c: In function 'print':
main.c:59:3: error: expected expression before 'else'
   59 |   else printf("leaf\n");
      |   ^~~~
main.c: At top level:
main.c:65:1: error: return type defaults to 'int' [-Wimplicit-int]
   65 | main(){
      | ^~~~
Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

struct node {int parent,left,right;};

node t[MAX];
int n d[MAX],h[MAX];

void setdepth(int u,int d){
  if(u==NIL) return;
  d[u]=d;
  setdepth(t[u].left,d+1);
  setdepth(t[u].right,d+1);
}

int setheight(int u){
  int h1=0,h2=0;
  if(t[u].left!=NIL)
    h1=setheight(t[u].left)+1;
  if(t[u].right!=NIL)
    h2=setheight(t[u].right)+1;
  return h[u]=(h1>h2?h1:h2);
}

int getsibling(int u){
  if(t[u].parent==NIL) return NIL;
  if(t[t[u].parent].left!=u&&t[t[u].parent].left!=NIL)
    return t[t[u].parent].left;
  if(t[t[u].parent].right != u&&t[t[u].parent].right!=NIL)
    return t[t[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",t[u].parent);
  printf("sibling = %d, ",getsibling(u));
  int deg=0;
  if(t[u].left!=NIL) deg++;
  if(t[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",d[u]);
  printf("height = %d, ",h[u]);

  if(t[u].parent==NIL){
    pintf("root\n");
  }else if(t[u].left==NIL&&t[u].right==NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,root=0;
  scanf("%d",&n);

  for(int i=0;i<n;i++) t[i].parent=NIL;

  for(int i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    t[v].left=l;
    t[v].right=r;
    if(l!=NIL) t[l].parent=v;
    if(r!=NIL) t[r].parent=v;
  }

  for(int i=0;i<n;i++) if(t[i].parent==NIL) root=i;
  setdepth(root,0);
  setheight(root);
  for(int i=0;i<n;i++) print(i);

  return 0;
}



Compiler output:
a.cc:8:7: error: expected initializer before 'd'
    8 | int n d[MAX],h[MAX];
      |       ^
a.cc: In function 'void setdepth(int, int)':
a.cc:12:4: error: invalid types 'int[int]' for array subscript
   12 |   d[u]=d;
      |    ^
a.cc: In function 'int setheight(int)':
a.cc:23:10: error: 'h' was not declared in this scope; did you mean 'h2'?
   23 |   return h[u]=(h1>h2?h1:h2);
      |          ^
      |          h2
a.cc: In function 'void print(int)':
a.cc:43:25: error: 'd' was not declared in this scope
   43 |   printf("depth = %d, ",d[u]);
      |                         ^
a.cc:44:26: error: 'h' was not declared in this scope
   44 |   printf("height = %d, ",h[u]);
      |                          ^
a.cc:47:5: error: 'pintf' was not declared in this scope; did you mean 'printf'?
   47 |     pintf("root\n");
      |     ^~~~~
      |     printf
a.cc: In function 'int main()':
a.cc:57:15: error: 'n' was not declared in this scope
   57 |   scanf("%d",&n);
      |               ^
Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

struct node {int parent,left,right;};

node t[MAX];
int n D[MAX],H[MAX];

void setdepth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  setdepth(t[u].left,d+1);
  setdepth(t[u].right,d+1);
}

int setheight(int u){
  int h1=0,h2=0;
  if(t[u].left!=NIL)
    h1=setheight(t[u].left)+1;
  if(t[u].right!=NIL)
    h2=setheight(t[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}

int getsibling(int u){
  if(t[u].parent==NIL) return NIL;
  if(t[t[u].parent].left!=u&&t[t[u].parent].left!=NIL)
    return t[t[u].parent].left;
  if(t[t[u].parent].right != u&&t[t[u].parent].right!=NIL)
    return t[t[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",t[u].parent);
  printf("sibling = %d, ",getsibling(u));
  int deg=0;
  if(t[u].left!=NIL) deg++;
  if(t[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(t[u].parent==NIL){
    pintf("root\n");
  }else if(t[u].left==NIL&&t[u].right==NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,root=0;
  scanf("%d",&n);

  for(int i=0;i<n;i++) t[i].parent=NIL;

  for(int i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    t[v].left=l;
    t[v].right=r;
    if(l!=NIL) t[l].parent=v;
    if(r!=NIL) t[r].parent=v;
  }

  for(int i=0;i<n;i++) if(t[i].parent==NIL) root=i;
  setdepth(root,0);
  setheight(root);
  for(int i=0;i<n;i++) print(i);

  return 0;
}



Compiler output:
a.cc:8:7: error: expected initializer before 'D'
    8 | int n D[MAX],H[MAX];
      |       ^
a.cc: In function 'void setdepth(int, int)':
a.cc:12:3: error: 'D' was not declared in this scope
   12 |   D[u]=d;
      |   ^
a.cc: In function 'int setheight(int)':
a.cc:23:10: error: 'H' was not declared in this scope
   23 |   return H[u]=(h1>h2?h1:h2);
      |          ^
a.cc: In function 'void print(int)':
a.cc:43:25: error: 'D' was not declared in this scope
   43 |   printf("depth = %d, ",D[u]);
      |                         ^
a.cc:44:26: error: 'H' was not declared in this scope
   44 |   printf("height = %d, ",H[u]);
      |                          ^
a.cc:47:5: error: 'pintf' was not declared in this scope; did you mean 'printf'?
   47 |     pintf("root\n");
      |     ^~~~~
      |     printf
a.cc: In function 'int main()':
a.cc:57:15: error: 'n' was not declared in this scope
   57 |   scanf("%d",&n);
      |               ^
Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

struct node {int parent,left,right;};

node t[MAX];
int n, D[MAX],H[MAX];

void setdepth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  setdepth(t[u].left,d+1);
  setdepth(t[u].right,d+1);
}

int setheight(int u){
  int h1=0,h2=0;
  if(t[u].left!=NIL)
    h1=setheight(t[u].left)+1;
  if(t[u].right!=NIL)
    h2=setheight(t[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}

int getsibling(int u){
  if(t[u].parent==NIL) return NIL;
  if(t[t[u].parent].left!=u&&t[t[u].parent].left!=NIL)
    return t[t[u].parent].left;
  if(t[t[u].parent].right != u&&t[t[u].parent].right!=NIL)
    return t[t[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",t[u].parent);
  printf("sibling = %d, ",getsibling(u));
  int deg=0;
  if(t[u].left!=NIL) deg++;
  if(t[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(t[u].parent==NIL){
    pintf("root\n");
  }else if(t[u].left==NIL&&t[u].right==NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,root=0;
  scanf("%d",&n);

  for(int i=0;i<n;i++) t[i].parent=NIL;

  for(int i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    t[v].left=l;
    t[v].right=r;
    if(l!=NIL) t[l].parent=v;
    if(r!=NIL) t[r].parent=v;
  }

  for(int i=0;i<n;i++) if(t[i].parent==NIL) root=i;
  setdepth(root,0);
  setheight(root);
  for(int i=0;i<n;i++) print(i);

  return 0;
}



Compiler output:
a.cc: In function 'void print(int)':
a.cc:47:5: error: 'pintf' was not declared in this scope; did you mean 'printf'?
   47 |     pintf("root\n");
      |     ^~~~~
      |     printf
Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node {int parent, left, right;};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u, int d){
  if(u==NIL) return;
  D[u]=d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL) h1=setHight(T[u].left)+1;
  if(T[u].right!=NIL) h1=setHight(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}

int getSibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL) return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("hight = %d, ",H[u]);

  if(T[u].parent==NIL){
    printf("root\n");
  }
  else if(T[u].left==NIL&&T[u].right==NIL){
    printf("leaf\n");
  }
  else printf("internal node\n");
}

int main(){
  int v,l,r,root=0;
  scanf("%d",&n);

  for(int i=0;i<n;i++) T[i].parent=NIL;

  for(int i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }

  for(int i=0;i<n;i++) if(T[i].parent==NIL) root=i;

  setDepth(root,0);
  setHoght(root);

  for(int i=0;i<n;i++) print(i);

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:68:3: error: 'setHoght' was not declared in this scope; did you mean 'setHight'?
   68 |   setHoght(root);
      |   ^~~~~~~~
      |   setHight
Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node {int p,l,r;};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].l,d+1);
  setDepth(T[u].r,d+1);
}

int setHeght(int u){
  int h1=0,h2=0;
  if(T[u].l!=NIL)
    h1=setHight(T[u].l)+1;
  if(T[u].r!=NIL)
    h2=setHight(T[u].r)+1;
  return H[u]=(h1>h2 ? h1:h2);
}

int getSibling(int u){
  if(T[u].p==NIL)
    return NIL;
  if(T[T[u].p].l!=u&&T[T[u].p].l!=NIL)
    return T[T[u].p].l;
  if(T[T[u].p].r!=u&&T[T[u].p].r!=NIL)
    return T[T[u].p].r;

  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getSibling(u));

  int deg=0;
  if(T[u].l!=NIL)deg++;
  if(T[u].r!=NIL)deg++;

  printf("degree = %d: ",deg);
  printf("depth = %d, ",D[u]);
  printf("heght = %d, ",H[u]);

  if(T[u].p==NIL)
      printf("root\n");
  else  if(T[u].l==NIL&&T[u].r==NIL)
      printf("leaf\n");
  else
    printf("internal node\n");
}

int main(){
  int v,le,ri,root=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
    T[i].p==NIL;
    
    
  for(int i=0;i<n;i++){
    scanf("%d%d%d",&v,&le,&ri);
    T[v].l=le;
    T[v].r=ri;

    if(le!=NIL)T[le].p=v;
    if(ri!=NIL)T[ri].p=v;
  }

  for(int i=0;i<n;i++)
    if(T[i].p==NIL)
      root=i;
  setDepth(root,0);
  setHight(root);
  for(int i=0;i<n;i++)print(i);
  return 0;
}


Compiler output:
a.cc: In function 'int setHeght(int)':
a.cc:20:8: error: 'setHight' was not declared in this scope; did you mean 'setHeght'?
   20 |     h1=setHight(T[u].l)+1;
      |        ^~~~~~~~
      |        setHeght
a.cc:22:8: error: 'setHight' was not declared in this scope; did you mean 'setHeght'?
   22 |     h2=setHight(T[u].r)+1;
      |        ^~~~~~~~
      |        setHeght
a.cc: In function 'int main()':
a.cc:78:3: error: 'setHight' was not declared in this scope; did you mean 'setHeght'?
   78 |   setHight(root);
      |   ^~~~~~~~
      |   setHeght
Language: C++

#include <iostream>
using namespace std;

static const int maxn=10000;

struct Node {
  int parent,left,right;
};

Node T[maxn];
int n,D[maxn],H[maxn];

void setDepth(int getu,int d) {
  if (getu==(-1)) {
    return ;
  }
  D[getu]=d;
  setDepth(T[getu].left,d+1);
  setDepth(T[getu].right,d+1);
}
int setHeight(int getu) {
  int h1=0,h2=0;
  if (T[getu].left!=(-1)) {
    h1=setHeight(T[getu].left)+1;
  }
  if (T[getu].right!=(-1)) {
    h2=setHeight(T[getu].right)+1;
  }
  return H[uget]=max(h1,h2);
}
int getSibling(int u) {
  if (T[u].parent==(-1)) {
    return (-1);
  }
  if (T[T[u].parent].left!=u and T[T[u].parent].left!=(-1)) {
    return T[T[u].parent].left;
  }
  if (T[T[u].parent].right!=u and T[T[u].parent].right!=(-1)) {
    return T[T[u].parent].right;
  }
  return (-1);
}
void print(int u) {
  cout<<"node "<<u<<": "<<flush;
  cout<<"parent = "<<T[u].parent<<", "<<flush;
  cout<<"sibling = "<<getSibling(u)<<", "<<flush;
  int deg=0;
  if (T[u].left!=(-1)) {
    deg++;
  }
  if (T[u].right!=(-1)) {
    deg++;
  }
  cout<<"degree = "<<deg<<", "<<flush;
  cout<<"depth = "<<D[u]<<", "<<flush;
  cout<<"height = "<<H[u]<<", "<<flush;
  if (T[u].parent==(-1)) {
    cout<<"root"<<endl;
  }
  else if (T[u].left==(-1) and T[u].right==(-1)) {
    cout<<"leaf"<<endl;
  }
  else {
    cout<<"internal node"<<endl;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin>>n;
  for (int i=0; i<n; i++) {
    T[i].parent=(-1);
  }
  for (int i=0; i<n; i++) {
    int v,l,r;
    cin>>v>>l>>r;
    T[v].left=l;
    T[v].right=r;
    if (l!=(-1)) {
      T[l].parent=v;
    }
    if (r!=(-1)) {
      T[r].parent=v;
    }
  }
  int root=0;
  for (int i=0; i<n; i++) {
    if (T[i].parent==(-1)) {
      root=i;
    }
  }
  setDepth(root,0);
  setHeight(root);
  for (int i=0; i<n; i++) {
    print(i);
  }
  return 0;
}



Compiler output:
a.cc: In function 'int setHeight(int)':
a.cc:29:12: error: 'uget' was not declared in this scope
   29 |   return H[uget]=max(h1,h2);
      |            ^~~~
Language: C++

N = int(input())

binary_tree = [{"parent": -1, "sibling": -1} for _ in range(N)]
for _ in range(N):
    node_input = input()
    id, left, right = map(int, node_input.split())

    binary_tree[id]["left"] = left
    binary_tree[id]["right"] = right

    degree = 0
    if left != -1:
        degree += 1
        binary_tree[left]["parent"] = id
        binary_tree[left]["sibling"] = right
    if right != -1:
        degree += 1
        binary_tree[right]["parent"] = id
        binary_tree[right]["sibling"] = left
    binary_tree[id]["degree"] = degree


def measure_depth_and_height(id, depth):
    H[id] = max(H[id], depth)

    parent_id = binary_tree[id]["parent"]
    if parent_id == -1:
        return depth

    return measure_depth_and_height(parent_id, depth+1)

D = [0 for i in range(N)]
H = [0 for i in range(N)]
for id in range(N):
    depth = measure_depth_and_height(id, 0)
    D[id] = depth


def get_type(node):
    if node["degree"] == 0:
        return "leaf"
    if node["parent"] == -1:
        return "root"
    return "internal node"

for id in range(N):
    node = binary_tree[id]
    parent_id = node["parent"]
    sibling_id = node["sibling"]
    degree = node["degree"]
    node_type = get_type(node)
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(id, parent_id, sibling_id, degree, D[id], H[id], node_type))


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
a.cc:3:46: error: expected unqualified-id before 'for'
    3 | binary_tree = [{"parent": -1, "sibling": -1} for _ in range(N)]
      |                                              ^~~
Language: C++

N = int(input())

binary_tree = [{"parent": -1, "sibling": -1} for _ in range(N)]
for _ in range(N):
    node_input = input()
    id, left, right = map(int, node_input.split())

    binary_tree[id]["left"] = left
    binary_tree[id]["right"] = right

    degree = 0
    if left != -1:
        degree += 1
        binary_tree[left]["parent"] = id
        binary_tree[left]["sibling"] = right
    if right != -1:
        degree += 1
        binary_tree[right]["parent"] = id
        binary_tree[right]["sibling"] = left
    binary_tree[id]["degree"] = degree


def measure_depth_and_height(id, depth):
    H[id] = max(H[id], depth)

    parent_id = binary_tree[id]["parent"]
    if parent_id == -1:
        return depth

    return measure_depth_and_height(parent_id, depth+1)

D = [0 for i in range(N)]
H = [0 for i in range(N)]
for id in range(N):
    depth = measure_depth_and_height(id, 0)
    D[id] = depth


def get_type(node):
    if node["parent"] == -1:
        return "root"
    if node["degree"] == 0:
        return "leaf"
    if node["parent"] == -1:
        return "root"
    return "internal node"

for id in range(N):
    node = binary_tree[id]
    parent_id = node["parent"]
    sibling_id = node["sibling"]
    degree = node["degree"]
    node_type = get_type(node)
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(id, parent_id, sibling_id, degree, D[id], H[id], node_type))


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
a.cc:3:46: error: expected unqualified-id before 'for'
    3 | binary_tree = [{"parent": -1, "sibling": -1} for _ in range(N)]
      |                                              ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if (u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if (T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if (T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = ( h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
  int pp;
  pp = T[u].parent
  if ( pp == NIL ) return NIL;
  if ( T[pp].left != u && T[pp].left != NIL )
    return T[pp].left;
  if ( T[pp].right != u && T[pp].right != NIL )
    return T[pp].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].left != NIL ) deg++;
  if ( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if (T[u].parent == NIL) {
    printf("root\n");
  } else if (T[u].left == NIL && T[u].right == NIL ) {
    cout << "leaf" << endl;
  } else {
    cout << "internal node" << endl;
  }
}

int main() {
  int v, l, r, root = 0;
  cin >> n;

  for (int i = 0; i < n; i++) T[i].parent = NIL;

  for (int i = 0; i < n; i++) {
    cin >> v >> l >> r;
    T[v].left = l;
    T[v].right = r;
    if (l != NIL) T[l].parent = v;
    if (r != NIL) T[r].parent = v;
  }

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) root = i;
  }

  setDepth(root, 0);
  setHeight(root);

  for (int i = 0; i < n; i++) print(i);

  return 0;

}


Compiler output:
a.cc: In function 'int getSibling(int)':
a.cc:29:19: error: expected ';' before 'if'
   29 |   pp = T[u].parent
      |                   ^
      |                   ;
   30 |   if ( pp == NIL ) return NIL;
      |   ~~
Language: C++

#include <iostream>

using namespace std;
#define MAX 26
#define NIL -1
struct Node{
    int p,l,r;
};

Node T[MAX];
int D[MAX];
int H[MAX];
int n;
int getchild(int u){
   if(T[u].l == -1&&T[u].r == -1){
        return 0;
   } else if(T[u].l == -1||T[u].r == -1){
       return 1;
   }else{
       return 2;
   }
}
void getdep(int r,int d){
    D[r] = d;
    if(T[r].l!=NIL){
         getdep(T[r].l,d+1);
    }
    if(T[r].r!=NIL){
        getdep(T[r].r,d+1);
    }

}
int gethigh(int l){
    if(T[l].l == -1&&T[l].r == -1){
        return 0;
    }
    int high = gethigh(T[l].l)>gethigh(T[l.r])?gethigh(T[l].l):gethigh(T[l.r]);
    return high;

}
void print(int u){
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].p<<", ";
    int sibling = -1;
    for(int i=0;i<n;i++){
        if(T[i].p==T[u].p){
            sibling = i;
        }
    }
    cout<<"sibling = "<<sibling<<", ";
    cout<<"degree = "<<getchild(u)<<", ";
    cout<<"depth = "<<D[u]<<", ";
    cout<<"height = "<<gethigh(u)<<", ";
    if(T[u].p == NIL){
        cout<<"root"<<endl;
    }else if(T[u].l == NIL){
        cout<<"leaf"<<endl;
    }else{
        cout<<"internal node"<<endl;
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        T[i].p = T[i].l = T[i].r = NIL;
    }
    for(int i=0;i<n;i++){
        int id,l,r;
        cin>>id>>l>>r;
        T[id].l = l;
        T[id].r = r;
        T[l].p = id;
        T[r].p = id;
    }
    for(int i=0;i<n;i++){
        if(T[i].p==NIL) getdep(i,0);
    }

    for(int i=0;i<n;i++){
        if(T[i].l == NIL){
            gethigh(i,0);
        }
    }

    for(int i=0;i<n;i++){
        print(i);

    }
    return 0;
}



Compiler output:
a.cc: In function 'int gethigh(int)':
a.cc:37:44: error: request for member 'r' in 'l', which is of non-class type 'int'
   37 |     int high = gethigh(T[l].l)>gethigh(T[l.r])?gethigh(T[l].l):gethigh(T[l.r]);
      |                                            ^
a.cc:37:76: error: request for member 'r' in 'l', which is of non-class type 'int'
   37 |     int high = gethigh(T[l].l)>gethigh(T[l.r])?gethigh(T[l].l):gethigh(T[l.r]);
      |                                                                            ^
a.cc: In function 'int main()':
a.cc:83:20: error: too many arguments to function 'int gethigh(int)'
   83 |             gethigh(i,0);
      |             ~~~~~~~^~~~~
a.cc:33:5: note: declared here
   33 | int gethigh(int l){
      |     ^~~~~~~
Language: C++

#include <iostream>

using namespace std;
#define MAX 26
#define NIL -1
struct Node{
    int p,l,r;
};

Node T[MAX];
int D[MAX];
int n;
int getchild(int u){
   if(T[u].l == -1&&T[u].r == -1){
        return 0;
   } else if(T[u].l == -1||T[u].r == -1){
       return 1;
   }else{
       return 2;
   }
}
void getdep(int r,int d){
    if(u==NIL) return;
    D[r] = d;
    getdep(T[r].l,d+1);
    getdep(T[r].r,d+1);
    

}
int gethigh(int u){
    int h1=0,h2=0;
    if(T[u].l!=NIL){
        h1 = gethigh(T[u].l)+1;
    }
    if(T[u].r!=NIL){
        h2 = gethigh(T[u].r)+1;
    }
    return h1>h2?h1:h2;

}
void print(int u){
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].p<<", ";
    int sibling = -1;
    if(T[T[u].p].l!=NIL&&T[T[u].p].l!=u){
        sibling = T[T[u].p].l;
    }
    if(T[T[u].p].r!=NIL&&T[T[u].p].r!=u){
        sibling = T[T[u].p].r;
    }
    cout<<"sibling = "<<sibling<<", ";
    cout<<"degree = "<<getchild(u)<<", ";
    cout<<"depth = "<<D[u]<<", ";
    cout<<"height = "<<gethigh(u)<<", ";
    if(T[u].p == NIL){
        cout<<"root"<<endl;
    }else if(T[u].l == NIL){
        cout<<"leaf"<<endl;
    }else{
        cout<<"internal node"<<endl;
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        T[i].p = T[i].l = T[i].r = NIL;
    }
    for(int i=0;i<n;i++){
        int id,l,r;
        cin>>id>>l>>r;
        T[id].l = l;
        T[id].r = r;
        T[l].p = id;
        T[r].p = id;
    }
    for(int i=0;i<n;i++){
        if(T[i].p==NIL) getdep(i,0);
    }



    for(int i=0;i<n;i++){
        print(i);

    }
    return 0;
}



Compiler output:
a.cc: In function 'void getdep(int, int)':
a.cc:23:8: error: 'u' was not declared in this scope
   23 |     if(u==NIL) return;
      |        ^
Language: C++

#include<stdio.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if (T[u].p == NIL ) cout << "root, ";
  else if ( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for ( i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ){
    if (i) cout << ", "; 
    cout << c;
  }
  cout << "]" << endl;
}


int rec(int u, int p){
  D[u] = p;
  if ( T[u].r != NIL ) rec(T[u].r, p);
  if ( T[u].l != NIL ) rec(T[u].l, p + 1);
}

int main(){
  int i, j, d, v, c, l, r;
  cin >> n;
  for ( i = 0; i < n ; i++) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n; i++){
    cin >> v >> d;
    for ( j = 0; j < d; j++){
      cin >> c;
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for ( i = 0; i < n; i++){
    if (T[i].p == NIL) r = i;
  }
  rec(r, 0);

  for ( i = 0; i < n; i++) print(i);
  
  return 0;
}

Compiler output:
a.cc: In function 'void print(int)':
a.cc:13:3: error: 'cout' was not declared in this scope
   13 |   cout << "node " << u << ": ";
      |   ^~~~
a.cc:2:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<stdio.h>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:27:18: error: 'endl' was not declared in this scope
   27 |   cout << "]" << endl;
      |                  ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<stdio.h>
  +++ |+#include <ostream>
    2 | using namespace std;
a.cc: In function 'int rec(int, int)':
a.cc:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^
a.cc: In function 'int main()':
a.cc:39:3: error: 'cin' was not declared in this scope
   39 |   cin >> n;
      |   ^~~
a.cc:39:3: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if (T[u].p == NIL ) cout << "root, ";
  else if ( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for ( i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ){
    if (i) cout << ", "; 
    cout << c;
  }
  cout << "]" << endl;
}


int rec(int u, int p){
  D[u] = p;
  if ( T[u].r != NIL ) rec(T[u].r, p);
  if ( T[u].l != NIL ) rec(T[u].l, p + 1);
}

int main(){
  int i, j, d, v, c, l, r;
  cin >> n;
  for ( i = 0; i < n ; i++) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n; i++){
    cin >> v >> d;
    for ( j = 0; j < d; j++){
      cin >> c;
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for ( i = 0; i < n; i++){
    if (T[i].p == NIL) r = i;
  }
  rec(r, 0);

  for ( i = 0; i < n; i++) print(i);
  
  return 0;
}

Compiler output:
a.cc: In function 'void print(int)':
a.cc:15:3: error: 'cout' was not declared in this scope
   15 |   cout << "node " << u << ": ";
      |   ^~~~
a.cc:4:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<string.h>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:29:18: error: 'endl' was not declared in this scope
   29 |   cout << "]" << endl;
      |                  ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    3 | #include<string.h>
  +++ |+#include <ostream>
    4 | using namespace std;
a.cc: In function 'int rec(int, int)':
a.cc:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
   37 | }
      | ^
a.cc: In function 'int main()':
a.cc:41:3: error: 'cin' was not declared in this scope
   41 |   cin >> n;
      |   ^~~
a.cc:41:3: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

class Node:
    def __init__(self):
        self.parent = -1
        self.sibling = -1


def dfs(v, d=0):
    G[v].depth, G[v].height = d, 0
    if G[v].left != -1:
        G[v].height = max(G[v].height, dfs(G[v].left, d+1) + 1)
    if G[v].right != -1:
        G[v].height = max(G[v].height, dfs(G[v].right, d+1) + 1)
    return G[v].height

N = int(input())
G = [Node() for _ in range(N)]
for _ in range(N):
    idx, *children = [int(x) for x in input().split()]
    G[idx].left, G[idx].right = children
    if G[idx].left != -1 and G[idx].right != -1:
        G[G[idx].left].sibling, G[G[idx].right].sibling = G[idx].right, G[idx].left
    if G[idx].left != -1 or G[idx].right != -1:
        G[idx].type = 'internal node'
    else:
        G[idx].type = 'leaf'
    for child in children:
        if child != -1:
            G[child].parent = idx
root = [i for i, x in enumerate(G) if x.parent == -1][0]
G[root].type = 'root'
dfs(root)
for i, node in enumerate(G):
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(i, node.parent, node.sibling, (node.left != -1) + (node.right != -1), node.depth, node.height, node.type))

Compiler output:
a.cc:23:23: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes
   23 |         G[idx].type = 'internal node'
      |                       ^~~~~~~~~~~~~~~
a.cc:25:23: warning: multi-character character constant [-Wmultichar]
   25 |         G[idx].type = 'leaf'
      |                       ^~~~~~
a.cc:30:16: warning: multi-character character constant [-Wmultichar]
   30 | G[root].type = 'root'
      |                ^~~~~~
a.cc:33:11: warning: multi-character literal with 76 characters exceeds 'int' size of 4 bytes
   33 |     print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(i, node.parent, node.sibling, (node.left != -1) + (node.right != -1), node.depth, node.height, node.type))
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:2:9: error: expected class-name before '__init__'
    2 |     def __init__(self):
      |         ^~~~~~~~
a.cc:2:9: error: expected '{' before '__init__'
a.cc:2:18: error: 'self' was not declared in this scope
    2 |     def __init__(self):
      |                  ^~~~
Language: C++

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

struct N {
	int l, r, p, d;
	int deg, sib;
	void setd(int d);
	void print();
};

int n, root;
N T[25];
int md;

void N::setd(int _d){
	d=_d++;
	deg=0;
	if (md<d)md=d;
	if (l!=-1)
	{
		T[l].setd(_d);
		deg++;
	}
	if(r!=-1)
	{
		T[r].setd(_d);
		deg++;
	}
	if(deg ==2)
	{
		T[r].sib=l;
		T[l].sib=r;
	}
}

void N::print()
{
	int id =this-T;
	cout<< "node " <<id;
	cout<<": parent = "<<p;
	cout<<": sibling = "<<sib;
	cout<<":degree = "<<deg;
	cout<<": depth = "<<d;
	cout<<":height = "<<md-d;
	if (id==root) cout<<", root"<<endl;
	else if (deg==0) cout<<", leaf"<<endl;
	else cout<<", internal node"<<endl;
}


int main()
{
	memset(T,-1,sizeof(T));
	cin >>n;
	for(int i=0;i<n;i++){
		int id, l, r;
		cin>>id>>l>>r;
		T[id].l=l;
		T[id].r=r;
		T[l].p=id;
		T[r].p=id;
	}
	for(int i=0;i<n;i++){
		if(T[i].p==-1) {
			root=i;
			break;
		}
	}
	T[root].setd(0);
	for(int i=0;i<n;i++){
		T[i].print();
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:9: error: 'memset' was not declared in this scope
   54 |         memset(T,-1,sizeof(T));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdlib>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

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

int main() {
	int x[25][10];
	int c = 0;
	memset(x, -1, sizeof(x));
	int n, a, b;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cin >> x[a][1];
		cin >> x[a][2];
		b = 0;
		if (x[a][1] != -1) {
			x[x[a][1]][0] = i;
			b++;
			
		}
		if (x[a][2] != -1) {
			x[x[a][2]][0] = i;
			b++;
		}
		x[a][4] = b;
	}
	for (int i = 0; i < n; i++) {
		if (x[a][0] == 0) {
			x[a][3] = 0;
		}
		else if (x[a][1] == -1 && x[a][2] == -1) {
			x[a][3] = 2;
		}
		else {
			x[a][3] = 1;
		}
	}
	for(int i = 0; i < n; i++) {
		x[i][6] = 10000;
		if (x[i][0] == 0) {
			x[i][6] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			x[j][6] = min(x[j][6], x[x[j][0]][6] + 1);
		}
	}
	for (int i = 0; i < n; i++) {
		x[i][7] = 10000;
		if (x[i][3] == 2) {
			x[i][7] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			x[j][7] = min(x[j][7], x[x[j][1]][7]);
			x[j][7] = min(x[j][7], x[x[j][2]][7]);
		}
	}
	for (int a = 0; a < n; a++) {
		cout << "node " << a << ": parent = " << x[a][0] << ", sibling = ";
		if (x[x[a][0]][1] == i) {
			x[a][5] = x[x[a][0]][2];
		}
		if (x[x[a][0]][2] == i) {
			x[a][5] = x[x[a][0]][1];
		}
		cout << x[a][5] << ", degree = " << x[a][4] << ", depth = " << x[a][6] << ", height = " << x[a][7] << ;
		if (x[a][3] == 0) {
			cout << ", root" << endl;
		}
		else if (x[a][3] == 1) {
			cout << ", internal node" << endl;
		}
		else {
			cout << ", leaf" << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:38: error: 'i' was not declared in this scope
   64 |                 if (x[x[a][0]][1] == i) {
      |                                      ^
a.cc:67:38: error: 'i' was not declared in this scope
   67 |                 if (x[x[a][0]][2] == i) {
      |                                      ^
a.cc:70:119: error: expected primary-expression before ';' token
   70 |                 cout << x[a][5] << ", degree = " << x[a][4] << ", depth = " << x[a][6] << ", height = " << x[a][7] << ;
      |                                                                                                                       ^
Language: C++

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

int main() {
	int x[25][10];
	int c = 0;
	memset(x, -1, sizeof(x));
	int n, a, b;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cin >> x[a][1];
		cin >> x[a][2];
		b = 0;
		if (x[a][1] != -1) {
			x[x[a][1]][0] = i;
			b++;
			
		}
		if (x[a][2] != -1) {
			x[x[a][2]][0] = i;
			b++;
		}
		x[a][4] = b;
	}
	for (int i = 0; i < n; i++) {
		if (x[a][0] == 0) {
			x[a][3] = 0;
		}
		else if (x[a][1] == -1 && x[a][2] == -1) {
			x[a][3] = 2;
		}
		else {
			x[a][3] = 1;
		}
	}
	for(int i = 0; i < n; i++) {
		x[i][6] = 10000;
		if (x[i][0] == 0) {
			x[i][6] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			x[j][6] = min(x[j][6], x[x[j][0]][6] + 1);
		}
	}
	for (int i = 0; i < n; i++) {
		x[i][7] = 10000;
		if (x[i][3] == 2) {
			x[i][7] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			x[j][7] = min(x[j][7], x[x[j][1]][7]);
			x[j][7] = min(x[j][7], x[x[j][2]][7]);
		}
	}
	for (int a = 0; a < n; a++) {
		cout << "node " << a << ": parent = " << x[a][0] << ", sibling = ";
		if (x[x[a][0]][1] == a) {
			x[a][5] = x[x[a][0]][2];
		}
		if (x[x[a][0]][2] == a) {
			x[a][5] = x[x[a][0]][1];
		}
		cout << x[a][5] << ", degree = " << x[a][4] << ", depth = " << x[a][6] << ", height = " << x[a][7] << ;
		if (x[a][3] == 0) {
			cout << ", root" << endl;
		}
		else if (x[a][3] == 1) {
			cout << ", internal node" << endl;
		}
		else {
			cout << ", leaf" << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:119: error: expected primary-expression before ';' token
   70 |                 cout << x[a][5] << ", degree = " << x[a][4] << ", depth = " << x[a][6] << ", height = " << x[a][7] << ;
      |                                                                                                                       ^
Language: C++


#include <iostream>
using  namespace std;

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

struct Node{
    // ????????????????§????
    int parent;
    int left_child;
    int right_sibling;
};

Node T[MAX];
int n,D[MAX],H[MAX],Deg[MAX]; //depth,height,degree


int getSibling(int u){
    if(T[u].parent == NIL ) return NIL;
    if(T[T[u].parent].left_child != u and T[T[u].parent].left_child != NIL) return T[T[u].parent].left_child;
    if(T[T[u].parent].right_sibling != u and T[T[u].parent].right_sibling != NIL) return T[T[u].parent].right_sibling;
    return NIL;
}

int getDepth(int u){
    int d = 0;
    while(T[u].parent != NIL){
        u =T[u].parent;
        d++;
    }
    return d;
}

int setHeight(int u){
    int h1 = 0 , h2 = 0;
    if (T[u].left_child != NIL) h1 = setHeight(T[u].left_child) + 1;
    if (T[u].right_sibling != NIL) h2 = setHeight(T[u].right_sibling) + 1;
    return H[u] = max(h1,h2);
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    //getSibling
    cout << "degree = " << Deg[u] << ", ";
    //getDegree
    cout << "depth = " << D[u] << ", ";
    //getDepth
    cout << "height = " << H[u] << ", ";
    //getHeight
    if(T[u].parent == NIL) cout << "root";
    else if (T[u].left_child == NIL) cout << "leaf";
    else cout << "internal node";
    cout << endl;
}


int main(){
    int n,num,left,right,deg;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        T[i].parent = T[i].left_child = T[i].right_sibling = NIL;
    }
    for (int i = 0; i < n; ++i) {
        cin >> num >> left >> right;
        T[num].left_child = left;
        if(left != NIL)  deg ++;
        T[num].right_sibling = right; 
        if(right != NIL) deg ++
        if (left != NIL) T[left].parent = num;
        if (right != NIL) T[right].parent =num;
        Deg[i] = deg;
    }

    for (int i = 0; i < n ; ++i) {
        D[i] = getDepth(i);
        H[i] = setHeight(i);
        Deg[i] = getDegree(i);
    }

    for (int i = 0; i < n ; ++i) {
        print(i);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:32: error: expected ';' before 'if'
   71 |         if(right != NIL) deg ++
      |                                ^
      |                                ;
   72 |         if (left != NIL) T[left].parent = num;
      |         ~~                      
a.cc:80:18: error: 'getDegree' was not declared in this scope
   80 |         Deg[i] = getDegree(i);
      |                  ^~~~~~~~~
Language: C++

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
 
const int NIL=-1;
 
struct Node{int parent,left,right;};
Node T[10004];
int n,D[10004],H[10004];
 
void setDepth(int u,int d) {
    if(u==NIL) return;
    D[u]=d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}
 
int setHeight(int u) {
    int h1=0,h2=0;
    if(T[u].left!=NIL) h1=setHeight(T[u].left)+1;
    if(T[u].right!=NIL) h2=setHeight(T[u].right)+1;
 
    return H[u]=max(h1,h2);
}
 
int getSibling(int u) {
    if(T[u].parent==NIL) return NIL;
    if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) return T[T[u].parent].left;
    if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) return T[T[u].parent].right;
    return NIL;
}
 
void print(int u) {
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;
    if(T[u].left!=NIL) deg++;
    if(T[u].right!=NIL) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
 
    if(T[u].parent == NIL) {
        printf("root\n");
    }
    else if(T[u].left==NIL&&T[u].right==NIL) {
        printf("leaf\n");
    }
    else {
        printf("internal node\n");
    }
 
}
 
int main() {
    int v,l,r;
    int root=0;
    cin>>n;
    rep(i,n) T[i].parent=NIL;
    rep(i,n) {
        cin>>v>>l>>r;
        T[v].left=l;
        T[v].right=r;
        if(l!=NIL) T[l].parent=v;
        if(r!=NIL) T[r].parent=v;
    }
    rep(i,n) if(T[i].parent==NIL) root=i;
    setDepth(root,0);
    setHeight(root);
    rep(i,n) print(i);
    return 0;
}

Compiler output:
a.cc:5:9: error: 'pair' does not name a type
    5 | typedef pair<int ,int > P;
      |         ^~~~
a.cc: In function 'int setHeight(int)':
a.cc:26:17: error: 'max' was not declared in this scope
   26 |     return H[u]=max(h1,h2);
      |                 ^~~
a.cc: In function 'void print(int)':
a.cc:37:5: error: 'printf' was not declared in this scope
   37 |     printf("node %d: ",u);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | const int INF=100000000;
a.cc: In function 'int main()':
a.cc:62:5: error: 'cin' was not declared in this scope
   62 |     cin>>n;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | const int INF=100000000;
a.cc:63:9: error: 'i' was not declared in this scope
   63 |     rep(i,n) T[i].parent=NIL;
      |         ^
a.cc:63:5: error: 'rep' was not declared in this scope
   63 |     rep(i,n) T[i].parent=NIL;
      |     ^~~
Language: C++

#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
 
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
 

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status