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

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

void 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(void) {
  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:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
typedef struct{
  int number;
  int sa;//子の数
  int reach;
  int parent;
  int A[100000];
}node;

node B[10000];
int n;

int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<B[i].sa;j++){
      if(num==B[i].A[j]){
	r=i;
	return r;
      }
    }
  }
  return r;
}

int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}



int main(){
  int i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&B[k].sa);
    for(j=0;j<B[k].sa;j++){
      scanf("%d",&B[k].A[j]);
    }
  }
  
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,B[i].parent,B[i].reach);
    if(B[i].sa==0)printf("leaf, ");
    else if(B[i].parent==-1)printf("root, ");
    else printf("internal node, ");
    printf("[");
    for(j=0;j<B[i].sa;j++){
      if(j==0)printf("%d",B[i].A[j]);
      else printf(", %d",B[i].A[j]);
    }
     printf("]\n");

  }
  return 0;
}

Compiler output:
/tmp/ccCFx1Yl.o: in function `parent':
main.c:(.text+0x80): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccCFx1Yl.o
/tmp/ccCFx1Yl.o: in function `reach':
main.c:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccCFx1Yl.o
/tmp/ccCFx1Yl.o: in function `main':
main.c:(.text+0xfe): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccCFx1Yl.o
main.c:(.text+0x1e1): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccCFx1Yl.o
main.c:(.text+0x21e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccCFx1Yl.o
main.c:(.text+0x257): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccCFx1Yl.o
main.c:(.text+0x3fe): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccCFx1Yl.o
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
typedef struct{
  int number;
  int sa;//子の数
  int reach;
  int parent;
  int A[100000];
}node;

node B[100000];
int n;

int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<B[i].sa;j++){
      if(num==B[i].A[j]){
	r=i;
	return r;
      }
    }
  }
  return r;
}

int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}



int main(){
  int i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&B[k].sa);
    for(j=0;j<B[k].sa;j++){
      scanf("%d",&B[k].A[j]);
    }
  }
  
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,B[i].parent,B[i].reach);
    if(B[i].sa==0)printf("leaf, ");
    else if(B[i].parent==-1)printf("root, ");
    else printf("internal node, ");
    printf("[");
    for(j=0;j<B[i].sa;j++){
      if(j==0)printf("%d",B[i].A[j]);
      else printf(", %d",B[i].A[j]);
    }
     printf("]\n");

  }
  return 0;
}

Compiler output:
/tmp/ccrWBeqb.o: in function `parent':
main.c:(.text+0x80): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrWBeqb.o
/tmp/ccrWBeqb.o: in function `reach':
main.c:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrWBeqb.o
/tmp/ccrWBeqb.o: in function `main':
main.c:(.text+0xfe): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrWBeqb.o
main.c:(.text+0x1e1): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrWBeqb.o
main.c:(.text+0x21e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrWBeqb.o
main.c:(.text+0x257): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrWBeqb.o
main.c:(.text+0x3fe): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrWBeqb.o
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
typedef struct{
  int sa;//子の数
  int reach;
  int parent;
  int A[100000];
}node;

node B[100000];
int n;

int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<B[i].sa;j++){
      if(num==B[i].A[j]){
	r=i;
	return r;
      }
    }
  }
  return r;
}

int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}



int main(){
  int i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&B[k].sa);
    for(j=0;j<B[k].sa;j++){
      scanf("%d",&B[k].A[j]);
    }
  }
  
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,B[i].parent,B[i].reach);
    if(B[i].sa==0)printf("leaf, ");
    else if(B[i].parent==-1)printf("root, ");
    else printf("internal node, ");
    printf("[");
    for(j=0;j<B[i].sa;j++){
      if(j==0)printf("%d",B[i].A[j]);
      else printf(", %d",B[i].A[j]);
    }
     printf("]\n");

  }
  return 0;
}

