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

#include <iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int aa[1000]={};
int bb[1000]={};
int main()
{
    int a=0,b=0,c=0,n=0,i=0,j=0,k=0,count1=0;
    cin >> n;
    for (i=0;i<n;i++){
        cin >> a >> b >> c;
        aa[3*i]=a;
        aa[3*i+1]=b;
        aa[3*i+2]=c;
        bb[5*i]=i;
    }
    for(i=0;i<n;i++){//3*i??????????????????

        cout << "node "<<aa[3*i] <<": parent = ";
        count1=0;
        for(j=0;j<n;j++){//parent
            if(aa[3*i]==aa[3*j+1] || aa[3*i]==aa[3*j+2]){
                bb[5*i+1]=aa[3*i];//????????????
                cout << aa[3*j];
                count1++;
            }
        }
        if(count1==0)cout<<"-1";
        count1=0;
        cout <<", sibling = ";
        for(j=0;j<n;j++){//brother
            if(aa[3*i]=aa[3*j+1]){
                cout << aa[3*j+2];
                count1++;
            }
            if(aa[3*i]=aa[3*j+2]){
                cout << aa[3*j+1];
                count1++;
            }
            if(count1==0)cout<<"-1";
            count1=0;
        }
        cout <<" , degree = ";
        //junoior
        if(aa[3*i+1]>0 %% aa[3*i+2]>0)cout << 2;
        else if(aa[3*i+1]>0 || aa[3*i+2]>0)cout << 1;
        else if(aa[3*i+1]<0 && aa[3*i+2]<0){
            cout << 0;
            bb[5*i+2]=-1;//??????????????????
        }
        cout << ",depth = ";
        for(j=0;j<n;j++){
            if(bb[5*j+2]==-1){
                bb[5*j+3]==-1;//height==0
            }
        }
        for(j=0;j<n;j++){
            for(k=0;k<n;k++){
                if(bb[5*k+3]!=0)bb[5*bb[5*k+1]+3]=bb[5*k+3]+1;//?????????????????\??????

            }
        }

    }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:25: error: expected primary-expression before '%' token
   49 |         if(aa[3*i+1]>0 %% aa[3*i+2]>0)cout << 2;
      |                         ^
Language: C++

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  return 0;
}

Compiler output:
a.cc:1:9: fatal error: cstudio: No such file or directory
    1 | #include<cstudio>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  return 0;
}

Compiler output:
a.cc:1:9: fatal error: cstudio: No such file or directory
    1 | #include<cstudio>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  return 0;
}

Compiler output:
a.cc:1:9: fatal error: cstudio: No such file or directory
    1 | #include<cstudio>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  return 0;
}

Compiler output:
a.cc: In function 'int setHeight(int)':
a.cc:21:16: error: expected ')' before '!' token
   21 |   if(T[u].right ! = NIL)
      |     ~          ^~
      |                )
Language: C++

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  return 0;
}

Compiler output:
a.cc: In function 'int setHeight(int)':
a.cc:22:16: error: expected ')' before '!' token
   22 |   if(T[u].right ! = NIL){
      |     ~          ^~
      |                )
Language: C++

#include<cstdio>
using namespace std;

const int nil=-1;
struct node{
	int parent;
	int degree;
	int left;
	int right;
	int sibling;
	int depth;
	int height;
};
node *nodes;int n;

int height_setd(int id, int d) //????????????height, ????????¨??¨??????depth????¨????
{
	//if( d==0 )
	//	cout<<"root : "<<id<<endl;
	if( id==nil ){
		return -1;
	}else{
		nodes[id].depth=d;
		nodes[id].height=max(
			1 +height_setd(nodes[id].left, d+1),
		 	1 +height_setd(nodes[id].right, d+1)
		);
	}
}
int trackRoot(int start){
	int prt=nodes[start].parent;
	if( prt==nil )
		return start;
	else
		return trackRoot(prt);
}

void show()
{
	for( int i=0; i<n; i++ ){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
			i,
			nodes[i].parent,
			nodes[i].sibling,
			nodes[i].degree,
			nodes[i].depth,
			nodes[i].height
		);

		if( nodes[i].parent==nil ){
			printf("root");
		}else if( nodes[i].degree==0 ){
			printf("leaf");
		}else{
			printf("internal node");
		}
		printf("\n");
	}
}


	
	

