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

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

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

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

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

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

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

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

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

Compiler output:
main.c: In function 'setHeight':
main.c:22:20: error: 'NUL' undeclared (first use in this function); did you mean 'NIL'?
   22 |   if(T[u].right != NUL) h2 = setHeight(T[u].right) + 1;
      |                    ^~~
      |                    NIL
main.c:22:20: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>

#define N 25

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

int n,depth[N],height[N];

void getdepth(int);
int getheight(int);

main() {
  int i, d, id, c, l, in;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++){
    T[i].r = -1;
    T[i].l = -1;
    T[i].in = -1;
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d",&id,&l,&in);
    if(l != -1){
      T[l].r = id;
    }
    if(in != -1){
      T[in].r = id;
    }
    T[id].l = 1;
    T[id].in = in;
  }
  for(i = 0 ; i < n ; i++){
    if(T[i].l != -1){
      T[i].t++;
    }
    if(T[i].in != -1){
      T[i].t++;
    }
  }
  for(i = 0 ; i < n ; i++){
    if(T[i].r == -1){
      depth[i] = 0;
      getdepth(i);
      break;
    }
  }
  for(i = 0 ; i < n ; i++){
    height[i] = getheight(i);
  }
  
  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, ", i, T[i].r);
    if(T[i].r == -1)
      printf("sibling = %d, ",T[i].r);
    else if(T[T[i].r].in == i)
      printf("sibling = %d, ", T[T[i].r].l);
    else printf("sibling = %d, ", T[T[i].r].in);
		
    printf("degree = %d, ", T[i].t);
		
    printf("depth = %d, height = %d, ", depth[i], height[i]);
    
    if(T[i].r == -1) printf("root");
    else if(T[i].t == 0) printf("leaf");
    else prinf("internal node");
    printf("\n");
  }
  return 0;
}
void getdepth(int u){
  if(T[u].in != -1){
    depth[T[u].in] = depth[u]+1;
    getdepth(T[u].in);
  }
  if(T[u].l != -1){
    depth[T[u].l] = depth[u]+1;
    getdepth(T[u].l);
  }
}
int getheight(int u){
  int tmp,sum;
  if(T[u].in == -1 && T[u].l == -1) return 0;
  if(T[u].l != -1){
	tmp = getheight(T[u].l)+1;
      }
      if(T[u].in != -1){
	sum = getheight(T[u].in)+1;
      }
      if(tmp > sum) return tmp;
      else return sum;
      }

Compiler output:
main.c:13:1: error: return type defaults to 'int' [-Wimplicit-int]
   13 | main() {
      | ^~~~
main.c: In function 'main':
main.c:66:10: error: implicit declaration of function 'prinf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   66 |     else prinf("internal node");
      |          ^~~~~
      |          printf
Language: C

#include <stdio.h>
#define N 10000
 
typedef struct{
  int p;
  int l;
  int r;
}Node;
 
Node T[N];
int n, D[N], H[N];
 
void setDepth(int u, int d){
  if(u == -1) return;
  D[u] = d;
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
}
 
int setHeight(int u){
  int h1=0, h2=0;
  if(T[u].l != -1) h1 = setHeight(T[u].l) + 1;
  if(T[u].r != -1) h2 = setHeight(T[u].r) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}
 
int getSibling(int u){
  if(T[u].p == -1) return -1;
  if(T[T[u].p].l != u && T[T[u].p].l != -1) return  T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != -1) return T[T[u].p].r;
  return -1;
}
 
int main(){
  int i,v,l,r,d,r=0;
 
  scanf("%d", &n);
 
  for(i=0; i<n; i++) T[i].p = -1;
 
  for(i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != -1) T[l].p = v;
    if(r != -1) T[r].p = v;
  }
 
  for(i=0; i<n; i++){
    if(T[i].p == -1) r = i;
  }
 
  setDepth(r, 0);
  setHeight(r);
 
  for(i=0; i<n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", T[i].p);
    printf("sibling = %d, ", getSibling(i));
    d = 0;
    if(T[i].l != -1) deg++;
    if(T[i].r != -1) deg++;
    printf("degree = %d, ", d);
    printf("depth = %d, ", D[i]);
    printf("height = %d, ", H[i]);
 
    if(T[i].p == -1) printf("root\n");
    else if(T[i].l == -1 && T[i].r == -1) printf("leaf\n");
    else printf("internal node\n");
  }
   
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:35:17: error: redeclaration of 'r' with no linkage
   35 |   int i,v,l,r,d,r=0;
      |                 ^
main.c:35:13: note: previous declaration of 'r' with type 'int'
   35 |   int i,v,l,r,d,r=0;
      |             ^
main.c:61:22: error: 'deg' undeclared (first use in this function)
   61 |     if(T[i].l != -1) deg++;
      |                      ^~~
main.c:61:22: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define N 10000
 
typedef struct{
  int p,l,r;
}Node;
 
Node T[N];
int n, D[N], H[N];
 
void setDepth(int u, int d){
  if(u == -1) return;
  D[u] = d;
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
}
 
int setHeight(int u){
  int h1=0, h2=0;
  if(T[u].l != -1) h1 = setHeight(T[u].l) + 1;
  if(T[u].r != -1) h2 = setHeight(T[u].r) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}
 
int getSibling(int u){
  if(T[u].p == -1) return -1;
  if(T[T[u].p].l != u && T[T[u].p].l != -1) return  T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != -1) return T[T[u].p].r;
  return -1;
}
 