Compiler output:
/tmp/ccki7Q2O.o: in function `parent':
main.c:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccki7Q2O.o
/tmp/ccki7Q2O.o: in function `reach':
main.c:(.text+0xe4): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccki7Q2O.o
/tmp/ccki7Q2O.o: in function `main':
main.c:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccki7Q2O.o
main.c:(.text+0x1d9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccki7Q2O.o
main.c:(.text+0x216): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccki7Q2O.o
main.c:(.text+0x24f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccki7Q2O.o
main.c:(.text+0x3ee): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccki7Q2O.o
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
typedef struct{
  int sa;//子の数
  int reach;
  int parent;
  int A[99999];
}node;

node B[100000];
int n;

int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<B[i].sa;j++){
      if(num==B[i].A[j]){
	r=i;
	return r;
      }
    }
  }
  return r;
}

int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}



int main(){
  int i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&B[k].sa);
    for(j=0;j<B[k].sa;j++){
      scanf("%d",&B[k].A[j]);
    }
  }
  
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,B[i].parent,B[i].reach);
    if(B[i].sa==0)printf("leaf, ");
    else if(B[i].parent==-1)printf("root, ");
    else printf("internal node, ");
    printf("[");
    for(j=0;j<B[i].sa;j++){
      if(j==0)printf("%d",B[i].A[j]);
      else printf(", %d",B[i].A[j]);
    }
     printf("]\n");

  }
  return 0;
}

Compiler output:
/tmp/cc8VxZZn.o: in function `parent':
main.c:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8VxZZn.o
/tmp/cc8VxZZn.o: in function `reach':
main.c:(.text+0xe4): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8VxZZn.o
/tmp/cc8VxZZn.o: in function `main':
main.c:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8VxZZn.o
main.c:(.text+0x1d9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8VxZZn.o
main.c:(.text+0x216): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8VxZZn.o
main.c:(.text+0x24f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8VxZZn.o
main.c:(.text+0x3ee): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8VxZZn.o
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
typedef struct{
  int sa;//子の数
  int reach;
  int parent;
  int A[99999];
}node;

node B[99999];
int n;

int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<B[i].sa;j++){
      if(num==B[i].A[j]){
	r=i;
	return r;
      }
    }
  }
  return r;
}

int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}



int main(){
  int i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&B[k].sa);
    for(j=0;j<B[k].sa;j++){
      scanf("%d",&B[k].A[j]);
    }
  }
  
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,B[i].parent,B[i].reach);
    if(B[i].sa==0)printf("leaf, ");
    else if(B[i].parent==-1)printf("root, ");
    else printf("internal node, ");
    printf("[");
    for(j=0;j<B[i].sa;j++){
      if(j==0)printf("%d",B[i].A[j]);
      else printf(", %d",B[i].A[j]);
    }
     printf("]\n");

  }
  return 0;
}

Compiler output:
/tmp/ccQyUZTa.o: in function `parent':
main.c:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQyUZTa.o
/tmp/ccQyUZTa.o: in function `reach':
main.c:(.text+0xe4): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQyUZTa.o
/tmp/ccQyUZTa.o: in function `main':
main.c:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQyUZTa.o
main.c:(.text+0x1d9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQyUZTa.o
main.c:(.text+0x216): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQyUZTa.o
main.c:(.text+0x24f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQyUZTa.o
main.c:(.text+0x3ee): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQyUZTa.o
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
typedef struct{
  int number;
  int sa;//子の数
  int reach;
  int parent;
  int A[100000];
}node;
 
node B[10000];
int n;
 
int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<B[i].sa;j++){
      if(num==B[i].A[j]){
    r=i;
    return r;
      }
    }
  }
  return r;
}
 
int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}
 
 
 
int main(){
  int i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&B[k].sa);
    for(j=0;j<B[k].sa;j++){
      scanf("%d",&B[k].A[j]);
    }
  }
   
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
   
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
   
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,B[i].parent,B[i].reach);
    if(B[i].sa==0)printf("leaf, ");
    else if(B[i].parent==-1)printf("root, ");
    else printf("internal node, ");
    printf("[");
    for(j=0;j<B[i].sa;j++){
      if(j==0)printf("%d",B[i].A[j]);
      else printf(", %d",B[i].A[j]);
    }
     printf("]\n");
 
  }
  return 0;
}

Compiler output:
/tmp/ccOlND6o.o: in function `parent':
main.c:(.text+0x80): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOlND6o.o
/tmp/ccOlND6o.o: in function `reach':
main.c:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOlND6o.o
/tmp/ccOlND6o.o: in function `main':
main.c:(.text+0xfe): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOlND6o.o
main.c:(.text+0x1e1): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOlND6o.o
main.c:(.text+0x21e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOlND6o.o
main.c:(.text+0x257): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOlND6o.o
main.c:(.text+0x3fe): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOlND6o.o
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
typedef struct{
  int number;
  int sa;//子の数
  int reach;
  int parent;
  short A[100000];
}node;
 
node B[100000];
int n;
 
int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<B[i].sa;j++){
      if(num==B[i].A[j]){
    r=i;
    return r;
      }
    }
  }
  return r;
}
 
int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}
 
 
 
int main(){
  int i,j,k,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&B[k].sa);
    for(j=0;j<B[k].sa;j++){
      scanf("%d",&a);
      B[k].A[j]=(short)a;
    }
  }
   
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
   
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
   
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,B[i].parent,B[i].reach);
    if(B[i].sa==0)printf("leaf, ");
    else if(B[i].parent==-1)printf("root, ");
    else printf("internal node, ");
    printf("[");
    for(j=0;j<B[i].sa;j++){
      if(j==0)printf("%d",B[i].A[j]);
      else printf(", %d",B[i].A[j]);
    }
     printf("]\n");
 
  }
  return 0;
}