int main(void)
{
	cin>>n;nodes=new node[n];
	for(int i=0;i<n;i++)
		nodes[i].parent=nodes[i].left=nodes[i].right=nodes[i].sibling=nil;
	

	for(int i=0,id,l,r; i<n; i++){
		cin>>id;

		cin>>l>>r;
		if( l!=nil ){
			nodes[id].left=l;
			nodes[l].parent=id;
		}
		if( r!=nil ){
			nodes[id].right=r;
			nodes[r].parent=id;
		}
		if( r!=nil && l!=nil ){
			nodes[id].degree=2;
			nodes[r].sibling=l;
			nodes[l].sibling=r;
		}else if( r==nil && l==nil ){
			nodes[id].degree=0;
		}else{
			nodes[id].degree=1;
		}
		l=r=nil;
	}
	//cout<<"h(root) :"<<height_setd(root, 0)<<endl;;
	height_setd(trackRoot(0), 0);
	show();
	return 0;
	
}

Compiler output:
a.cc: In function 'int height_setd(int, int)':
a.cc:24:34: error: 'max' was not declared in this scope
   24 |                 nodes[id].height=max(
      |                                  ^~~
a.cc: In function 'int main()':
a.cc:67:9: error: 'cin' was not declared in this scope
   67 |         cin>>n;nodes=new node[n];
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<cstdio>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc: In function 'int height_setd(int, int)':
a.cc:23:32: warning: control reaches end of non-void function [-Wreturn-type]
   23 |                 nodes[id].depth=d;
      |                 ~~~~~~~~~~~~~~~^~
Language: C++

#include<cstdio>
#include<cmath>
using namespace std;

const int nil=-1;
struct node{
	int parent;
	int degree;
	int left;
	int right;
	int sibling;
	int depth;
	int height;
};
node *nodes;int n;

int height_setd(int id, int d) //????????????height, ????????¨??¨??????depth????¨????
{
	//if( d==0 )
	//	cout<<"root : "<<id<<endl;
	if( id==nil ){
		return -1;
	}else{
		nodes[id].depth=d;
		nodes[id].height=max(
			1 +height_setd(nodes[id].left, d+1),
		 	1 +height_setd(nodes[id].right, d+1)
		);
	}
}
int trackRoot(int start){
	int prt=nodes[start].parent;
	if( prt==nil )
		return start;
	else
		return trackRoot(prt);
}

void show()
{
	for( int i=0; i<n; i++ ){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
			i,
			nodes[i].parent,
			nodes[i].sibling,
			nodes[i].degree,
			nodes[i].depth,
			nodes[i].height
		);

		if( nodes[i].parent==nil ){
			printf("root");
		}else if( nodes[i].degree==0 ){
			printf("leaf");
		}else{
			printf("internal node");
		}
		printf("\n");
	}
}


	
	