int main(){
  int i, v, l, r, d, root=0;
 
  scanf("%d", &n);
 
  for(i=0; i<n; i++) T[i].p = -1;
 
  for(i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != -1) T[l].p = v;
    if(r != -1) T[r].p = v;
  }
 
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
 
  setDepth(root, 0);
  setHeight(root);
 
  for(i=0; i<n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", T[i].p);
    printf("sibling = %d, ", getSibling(i));
    deg = 0;
    if(T[i].l != -1) deg++;
    if(T[i].r != -1) deg++;
    printf("degree = %d, ", d);
    printf("depth = %d, ", D[i]);
    printf("height = %d, ", H[i]);
 
    if(T[i].p == -1) printf("root\n");
    else if(T[i].l == -1 && T[i].r == -1) printf("leaf\n");
    else printf("internal node\n");
  }
   
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:58:5: error: 'deg' undeclared (first use in this function)
   58 |     deg = 0;
      |     ^~~
main.c:58:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define N 10000
void setDepth(int u,int d);
int setHeight(int u);
int getSibling(int u);
typedef struct{
  int p;
  int l;
  int r;
}Node;
 
Node T[N];
int n,D[N],H[N];
 
void setDepth(int u,int d){
  if(u == -1) break;
  D[u] = d;
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
}
 
int setHeight(int u){
  int h1=0, h2=0;
  if(T[u].l != -1) h1 = setHeight(T[u].l)+1;
  if(T[u].r != -1) h2 = setHeight(T[u].r)+1;
  return H[u]=(h1 > h2 ? h1 : h2);
}
 
int getSibling(int u){
  if(T[u].p==-1) return -1;
  if(T[T[u].p].l!=u && T[T[u].p].l!=-1) return  T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=-1) return T[T[u].p].r;
  return -1;
}
 
int main(){
  int i,v,l,r,degree,root=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = -1;
  
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l!=-1) T[l].p = v;
    if(r!=-1) T[r].p = v;
  }
 
  for(i=0;i<n;i++){
    if(T[i].p==-1) root = i;
  }
 
  setDepth(root,0);
  setHeight(root);
 
  for(i=0; i<n; i++){
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("sibling = %d, ",getSibling(i));
    degree = 0;
    if(T[i].l != -1) degree++;
    if(T[i].r != -1) degree++;
    printf("degree = %d, ",degree);
    printf("depth = %d, ",D[i]);
    printf("height = %d, ",H[i]);
    if(T[i].p == -1) printf("root\n");
    else if(T[i].l == -1 && T[i].r == -1) printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'setDepth':
main.c:16:15: error: break statement not within loop or switch
   16 |   if(u == -1) break;
      |               ^~~~~
Language: C

#include<stdio.h>
#define MAX 100001
#define N -1
typedef struct{
  int parent,x,y;
}Node;
Node Tree[MAX];
int u,a,de[MAX];
int get(int);
void pr(int);
int main(){
  int i,j,l=0,d,v,z;
  scanf("%d" , &u);
  for(i = 0;i < u; i++){
    Tree[i].parent = N;
    Tree[i].x = N;
    Tree[i].y = N;
  }
  for( i = 0; i < u; i++){
    scanf("%d %d", &v,&d);
    for(j = 0;j<d;j++){
      scanf("%d" , &z);
      if(j ==0)Tree[v].x = z;
      else if(j != 0) Tree[l].y = z;
      l = z;
      Tree[z].parent = v;
    }
  }
  
    
  a = 0;
  for(i = 0;i < u; i++){
    de[i] = get(i);
    if(de[i] > a) a = de[i];
  }
  for(i=0;i<u;i++){
    pr(i);
  }
  return 0;
}
int get(int n){
  int d = 0;
  while(1){
    n = Tree[n].parent;
    if(n == N)break;
    d++;
  }
  return d;
}
void pr(int n){
  int i , j;
  printf("node %d: " , n);
  printf("parent = %d, ", Tree[n].parent);
  printf("depth = %d, ", de[n]);
  if(Tree[n].parent == -1)printf("root, ");
  else if(Tree[n].x == -1)printf("leaf, ");
  else{
    printf("internal node, ");
  }
  printf("[");
  for(i=0, j = Tree[n].x;j != N ; i++,j = Tree[j].y){
    // for(j = Tree[n].x; j != -1;j = Tree[j].y){
      if(i)printf(", ");
      printf("%d", j);
    }
  }
  printf("]\n");
}
      

Compiler output:
main.c:67:10: error: expected declaration specifiers or '...' before string constant
   67 |   printf("]\n");
      |          ^~~~~
main.c:68:1: error: expected identifier or '(' before '}' token
   68 | }
      | ^
Language: C

#include <stdio.h>
#include <stdlib.h>
 
struct node{
    int id;
    struct node *parentNode;
    struct node *first;
    struct node *sibling;
};
 
struct node* createNode(int);
struct node* searchNode(int);
int getHeight(struct node* nd);
 
struct node* nodes[26];
int n;
 
int main(){
 
int i,j;
int id;
int tmpId;
int left, right;
int depth;
struct node* currentNode;
struct node* tmpNode;
struct node* leftChild;
struct node* rightChild;
 
scanf("%d",&n);
     
for(i=0;i<n;i++){
     
    scanf("%d",&id);
    currentNode = createNode(id);
     
    scanf("%d",&left);
    leftChild = createNode(left);
    scanf("%d",&right);
    rightChild = createNode(right);
     
    if(leftChild){
        leftChild->sibling = rightChild;
        leftChild->parentNode = currentNode;
        currentNode->first = leftChild;
    }
    if(rightChild){
        rightChild->sibling = leftChild;
        rightChild->parentNode = currentNode;
        if(leftChild==NULL) currentNode->first = rightChild;
    }
     
}
     
    for(i=0; i<n; i++){
         
        printf("node %d: ",nodes[i]->id);
        printf("parent = %d, ",(nodes[i]->parentNode?nodes[i]->parentNode->id:-1));
        printf("sibling = %d, ",(nodes[i]->sibling?nodes[i]->sibling->id:-1));
        printf("degree = ");
        if(nodes[i]->first){
            if(nodes[i]->first->sibling) printf("2");
            else printf("1");
        }else{
            printf("0");    
        }
        printf(", ");
         
        depth = 0;
        tmpNode = nodes[i]->parentNode;
        while(tmpNode){
            depth++;
            tmpNode = tmpNode->parentNode;
        }
        printf("depth = %d, ",depth);
        printf("height = %d, ",getHeight(nodes[i]));
 
        if(depth==0) printf("root");
        else if(nodes[i]->first==NULL) printf("leaf");
        else printf("internal node");
         
        printf("\n");
         
    }
 
return 0;
}
 