Compiler output:
/tmp/ccnDloGV.o: in function `parent':
main.c:(.text+0x7e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnDloGV.o
/tmp/ccnDloGV.o: in function `reach':
main.c:(.text+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnDloGV.o
/tmp/ccnDloGV.o: in function `main':
main.c:(.text+0xfc): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnDloGV.o
main.c:(.text+0x1e5): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnDloGV.o
main.c:(.text+0x222): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnDloGV.o
main.c:(.text+0x25b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnDloGV.o
main.c:(.text+0x3fe): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnDloGV.o
collect2: error: ld returned 1 exit status
Language: C

/* A Rooted Trees */

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

int main(){
  int i, j;
  int n, id, k;
  int temp2;
  int d=0;

  scanf("%d",&n);

  int C[n][3];  /*C[n][0]=P, C[n][1]=L(left child), C[n][2]=R(right sibling)*/

  /* initialize C[n][3]*/
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      C[i][j]=NIL;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    if(k>0){
      // int temp[k];
      int *tmp = malloc(sizeof(int) * k);
      for(j=0;j<k;j++){
	if(j==0){
	  scanf("%d",&temp[0]);
	  C[id][1]=temp[0];
	  C[temp[0]][0]=id;
	}else{
	  scanf("%d",&temp[j]);
	  C[temp[j-1]][2]=temp[j];
	  C[temp[j]][0]=id;
	}
      }
      free(temp);
    }
  }
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",C[i][0]);

    /*search parent*/
    temp2=C[i][0];
    if(temp2!=NIL){
      while(1){
	if(C[temp2][0]==NIL){
	  d++;
	  break;
	}
	else{ 
	  temp2=C[temp2][0];
	  d++;
	}
      }
    }
    printf("depth = %d, ",d);
    d=0;
    
    if(C[i][0]==NIL){
      printf("root, [");
    }else if(C[i][1]==NIL){
      printf("leaf, []\n");
      continue;
    }else{
      printf("internal node, [");
    }

    /*search child*/
    if(C[i][1]!=NIL){
      printf("%d, ",C[i][1]);
      temp2=C[i][1];
      while(1){
	if(C[temp2][2]!=NIL){
	  printf("%d",C[temp2][2]);
	  temp2=C[temp2][2];
	  if(C[temp2][2]!=NIL)printf(", ");
	}else break;
      }
    }
    printf("]\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:27:18: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
   27 |       int *tmp = malloc(sizeof(int) * k);
      |                  ^~~~~~
main.c:4:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
    3 | #include<stdio.h>
  +++ |+#include <stdlib.h>
    4 | #define NIL -1
main.c:27:18: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   27 |       int *tmp = malloc(sizeof(int) * k);
      |                  ^~~~~~
main.c:27:18: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:30:23: error: 'temp' undeclared (first use in this function); did you mean 'tmp'?
   30 |           scanf("%d",&temp[0]);
      |                       ^~~~
      |                       tmp
main.c:30:23: note: each undeclared identifier is reported only once for each function it appears in
main.c:39:7: error: implicit declaration of function 'free' [-Wimplicit-function-declaration]
   39 |       free(temp);
      |       ^~~~
main.c:39:7: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:39:7: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
main.c:39:7: note: include '<stdlib.h>' or provide a declaration of 'free'
Language: C

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

const int MAX = 100000;
int n, pa[MAX], ch[MAX], br[MAX];

void solve(){
  for(int i=0;i<n;i++){
    cout << "node " << i << ": parent = " << pa[i] << ", depth = " << flush;

    int cnt = 0;
    for(int j=i; pa[j]!=-1; j=pa[j]) cnt++;
    cout << cnt << ", " << flush;

    if(pa[i] == -1) cout << "root, " << flush;
    else if(ch[i] == -1) cout << "leaf, " << flush;
    else cout << "internal node, " << flush;

    cout << "[";
    for(int j=ch[i]; j!=-1; j=br[j]){
      if(j != ch[i]) cout << ", ";
      cout << j;
    }
    cout << "]" << endl;
  }
}

int main(){
  fill(pa,pa+MAX,-1);
  fill(ch,ch+MAX,-1);
  fill(br,br+MAX,-1);
  cin >> n;
  for(int i=0;i<n;i++){
    int x,prev,y,c;
    cin >> x >> c;
    for(int j=0;j<c;j++){
      cin >> y;
      pa[y] = x;
      if(j == 0) ch[x] = y;
      else br[prev] = y;
      prev = y;
    }
  }
  solve();
}

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

#include<stdio.h>
#define MAX 100005
#define NIL -1

/*
 p: parent
 l: left-child
 r: right sibling
 */
struct Node{ int p, l, r;};
struct Node T[MAX]; // Tree
int *Child[MAX];

char type[3][20] = {
	"root",
	"internal node",
	"leaf"
};

void print(int u, int n){
	int p = T[u].p;
	int d = 0;
	int t = T[u].p;
	int i, j, z;
	int child[MAX];
	char *mes;
	int isfound;
	while(t != NIL) {
		t = T[t].p;
		d++;
	}
	
	if(p==NIL) {
		mes = type[0];
	} else if(T[u].l == NIL) {
		mes = type[2];
	} else {
		mes = type[1];
	}

	printf("node %d: parent = %d, depth = %d, %s, [", u, p, d, mes);
	for(i=0;i<Child[u][0];i++) {
		if(i==0) {
			printf("%d", Child[u][i+1]);
		} else {
			printf(", %d", Child[u][i+1]);
		}
	}

	printf("]\n");
}

int main(void){
    int i, j, d, v, c, n, old;
    short index[]

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ) {
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for ( i = 0; i < n; i++ ){
        scanf("%d %d", &v, &d);
        Child[v] = (int*)malloc(sizeof(int)*(d+1));
        Child[v][0] = d;
        for ( j = 0; j < d; j++ ){
            scanf("%d", &c);
            Child[v][j+1] = c;
            if(j==0) {
            	T[v].l = c;
            }
            T[c].p = v;
            if(j > 0) {
            	T[c].r = old;
            }
            old = c;
        }
    }
    
    for ( i = 0; i < n; i++ ) print(i, n);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:57:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'scanf'
   57 |     scanf("%d", &n);
      |     ^~~~~
main.c:65:26: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
   65 |         Child[v] = (int*)malloc(sizeof(int)*(d+1));
      |                          ^~~~~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
    1 | #include<stdio.h>
  +++ |+#include <stdlib.h>
    2 | #define MAX 100005
main.c:65:26: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   65 |         Child[v] = (int*)malloc(sizeof(int)*(d+1));
      |                          ^~~~~~
main.c:65:26: note: include '<stdlib.h>' or provide a declaration of 'malloc'
Language: C


#include<stdio.h>

#define N 100000
 
typedef struct{
  int de;
  int pa;
  int ll;
  int sib;
}node;
  
node A[100000];
int n;
 
int depth(int now){
  int dep = 0; 
  while(1){
    if(A[now].pa == -1)return dep;
    else {
      now=A[now].pa;
      dep++;
    }
  }
}
 
void init(){
  int i;
  for(i=0;i<n;i++){
    A[i].pa=-1;
    A[i].ll=-1;
    A[i].sib=-1;
  }
  return;
}
 
int main(int argc,char *argv[]){
  int i,j,now,leaf,k;
   
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%d",&now);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&leaf);
      if(j==0){
    A[now].ll=leaf;
    A[leaf].pa=now;
      }
      else {
    A[now].sib=leaf;
    A[leaf].pa=A[now].pa;
      }  
      now=leaf;
    }
  }
  for(i=0;i<n;i++){
    A[i].de=de(i);
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,A[i].pa,A[i].de);
    if(A[i].pa==-1)printf("root, ");
    else if(A[i].ll==-1)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(j=A[i].ll;j!=-1;j=A[j].sib){
      if(j==A[i].ll)printf("%d",j);
      else printf(", %d",j);
    }
    printf("]\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:59:13: error: implicit declaration of function 'de' [-Wimplicit-function-declaration]
   59 |     A[i].de=de(i);
      |             ^~
Language: C

#include<stdio.h>
#include<stdlib.h>
#define M 100000
 struct node{
  int id;
  int* k;
   int n;
  int p;
  int d;
  int type;
  struct node* next;
  struct node* prev; 
};
typedef struct node * NodePointer ;

NodePointer nil;

NodePointer t[M];
int m[M];
void depth(int key){
  NodePointer x;
  int i=0;
  for(x = t[key];x!=nil;x=x->prev,i++){
 
  }
  t[key]->d=i;
  if(i==0)t[key]->type=-1;
}



void init(){
  nil=malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil; 
}



void def(int key,int n){
  NodePointer x;
  int * m;
  x=t[key];
  x = malloc(sizeof(struct node));
  x->id = key; 
  x->prev = nil; 
  x->n=n;
  x->k=malloc(sizeof(int)*n+1);
  if(n==0)x->type=1;
  else x->type=0;
}



void printList(int n){
  int i,j; 
  for(i=0;i<n;i++){
    depth(i);
    printf("node %d: parent = %d, depth = %d, ",i,t[i]->p,t[i]->d);
    if( t[i]->type== -1) printf("root, ");
    else if(t[i]->type == 0)printf("internal node, ");
    else printf("leaf, ");
    if(t[i]->n==0)printf("[]\n");
    else {
      printf("[");
      for(j=0;j<t[i]->n -1;j++){
    printf("%d, ",t[i]->k[j]);
      }
      printf("%d]\n",t[i]->k[j]);
    }
  }
 

}




void chine(int a,int b,int j){

  t[b]->prev=t[a];
  t[a]->k[j]=b;

}





int main(){
  int i,j,a,b,e,n;


  scanf("%d",&n);
  init();

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


    scanf("%d %d",&a,&b);
    def(a,b);

  }

/*     for(j=0;j<b;j++){ */


/*        scanf("%d",&e); */
/*        chine(i,e,j); */


/*     } */
    
  }
  printList(n);
  

  


  return 0;
}

Compiler output:
main.c:115:3: warning: data definition has no type or storage class
  115 |   printList(n);
      |   ^~~~~~~~~
main.c:115:3: error: type defaults to 'int' in declaration of 'printList' [-Wimplicit-int]
main.c:115:3: error: parameter names (without types) in function declaration [-Wdeclaration-missing-parameter-type]
main.c:115:3: error: conflicting types for 'printList'; have 'int()'
main.c:55:6: note: previous definition of 'printList' with type 'void(int)'
   55 | void printList(int n){
      |      ^~~~~~~~~
main.c:121:3: error: expected identifier or '(' before 'return'
  121 |   return 0;
      |   ^~~~~~
main.c:122:1: error: expected identifier or '(' before '}' token
  122 | }
      | ^
Language: C

#include <stdio.h>

#define N 100001

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

Node T[N];

int main(){
  int n, i, j, buf;
  int id, degree, depth[N];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = N;
    T[i].right = N;
    depth[i] = 0;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d%d", &id, &degree);
    
    if(degree == 1){
      scanf("%d",&T[id].left);
      buf = T[id].left;
      T[buf].parent = id;
    }
    else if(degree > 1){
      scanf("%d",&T[id].left);
      buf = T[id].left;
      for(j = 1; j < degree; j++){
	scanf("%d", &T[buf].right);
	T[buf].parent = id;
	buf = T[buf].right;
      }
      T[buf].parent = id;
    }
  }
  
  for(i = 0; i < n; i++){
    buf = T[i].parent
    while(1){
      if(T[buf].parent == -1) break;
      else {
	buf = T[buf].parent;
	depth[i]++;
      }
}
    printf("node %d: parent = %d, depth = %d,", i, T[i].parent, depth[i]);
    
    if(T[i].parent == -1){
      if(T[i].left == N) printf(" root, []\n");
      else{
      printf(" root, [%d", T[i].left);
      buf = T[i].left;
      while(T[buf].right != N){
	printf(", %d", T[buf].right);
	buf = T[buf].right;
      }
      printf("]\n");
      }
    }
    else if(T[i].left == N)
      printf(" leaf, []\n");
    else{
      printf(" internal node, [%d", T[i].left);
      buf = T[i].left;
      while(T[buf].right != N){
	printf(", %d", T[buf].right);
	buf = T[buf].right;
      }
      printf("]\n");
    }
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:47:22: error: expected ';' before 'while'
   47 |     buf = T[i].parent
      |                      ^
      |                      ;
   48 |     while(1){
      |     ~~~~~
Language: C

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

typedef struct{
  int parent;
  int left;
  int right;
  int k;
}Node;

Node node[N];

int depth(int);

int main(){
  int i, j, id, sub, m, n, child;
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    node[i].left = node[i].parent = NIL;
  }
  for(i = 0;i < n;i++){
    scanf("%d%d", &id, &m);
    node[id].k = m;
    sub = id;
    for(j = 0;j < m;j++){
      scanf("%d", &child);
      if(j == 0){
        node[sub].left = child;
        node[node[sub].left].parent = id;
        sub = child;
      }
      else{
        node[sub].right = child;
        node[node[sub].right].parent = id;
        sub = child;
      }
    }
  }
  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, depth = %d, ", i, node[i].pa\
rent, depth(i));
    if(node[i].left != NIL){
      if(node[i].parent != NIL){
        printf("internal node, [");
      }
      else{
        printf("root, [");
      }
      for(j = 0;j < node[i].k-1;j++){
        if(j == 0){
        if(j == 0){
          sub = node[i].left;
          printf("%d, ", node[i].left);
        }
        else{
          printf("%d, ", node[sub].right);
          sub = node[sub].right;
        }
      }
      if(node[i].k == 1){
        printf("%d]\n", node[i].left);
      }
      else{
        printf("%d]\n", node[sub].right);
      }
    }
    else{
      if(node[i].parent == NIL){
        printf("root, []\n");
      }
      else{
        printf("leaf, []\n");
      }
    }
  }
  return 0;
}

int depth(int id){
  int dep = 0;
  while(1){
    if(node[id].parent == NIL){
      return dep;
    }
    else{
      dep++;
      id = node[id].parent;
    }
  }
}

Compiler output:
main.c: In function 'main':
main.c:68:5: error: expected '}' before 'else'
   68 |     else{
      |     ^~~~
Language: C

#include <stdio.h>
#define N 100000

typedef struct{
  int id,p,d,k;
  int jisu[50];
}Node;

Node tree[N];

void jisu(int,int);

int kaisu = 0,n;

main(){

  int j,i,nodeb;

  scanf("%d",&n);

  for(i = 0 ; i < n; i++){
    tree[i].p = -2;
    tree[i].k = 0;
    tree[i].d = 0;
  }

  for(j = 0 ; j < n; j++){
    scanf("%d",&nodeb);
    // 入力されたノード番号のIDをtreeの”入力されたノード番号”番目に設定する                                                                    
    tree[nodeb].id = nodeb;
    scanf("%d",&tree[nodeb].k);
    jisu(tree[nodeb].k,nodeb);

  }

  for(j = 0 ; j < n; j++ ){

    //if(tree[g].p == -1 || tree[g].p == -2)                                                                                                   
    // if((tree[j].d == tree[tree[j].p].d) && (tree[j].p == -1 || tree[j].p == -2)) tree[j].d++;                                               

    if(tree[j].p == -2) tree[j].p = -1;
    printf("node %d: parent = %d, depth = %d,",tree[j].id,tree[j].p,tree[j].d);

    if(tree[j].p == -1){
      printf(" root, [");
      for(i = 0 ; i < tree[j].k ; i++ ){
        printf("%d",tree[j].jisu[i]);
        if(i != tree[j].k - 1){
          printf(", ");
        }

      }
      printf("]");
    }

 if(tree[j].k == 0 && tree[j].p != -1){
      printf(" leaf, []");
    }

    if(tree[j].k != 0 && tree[j].p != -1){
      printf(" internal node, [");
     for(i = 0 ; i < tree[j].k ; i++ ){
        printf("%d",tree[j].jisu[i]);
        if(i != tree[j].k - 1){
          printf(", ");
        }
     }
      printf("]");
    }

    printf("\n");
  }

  return 0;

}

void jisu(int k,int now){
  int ii,g;

    for(ii = 0 ; ii < k; ii++){
      scanf("%d",&tree[now].jisu[ii]);
      if(tree[now].jisu[ii] == 0 && tree[tree[now].jisu[ii]].d != 0){
        tree[now].p = -1;
      }
    }

      //次数に親のidいれる                                                                                                                     

      tree[tree[now].jisu[ii]].p = now;
      tree[tree[now].jisu[ii]].d = tree[now].d + 1;


      for(g = 0 ; g < n; g++){
        if(tree[g].p == -1 || tree[g].p == -2) continue;
        if(tree[g].d == tree[tree[g].p].d) tree[g].d++;
      }

    }

}











                                                                                                                    

Compiler output:
main.c:15:1: error: return type defaults to 'int' [-Wimplicit-int]
   15 | main(){
      | ^~~~
main.c:101:1: error: expected identifier or '(' before '}' token
  101 | }
      | ^
Language: C

#include<stdio.h>
#define M 100001
typedef struct tree{
  int c[M];
  int d;
  int k;
  int root;
}t;
t T[M];
int n,i,j,l,sum,p;
void node(int i){
  printf("node %d: ",T[i].d);
}
void parent(int i){
  p=0;
  for(l=0;l<n;l++){
    if(i==l)
      l++;
    for(j=0;j<T[l].k;j++){
      if(T[i].d==T[l].c[j]){       
	printf("parent = %d, ",T[l].d);
	p=1;
	break;	
      }      
    }
    if(p==1)
      break;
  }
  if(p==0){
    printf("parent = -1, ");
    T[i].root=1;
  }
}
void depth(int i){
  p=0;
  for(l=0;l<n;l++){
    if(i==l)
      l++;
    for(j=0;j<T[l].k;j++){
      if(T[i].d==T[l].c[j]){   
	sum++;
	depth(l);
	p=1;
	break;
      }
    }
    if(p==1)
      break;
  }
}
void other(int i){
  if(T[i].root==1){
    printf("root, [");
    for(j=0;j<T[i].k-1;j++)
      printf("%d, ",T[i].c[j]);
    if(T[i].k==0)
      printf("]\n");
    else
      printf("%d]\n",T[i].c[T[i].k-1]);
  }
  else{
    if(T[i].k==0)
      printf("leaf, []\n");
    else{
      printf("internal node, [");
      for(j=0;j<T[i].k-1;j++)
	printf("%d, ",T[i].c[j]);
      printf("%d]\n",T[i].c[T[i].k-1]);
    }
  }
}
int main(void){
  int atai;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].root=0;
    scanf("%d%d",&T[i].d,&T[i].k);
    for(j=0;j<T[i].k;j++){
      scanf("%d",&T[i].c[j]);
    }
  } 
  atai=0;
  i=0;
  while(atai!=n){
    if(atai==T[i].d){
      sum=0;
      node(i);
      parent(i);
      depth(i);
      printf("depth = %d, ",sum);
      other(i);
      atai++;
      i=0;
      continue;    
    }
    i++;
  }
  return 0;
}

Compiler output:
/tmp/ccz4X4NO.o: in function `parent':
main.c:(.text+0x47): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0x51): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0x7a): relocation truncated to fit: R_X86_64_PC32 against symbol `j' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0x9f): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0xa5): relocation truncated to fit: R_X86_64_PC32 against symbol `j' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0xd0): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0xff): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccz4X4NO.o
main.c:(.text+0x10b): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>
#define N 100000

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