int main(void)
{
	scanf("%d",%n);nodes=new node[n];
	for(int i=0;i<n;i++)
		nodes[i].parent=nodes[i].left=nodes[i].right=nodes[i].sibling=nil;
	

	for(int i=0,id,l,r; i<n; i++){
		cin>>id;

		cin>>l>>r;
		if( l!=nil ){
			nodes[id].left=l;
			nodes[l].parent=id;
		}
		if( r!=nil ){
			nodes[id].right=r;
			nodes[r].parent=id;
		}
		if( r!=nil && l!=nil ){
			nodes[id].degree=2;
			nodes[r].sibling=l;
			nodes[l].sibling=r;
		}else if( r==nil && l==nil ){
			nodes[id].degree=0;
		}else{
			nodes[id].degree=1;
		}
		l=r=nil;
	}
	//cout<<"h(root) :"<<height_setd(root, 0)<<endl;;
	height_setd(trackRoot(0), 0);
	show();
	return 0;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:20: error: expected primary-expression before '%' token
   68 |         scanf("%d",%n);nodes=new node[n];
      |                    ^
a.cc:74:17: error: 'cin' was not declared in this scope
   74 |                 cin>>id;
      |                 ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<cmath>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc: In function 'int height_setd(int, int)':
a.cc:25:33: warning: control reaches end of non-void function [-Wreturn-type]
   25 |                 nodes[id].height=max(
      |                 ~~~~~~~~~~~~~~~~^~~~~
   26 |                         1 +height_setd(nodes[id].left, d+1),
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   27 |                         1 +height_setd(nodes[id].right, d+1)
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   28 |                 );
      |                 ~
Language: C++

#include <bits/stdc++.h>
#define MAX 10000
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
struct Node{int p,l,r;};
Node T[MAX];
int D[MAX],H[MAX];
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;
	H[u]=(h1>h2?h1:h2);
	return H[u];
}
int getsibling(int u){
	if(T[u].p==-1)return -1;
	if(T[T[u].p].l!=-1&&T[T[u].p].l!=u)
		return T[T[u].p].l;
	if(T[T[u].p].r!=-1&&T[T[u].p].r!=u)
		return T[T[u].p].r;
	//return -1;
}
void print(int u){
	cout<<"node "<<u;
	cout<<": parent = "<<T[u].p;
	cout<<", sibling = "<<getsibling(u);
	int deg=0;
	if(T[u].l!=-1)deg++;
	if(T[u].r!=-1)deg++;
	cout<<", degree = "<<deg;
	cout<<", depth = "<<D[u];
	cout<<", height = "<<H[u]<<", ";
	if(T[u].p==-1)cout<<"root";
	else if(deg==0)cout<<"leaf";
	else cout<<"internal node";
	cout<<endl;
}
int main(){
    int root,n,a,b,c;
	cin>>n;
	r(i,n)T[i].p=-1;
	r(i,n){
	  cin>>a>>b>>c;
	  T[a].l=b;
	  T[a].r=c;
	  if(b!=-1)T[b].p=a;
	  if(c!=-1)T[c].p=a;
	}
	r(i,n)if(T[i].p==-1)root=i;
	setdepth(root,0);
	setHeight(root);
	r(i,n)print(i);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:9: error: 'setdepth' was not declared in this scope; did you mean 'setDepth'?
   58 |         setdepth(root,0);
      |         ^~~~~~~~
      |         setDepth
a.cc: In function 'int getsibling(int)':
a.cc:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

#define NIL -1
#define N 100005

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

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

void setDepth(int u, int d){
	if (NIL == u) 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 (NIL != T[u].l) h1 = setHeight(T[u].l) + 1;
	if (NIL != T[u].r) h2 = setHeight(T[u].r) + 1;

	return H[u] = max(h1, h2);
}

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

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

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

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

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

int main1()
{
	int root = 0; cin >> n;
	for (int i = 0; i < n; ++i) T[i].p = NIL;

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

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

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

	return 0;
}

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

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

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

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

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

scanf("%d",&n);

for(inti=0;i<n;i++)T[i].p=NIL;

for(int 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(int i=0;i<n;i++)if(T[i].p==NIL)root=i;

dep(root,0);
height(root);

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

return0;
}

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

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

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

void print(int u){
printf("node %d: ",u);
printf("p = %d, ,",T[u].p);
printf("sibling = %d, ",Sib(u));
int deg=0;
if(T[u].l!-NIL)deg++;
if(T[u].r!=NIL)deg++;
printf("degree = %d, ",deg);
printf("depth = $d, ",D[u]);
printf("height = %d, ",H[u]);

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

Compiler output:
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:17:5: error: 'inti' was not declared in this scope; did you mean 'int'?
   17 | for(inti=0;i<n;i++)T[i].p=NIL;
      |     ^~~~
      |     int
a.cc:17:12: error: 'i' was not declared in this scope
   17 | for(inti=0;i<n;i++)T[i].p=NIL;
      |            ^
a.cc:29:1: error: 'dep' was not declared in this scope
   29 | dep(root,0);
      | ^~~
a.cc:30:1: error: 'height' was not declared in this scope
   30 | height(root);
      | ^~~~~~
a.cc:32:21: error: 'print' was not declared in this scope; did you mean 'printf'?
   32 | for(int i=0;i<n;i++)print(i);
      |                     ^~~~~
      |                     printf
a.cc:34:1: error: 'return0' was not declared in this scope
   34 | return0;
      | ^~~~~~~
a.cc: In function 'int height(int)':
a.cc:49:19: error: expected ')' before ';' token
   49 | h2=height(T[u].r+1;
      |          ~        ^
      |                   )
a.cc: In function 'void print(int)':
a.cc:67:10: error: expected ')' before '!' token
   67 | if(T[u].l!-NIL)deg++;
      |   ~      ^
      |          )
a.cc:75:2: error: expected '}' before 'else'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      | ~^~~~
a.cc:75:2: error: expected '}' before 'else'
a.cc:73:16: note: to match this '{'
   73 | if(T[u].p==NIL){
      |                ^
a.cc:75:31: error: 'NIl' was not declared in this scope; did you mean 'NIL'?
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                               ^~~
      |                               NIL
a.cc:77:1: error: expected '}' before 'else'
   77 | else{
      | ^~~~
a.cc:75:35: note: to match this '{'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                                   ^
Language: C++

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

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

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

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

scanf("%d",&n);

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

for(int i=0;i<n;i++){
scanf("%d%d%d",&v,&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(int i=0;i<n;i++)if(T[i].p==NIL)root=i;

dep(root,0);
height(root);

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

return0;
}

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

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

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

void print(int u){
printf("node %d: ",u);
printf("p = %d, ,",T[u].p);
printf("sibling = %d, ",Sib(u));
int deg=0;
if(T[u].l!-NIL)deg++;
if(T[u].r!=NIL)deg++;
printf("degree = %d, ",deg);
printf("depth = $d, ",D[u]);
printf("height = %d, ",H[u]);

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

Compiler output:
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:1: error: 'dep' was not declared in this scope
   29 | dep(root,0);
      | ^~~
a.cc:30:1: error: 'height' was not declared in this scope
   30 | height(root);
      | ^~~~~~
a.cc:32:21: error: 'print' was not declared in this scope; did you mean 'printf'?
   32 | for(int i=0;i<n;i++)print(i);
      |                     ^~~~~
      |                     printf
a.cc:34:1: error: 'return0' was not declared in this scope
   34 | return0;
      | ^~~~~~~
a.cc: In function 'int height(int)':
a.cc:49:19: error: expected ')' before ';' token
   49 | h2=height(T[u].r+1;
      |          ~        ^
      |                   )
a.cc: In function 'void print(int)':
a.cc:67:10: error: expected ')' before '!' token
   67 | if(T[u].l!-NIL)deg++;
      |   ~      ^
      |          )
a.cc:75:2: error: expected '}' before 'else'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      | ~^~~~
a.cc:75:2: error: expected '}' before 'else'
a.cc:73:16: note: to match this '{'
   73 | if(T[u].p==NIL){
      |                ^
a.cc:75:31: error: 'NIl' was not declared in this scope; did you mean 'NIL'?
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                               ^~~
      |                               NIL
a.cc:77:1: error: expected '}' before 'else'
   77 | else{
      | ^~~~
a.cc:75:35: note: to match this '{'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                                   ^
Language: C++

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

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

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

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

scanf("%d",&n);

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

for(int i=0;i<n;i++){
scanf("%d%d%d",&v,&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(int i=0;i<n;i++)if(T[i].p==NIL)root=i;

dep(root,0);
height(root);

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

return 0;
}

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

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

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

void print(int u){
printf("node %d: ",u);
printf("p = %d, ,",T[u].p);
printf("sibling = %d, ",Sib(u));
int deg=0;
if(T[u].l!-NIL)deg++;
if(T[u].r!=NIL)deg++;
printf("degree = %d, ",deg);
printf("depth = $d, ",D[u]);
printf("height = %d, ",H[u]);

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

Compiler output:
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:1: error: 'dep' was not declared in this scope
   29 | dep(root,0);
      | ^~~
a.cc:30:1: error: 'height' was not declared in this scope
   30 | height(root);
      | ^~~~~~
a.cc:32:21: error: 'print' was not declared in this scope; did you mean 'printf'?
   32 | for(int i=0;i<n;i++)print(i);
      |                     ^~~~~
      |                     printf
a.cc: In function 'int height(int)':
a.cc:49:19: error: expected ')' before ';' token
   49 | h2=height(T[u].r+1;
      |          ~        ^
      |                   )
a.cc: In function 'void print(int)':
a.cc:67:10: error: expected ')' before '!' token
   67 | if(T[u].l!-NIL)deg++;
      |   ~      ^
      |          )
a.cc:75:2: error: expected '}' before 'else'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      | ~^~~~
a.cc:75:2: error: expected '}' before 'else'
a.cc:73:16: note: to match this '{'
   73 | if(T[u].p==NIL){
      |                ^
a.cc:75:31: error: 'NIl' was not declared in this scope; did you mean 'NIL'?
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                               ^~~
      |                               NIL
a.cc:77:1: error: expected '}' before 'else'
   77 | else{
      | ^~~~
a.cc:75:35: note: to match this '{'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                                   ^
Language: C++

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

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

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

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

scanf("%d",&n);

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

for(int i=0;i<n;i++){
scanf("%d%d%d",&v,&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(int i=0;i<n;i++)if(T[i].p==NIL)root=i;

dep(root,0);
height(root);

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

return 0;
}

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

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

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

void print(int u){
printf("node %d: ",u);
printf("p = %d, ,",T[u].p);
printf("sibling = %d, ",Sib(u));
int deg=0;
if(T[u].l!=NIL)deg++;
if(T[u].r!=NIL)deg++;
printf("degree = %d, ",deg);
printf("depth = $d, ",D[u]);
printf("height = %d, ",H[u]);

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

Compiler output:
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:1: error: 'dep' was not declared in this scope
   29 | dep(root,0);
      | ^~~
a.cc:30:1: error: 'height' was not declared in this scope
   30 | height(root);
      | ^~~~~~
a.cc:32:21: error: 'print' was not declared in this scope; did you mean 'printf'?
   32 | for(int i=0;i<n;i++)print(i);
      |                     ^~~~~
      |                     printf
a.cc: In function 'int height(int)':
a.cc:49:19: error: expected ')' before ';' token
   49 | h2=height(T[u].r+1;
      |          ~        ^
      |                   )
a.cc: In function 'void print(int)':
a.cc:75:2: error: expected '}' before 'else'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      | ~^~~~
a.cc:75:2: error: expected '}' before 'else'
a.cc:73:16: note: to match this '{'
   73 | if(T[u].p==NIL){
      |                ^
a.cc:75:31: error: 'NIl' was not declared in this scope; did you mean 'NIL'?
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                               ^~~
      |                               NIL
a.cc:77:1: error: expected '}' before 'else'
   77 | else{
      | ^~~~
a.cc:75:35: note: to match this '{'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                                   ^
Language: C++

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

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

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

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

scanf("%d",&n);

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

for(int i=0;i<n;i++){
scanf("%d%d%d",&v,&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(int i=0;i<n;i++)if(T[i].p==NIL)root=i;

dep(root,0);
height(root);

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

return 0;
}

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

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

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

void print(int u){
printf("node %d: ",u);
printf("p = %d, ,",T[u].p);
printf("sibling = %d, ",Sib(u));
int deg=0;
if(T[u].l!=NIL)deg++;
if(T[u].r!=NIL)deg++;
printf("degree = %d, ",deg);
printf("depth = $d, ",D[u]);
printf("height = %d, ",H[u]);

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

Compiler output:
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:1: error: 'dep' was not declared in this scope
   29 | dep(root,0);
      | ^~~
a.cc:30:1: error: 'height' was not declared in this scope
   30 | height(root);
      | ^~~~~~
a.cc:32:21: error: 'print' was not declared in this scope; did you mean 'printf'?
   32 | for(int i=0;i<n;i++)print(i);
      |                     ^~~~~
      |                     printf
a.cc: In function 'int height(int)':
a.cc:49:19: error: expected ')' before ';' token
   49 | h2=height(T[u].r+1;
      |          ~        ^
      |                   )
a.cc: In function 'void print(int)':
a.cc:75:2: error: expected '}' before 'else'
   75 | {else if(T[u].l==NIL&&T[u].r==NIL){
      | ~^~~~
a.cc:75:2: error: expected '}' before 'else'
a.cc:73:16: note: to match this '{'
   73 | if(T[u].p==NIL){
      |                ^
a.cc:77:1: error: expected '}' before 'else'
   77 | else{
      | ^~~~
a.cc:75:35: note: to match this '{'
   75 | {else if(T[u].l==NIL&&T[u].r==NIL){
      |                                   ^
Language: C++

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

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

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

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

scanf("%d",&n);

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

for(int i=0;i<n;i++){
scanf("%d%d%d",&v,&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(int i=0;i<n;i++)if(T[i].p==NIL)root=i;

dep(root,0);
height(root);

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

return 0;
}

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

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

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

void print(int u){
printf("node %d: ",u);
printf("p = %d, ,",T[u].p);
printf("sibling = %d, ",Sib(u));
int deg=0;
if(T[u].l!=NIL)deg++;
if(T[u].r!=NIL)deg++;
printf("degree = %d, ",deg);
printf("depth = $d, ",D[u]);
printf("height = %d, ",H[u]);

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

Compiler output:
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:1: error: 'dep' was not declared in this scope
   29 | dep(root,0);
      | ^~~
a.cc:30:1: error: 'height' was not declared in this scope
   30 | height(root);
      | ^~~~~~
a.cc:32:21: error: 'print' was not declared in this scope; did you mean 'printf'?
   32 | for(int i=0;i<n;i++)print(i);
      |                     ^~~~~
      |                     printf
a.cc: In function 'int height(int)':
a.cc:49:19: error: expected ')' before ';' token
   49 | h2=height(T[u].r+1;
      |          ~        ^
      |                   )
a.cc: In function 'void print(int)':
a.cc:78:1: error: expected '}' before 'else'
   78 | else{
      | ^~~~
a.cc:76:34: note: to match this '{'
   76 | else if(T[u].l==NIL&&T[u].r==NIL){
      |                                  ^
Language: C++

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

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

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

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

scanf("%d",&n);

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

for(int i=0;i<n;i++){
scanf("%d%d%d",&v,&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(int i=0;i<n;i++)if(T[i].p==NIL)root=i;

dep(root,0);
height(root);

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

return 0;
}

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

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

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

void print(int u){
printf("node %d: ",u);
printf("p = %d, ,",T[u].p);
printf("sibling = %d, ",Sib(u));
int deg=0;
if(T[u].l!=NIL)deg++;
if(T[u].r!=NIL)deg++;
printf("degree = %d, ",deg);
printf("depth = $d, ",D[u]);
printf("height = %d, ",H[u]);

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

Compiler output:
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:1: error: 'dep' was not declared in this scope
   29 | dep(root,0);
      | ^~~
a.cc:30:1: error: 'height' was not declared in this scope
   30 | height(root);
      | ^~~~~~
a.cc:32:21: error: 'print' was not declared in this scope; did you mean 'printf'?
   32 | for(int i=0;i<n;i++)print(i);
      |                     ^~~~~
      |                     printf
Language: C++

#include<cstdio.h>
#define Max 10000
#define None -1

typedef struct{
  int parent, left ,right;
}Node;
Node Tree[Max];
int n,Depth[Max],Height[Max];
int Dep(int,int);
int  Hei(int);
void print_out(int );
int Sibling(int);
int main()
{
  int v,l,r,i;
  int root =0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    Tree[i].parent=None;
    for(i=0;i<n;i++){
      scanf("%d%d%d",&v,&l,&r);
      Tree[v].left=l;
      Tree[v].right=r;
      if(l!=None)Tree[l].parent=v;
      if(r!=None)Tree[r].parent=v;
    }
    for(i=0;i<n;i++)if(Tree[i].parent==None)root=i;

    Dep(root,0);
    Hei(root);
    for(i=0;i<n;i++)print_out(i);
    return 0;
}
  
  Dep(int u,int d){
  if(u==None) return;
  Depth[u] = d;
  Dep(Tree[u].left,d+1);
  Dep(Tree[u].right,d+1);
}
int Hei(int u){
  int h1=0;
  int h2=0;
  if(Tree[u].left!=None)
    h1=Hei(Tree[u].left)+1;
  if(Tree[u].right!=None)
    h2= Hei(Tree[u].right)+1;
      if(h1>h2)return Height[u]=h1;
      else return Height[u]=h2;
}

int Sibling(int u){
  if(Tree[u].parent==None)return None;
  if(Tree[Tree[u].parent].left!=u&&Tree[Tree[u].parent].left!=None)
    return Tree[Tree[u].parent].left;
  if(Tree[Tree[u].parent].right!=u&&Tree[Tree[u].parent].right!=None)
    return Tree[Tree[u].parent].right;
     return None;
     }
  void print_out(int u){
    printf("node %d: ",u);
    printf("parent = = %d, ",Tree[u].parent);
    printf("sibling = %d ",Sibling(u));
    int deg =0;
    if(Tree[u].left!=None)deg++;
    if(Tree[u].right!=None)deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ", Depth[u]);
    printf("height = %d, ",Height[u]);

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

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

#include<stdio.h>
#define Max 10000
#define None -1

typedef struct{
  int parent, left ,right;
}Node;
Node Tree[Max];
int n,Depth[Max],Height[Max];
int Dep(int,int);
int  Hei(int);
void print_out(int );
int Sibling(int);
int main()
{
  int v,l,r,i;
  int root =0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    Tree[i].parent=None;
    for(i=0;i<n;i++){
      scanf("%d%d%d",&v,&l,&r);
      Tree[v].left=l;
      Tree[v].right=r;
      if(l!=None)Tree[l].parent=v;
      if(r!=None)Tree[r].parent=v;
    }
    for(i=0;i<n;i++)if(Tree[i].parent==None)root=i;

    Dep(root,0);
    Hei(root);
    for(i=0;i<n;i++)print_out(i);
    return 0;
}

  Dep(int u,int d){
  if(u==None) return;
  Depth[u] = d;
  Dep(Tree[u].left,d+1);
  Dep(Tree[u].right,d+1);
}
int Hei(int u){
  int h1=0;
  int h2=0;
  if(Tree[u].left!=None)
    h1=Hei(Tree[u].left)+1;
  if(Tree[u].right!=None)
    h2= Hei(Tree[u].right)+1;
      if(h1>h2)return Height[u]=h1;
      else return Height[u]=h2;
}

int Sibling(int u){
  if(Tree[u].parent==None)return None;
  if(Tree[Tree[u].parent].left!=u&&Tree[Tree[u].parent].left!=None)
    return Tree[Tree[u].parent].left;
  if(Tree[Tree[u].parent].right!=u&&Tree[Tree[u].parent].right!=None)
    return Tree[Tree[u].parent].right;
     return None;
     }
  void print_out(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",Tree[u].parent);
    printf("sibling = %d, ",Sibling(u));
    int deg =0;
    if(Tree[u].left!=None)deg++;
    if(Tree[u].right!=None)deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ", Depth[u]);
    printf("height = %d, ",Height[u]);

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

Compiler output:
a.cc:36:3: error: ISO C++ forbids declaration of 'Dep' with no type [-fpermissive]
   36 |   Dep(int u,int d){
      |   ^~~
a.cc: In function 'int Dep(int, int)':
a.cc:37:15: error: return-statement with no value, in function returning 'int' [-fpermissive]
   37 |   if(u==None) return;
      |               ^~~~~~
a.cc:40:6: warning: control reaches end of non-void function [-Wreturn-type]
   40 |   Dep(Tree[u].right,d+1);
      |   ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
typedef struct{
  int id;
  int left;
  int right;
  int parent;
  int sibling;
}Node;
 
Node *S;
 
int degree(int);
int depth(int);
int height(int);
 
int d = 0;
 
int main(){
  int i, n, id;
  char s[20];
 
  scanf("%d", &n);
 
  S = malloc(sizeof(Node)*n);
 
  //initialize
  for(i = 0; i < n; i++){
    S[i].parent = -1;
    S[i].sibling = -1;
  }
 
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    S[id].id = id;
 
    scanf("%d%d", &S[id].left, &S[id].right);
    S[S[id].left].parent = id;
    S[S[id].right].parent = id;
    S[S[id].left].sibling = S[id].right;
    S[S[id].right].sibling = S[id].left;
  }
 
  for(i = 0; i < n; i++){
    if(S[i].parent == -1) strcpy(s, "root");
    else if(S[i].left == -1 && S[i].right == -1) strcpy(s, "leaf");
    else strcpy(s,"internal node");
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, S[i].parent, S[i].sibling, degree(i), depth(i), height(i), s);
    d = 0;
  }
  return 0;
}
 
int degree(int i){
  int deg = 0;
 
  if(S[i].left != -1) deg++;
  if(S[i].right != -1) deg++;
  return deg;
}
 
int depth(int i){
  if(S[i].parent == -1) return d;
  else{
    d++;
    return depth(S[i].parent);
  }
}
 
int height(int i){
  int lef = 0, rig = 0;
 
  if(S[i].left != -1){
    lef++;
    lef += height(S[i].left);
  }
 
  if(S[i].right != -1){
    rig++;
    rig += height(S[i].right);
  }
 
  if(rig >= lef) return rig;
  else return lef;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: invalid conversion from 'void*' to 'Node*' [-fpermissive]
   27 |   S = malloc(sizeof(Node)*n);
      |       ~~~~~~^~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

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

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

int D[MAX], H[MAX], n, l, r, v, i;
struct Node T[MAX];

void start(int);
int check(int);
int divide(int);

int main()
{
  scanf("%d", &n);

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

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);

    T[v].l = l;
    T[v].r = r;

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

  }

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

    D[i] = check(i);
    H[i] = 0;

  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NUL && T[i].r == NUL ) { // leaf
      H[i] = 0;
      int p = T[i].p;
      int z = 1;
      while(1){
    if ( p == NUL ) break;
    if ( H[p] < z ) H[p] = z;
    z++;
    p = T[p].p;
      }
    }
  }

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


  return 0;
}

int divide(int u){
  if ( T[u].p == NUL ) return NUL;
  if ( T[T[u].p].l != u && T[T[u].p].l != NUL ) return T[T[u].p].l;
  if ( T[T[u].p].r != u && T[T[u].p].r != NUL ) return T[T[u].p].r;
  return NUL;
}

int check(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NUL ) break;
    d++;
  }
  return d;
}


void start(int u){
  int deg = 0;

  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", divide(u));

  if ( T[u].l != NUL ) chedkg++;
  if ( T[u].r != NUL ) deg++;

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

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

Compiler output:
a.cc: In function 'void start(int)':
a.cc:83:24: error: 'chedkg' was not declared in this scope; did you mean 'check'?
   83 |   if ( T[u].l != NUL ) chedkg++;
      |                        ^~~~~~
      |                        check
Language: C++

#include <iostream>
#define MAX 10000
#define NIL -1
using namespace std;

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

int setHight(int,int);
int setDepth(int,int);
int setSibling(int);
void print(int);

struct Node T[MAX];
int n,A[MAX],H[MAX];

int main(){
  int v,l,r,i;
  int root = 0;
  cin >> n;
  for(i = 0; i < n; i++){
    T[i].parent = NIL;
  }
  for(i = 0; i < n; i++){
    cin >> v >> l >> r;
    T[v].length = 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);
  setHight(root);
  for(i = 0; i < n; i++){
    print(i);
  }
  return 0;
}//end of main func

void setDepth(int u,int d){
  
}

int setHight(int u, int/*?????????...*/){
  
}
int setSibling(int u){
  
}
void print(int u){
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:10: error: 'struct Node' has no member named 'length'
   29 |     T[v].length = l;
      |          ^~~~~~
a.cc:44:11: error: too few arguments to function 'int setHight(int, int)'
   44 |   setHight(root);
      |   ~~~~~~~~^~~~~~
a.cc:12:5: note: declared here
   12 | int setHight(int,int);
      |     ^~~~~~~~
a.cc: At global scope:
a.cc:51:6: error: ambiguating new declaration of 'void setDepth(int, int)'
   51 | void setDepth(int u,int d){
      |      ^~~~~~~~
a.cc:13:5: note: old declaration 'int setDepth(int, int)'
   13 | int setDepth(int,int);
      |     ^~~~~~~~
a.cc: In function 'int setHight(int, int)':
a.cc:57:1: warning: no return statement in function returning non-void [-Wreturn-type]
   57 | }
      | ^
a.cc: In function 'int setSibling(int)':
a.cc:60:1: warning: no return statement in function returning non-void [-Wreturn-type]
   60 | }
      | ^
Language: C++

9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 9
      | ^