struct node* createNode(int id){
    struct node *newNode;
    if(id < 0) return NULL;
    if(newNode = searchNode(id)) return newNode;
    newNode = (struct node*)malloc(sizeof(struct node));
    newNode->id=id;
    newNode->parentNode = NULL;
    newNode->first = NULL;
    newNode->sibling = NULL;
    nodes[id] = newNode;
    return newNode;
}
 
struct node* searchNode(int id){
    if(nodes[id]) return nodes[id];
    return NULL;
}
 
int getHeight(struct node* nd){
    int tmpLeft=-1, tmpRight=-1;
    if(nd->first) tmpLeft = getHeight(nd->firstChild);
    if(nd->first && nd->first->sibling) tmpRight = getHeight(nd->first->sibling);
    return (tmpLeft>tmpRight?tmpLeft:tmpRight)+1;
}

Compiler output:
main.c: In function 'getHeight':
main.c:109:41: error: 'struct node' has no member named 'firstChild'
  109 |     if(nd->first) tmpLeft = getHeight(nd->firstChild);
      |                                         ^~
Language: C

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

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

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

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

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

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

void printer(int u){
  printf("node %d: ",T[u]);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

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

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

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

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

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

Compiler output:
main.c: In function 'setHeight':
main.c:24:8: error: implicit declaration of function 'setheight'; did you mean 'setHeight'? [-Wimplicit-function-declaration]
   24 |     h2=setheight(T[u].right)+1;
      |        ^~~~~~~~~
      |        setHeight
main.c: In function 'getSibling':
main.c:30:8: error: expected expression before '[' token
   30 |   if(T[[u].parent].left != u && T[T[u].paret].left != NIL)
      |        ^
main.c:31:17: error: request for member 'paret' in something not a structure or union
   31 |     return T[T[u.paret]].left;
      |                 ^
main.c:32:8: error: expected expression before '[' token
   32 |   if(T[[u].parent].right != u && T[T[u].paret].right != NIL)
      |        ^
main.c:33:17: error: request for member 'paret' in something not a structure or union
   33 |     return T[T[u.paret]].right;
      |                 ^
Language: C

  else return countj;
}

int sibling(int m)
{
  int i;
  for(i=0;i<n;i++)
    {
      if((A[i].id!=m)&&(A[m].parent==A[i].parent)) return A[i].id;
    }
  return -1;
}

int degree(int m)
{
  int i=0;
  if(A[m].left!=-1) i++;
  if(A[m].right!=-1) i++;
  return i;
}

Compiler output:
main.c:1:3: error: expected identifier or '(' before 'else'
    1 |   else return countj;
      |   ^~~~
main.c:2:1: error: expected identifier or '(' before '}' token
    2 | }
      | ^
main.c: In function 'sibling':
main.c:7:13: error: 'n' undeclared (first use in this function)
    7 |   for(i=0;i<n;i++)
      |             ^
main.c:7:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:11: error: 'A' undeclared (first use in this function)
    9 |       if((A[i].id!=m)&&(A[m].parent==A[i].parent)) return A[i].id;
      |           ^
main.c: In function 'degree':
main.c:17:6: error: 'A' undeclared (first use in this function)
   17 |   if(A[m].left!=-1) i++;
      |      ^
Language: C

#include <stdio.h>

#define nil -1
#define n 25

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

node t[n];

int getsib(int id) {
	if (t[id].p == nil) return nil;

	if (t[t[id].p].l != id) return t[t[id].p].l;
	return t[t[id].p].r;
}

int getdegree(int id) {
	if (t[id].l != nil) return 2;
	if (t[id].r != nil) return 2;

	return 0;
}

int getdepth(int id) {
	int depth = 1;

	if (t[id].p == nil) return 0;
	depth += getdepth(t[id].p);
	return depth;
}

int getheight(int id) {
	int height = 1;
	int r,l;

	if (t[id].l == -1 && t[id].r == -1) {
		return 0;
	}

	if (t[id].l == -1) {
		height += getheight(t[id].r);
	} else if (t[id].r == -1) {
		height += getheight(t[id].l);
	} else {
		r = getheight(t[id].r);
		l = getheight(t[id].l);
		if (r >= l) height += r;
		else height += l;
	}

	return height;
}

int main() {
	int i,j,n;
	int id,l,r;

	scanf("%d",&n);

	for (i = 0; i < n; i++) {
		t[i].p = nil;
	}
	for (i = 0; i < n; i++) {
		scanf("%d %d %d",&id,&l,&r);
		t[i].l = l;
		t[i].r = r;
		if (l != nil) t[l].p = id;
		if (r != nil) t[r].p = id;
	}

	for (i = 0; i < n; i++) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d",i,t[i].p, getsib(i), getdegree(i), getdepth(i), getheight(i));
		if (t[i].p == nil) printf(" root\n");
		else if (t[i].l != nil) printf(" internal node\n");
		else printf(" leaf\n");
	}

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:11: error: expected identifier or '(' before numeric constant
    4 | #define n 25
      |           ^~
main.c:57:17: note: in expansion of macro 'n'
   57 |         int i,j,n;
      |                 ^
main.c:60:20: error: lvalue required as unary '&' operand
   60 |         scanf("%d",&n);
      |                    ^
Language: C

#include <stdio.h>

#define nil -1
#define N 25

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

node T[n];

int getsib(int id) {
	if (T[id].p == nil) return nil;

	if (T[T[id].p].l != id) return T[T[id].p].l;
	return T[T[id].p].r;
}