Node node[N];

main() {
  int i,j,id,k,n,left,child;

  scanf("%d",&n);

  for(i=0; i<n; i++) {
    node[i].parent = -1;
    node[i].left = -1;
    node[i].right = -1;
  }

  for(i=0; i<n; i++) {
    scanf("%d%d",&id,&k);
    for(j=0; j<k; j++){
      scanf("%d",&child);
      if(j == 0)
	node[id].left = child;
      else
	node[left].right = child;
      node[child].parent = id;
      left = child;
    }
  }


  for(i=0; i<n; i++) {
    printf("node %d: parent = %d, depth = %d, ",i,node[i].parent,depth(i));
    judgenode(i);
    Child(i);
  }

  return 0;

}


  int depth(int i) {
    int count=0; parent;
    parent=i;
    while(1) {
      if(node[parent].parent == -1)
	break;
      parent = node[parent].p;
      count+=1;
    }
    return count;
  }


  void judgenode(int i) {
    if(node[i].left == -1 && node[i].parent != -1)
      printf("leaf, ");
    else if(node[i].parent == -1)
      printf("root, ");
    else 
      pintf("internal node ,");
  }


void Child(int i) {
  int sibling;
  printf(" [");
  if(node[i].left != -1) {
    printf("%d",node[i].left);
    sibling = node[i].left;
    while(1) {
      if(node[sibling].right == -1)
	break;
      printf(", %d",node[sibling].right);
      sibling = node[sibling].right;
    }
  }
  printf("]\n");
}

