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

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

typedef struct{
  int p,l,r;
}Node;
 
Node T[MAX];
 
int depth(int x){
  if(T[x].p == NIL){
    return 0;
  }
  else{
    return depth(T[x].p) + 1;
  }       
}

void cprint(int y){
  if(y == NIL) return;

  if(T[y].r == NIL){
    printf("%d",y);
  }

  else{printf("%d, ",y);
  }

  if(T[y].r == NIL)return;
 
  cprint(T[y].r);
}
 
void print(int z){
 
  printf("node %d: parent = %d, depth = %d, %s, [",u,T[z].p,depth(z),T[z].p == NIL?"root":(T[z].l == NIL?"leaf":"internal node"));
  cprint(T[z].l);
  printf("]\n");
} 
 
 
int main(){
  int i,j,n,v,s,c,tmp;
   
  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",&v);
    scanf("%d",&s);
    for(j = 0;j < s;j++){
      scanf("%d",&c);
      T[c].p = v;
      if(j == 0){
	T[v].l = c;
      }else{
	T[tmp].r = c;
      }
      tmp = c;     
    }
  } 
  for(i = 0;i < n;i++){
    print(i);
  }
  return 0;
}

Compiler output:
main.c: In function 'print':
main.c:37:52: error: 'u' undeclared (first use in this function)
   37 |   printf("node %d: parent = %d, depth = %d, %s, [",u,T[z].p,depth(z),T[z].p == NIL?"root":(T[z].l == NIL?"leaf":"internal node"));
      |                                                    ^
main.c:37:52: note: each undeclared identifier is reported only once for each function it appears in
Language: C

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

typedef struct{
  int parent;
  int leftch;
  int rightsib;
}Node;



int main(){

  int n,i,j,id,child,k,r,depth;
  Node *Tree;

  scanf("%d",&n);

  Tree = malloc(sizeof(Node)*n);

  for(i = 0 ; i < n ; i++){
    Tree[i].parent = -1;
    Tree[i].leftch = -1;
    Tree[i].rightsib = -1;
  }

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

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

      scanf("%d",&child);
      Tree[child].parent = id;

      if(j == 0)
	Tree[id].leftch = child;
 else if(j > 0){
          Tree[r].rightsib = child;
        }
        r = child;
      }
    }
  
  

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

      depth = 0;

      i = Tree[j].parent;

    while(i != -1){
      i = Tree[i].parent;
      depth++;
    }
    if(depth == 0){
      printf("node %d: parent = %d, depth = %d, root, ",j,Tree[j].parent,depth);
    }
    else if(Tree[j].leftch == -1){
      printf("node %d: parent = %d, depth = %d, leaf, ",j,Tree[j].parent,depth);
    }
    else{
      printf("node %d: parent = %d, depth = %d, internal node, ",j,Tree[j].parent,depth);
    }
  
    i = Tree[j].leftch;
    printf("[");
    if(i != -1){
      printf("%d",i);
    }
    while(i != -1){ 
      i = Tree[i].rightsib;
      
      if(i != -1){
        printf(", %d", i);
      }
    }
    printf("]\n");
    }
    retunr 0;
}

Compiler output:
main.c: In function 'main':
main.c:80:5: error: 'retunr' undeclared (first use in this function)
   80 |     retunr 0;
      |     ^~~~~~
main.c:80:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:80:11: error: expected ';' before numeric constant
   80 |     retunr 0;
      |           ^~
      |           ;
Language: C

#include <stdio.h>
#define MAX 100001

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

Node T[MAX];

int main(void){
  
  int n,i,j,k,id,child,sibling,tmp2;

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

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

int depth(int node){
    if(T[node].parent == NIL){
      return 0;
    }
    else {
      return depth(T[node].p) + 1;
    }
  }
  
void print_degree(int i){
  
  if(i != NIL){
    if(T[i].right == NIL)
      printf("%d",i);
    else printf("%d, ",i);
  print_degree(T[i].right);
  }
}

Compiler output:
main.c: In function 'main':
main.c:35:63: error: implicit declaration of function 'depth' [-Wimplicit-function-declaration]
   35 |     printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth(i));
      |                                                               ^~~~~
main.c:36:23: error: 'NIL' undeclared (first use in this function)
   36 |     if(T[i].parent == NIL)
      |                       ^~~
main.c:36:23: note: each undeclared identifier is reported only once for each function it appears in
main.c:38:17: error: 'Node' {aka 'struct tree'} has no member named 'l'
   38 |     else if(T[i].l == NIL)
      |                 ^
main.c:42:5: error: implicit declaration of function 'print_degree' [-Wimplicit-function-declaration]
   42 |     print_degree(T[i].l);
      |     ^~~~~~~~~~~~
main.c:42:22: error: 'Node' {aka 'struct tree'} has no member named 'l'
   42 |     print_degree(T[i].l);
      |                      ^