int getdegree(int id) {
	if (T[id].l != nil) return 2;
	if (T[id].r != nil) return 2;

	return 0;
}

int getdepth(int id) {
	int depth = 1;

	if (T[id].p == nil) return 0;
	depth += getdepth(T[id].p);
	return depth;
}

int getheight(int id) {
	int height = 1;
	int r,l;

	if (T[id].l == -1 && T[id].r == -1) {
		return 0;
	}

	if (T[id].l == -1) {
		height += getheight(T[id].r);
	} else if (T[id].r == -1) {
		height += getheight(T[id].l);
	} else {
		r = getheight(T[id].r);
		l = getheight(T[id].l);
		if (r >= l) height += r;
		else height += l;
	}

	return height;
}

int main() {
	int i,n;
	int id,l,r;

	scanf("%d",&n);

	for (i = 0; i < n; i++) {
		T[i].p = nil;
	}
	for (i = 0; i < n; i++) {
		scanf("%d %d %d",&id,&l,&r);
		T[i].l = l;
		T[i].r = r;
		if (l != nil) T[l].p = id;
		if (r != nil) T[r].p = id;
	}

	for (i = 0; i < n; i++) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d",i,T[i].p, getsib(i), getdegree(i), getdepth(i), getheight(i));
		if (T[i].p == nil) printf(" root\n");
		else if (T[i].l != nil) printf(" internal node\n");
		else printf(" leaf\n");
	}

	return 0;
}

Compiler output:
main.c:10:8: error: 'n' undeclared here (not in a function)
   10 | node T[n];
      |        ^
Language: C

#include<cstdio>
 
struct node{
    int parent;
    int left;
    int right;
    int sibling;
    int degree;
    int depth;
    int height;
};
 
node ki[25];
 
void dasu(int depth,int id){
    ki[id].depth = depth;
    if(ki[id].left >= 0){
        dasu(depth + 1,ki[id].left);
    }
    if(ki[id].right >= 0){
        dasu(depth + 1,ki[id].right);
    }
}
 
int iroiro(int id){
    if(id==-1) return -1;
    if(ki[id].left==-1 && ki[id].right==-1){
        ki[id].height = 0;
        return 1;
    }
 
    int a = iroiro(ki[id].left);
    int b = iroiro(ki[id].right);
    ki[id].height =  a >= b ? a : b;
    return ki[id].height + 1;
}
 
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        ki[i].sibling = -1;
        ki[i].degree = 0;
        ki[i].parent = -1;
    }
    for(int i=0;i<n;i++){
        int id,left,right;
        scanf("%d%d%d",&id,&left,&right);
        ki[id].left = left;
        ki[id].right = right;
        if(left >= 0){
            ki[left].parent = id;
            ki[id].degree++;
        }
        if(right>=0){
            ki[right].parent = id;
            ki[id].degree++;
        }
        if(left>=0 && right>=0){
            ki[left].sibling = right;ki[right].sibling = left;
        }
    }
    int root;
    for(int i=0;i<n;i++)
        if(ki[i].parent == -1){
            root =  i;
            break;
        }
    dasu(0,root);
    iroiro(root);
 
    for(int i=0;i<n;i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,ki[i].parent,ki[i].sibling,ki[i].degree,ki[i].depth,ki[i].height);
        if(ki[i].parent == -1){
            printf("root");
	}
        else if(ki[i].left >= 0 || ki[i].right >= 0)
	  {
            printf("internal node");
	  }
        else
            printf("leaf");
        printf("\n");
    }
    return 0;
}

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

#include<cstdio>
 
struct node{
    int parent;
    int left;
    int right;
    int sibling;
    int degree;
    int depth;
    int height;
};
 
node tree[25];
 
 
int takasa(int id){
    if(id == -1)
        return -1;
    if(tree[id].left == -1 && tree[id].right == -1){
        tree[id].height = 0;
        return 1;
    }
    int a = takasa(tree[id].left);
    int b = takasa(tree[id].right);
    tree[id].height =  a >= b ? a : b;
    return tree[id].height + 1;
}
void hukasa(int depth,int id){
    tree[id].depth = depth;
    if(tree[id].left >= 0)
        hukasa(depth + 1,tree[id].left);
    if(tree[id].right >= 0)
        hukasa(depth + 1,tree[id].right);
}
 
 
int main(void){
    int n;
    scanf("%d",&n);
 
    for(int i = 0;i < n;i++){
        tree[i].sibling = -1;
        tree[i].degree = 0;
        tree[i].parent = -1;
    }
    for(int i = 0;i < n;i++){
        int id,left,right;
        scanf("%d%d%d",&id,&left,&right);
        tree[id].left = left;
        tree[id].right = right;
        if(left >= 0){
            tree[left].parent = id;
            tree[id].degree++;
        }
        if(right >= 0){
            tree[right].parent = id;
            tree[id].degree++;
        }
        if(left >= 0 && right >= 0){
            tree[left].sibling = right;tree[right].sibling = left;
        }
    }
    int root;
    for(int i = 0;i < n;i++)
        if(tree[i].parent == -1){
            root =  i;
            break;
        }
    hukasa(0,root);
    takasa(root);
 
    for(int i = 0;i < n;i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,tree[i].sibling,tree[i].degree,tree[i].depth,tree[i].height);
 
        if(tree[i].parent == -1){
            printf("root");
	}
        else if(tree[i].left >= 0 || tree[i].right >= 0){
            printf("internal node");
	}
        else
            printf("leaf");
        printf("\n");
    }
    return 0;
}

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

#include<stdio.h>
 
#define MAX 100000
 
 
 
typedef struct{
  int parent;
  int left;
  int right;
  int degree;
}node;
 
int getdepth(int);
int getsibling(int);
int getheight(int);
 
node ki[MAX];
 