Compiler output:
main.c:12:1: error: return type defaults to 'int' [-Wimplicit-int]
   12 | main() {
      | ^~~~
main.c: In function 'main':
main.c:38:66: error: implicit declaration of function 'depth' [-Wimplicit-function-declaration]
   38 |     printf("node %d: parent = %d, depth = %d, ",i,node[i].parent,depth(i));
      |                                                                  ^~~~~
main.c:39:5: error: implicit declaration of function 'judgenode' [-Wimplicit-function-declaration]
   39 |     judgenode(i);
      |     ^~~~~~~~~
main.c:40:5: error: implicit declaration of function 'Child' [-Wimplicit-function-declaration]
   40 |     Child(i);
      |     ^~~~~
main.c: In function 'depth':
main.c:49:18: error: 'parent' undeclared (first use in this function)
   49 |     int count=0; parent;
      |                  ^~~~~~
main.c:49:18: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:61:8: warning: conflicting types for 'judgenode'; have 'void(int)'
   61 |   void judgenode(int i) {
      |        ^~~~~~~~~
main.c:39:5: note: previous implicit declaration of 'judgenode' with type 'void(int)'
   39 |     judgenode(i);
      |     ^~~~~~~~~
main.c: In function 'judgenode':
main.c:67:7: error: implicit declaration of function 'pintf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   67 |       pintf("internal node ,");
      |       ^~~~~
      |       printf
main.c: At top level:
main.c:71:6: warning: conflicting types for 'Child'; have 'void(int)'
   71 | void Child(int i) {
      |      ^~~~~
main.c:40:5: note: previous implicit declaration of 'Child' with type 'void(int)'
   40 |     Child(i);
      |     ^~~~~
Language: C

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

struct Node{
  int p,l,r;
};
struct Node T[N];

int CalcDepth(int id){
  if(T[id].p==-1)return 0;
  return CalcDepth(T[id].p)+1;
}

int printc(int id){
  if(id==-1) return 0;
  if(T[id].r==-1)printf("%d",id);
  else {
    printf("%d, ",id);
    printc(T[id].r);
  }
  return 0;
}

int main(){
  int n,i,j,id,k,c,pr;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++){   
      T[c].p=id;  
      scanf("%d",&c);
      if(j==0) T[id].l=c;
      else T[pr].r=c;
      pr=c;     
    }
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,CalcDepth(i));
    if(T[i].p==NIL) printf("root, ["); 
    else if(T[i].l==-1) printf("leaf, [");
    else printf("internal node, [");
    printc(T[id].l);
    else printf("]\n");    
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:49:5: error: 'else' without a previous 'if'
   49 |     else printf("]\n");
      |     ^~~~
Language: C

include<stdio.h>
#define NIL -1

int detDepth(int);

typedef struct tree{
  int p; //親
  int l; //一番左の子
  int r; //右の兄弟
}tree;

tree T[100001];

int main(){
  int i,j;
  int n,id; //接点の個数,番号
  int k;    //次数(葉は次数0)
  int c;    //一番左の子の接点番号
  int d[100001];    //深さ
  int u;

  scanf("%d",&n);

  for(i=0 ; i<n ; i++) {
    scanf("%d %d",&id,&k);
    for(j=0 ; j<k ; j++){
      scanf("%d",&c);

      if(j==0) T[id].l = c;
      else {
        T[u].r = c;
        T[c].p = id;
        u = c;
      }
    }
  }
  for(i=0 ; i<n ; i++) d[i] = detDepth(i);

  for(i=0 ; i<n ; i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,d[i]);
    if(T[i].p==NIL) printf("root,[");
    else if(T[i].l==NIL) printf("leaf,[");
    else printf("internal node,[");

    if(T[i].l != NIL){
      printf("%d",T[i].l);
      u = T[i].l;
      while(1){
        if(T[u].r == NIL) break;
        printf(", %d",T[u].r);
        u = T[u].r;
      }
    }
    printf("]\n",u);
  }
  return 0;

}

int detDepth(int p){
  if(T[p].p==NIL) return 0;
  return getDepth(T[p].p)+1;
}

Compiler output:
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include<stdio.h>
      |        ^
main.c: In function 'main':
main.c:22:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   22 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | include<stdio.h>
main.c:22:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   22 |   scanf("%d",&n);
      |   ^~~~~
main.c:22:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:37:31: error: implicit declaration of function 'detDepth' [-Wimplicit-function-declaration]
   37 |   for(i=0 ; i<n ; i++) d[i] = detDepth(i);
      |                               ^~~~~~~~
main.c:40:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   40 |     printf("node %d: parent = %d, depth = %d, ",i,T[i].p,d[i]);
      |     ^~~~~~
main.c:40:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:40:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:40:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: In function 'detDepth':
main.c:62:10: error: implicit declaration of function 'getDepth'; did you mean 'detDepth'? [-Wimplicit-function-declaration]
   62 |   return getDepth(T[p].p)+1;
      |          ^~~~~~~~
      |          detDepth
Language: C

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

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

}Node;