main.c: In function 'depth':
main.c:50:26: error: 'NIL' undeclared (first use in this function)
   50 |     if(T[node].parent == NIL){
      |                          ^~~
main.c:54:27: error: 'Node' {aka 'struct tree'} has no member named 'p'
   54 |       return depth(T[node].p) + 1;
      |                           ^
main.c: At top level:
main.c:58:6: warning: conflicting types for 'print_degree'; have 'void(int)'
   58 | void print_degree(int i){
      |      ^~~~~~~~~~~~
main.c:42:5: note: previous implicit declaration of 'print_degree' with type 'void(int)'
   42 |     print_degree(T[i].l);
      |     ^~~~~~~~~~~~
main.c: In function 'print_degree':
main.c:60:11: error: 'NIL' undeclared (first use in this function)
   60 |   if(i != NIL){
      |           ^~~
Language: C

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

struct {
  int id;
  int num;
  int *list_c;
  int pare;
  int depth;
  int flag;
} typedef Tree;

int main(){
  Tree *k;
  int n, id, num, p, i, j;

  scanf("%d", &n);
  k = (Tree *)malloc(sizeof(Tree) * n);

  if(k == NULL){
    printf("error!\n");
    exit(-1);
  }

  for(i = 0; i < n; i++){
    scanf("%d %d", &id, &num);
    k[id].id = id;
    k[id].num = num;
    if(num != 0){
      k[id].list_c = (int *)malloc(sizeof(int) * num);
      if( k[id].list_c == NULL){
	printf("error!\n");
	free(k);
	exit(-1);
      }
      for(j = 0; j < num_c; j++) scanf("%d", &k[id].list_c[j]); 
    }
  }
  
  for(i = 0; i < n; i++){
    k[i].pare = -1;
    k[i].depth = 0;
    k[i].flag = 0;
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < k[i].num; j++){
      if( i == 0) k[ k[i].list_c[j] ].flag = 1; 
      k[ k[i].list_c[j] ].pare = k[i].id;  
      k[ k[i].list_c[j] ].depth += 1; 

      p = t[i].parent;
      while(p != -1){
	k[ k[i].list_c[j] ].depth += 1; 
	p = k[p].pare;
      }
      
    }
  }
  
  for(i = 0; i < n; i++){
    if(t[i].flag == 1) k[i].depth += k[ k[i].pare ].depth;
  }

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", k[i].id, k[i].pare, k[i].depth);
    if(k[i].pare == -1) printf("root, [");
    else if(k[i].num != 0) printf("internal node, [");
    else printf("leaf, [");
    if(k[i].num != 0){
      for(j = 0; j < k[i].num - 1; j++) printf("%d, ", k[i].list_c[j]);
      printf("%d]\n", k[i].list_c[j]);
    }
    else printf("]\n");
  }

  for(i = 0; i < n; i++) free( k[i].list_c );
  free(k);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:36:22: error: 'num_c' undeclared (first use in this function); did you mean 'num'?
   36 |       for(j = 0; j < num_c; j++) scanf("%d", &k[id].list_c[j]);
      |                      ^~~~~
      |                      num
main.c:36:22: note: each undeclared identifier is reported only once for each function it appears in
main.c:52:11: error: 't' undeclared (first use in this function)
   52 |       p = t[i].parent;
      |           ^
Language: C

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

struct {
  int id;
  int num;
  int *list_c;
  int pare;
  int depth;
  int flag;
} typedef Tree;

int main(){
  Tree *k;
  int n, id, num, p, i, j;

  scanf("%d", &n);
  k = (Tree *)malloc(sizeof(Tree) * n);

  if(k == NULL){
    printf("error!\n");
    exit(-1);
  }

  for(i = 0; i < n; i++){
    scanf("%d %d", &id, &num);
    k[id].id = id;
    k[id].num = num;
    if(num != 0){
      k[id].list_c = (int *)malloc(sizeof(int) * num);
      if( k[id].list_c == NULL){
	printf("error!\n");
	free(k);
	exit(-1);
      }
      for(j = 0; j < num; j++) scanf("%d", &k[id].list_c[j]); 
    }
  }
  
  for(i = 0; i < n; i++){
    k[i].pare = -1;
    k[i].depth = 0;
    k[i].flag = 0;
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < k[i].num; j++){
      if( i == 0) k[ k[i].list_c[j] ].flag = 1; 
      k[ k[i].list_c[j] ].pare = k[i].id;  
      k[ k[i].list_c[j] ].depth += 1; 

      p = k[i].parent;
      while(p != -1){
	k[ k[i].list_c[j] ].depth += 1; 
	p = k[p].pare;
      }
      
    }
  }
  
  for(i = 0; i < n; i++){
    if(t[i].flag == 1) k[i].depth += k[ k[i].pare ].depth;
  }

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", k[i].id, k[i].pare, k[i].depth);
    if(k[i].pare == -1) printf("root, [");
    else if(k[i].num != 0) printf("internal node, [");
    else printf("leaf, [");
    if(k[i].num != 0){
      for(j = 0; j < k[i].num - 1; j++) printf("%d, ", k[i].list_c[j]);
      printf("%d]\n", k[i].list_c[j]);
    }
    else printf("]\n");
  }

  for(i = 0; i < n; i++) free( k[i].list_c );
  free(k);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:52:16: error: 'Tree' has no member named 'parent'; did you mean 'pare'?
   52 |       p = k[i].parent;
      |                ^~~~~~
      |                pare
main.c:62:8: error: 't' undeclared (first use in this function)
   62 |     if(t[i].flag == 1) k[i].depth += k[ k[i].pare ].depth;
      |        ^
main.c:62:8: note: each undeclared identifier is reported only once for each function it appears in
Language: C

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

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

struct Node T[N];
int a,f[N];

int getDepth(int b){
  int count = 0,i ;
  while(T[b].p!=NIL){
    b = T[b].p;
    count++;
  }
  return count;
}




void print(int u){
  int i;
  printf("node %d: parent = %d, depth =%d, ",u,T[u].p,getDepth(u));
  if(T[u].p == NIL)printf("root, ");
  else if(T[u].l == NIL)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  printChild(T[u].l);
  printf("]\n");
}
void printChild(int u){
  int c;
  c = T[u].l;
  while(c != NIL){
    printf("%d, ",u);
    c = T[c].r;
  }
}




int main(){
  int i,j,a,b,c,d,k=0,l;
  scanf("%d",&a);
 for(i=0;i<a;i++){
   T[i].p = T[i].l = T[i].r = NIL;
 }
  for(i=0;i<a;i++){
    scanf("%d %d",&c,&d);

    for(j=0;j<d;j++){
      scanf("%d",&b);
      if(j==0)T[c].l = b;
      else T[k].r = b;
	k=b;
	T[b].p = c;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p == NIL) r = i;
  }
  for(i=0;i<a;i++){
    print(i);
    printf("\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'print':
main.c:33:3: error: implicit declaration of function 'printChild' [-Wimplicit-function-declaration]
   33 |   printChild(T[u].l);
      |   ^~~~~~~~~~
main.c: At top level:
main.c:36:6: warning: conflicting types for 'printChild'; have 'void(int)'
   36 | void printChild(int u){
      |      ^~~~~~~~~~
main.c:33:3: note: previous implicit declaration of 'printChild' with type 'void(int)'
   33 |   printChild(T[u].l);
      |   ^~~~~~~~~~
main.c: In function 'main':
main.c:65:13: error: 'n' undeclared (first use in this function)
   65 |   for(i=0;i<n;i++){
      |             ^
main.c:65:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:66:23: error: 'r' undeclared (first use in this function)
   66 |     if(T[i].p == NIL) r = i;
      |                       ^
Language: C

#include <stdio.h>

void depth(int,int);

int d[100000],k[100000],c[100000][100000],g[100000],root,id;

int main()
{
  int i,n,id,j,p[100000],type[100000];

  scanf("%d",&n);

  for(j=0;j<n;j++) d[j]=0;

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

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

	d[c[id][i]]= d[id] + 1;
  
      p[c[id][i]] = id;
    }

    if(d[id]==0){
 p[id] =-1;
    }
  }

  /*type*/
  for(j=0;j<n;j++){
    if(p[j]==-1) {
type[j] = 0;
 root = j;
    }
    else if(k[j]==0) type[j] = 1;
    else type[j] = 2;
  }

  depth(root,0);

  for(j=0;j<n;j++){
    printf("node %d: parent = %d, depth = %d, ",j,p[j],g[j]);

    if(type[j]==0) printf("root, ");
    else if(type[j]==1) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(i=0;i<k[j];i++){
      printf("%d",c[j][i]);  
      if(i!=k[j]-1) printf(", ");
    }
    printf("]\n");
  }

  return 0;
}

void depth(int v,int dep){
  int i;
  g[root]=0;
  if(k[v]==0) return;
  dep++;
  for(i=0;i<k[v];i++){    
    g[c[v][i]]=dep;
  }

  for(i=0;i<k[v];i++){
    depth(c[v][i],dep);
  }

}

Compiler output:
/tmp/ccxOAyK6.o: in function `main':
main.c:(.text+0x20b): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccxOAyK6.o
main.c:(.text+0x25c): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccxOAyK6.o
main.c:(.text+0x288): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccxOAyK6.o
/tmp/ccxOAyK6.o: in function `depth':
main.c:(.text+0x3f2): relocation truncated to fit: R_X86_64_PC32 against symbol `root' defined in .bss section in /tmp/ccxOAyK6.o
main.c:(.text+0x403): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccxOAyK6.o
main.c:(.text+0x46e): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccxOAyK6.o
collect2: error: ld returned 1 exit status
Language: C

include <stdio.h>
#define NIL -1
 
struct setu {
  int r;
  int l;
  int p;
};
struct setu T[100000];
int n,K[100000];
 
int depth(int,int);
void strk(int);
 
int main(){
 
  int i,j,id,k,c,l,r;
 
  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++){
 
      scanf("%d",&c);
      if( j==0 ) T[id].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = id;
 
    }
  }
 
  for(i=0;i<n;i++){
    if(T[i].p == NIL) r = i;
  }
  depth(r,0);
 
  for(i = 0;i<n ;i++) strk(i);
 
  return 0;
}
 
int depth(int u, int p){
  K[u] = p;
  if(T[u].r != NIL) depth(T[u].r,p);
  if(T[u].l != NIL) depth(T[u].l,p + 1);
}
 
void strk(int u){
 
  int i,c;
 
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", K[u]);
 
  if(T[u].p == NIL ) printf("root, ");
 
  else if(T[u].l == NIL) printf("leaf, ");
 
  else printf("internal node, ");
 
  printf("[");
 
  for(i=0,c = T[u].l ; c !=NIL;i++,c = T[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

Compiler output:
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include <stdio.h>
      |         ^
main.c:9:13: error: array type has incomplete element type 'struct setu'
    9 | struct setu T[100000];
      |             ^
main.c: In function 'main':
main.c:19:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   19 |   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:19:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   19 |   scanf("%d",&n);
      |   ^~~~~
main.c:19:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c: In function 'strk':
main.c:62:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   62 |   printf("node %d: ", u);
      |   ^~~~~~
main.c:62:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:62:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:62:3: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C

include <stdio.h>
#define NIL -1
 
struct setu {
  int r;
  int l;
  int p;
};
struct setu T[100000];
int n,K[100000];
 
int depth(int,int);
void strk(int);
 
int main(){
 
  int i,j,id,k,c,l,r;
 
  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++){
 
      scanf("%d",&c);
      if( j==0 ) T[id].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = id;
 
    }
  }
 
  for(i=0;i<n;i++){
    if(T[i].p == NIL) r = i;
  }
  depth(r,0);
 
  for(i = 0;i<n ;i++) strk(i);
 
  return 0;
}
 
int depth(int u, int p){
  K[u] = p;
  if(T[u].r != NIL) depth(T[u].r,p);
  if(T[u].l != NIL) depth(T[u].l,p + 1);
}
 
void strk(int u){
 
  int i,c;
 
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", K[u]);
 
  if(T[u].p == NIL ) printf("root, ");
 
  else if(T[u].l == NIL) printf("leaf, ");
 
  else printf("internal node, ");
 
  printf("[");
 
  for(i=0,c = T[u].l ; c !=NIL;i++,c = T[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

Compiler output:
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include <stdio.h>
      |         ^
main.c:9:13: error: array type has incomplete element type 'struct setu'
    9 | struct setu T[100000];
      |             ^
main.c: In function 'main':
main.c:19:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   19 |   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:19:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   19 |   scanf("%d",&n);
      |   ^~~~~
main.c:19:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c: In function 'strk':
main.c:62:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   62 |   printf("node %d: ", u);
      |   ^~~~~~
main.c:62:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:62:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:62:3: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C


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

typedef struct{
  int p,l,r;
}Node;
Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);
  if(T[u].p == NIL)printf("root, ");
  else if(T[u].l == NIL)printf("leaf, ");
  else printf("internal code, ");

  printf("[");
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

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

int main(){
  int i,j,d,v,c,l,r;
  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",&v);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&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;
  }

Compiler output:
main.c: In function 'setDepth':
main.c:29:6: error: type of 'u' defaults to 'int' [-Wimplicit-int]
   29 | void setDepth(u,p){
      |      ^~~~~~~~
main.c:29:6: error: type of 'p' defaults to 'int' [-Wimplicit-int]
main.c: In function 'main':
main.c:52:3: error: expected declaration or statement at end of input
   52 |   }
      |   ^
Language: C

#include <stdio.h>

void depth(int,int);

int k[100000],c[100000][20],g[20],root,id;

int main()
{
  int i,n,id,j,p[100000],type[100000];

  scanf("%d",&n);

  for(j=0;j<n;j++) d[j]=0;

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

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

      //	d[c[id][i]]= d[id] + 1;
  
      p[c[id][i]] = id;
    }

    if(d[id]==0){
 p[id] =-1;
    }
  }

  /*type*/
  for(j=0;j<n;j++){
    if(p[j]==-1) {
type[j] = 0;
 root = j;
    }
    else if(k[j]==0) type[j] = 1;
    else type[j] = 2;
  }

  depth(root,0);

  for(j=0;j<n;j++){
    printf("node %d: parent = %d, depth = %d, ",j,p[j],g[j]);

    if(type[j]==0) printf("root, ");
    else if(type[j]==1) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(i=0;i<k[j];i++){
      printf("%d",c[j][i]);  
      if(i!=k[j]-1) printf(", ");
    }
    printf("]\n");
  }

  return 0;
}

void depth(int v,int dep){
  int i;
  g[root]=0;
  if(k[v]==0) return;
  dep++;
  for(i=0;i<k[v];i++){    
    g[c[v][i]]=dep;
  }

  for(i=0;i<k[v];i++){
    depth(c[v][i],dep);
  }

}

Compiler output:
main.c: In function 'main':
main.c:13:20: error: 'd' undeclared (first use in this function)
   13 |   for(j=0;j<n;j++) d[j]=0;
      |                    ^
main.c:13:20: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define MAX 10005

typedef struct node{
  int x,y,z;
}Node;

Node t[MAX];
int n,d[MAX];

void print(int u);
int rec(int u,int x);

int main(){
  int i,j,a,b,c,y,z;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].x=T[i].y=T[i].z=-1;

  for(i=0;i<n;i++){
    scanf("%d%d",&b,&a);
    for(j=0;j<a;j++){
      scanf("%d",&c);
      if(j==0)
	T[a]=c;
      else T[y].z=c;
      x=c;
      T[c].x=b;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].x==-1)y=i;
  }
  rec(z,0);

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

void print(int u){
  int i,c;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].x);
  printf("depth = %d, ",D[u]);

  if(T[u].p==-1) printf("root, ");
  else if (T[u].y==-1) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].y; c!=-1; i++, c=T[c].z){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u, int p){
  D[u] = p;
  if(T[u].z !=-1) rec(T[u].z, x);
  if(T[u].y !=-1) rec(T[u].y, x+1);
}

Compiler output:
main.c: In function 'main':
main.c:18:5: error: 'T' undeclared (first use in this function)
   18 |     T[i].x=T[i].y=T[i].z=-1;
      |     ^
main.c:18:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:27:7: error: 'x' undeclared (first use in this function)
   27 |       x=c;
      |       ^
main.c: In function 'print':
main.c:44:26: error: 'T' undeclared (first use in this function)
   44 |   printf("parent = %d, ",T[u].x);
      |                          ^
main.c:45:25: error: 'D' undeclared (first use in this function)
   45 |   printf("depth = %d, ",D[u]);
      |                         ^
main.c: In function 'rec':
main.c:61:3: error: 'D' undeclared (first use in this function)
   61 |   D[u] = p;
      |   ^
main.c:62:6: error: 'T' undeclared (first use in this function)
   62 |   if(T[u].z !=-1) rec(T[u].z, x);
      |      ^
main.c:62:31: error: 'x' undeclared (first use in this function)
   62 |   if(T[u].z !=-1) rec(T[u].z, x);
      |                               ^
Language: C

#include <stdio.h>
#define N -1
  
struct s {
  int a;
  int b;
  int c;
};


struct s T[100000];
int n,K[100000];
  
int dep(int,int);
void str(int);
  
int main(){
  
  int i,j,id,k,d,l,r,m,n;
  
  scanf("%d",&n);
  
  
  for(i=0;i<n;i++){
    T[i].a = N;
    T[i].c = N;
    T[i].b = N;
  } 
  for(i = 0;i < n; i++){
    scanf("%d",&i); 
    scanf("%d",&m);
   
    for(j = 0;j < m;j++){
  
      scanf("%d",&c);
      if( j==0 ) T[id].c= d;
      else T[l].b = d;
      c = d;
      T[d].a = id;
  
    }
  }
  
  for(i  = 0;i < n; i++){
    if(T[i].a == N) 
    b = i;
  }
  dep( b , 0);
  
  for(i = 0;i < n ; i++) str(i);
  
  return 0;
}
  
int dep(int u, int a){
  K[u] = a;
  if(T[u].b != N) depth(T[u].b,a);
  if(T[u].c != N) depth(T[u].c,a + 1);
}
  
void str(int u){
  
  int i,d;
  
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].a);
  printf("depth = %d, ", K[u]);
  
  if(T[u].a == N ) printf("root, ");
  
  else if(T[u].c == N) printf("leaf, ");
  
  else printf("internal node, ");
  
  printf("[");
  
  for(i=0,d = T[u].c ; d !=N;i++,d = T[d].b){
    if(i) printf(", ");
    printf("%d",d);
  }
  printf("]\n");
}
 

*/

Compiler output:
main.c: In function 'main':
main.c:35:19: error: 'c' undeclared (first use in this function)
   35 |       scanf("%d",&c);
      |                   ^
main.c:35:19: note: each undeclared identifier is reported only once for each function it appears in
main.c:46:5: error: 'b' undeclared (first use in this function)
   46 |     b = i;
      |     ^
main.c: In function 'dep':
main.c:57:19: error: implicit declaration of function 'depth'; did you mean 'dep'? [-Wimplicit-function-declaration]
   57 |   if(T[u].b != N) depth(T[u].b,a);
      |                   ^~~~~
      |                   dep
main.c: At top level:
main.c:85:2: error: expected identifier or '(' before '/' token
   85 | */
      |  ^
Language: C

#include <stdio.h>
#define N -1
  
struct s {
  int a;
  int b;
  int c;
};


struct s T[100000];
int n,K[100000];
  
int dep(int,int);
void str(int);
  
int main(){
  
  int i,j,id,k,d,l,r,m,n,c,b,a;
  
  scanf("%d",&n);
  
  
  for(i=0;i<n;i++){
    T[i].a = N;
    T[i].c = N;
    T[i].b = N;
  } 
  for(i = 0;i < n; i++){
    scanf("%d",&i); 
    scanf("%d",&m);
   
    for(j = 0;j < m;j++){
  
      scanf("%d",&c);
      if( j==0 ) T[id].c= d;
      else T[c].b = d;
      c = d;
      T[d].a = id;
  
    }
  }
  
  for(i  = 0;i < n; i++){
    if(T[i].a == N) 
    b = i;
  }
  dep( b , 0);
  
  for(i = 0;i < n ; i++) str(i);
  
  return 0;
}
  
int dep(int u, int a){
  K[u] = a;
  if(T[u].b != N) depth(T[u].b,a);
  if(T[u].c != N) depth(T[u].c,a + 1);
}
  
void str(int u){
  
  int i,d;
  
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].a);
  printf("depth = %d, ", K[u]);
  
  if(T[u].a == N ) printf("root, ");
  
  else if(T[u].c == N) printf("leaf, ");
  
  else printf("internal node, ");
  
  printf("[");
  
  for(i=0,d = T[u].c ; d !=N;i++,d = T[d].b){
    if(i) printf(", ");
    printf("%d",d);
  }
  printf("]\n");
}
 

Compiler output:
main.c: In function 'dep':
main.c:57:19: error: implicit declaration of function 'depth'; did you mean 'dep'? [-Wimplicit-function-declaration]
   57 |   if(T[u].b != N) depth(T[u].b,a);
      |                   ^~~~~
      |                   dep
Language: C

    printf("]\n");

    }

    return 0;

}
 
int depth(int a){

    if(tree[a].parent != -1){

        count++;

        return depth(tree[a].parent);

    }

    else
      return count;

}
 
void output(int b){
    
  if(b != -1){
    
    if(count != 0)
      printf(", ");
         
    count++;

    printf("%d", b);

    output(tree[b].right);

    }
  
}

Compiler output:
main.c:1:12: error: expected declaration specifiers or '...' before string constant
    1 |     printf("]\n");
      |            ^~~~~
main.c:3:5: error: expected identifier or '(' before '}' token
    3 |     }
      |     ^
main.c:5:5: error: expected identifier or '(' before 'return'
    5 |     return 0;
      |     ^~~~~~
main.c:7:1: error: expected identifier or '(' before '}' token
    7 | }
      | ^
main.c: In function 'depth':
main.c:11:8: error: 'tree' undeclared (first use in this function)
   11 |     if(tree[a].parent != -1){
      |        ^~~~
main.c:11:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:13:9: error: 'count' undeclared (first use in this function)
   13 |         count++;
      |         ^~~~~
main.c: In function 'output':
main.c:28:8: error: 'count' undeclared (first use in this function)
   28 |     if(count != 0)
      |        ^~~~~
main.c:29:7: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   29 |       printf(", ");
      |       ^~~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf'
  +++ |+#include <stdio.h>
    1 |     printf("]\n");
main.c:29:7: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   29 |       printf(", ");
      |       ^~~~~~
main.c:29:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:33:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   33 |     printf("%d", b);
      |     ^~~~~~
main.c:33:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:35:12: error: 'tree' undeclared (first use in this function)
   35 |     output(tree[b].right);
      |            ^~~~
Language: C

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

typedef struct {
  int parent;
  int next;
  int rig;
  
}Node;
  
Node tree[MAX];
int s_dep(int,int);
int main(void){

  int i,t,n,id,deg,cha,fr;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    tree[i].parent=END;
    tree[i].next=END;
    tree[i].rig=-1;

  }

  //input the tree
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&deg);
    for(t=0;t<deg;t++){
      scanf("%d",&cha);
      if(t==0){
        tree[cha].parent=id;
        tree[id].next = cha;
        fr = cha;
      }
      else {
        tree[fr].rig = cha;
        tree[cha].parent = id;
        fr = cha;
      }
    }    
  }
  //output the tree
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",tree[i].parent);
    printf("depth = %d, ",s_dep(i,0));
    if(tree[i].parent==END) printf("root, [");
    else if(tree[i].next != END) printf("internal node, [");
    else {
      printf("leaf, []\n");
      continue;
    }
    printf("%d",tree[i].next);
    cha =  tree[i].next;
    while(1){
      if(tree[cha].rig !=END){
        printf(", %d",tree[cha].rig);
        cha = tree[cha].rig;
      }
      else break;
      
    }
    printf("]\n");
    
    
  }
  
  return 0;
}


int s_dep(int id,int c){
  int i;
  int de = 0;

  if(tree[id].parent!=-1){
    de = s_dep(tree[id].parent,c);
    return de+1;
  }
  else return c;

}
ss

Compiler output:
main.c:84:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
   84 | ss
      | ^~
Language: C

#include <stdio.h>
 
#define max 100000
#define nil -1
void print(int);
void depth(int, int);
 
struct Node {
        int p, l, r;
};
struct Node a[MAX];
int n,dp[MAX];
 
int main(){
        int i,j,v,dg,c,l,r;
        scanf("%d",&n);
 
 
        for(i=0; i<n; i++) {
                A[i].p = nil;
                A[i].l = nil;
                A[i].r = nil;
        }
 
        for(i=0; i<n; i++) {
                scanf("%d%d",&v, &dg);
                for(j=0; j<dg; j++) {
                        scanf("%d", &c);
                        if(j==0) {
                                a[v].l = c;
                        }else {
                                a[l].r = c;
                        }
                        l = c;
                        A[c].p = v;
                }
        }
 
        for(i=0; i<n; i++) {
                if(a[i].p == nil) {
                        r = i;
                }
        }
        depth(r, 0);
 
        for(i=0; i<n; i++) {
                print(i);
        }
 
        return 0;
}
 
 
void print(int node) {
        int i, c;
 
        printf("node %d: ",node);
        printf("parent = %d, ", a[node].p);
        printf("depth = %d, ", dp[node]);
 
        if(A[node].p == nil) {
                printf("root, ");
        }else if(A[node].l == nil) {
                printf("leaf, ");
        }else {
                printf("internal node, ");
        }
 
        printf("[");
        c = a[node].l;
        while(c!=NIL) {
                if(c==a[node].l) {
                        printf("%d",c);
                }else {
                        printf(", %d", c);
                }
                c = a[c].r;
        }
        printf("]\n");
}
 
 
void depth(int node, int dep){
        dp[node] = dep;
        if(A[node].r!=NIL) {
                depth(A[node].r, dep);
        }
        if(A[node].l!=NIL) {
                Depth(A[node].l, dep+1);
        }
}

Compiler output:
main.c:11:15: error: 'MAX' undeclared here (not in a function)
   11 | struct Node a[MAX];
      |               ^~~
main.c: In function 'main':
main.c:20:17: error: 'A' undeclared (first use in this function)
   20 |                 A[i].p = nil;
      |                 ^
main.c:20:17: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'print':
main.c:61:12: error: 'A' undeclared (first use in this function)
   61 |         if(A[node].p == nil) {
      |            ^
main.c:71:18: error: 'NIL' undeclared (first use in this function)
   71 |         while(c!=NIL) {
      |                  ^~~
main.c: In function 'depth':
main.c:85:12: error: 'A' undeclared (first use in this function)
   85 |         if(A[node].r!=NIL) {
      |            ^
main.c:85:23: error: 'NIL' undeclared (first use in this function)
   85 |         if(A[node].r!=NIL) {
      |                       ^~~
main.c:89:17: error: implicit declaration of function 'Depth'; did you mean 'depth'? [-Wimplicit-function-declaration]
   89 |                 Depth(A[node].l, dep+1);
      |                 ^~~~~
      |                 depth
Language: C

#include<stdio.h>
#define MAX 100000
#define NIL -1
 
typedef struct{
  int oya, left, right;
}Node;
 
Node Tree[MAX];
int n, Depth[MAX];
 
int getDepth(int);
void print(int);
 
int child[MAX];
 
int main(void){
  int i, j;
  int d, v;
 
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ) {
    Tree[i].oya = NIL;
    Tree[i].left = NIL;
    Tree[i].right = NIL;
  }
 
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &child[j]);
 
      Tree[child[j]].oya = v;
       
      
      if(j == 0)
    Tree[vertex].left = child[0];
       
      else
    Tree[child[j - 1]].right = child[j];
    }
  }
   
  for ( i = 0; i < n; i++ )
    Depth[i] = getDepth(i);
   
  for ( i = 0; i < n; i++ )
    print(i);
   
  return 0;
}
 
int getDepth(int u){
  int d = 0;
 
  while(Tree[u].oya >= 0){
    u = Tree[u].oya;
    d++;
  }
 
  return d;
}
 
void print(int u){
 
  int i, cnt = 0;
 
  printf("node %d: parent = %d, depth = %d, ",u,Tree[u].oya,Depth[u]);
 
  if(Tree[u].oya == NIL)
    printf("root, [");
 
  else if(Tree[u].left == NIL)
    printf("leaf, [");
 
  else
    printf("internal node, [");
 
  u = Tree[u].left;
  while(u != NIL){
    if(cnt == 0)
      printf("%d",u); 
 
    else
      printf(", %d",u);
   
    u = Tree[u].right;
    cnt++;
 
     
  
 }
 
 
    printf("]\n");
 
}

Compiler output:
main.c: In function 'main':
main.c:38:10: error: 'vertex' undeclared (first use in this function)
   38 |     Tree[vertex].left = child[0];
      |          ^~~~~~
main.c:38:10: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
 
#define max 100000
#define nil -1
void print(int);
void depth(int, int);
 
struct Node {
        int p, l, r;
};
struct Node a[MAX];
int n,dp[MAX];
 
int main(){
        int i,j,v,dg,c,l,r;
        scanf("%d",&n);
 
 
        for(i=0; i<n; i++) {
                A[i].p = nil;
                A[i].l = nil;
                A[i].r = nil;
        }
 
        for(i=0; i<n; i++) {
                scanf("%d%d",&v, &dg);
                for(j=0; j<dg; j++) {
                        scanf("%d", &c);
                        if(j==0) {
                                a[v].l = c;
                        }else {
                                a[l].r = c;
                        }
                        l = c;
                        A[c].p = v;
                }
        }
 
        for(i=0; i<n; i++) {
                if(a[i].p == nil) {
                        r = i;
                }
        }
        depth(r, 0);
 
        for(i=0; i<n; i++) {
                print(i);
        }
 
        return 0;
}
 
 
void print(int node) {
        int i, c;
 
        printf("node %d: ",node);
        printf("parent = %d, ", a[node].p);
        printf("depth = %d, ", dp[node]);
 
        if(A[node].p == nil) {
                printf("root, ");
        }else if(a[node].l == nil) {
                printf("leaf, ");
        }else {
                printf("internal node, ");
        }
 
        printf("[");
        c = a[node].l;
        while(c!=nil) {
                if(c==a[node].l) {
                        printf("%d",c);
                }else {
                        printf(", %d", c);
                }
                c = a[c].r;
        }
        printf("]\n");
}
 
 
void depth(int node, int dep){
        dp[node] = dep;
        if(a[node].r!=nil) {
                depth(a[node].r, dep);
        }
        if(a[node].l!=nil) {
                depth(a[node].l, dep+1);
        }
}

Compiler output:
main.c:11:15: error: 'MAX' undeclared here (not in a function)
   11 | struct Node a[MAX];
      |               ^~~
main.c: In function 'main':
main.c:20:17: error: 'A' undeclared (first use in this function)
   20 |                 A[i].p = nil;
      |                 ^
main.c:20:17: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'print':
main.c:61:12: error: 'A' undeclared (first use in this function)
   61 |         if(A[node].p == nil) {
      |            ^
Language: C

#include <stdio.h>
 
#define max 100000
#define nil -1
void print(int);
void depth(int, int);
 
struct Node {
        int p, l, r;
};
struct Node a[MAX];
int n,dp[MAX];
 
int main(){
        int i,j,v,dg,c,l,r;
        scanf("%d",&n);
 
 
        for(i=0; i<n; i++) {
                A[i].p = nil;
                A[i].l = nil;
                A[i].r = nil;
        }
 
        for(i=0; i<n; i++) {
                scanf("%d%d",&v, &dg);
                for(j=0; j<dg; j++) {
                        scanf("%d", &c);
                        if(j==0) {
                                a[v].l = c;
                        }else {
                                a[l].r = c;
                        }
                        l = c;
                        A[c].p = v;
                }
        }
 
        for(i=0; i<n; i++) {
                if(a[i].p == nil) {
                        r = i;
                }
        }
        depth(r, 0);
 
        for(i=0; i<n; i++) {
                print(i);
        }
 
        return 0;
}
 
 
void print(int node) {
        int i, c;
 
        printf("node %d: ",node);
        printf("parent = %d, ", a[node].p);
        printf("depth = %d, ", dp[node]);
 
        if(a[node].p == nil) {
                printf("root, ");
        }else if(a[node].l == nil) {
                printf("leaf, ");
        }else {
                printf("internal node, ");
        }
 
        printf("[");
        c = a[node].l;
        while(c!=nil) {
                if(c==a[node].l) {
                        printf("%d",c);
                }else {
                        printf(", %d", c);
                }
                c = a[c].r;
        }
        printf("]\n");
}
 
 
void depth(int node, int dep){
        dp[node] = dep;
        if(a[node].r!=nil) {
                depth(a[node].r, dep);
        }
        if(a[node].l!=nil) {
                depth(a[node].l, dep+1);
        }
}

Compiler output:
main.c:11:15: error: 'MAX' undeclared here (not in a function)
   11 | struct Node a[MAX];
      |               ^~~
main.c: In function 'main':
main.c:20:17: error: 'A' undeclared (first use in this function)
   20 |                 A[i].p = nil;
      |                 ^
main.c:20:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
 
#define max 100000
#define nil -1
void print(int);
void depth(int, int);
 
struct Node {
        int p, l, r;
};
struct Node a[max];
int n,dp[max];
 
int main(){
        int i,j,v,dg,c,l,r;
        scanf("%d",&n);
 
 
        for(i=0; i<n; i++) {
                A[i].p = nil;
                A[i].l = nil;
                A[i].r = nil;
        }
 
        for(i=0; i<n; i++) {
                scanf("%d%d",&v, &dg);
                for(j=0; j<dg; j++) {
                        scanf("%d", &c);
                        if(j==0) {
                                a[v].l = c;
                        }else {
                                a[l].r = c;
                        }
                        l = c;
                        A[c].p = v;
                }
        }
 
        for(i=0; i<n; i++) {
                if(a[i].p == nil) {
                        r = i;
                }
        }
        depth(r, 0);
 
        for(i=0; i<n; i++) {
                print(i);
        }
 
        return 0;
}
 
 
void print(int node) {
        int i, c;
 
        printf("node %d: ",node);
        printf("parent = %d, ", a[node].p);
        printf("depth = %d, ", dp[node]);
 
        if(a[node].p == nil) {
                printf("root, ");
        }else if(a[node].l == nil) {
                printf("leaf, ");
        }else {
                printf("internal node, ");
        }
 
        printf("[");
        c = a[node].l;
        while(c!=nil) {
                if(c==a[node].l) {
                        printf("%d",c);
                }else {
                        printf(", %d", c);
                }
                c = a[c].r;
        }
        printf("]\n");
}
 
 
void depth(int node, int dep){
        dp[node] = dep;
        if(a[node].r!=nil) {
                depth(a[node].r, dep);
        }
        if(a[node].l!=nil) {
                depth(a[node].l, dep+1);
        }
}

Compiler output:
main.c: In function 'main':
main.c:20:17: error: 'A' undeclared (first use in this function)
   20 |                 A[i].p = nil;
      |                 ^
main.c:20:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
 
#define max 100000
#define nil -1
void print(int);
void depth(int, int);
 
struct Node {
        int p, l, r;
};
struct Node a[max];
int n,dp[max];
 
int main(){
        int i,j,v,dg,c,l,r;
        scanf("%d",&n);
 
 
        for(i=0; i<n; i++) {
                a[i].p = nil;
                a[i].l = nil;
                a[i].r = nil;
        }
 
        for(i=0; i<n; i++) {
                scanf("%d%d",&v, &dg);
                for(j=0; j<dg; j++) {
                        scanf("%d", &c);
                        if(j==0) {
                                a[v].l = c;
                        }else {
                                a[l].r = c;
                        }
                        l = c;
                        A[c].p = v;
                }
        }
 
        for(i=0; i<n; i++) {
                if(a[i].p == nil) {
                        r = i;
                }
        }
        depth(r, 0);
 
        for(i=0; i<n; i++) {
                print(i);
        }
 
        return 0;
}
 
 
void print(int node) {
        int i, c;
 
        printf("node %d: ",node);
        printf("parent = %d, ", a[node].p);
        printf("depth = %d, ", dp[node]);
 
        if(a[node].p == nil) {
                printf("root, ");
        }else if(a[node].l == nil) {
                printf("leaf, ");
        }else {
                printf("internal node, ");
        }
 
        printf("[");
        c = a[node].l;
        while(c!=nil) {
                if(c==a[node].l) {
                        printf("%d",c);
                }else {
                        printf(", %d", c);
                }
                c = a[c].r;
        }
        printf("]\n");
}
 
 
void depth(int node, int dep){
        dp[node] = dep;
        if(a[node].r!=nil) {
                depth(a[node].r, dep);
        }
        if(a[node].l!=nil) {
                depth(a[node].l, dep+1);
        }
}

Compiler output:
main.c: In function 'main':
main.c:35:25: error: 'A' undeclared (first use in this function)
   35 |                         A[c].p = v;
      |                         ^
main.c:35:25: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define N 100000

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

Node T[N];

int depth(int);
int degree(int);

int main()
{
  int n,i,j,id,d,c,k;

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

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

int degree(int y)
{
  if(y==-1){
    return 0;
  }

  if(T[y].r==-1){
    printf("%d",y);
  }
  else{
    printf("%d, ",y);
    degree(T[y].r);
  }
}

Compiler output:
main.c: In function 'main':
main.c:27:7: error: implicit declaration of function 'scan'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   27 |       scan("%d",&c);
      |       ^~~~
      |       scanf
main.c: In function 'depth':
main.c:60:26: error: expected ')' before ';' token
   60 |   return 1 + depth(T[x].p;
      |                   ~      ^
      |                          )
main.c:60:27: error: expected ';' before '}' token
   60 |   return 1 + depth(T[x].p;
      |                           ^
      |                           ;
   61 | }
      | ~
Language: C

#include<stdio.h>
#include <stdlib.h>
#define N 100000

typedef struct{
  int p;
  int k;
  int *child;
}Node;

int depth_count(Node*,int,int);

int main(){
  int num,i,j,k,number;
  Node node[N]; 
  
  scanf("%d",&num);

  for(i=0; i<num; i++){
    scanf("%d",&number);
    scanf("%d",&node[i].k);
    node[i].child = (int *)malloc(sizeof(int) * node[i].k);
    for(j=0; j<node[i].k; j++){
      scanf("%d",&node[i].child[j]);
      node[node[i].child[j]].p = i;
    }
    node[0].p = -1;
  }
  
  
  for(i=0; i<num; i++){
    printf("node %d: parent= %d, ",i,node[i].p);
    printf("depth = %d, ",depth_count(node,i,0));
    
    if(node[i].p==-1) printf("root, [");
    else if(node[i].k==0) printf("leaf, [");
    else printf("internal node, [");
    
    for(j=0; j<node[i].k; j++){
      printf("%d",node[i].child[j]);
      if(j+1<node[i].k) printf(", ");
    }
    printf("]\n");
  }
  

  return 0;
}

Compiler output:
/usr/bin/ld: /tmp/cc7pO2Va.o: in function `main':
main.c:(.text+0x1ba): undefined reference to `depth_count'
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
#include <stdlib.h>
#define N 100000

typedef struct{
  int p;
  int k;
  int *child;
}Node;

int depth_count(Node*,int,int);

int main(){
  int num,i,j,k,number;
  Node node[N]; 
  
  scanf("%d",&num);

  for(i=0; i<num; i++){
    scanf("%d",&number);
    scanf("%d",&node[i].k);
    node[i].child = (int *)malloc(sizeof(int) * node[i].k);
    for(j=0; j<node[i].k; j++){
      scanf("%d",&node[i].child[j]);
      node[node[i].child[j]].p = i;
    }
    node[0].p = -1;
  }
  
  
  for(i=0; i<num; i++){
    printf("node %d: parent= %d, ",i,node[i].p);
    printf("depth = %d, ",depth_count(node,i,0));
    
    if(node[i].p==-1) printf("root, [");
    else if(node[i].k==0) printf("leaf, [");
    else printf("internal node, [");
    
    for(j=0; j<node[i].k; j++){
      printf("%d",node[i].child[j]);
      if(j+1<node[i].k) printf(", ");
    }
    printf("]\n");
  }
  

  return 0;
}

Compiler output:
/usr/bin/ld: /tmp/ccmfW73F.o: in function `main':
main.c:(.text+0x1ba): undefined reference to `depth_count'
collect2: error: ld returned 1 exit status