int main(){
  int i, kazu, n, depth;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++) ki[i].parent = ki[i].left = ki[i].right = -1;
 
  for(i=0 ; i<n ; i++){
    scanf("%d",&kazu);
    scanf("%d%d",&ki[id].left,&ki[id].right);
    if(ki[id].left != -1){
      ki[ki[kazu].left].parent = kazu;
      ki[kazu].degree++;
    }
    if(ki[kazu].right != -1){
      ki[ki[kazu].right].parent = kazu;
      ki[kazu].degree++;
    }

  }
 
  for(i=0 ; i<n ; i++){
 
    depth = getdepth(i);
    if(depth==0) printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n", i, ki[i].parent, getsibling(i), ki[i].degree, depth, getheight(i));
 
    else if(ki[i].left==-1 && ki[i].right==-1) printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n", i, ki[i].parent, getsibling(i), ki[i].degree, depth, getheight(i));
 
    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n", i, ki[i].parent, getsibling(i), ki[i].degree, depth, getheight(i));
  }
  return 0;
}
 
int getdepth(int i){
  int kazu = ki[i].parent;
  int sum = 0;
 
  while(kazu != -1){
    kazu = ki[kazu].parent;
    sum++;
  }
  return sum;
}
 
int getsibling(int i){
  if(ki[i].parent == -1) return -1;
  else if(ki[ki[i].parent].left == i) return ki[ki[i].parent].right;
  else return ki[ki[i].parent].left;
}
 
int getheight(int i){
  int l, r;
  if(i==-1) return -1;
 
  l = getheight(ki[i].left);
  r = getheight(ki[i].right);
 
  if(l>r) return l+1;
  else return r+1;
 
}

Compiler output:
main.c: In function 'main':
main.c:29:22: error: 'id' undeclared (first use in this function); did you mean 'i'?
   29 |     scanf("%d%d",&ki[id].left,&ki[id].right);
      |                      ^~
      |                      i
main.c:29:22: note: each undeclared identifier is reported only once for each function it appears in
Language: C

include<stdio.h>
#define NIL -1
#define MAX 10000
struct Node{
  int p;
  int l;
  int r;
};
struct Node T[MAX];
int n,D[MAX],H[MAX];
void setDepth(int, int);
int setHeight(int);
int getSibling(int);
int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=NIL;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }
  for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d",i,T[i].p,getSibling(i));
    int deg=0;
    if(T[i].l!=NIL)deg++;
    if(T[i].r!=NIL)deg++;
    printf("defree = %d, depth = %d, height = %d, ",deg,D[i],H[i]);
    if(T[i].p==NIL) printf("root\n");
    else if(T[i].l==NIL && T[i].r==NIL)printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}
void setDepth(int u, int d){
  if(u==NIL)return;
  D[u]=d;
setDepth(T[u].l,d+1);
  setDepth(T[u].r,d+1);
}
int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].l!=NIL)h1=setHeight(T[u].l)+1;
  if(T[u].r!=NIL)h2=setHeight(T[u].r)+1;
  if(h1>h2)return H[u]=h1;
  else return H[u]=h2;
}
int getSibling(int u){
  if(T[u].p==NIL)return NIL;
  if(T[T[u].p].l!=u && T[T[u].p].l!=NIL)return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=NIL)return T[T[u].p].r;
  return NIL;
}

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

#include <iostream>
#include <string>
 
using namespace std;
 
class Node{
    public:
        int l, r, p;
        int deg, sib, dep, hig;
        string typ;
};
Node nodes[25];
 
int top(int id,int tp){
    if(nodes[id].p!=-1){
        return top(nodes[id].p,tp+1);
    }
    return tp;
}
 
 
int dfs(int id,int dep){
    if(nodes[id].r!=-1||nodes[id].l!=-1){
      int m=0;
      if(nodes[id].r!=-1)
          m = dfs(nodes[id].r,dep+1);
      if(nodes[id].l!=-1)
          m = max(m,dfs(nodes[id].l,dep+1));
      return m;
    }
    return dep;
}
 