struct Node T[N];

main(){
  int i;
  int j;
  int n;
  int v;
  int d;
  int c;
  int l;

  scanf("%d",&n);
  
  for(i=1 ; i =< n ; i++){
    scanf("%d %d",&v,&d);
    
    for(j=1 ; j =< d ; j++){
      scanf("%d",&c);
      
      if(j==0){
	T[v].l=c;
	l=c;
	T[c].p=v;
      }
      else {
	T[l].r=c;
	l=c;
	T[c].p=v;
      }
    }
    if(T[v].p==0) T[v].p=NIL;
  }
  
  for(i=1 ; i =< n ; i++){
    printf("node %d: parent = %d, depth = %d,,\n",i,T[i].p,getDepth(i));
    
  }
  
  
}

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

Compiler output:
main.c:14:1: error: return type defaults to 'int' [-Wimplicit-int]
   14 | main(){
      | ^~~~
main.c: In function 'main':
main.c:25:16: error: expected expression before '<' token
   25 |   for(i=1 ; i =< n ; i++){
      |                ^
main.c:28:18: error: expected expression before '<' token
   28 |     for(j=1 ; j =< d ; j++){
      |                  ^
main.c:45:16: error: expected expression before '<' token
   45 |   for(i=1 ; i =< n ; i++){
      |                ^
main.c:46:60: error: implicit declaration of function 'getDepth' [-Wimplicit-function-declaration]
   46 |     printf("node %d: parent = %d, depth = %d,,\n",i,T[i].p,getDepth(i));
      |                                                            ^~~~~~~~
Language: C++

#include<iostream>
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:23:26: error: expected ')' before ';' token
   23 |   for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |      ~                   ^
a.cc:23:39: error: expected ';' before ')' token
   23 |   for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |                                       ^
      |                                       ;
a.cc: In function 'int rec(int, int)':
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
   34 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
const double EPS = 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

using namespace std;
#define NIL -1
typedef struct node {
  int id=-1;
  int k;
  int r,l,p;
  int depth = 0;
} tree;
tree t[100000];
int getdepth(int u){
  int d=0;
  while(t[u].p!=NIL){
    u=t[u].p;
    d++;
  }
  return d;
}

int main(){
  int n;
  int temp;
  cin>>n;
  for(int i=0;i<n;i++){
    scanf("%d%d",&t[i].id,&t[i].k);
    for(int j=0;j<t[i].k;j++){
      scanf("%d",&temp);
      if(j==0)T[i]
    }
  }


  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:15: error: 'T' was not declared in this scope
   40 |       if(j==0)T[i]
      |               ^