int main(){
    int n, id, r, l;
    int parent;
    cin>>n;
    for(int i=0;i<n;i++){
        nodes[i].p=-1;
        nodes[i].sib=-1;
        nodes[i].dep= -1;
        nodes[i].typ = "";
    }
             
    for(int i=0;i<n;i++){
        bool flag=true;
        cin>>id>>r>>l;
        if(r!=-1){
            nodes[ r].p = id;
            nodes[id].r = r;
            nodes[id].deg = 1;
            flag=false;
        }else{
            nodes[id].r = -1;
        }
        if(l!=-1){
            nodes[ l].p = id;
            nodes[id].l = l;
            nodes[id].deg = 1;
            flag=false;
        }else{
            nodes[id].l = -1;
        }
        if(r!=-1&&l!=-1){
            nodes[ l].sib = r;
            nodes[ r].sib = l;
            nodes[id].deg = 2;
        }
        if(flag)
            nodes[id].typ="leaf";
        else
            nodes[id].typ="internal node";
    }
    for(int i=0;i<n;i++){
        if(nodes[i].p==-1){
            nodes[i].typ = "root";
        }
        nodes[i].hig=dfs(i,0);
        nodes[i].dep=top(i,0);
    }
    for(int i=0;i<n;i++){
        cout<<"node "<<i;
        cout<<": parent = "<<nodes[i].p;
        cout<<", sibling = "<<nodes[i].sib;
        cout<<", degree = "<<nodes[i].deg;
        cout<<", depth = "<<nodes[i].dep;
        cout<<", height = "<<nodes[i].hig;
        cout<<", "<<nodes[i].typ;
        cout<<endl;
    }
     
 
    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>
#include <stdlib.h>
#define NIL -1

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

int getSibling(int);
int getDegree(int);
int getDepth(int);
int getHeight(int);
void printTree(void);

node *tree;
int n;

int main(){
  int id,left,right,i;
  
  scanf("%d",&n);
  tree = (node *)malloc(sizeof(node)*n);
  for(i=0;i<n;i++){
    tree[i].parent = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    
    tree[id].left = left;
    
    tree[id].right = right;
    
    tree[tree[id].left].parent = id;
    
    tree[tree[id].right].parent = id;
  }

  printTree();

  return 0;
}

int getSibling(int c){
  int left,right;
  if(tree[c].parent!=-1){
    left = tree[tree[c].parent].left;
    right = tree[tree[c].parent].right;

    if(left!=-1&&c!=left) return left;
    else if(right!=-1&&c!=right) return right;
  }
  return -1;
}

int getDegree(int c){
  int d=0;
  if(tree[c].left!=-1) d++;
  if(tree[c].right!=-1) d++;
 
  return d;
}

int getDepth(int c){
  int d=0;
  while(tree[c].parent!=-1){
    c=tree[c].parent;
    d++;
  }
  return d;
}

int getHeight(int c){
  int d=0;
  if(tree[c].left==-1&&tree[c].right==-1) return 0;
  if(tree[c].left==-1) return getHeight(tree[c].right)+1;
  if(tree[c].right==-1) return getHeight(tree[c].left)+1;
  if(getHeight(tree[c].left)<getHeight(tree[c].right))
    return getHeight(tree[c].right)+1;
  else return getHeight(tree[c].left)+1;
  return d;
}

void printTree(){
  int i,deep,h;
  for(i=0;i<n;i++){
    dep=getDepth(i);
    h=getHeight(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,getSibling(i),getDegree(i),deep,h);
    if(deep==0) printf("root\n");
    else if(h==0) printf("leaf\n");
    else printf("internal node\n");
  }

  return;
}

Compiler output:
main.c: In function 'printTree':
main.c:88:5: error: 'dep' undeclared (first use in this function); did you mean 'deep'?
   88 |     dep=getDepth(i);
      |     ^~~
      |     deep
main.c:88:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define MAX 26
 
typedef struct{
  int l,r,parent;
  int sibling,deg;
  int depth,height;
}Node;
  
Node node[MAX];
  
int Height(int i){
  int l=0,r=0; 
  
  if( node[i].l != -1 ) l = Height(node[i].l) + 1;
  
  if( node[i].r != -1 ) r = Height(node[i].r) + 1;
  
  if( r <= l ) return l;
  
  else if( r > l ) return r;
}
  
int main(){
   
  int n,id,r,l,i;
  
  scanf("%d",&n);
  
  for( i = 0 ; i < n ; i++ )
    {
      node[i].l = node[i].r = node[i].parent = node[i].sibling = -1;
      node[i].deg = node[i].depth = node[i].height = 0;
    }
    
  for( i = 0 ; i < n ; i++ )
    {
      scanf("%d%d%d",&id,&right,&left);
      if(right != -1 && left != -1){
    node[right].sibling = l;
    node[left].sibling = r;
    node[id].right = r;
    node[id].left = l;
    node[right].parent = node[left].parent = id;
    node[id].deg = 2;
      }
      else if( r == -1 && l != -1 ){
    node[id].left = left;
    node[l].parent = id;
    node[id].deg++;
      }
      else if( l == -1 && r != -1 ) {
    node[id].r = r;
    node[r].parent = id;
    node[id].deg++;
      }
    }
  int x;
  
  for( i = 0 ; i < n ; i++ )
    {
      x = i;
      while( node[x].parent != -1 )
    {
      x = node[x].parent;
          node[i].depth++;
    }
      node[i].height =  Height(i);
    }
  
  for( i = 0 ; i < n ; i++ )
    {
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,node[i].parent,node[i].sibling,node[i].deg,node[i].depth,node[i].height);
      if(node[i].parent == -1 ) printf("root\n");
      else if(node[i].deg == 0 ) printf("leaf\n");
      else printf("internal node\n");
    }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:38:27: error: 'right' undeclared (first use in this function); did you mean 'Height'?
   38 |       scanf("%d%d%d",&id,&right,&left);
      |                           ^~~~~
      |                           Height
main.c:38:27: note: each undeclared identifier is reported only once for each function it appears in
main.c:38:34: error: 'left' undeclared (first use in this function)
   38 |       scanf("%d%d%d",&id,&right,&left);
      |                                  ^~~~
main.c:42:14: error: 'Node' has no member named 'right'; did you mean 'height'?
   42 |     node[id].right = r;
      |              ^~~~~
      |              height
main.c:43:13: error: 'Node' has no member named 'left'
   43 |     node[id].left = l;
      |             ^
main.c:48:13: error: 'Node' has no member named 'left'
   48 |     node[id].left = left;
      |             ^
Language: C

#include <stdio.h>
 
#define MAX 25
 
struct Node{
  int parent;
  int right;
  int left;
  int degree;
};
int n;
struct Node u[MAX];
int s(int);
int d(int);
int h(int);

int s(int x){
  if(u[x].right!=-1) return u[x].right;
  else if(u[u[x].parent].left!=x) return u[u[x].parent].left;
  else return -1;
}
 
int d(int x){
  int d=0,p;
  p=u[x].parent;
 
  while(p!=-1){
    p=u[p].parent;
    d++;
  }
 
  return d;
}
int h(int x) {
  int i,h=0,y;
  
  for(i=0;i<n;i++) {
    if(u[i].parent==x) {
      y=h(i)+1;
      if(y>h) h=y;
    }
  }
  return h;
}

int main(){
  int i,id,r,l;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    u[i].parent=-1;
    u[i].right=-1;
    u[i].left=-1;
    u[i].degree=0;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    u[id].left=l;
    u[u[id].left].right=r;
    if(u[id].left!=-1){
      u[u[id].left].parent=id;
      u[id].degree++;
    }
    if(u[u[id].left].right!=-1){
      u[u[u[id].left].right].parent=id;
      u[id].degree++;
    }
  }
 
  for(i=0;i<n;i++){
    if(u[i].parent==-1)
      printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,u[i].degree,h(i));
 
    else if(u[i].degree==0)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,u[i].parent,s(i),u[i].degree,d(i),h(i));
 
    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",i,u[i].parent,s(i),u[i].degree,d(i),h(i));
  }
 
  return 0;
}
 

Compiler output:
main.c: In function 'h':
main.c:39:9: error: called object 'h' is not a function or function pointer
   39 |       y=h(i)+1;
      |         ^
main.c:35:9: note: declared here
   35 |   int i,h=0,y;
      |         ^
Language: C

#include<stdio.h>
#define MAX 26
 
typedef struct{
  int l;
  int r;
  int parent;
  int sibling;
  int deg;
  int depth;
  int height;
}Node;
  
Node node[MAX];
  
int Height(int i){
  int l=0,r=0; 
  if( node[i].l != -1 ) l = Height(node[i].l) + 1;
  if( node[i].r != -1 ) r = Height(node[i].r) + 1;
  if( r <= l ) return l;
  else if( r > l ) return r;
}
  
int main(){
   
  int n,id,r,l,i;
  
  scanf("%d",&n);
  
  for( i = 0 ; i < n ; i++ )
    {
      node[i].l = node[i].r = node[i].parent = node[i].sibling = -1;
      node[i].deg = node[i].depth = node[i].height = 0;
    }
    
  for( i = 0 ; i < n ; i++ )
    {
      scanf("%d%d%d",&id,&r,&l);
      if(r != -1 && l != -1){
    node[r].sibling = l;
    node[left].sibling = r;
    node[id].r = r;
    node[id].l = l;
    node[r].parent = node[l].parent = id;
    node[id].deg = 2;
      }
      else if( r == -1 && l != -1 ){
    node[id].l = l;
    node[l].parent = id;
    node[id].deg++;
      }
      else if( l == -1 && r != -1 ) {
    node[id].r = r;
    node[r].parent = id;
    node[id].deg++;
      }
    }
  int x;
  
  for( i = 0 ; i < n ; i++ )
    {
      x = i;
      while( node[x].parent != -1 )
    {
      x = node[x].parent;
          node[i].depth++;
    }
      node[i].height =  Height(i);
    }
  
  for( i = 0 ; i < n ; i++ )
    {
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,node[i].parent,node[i].sibling,node[i].deg,node[i].depth,node[i].height);
      if(node[i].parent == -1 ) printf("root\n");
      else if(node[i].deg == 0 ) printf("leaf\n");
      else printf("internal node\n");
    }
  return 0;
}

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

#include <stdio.h>
#define MAX 25
struct Node{
  int parent;
  int right;
  int left;
  int degree;
};
int n;
struct Node U[MAX];
int sib(int);
int dep(int);
int hei(int);
 
int sib(int x){
  if(U[x].right!=-1) return U[x].right;
  else if(U[U[x].parent].left!=x) return U[U[x].parent].left;
  else return -1;
}
  
int dep(int x){
  int d=0,p;
  p=U[x].parent;
  
  while(p!=-1){
    p=U[p].parent;
    d++;
  }
  
  return d;
}
int hei(int x) {
  int i,a=0,y;
   
  for(i=0;i<n;i++) {
    if(U[i].parent==x) {
      y=h(i)+1;
      if(y>a) a=y;
    }
  }
  return a;
}
 
int main(){
  int i,id,r,l;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    U[i].parent=-1;
    U[i].right=-1;
    U[i].left=-1;
    U[i].degree=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    U[id].left=l;
    U[U[id].left].right=r;
    if(U[id].left!=-1){
      U[U[id].left].parent=id;
      U[id].degree++;
    }
    if(U[U[id].left].right!=-1){
      U[U[U[id].left].right].parent=id;
      U[id].degree++;
    }
  }
  
  for(i=0;i<n;i++){
    if(U[i].parent==-1)
      printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,U[i].degree,h(i));
  
    else if(U[i].degree==0)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,U[i].parent,sib(i),U[i].degree,dep(i),hei(i));
  
    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",i,U[i].parent,sib(i),U[i].degree,dep(i),hei(i));
  }
  
  return 0;
}

Compiler output:
main.c: In function 'hei':
main.c:37:9: error: implicit declaration of function 'h' [-Wimplicit-function-declaration]
   37 |       y=h(i)+1;
      |         ^
Language: C

#include<stdio.h>
#define MAX 10000
#define NIL -1
 
typedef struct {int parent, left , right;} Node;
 
Node T[MAX];
int n,D[MAX], H[MAX];
 
void setDepth(int u , int d) {
  if ( u == NIL) return ;
  D[u]  = d;
  setDepth(T[u].left , d + 1);
  setDepth(T[u].right, d + 1);
 
}
 
int setHeight(int u)  {
  int h1 = 0, h2 = 0;
  if( T[u].left != NIL)
  h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
  h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}
 
int getSibling(int u) {
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
  return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
  return T[T[u].parent].right;
  return NIL;
}
 
void print(int u) {
  int i,c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
    int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ", deg );
  printf("depth = %d, ", D[u] );
  printf("height = %d, ", H[u] );
 
  if(T[u].parent == NIL) printf("root\n");
  else if (T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
  else printf("internal node\n");
 
}
 
int main()  {
  int i,a,b,c,root = 0;
  scanf("%d\n",  &n);
 
  for(i = 0; i < n;i++) T[i].parent = NIL;
 
  for(i = 0 ; i < n ; i++) {
    scanf("%d %d %d \n", &a, &b , &r);
    T[a].left = b;
    T[a].right = c;
    if ( b!= NIL) T[b].parent = a;
    if ( c!= NIL) T[r].parent = a;
  }
 
  for(i = 0; i < n ;i++) if ( T[i].parent == NIL) root = i;
 
  setDepth(root , 0);
  setHeight(root);
 
  for ( i = 0; i  < n; i++) print(i);
 
  return 0;
}




 
 

Compiler output:
main.c: In function 'main':
main.c:61:36: error: 'r' undeclared (first use in this function)
   61 |     scanf("%d %d %d \n", &a, &b , &r);
      |                                    ^
main.c:61:36: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define N 10000

void sD(int,int);
int sH(int)l;
int gS(int);

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

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

void sD(int a,int b){
  if(a==-1)return;
  D[a] = b;
  sD(T[a].l,b+1);
  sD(T[a].r,b+1);
}
int sH(int a){
  int x=0,y=0;
  if(T[a].l!=-1)x = sH(T[a].l)+1;
  if(T[a].r!=-1)y = sH(T[a].r)+1;
  return H[a]=(x>y?x:y);
}
int gS(int a){
  if(T[a].p == -1)return -1;
  if(T[T[a].p].l!=a && T[T[a].p].l != -1)return  T[T[a].p].l;
  if(T[T[a].p].r!=a && T[T[a].p].r != -1)return  T[T[a].p].r;
  return -1;
}

int main(){
  int i,v,l,r,d,r=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;

    if(l!=-1)T[l].p=v;
    if(r!=-1)T[r].p=v;

  }
  sD(r=0);
  sH(r);

  for(i=0;i<n;i++){
    printf("node %d: " , i);
    printf("depth = %d, ", D[i]);
    printf("height = %d, ", H[i]);

    if(T[i].p == -1)printf("root\n");
    else if(T[i].l == -1 && T[i].r == -1)printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'sH':
main.c:5:12: error: expected declaration specifiers before 'l'
    5 | int sH(int)l;
      |            ^
main.c:10:2: error: storage class specified for parameter 'Node'
   10 | }Node;
      |  ^~~~
main.c:12:1: error: expected declaration specifiers before 'Node'
   12 | Node T[N];
      | ^~~~
main.c:16:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   16 | void sD(int a,int b){
      |                     ^
main.c:22:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   22 | int sH(int a){
      |              ^
main.c:28:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   28 | int gS(int a){
      |              ^
main.c:35:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   35 | int main(){
      |           ^
main.c:5:5: error: old-style parameter declarations in prototyped function definition
    5 | int sH(int)l;
      |     ^~
main.c:65: error: expected '{' at end of input
Language: C

#include<stdio.h>
#define N 10000

void sD(int,int);
int sH(int);
int gS(int);

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

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

void sD(int a,int b){
  if(a==-1)return;
  D[a] = b;
  sD(T[a].l,b+1);
  sD(T[a].r,b+1);
}
int sH(int a){
  int x=0,y=0;
  if(T[a].l!=-1)x = sH(T[a].l)+1;
  if(T[a].r!=-1)y = sH(T[a].r)+1;
  return H[a]=(x>y?x:y);
}
int gS(int a){
  if(T[a].p == -1)return -1;
  if(T[T[a].p].l!=a && T[T[a].p].l != -1)return  T[T[a].p].l;
  if(T[T[a].p].r!=a && T[T[a].p].r != -1)return  T[T[a].p].r;
  return -1;
}

int main(){
  int i,v,l,r,d,root=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;

    if(l!=-1)T[l].p=v;
    if(r!=-1)T[r].p=v;

  }
  for(i=0;i<n;i++){
    if(T[i].p==-1)root = i);
}
  sD(root,0);
  sH(root);

  for(i=0;i<n;i++){
    printf("node %d: " , i);
    printf("parent %d:, ",T[i].p);
    printf("sibling = %d, ",gS(i));
    d = 0;

    if(T[i].l != -1)d++;
    if(T[i].r != -1)d++;
    printf("degree = %d, " , d);
    printf("depth = %d, ", D[i]);
    printf("height = %d, ", H[i]);


    if(T[i].p == -1)printf("root\n");
    else if(T[i].l == -1 && T[i].r == -1)printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:52:27: error: expected ';' before ')' token
   52 |     if(T[i].p==-1)root = i);
      |                           ^
      |                           ;
main.c:52:27: error: expected statement before ')' token
Language: C

#include <cstdio>
struct node{int p,l,r;};
node t[25];
int n,h[25],d[25];
void dp1(int now,int de){
  d[now]=de;
  if(t[now].l!=-1) dp1(t[now].l,de+1);
  if(t[now].r!=-1) dp1(t[now].r,de);
}
void dp2(int f,int now,int he){
  if(h[f]<he) h[f]=he;
  if(t[now].l!=-1) dp2(f,t[now].l,he+1);
  if(t[now].l!=-1) if(t[t[now].l].r!=-1) dp2(f,t[t[now].l].r,he+1);
}
int main(){
  int now,tmpl,tmpr,s[25]={0},p[25];
  scanf("%d",&n);
  for(int i=0;i<n;i++) t[i].p=t[i].l=t[i].r=p[i]=-1;
  for(int i=0;i<n;i++){
    scanf("%d%d%d",&now,&tmpl,&tmpr);
    if(tmpl==-1) tmpl=tmpr,tmpr=-1;
    if(tmpl!=-1) s[now]++,t[tmpl].p=now,t[tmpl].r=tmpr;
    if(tmpr!=-1) s[now]++,t[tmpr].p=now;
    t[now].l=tmpl;
  }
  for(int i=0;i<n;i++){
    if(t[i].r!=-1) p[i]=t[i].r;
    else if(t[i].p!=-1) if(t[t[i].p].l!=-1&&t[t[i].p].l!=i) p[i]=t[t[i].p].l;
  }
  int st;
  for(int i=0;i<n;i++) if(t[i].p==-1) st=i;
  dp1(st,0);
  for(int i=0;i<n;i++) dp2(i,i,0);
  for(int i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,t[i].p,p[i]);
    printf("degree = %d, depth = %d, height = %d, ",s[i],d[i],h[i]);
    if(t[i].p==-1) printf("root\n");
    else if(t[i].l!=-1) printf("internal node\n");
    else printf("leaf\n");
  }
  return 0;
}

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