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

#include<iostream>
using namespace std;
#define MAX 10005
#define NIL -1
struct Node {int p,l.r;};
Node T[MAX];
int n,D[MAX];
void print (int u){
int i,c;
cout<<"node"<<u<<":";
cout<<"parent="<<T[u].p<<",";
cout<<"depth="<<D[u]<<",";
if(T[u].p == NIL)cout<<root,";
else if(T[u].l ==)cout<<"reaf,";
else cout << "internal node,";
cout<<"";
for(i=0,c=T[u].l==NIL; i++,C = T[c].r ){
if(i)cout<<",";
cout<<c;
}
cout<<"]"<<endl;
}
int rec(int u,int p){
D[u] = p;
if(T[u].r != NIL )rec(T[u].r,p);
if(T[u].l != NIL )rec(T[u].r,p+1);	
}
int main(){
int i,j,d,v,c,l,r;
cin >> n;
for(i=0;i<n;i++)T[i].p = T[i].l = T[i].r = NIL;
for(i=0;i<n;i++){
cin>>v>>d;
for(j=0;j<d;j++){
if(j==0)T[v].l = c;
else T[l].r = c;
l=c;
T[c].p = v;
}
}
for(i=0;i<n;i++){
if(T[i].p==NIL)r=i;
}
rec(r,0);
for(i=0;i<0;i++)print(i);
return 0;
}


Compiler output:
a.cc:13:29: warning: missing terminating " character
   13 | if(T[u].p == NIL)cout<<root,";
      |                             ^
a.cc:13:29: error: missing terminating " character
   13 | if(T[u].p == NIL)cout<<root,";
      |                             ^~
a.cc:5:20: error: expected ';' at end of member declaration
    5 | struct Node {int p,l.r;};
      |                    ^
      |                     ;
a.cc:5:21: error: expected unqualified-id before '.' token
    5 | struct Node {int p,l.r;};
      |                     ^
a.cc: In function 'void print(int)':
a.cc:13:24: error: 'root' was not declared in this scope
   13 | if(T[u].p == NIL)cout<<root,";
      |                        ^~~~
a.cc:14:1: error: expected primary-expression before 'else'
   14 | else if(T[u].l ==)cout<<"reaf,";
      | ^~~~
a.cc:17:28: error: 'C' was not declared in this scope
   17 | for(i=0,c=T[u].l==NIL; i++,C = T[c].r ){
      |                            ^
a.cc:17:37: error: 'struct Node' has no member named 'r'
   17 | for(i=0,c=T[u].l==NIL; i++,C = T[c].r ){
      |                                     ^
a.cc:17:38: error: expected ';' before ')' token
   17 | for(i=0,c=T[u].l==NIL; i++,C = T[c].r ){
      |                                      ^~
      |                                      ;
a.cc: In function 'int rec(int, int)':
a.cc:25:9: error: 'struct Node' has no member named 'r'
   25 | if(T[u].r != NIL )rec(T[u].r,p);
      |         ^
a.cc:25:28: error: 'struct Node' has no member named 'r'
   25 | if(T[u].r != NIL )rec(T[u].r,p);
      |                            ^
a.cc:26:28: error: 'struct Node' has no member named 'r'
   26 | if(T[u].l != NIL )rec(T[u].r,p+1);
      |                            ^
a.cc:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
   27 | }
      | ^
a.cc: In function 'int main()':
a.cc:31:40: error: 'struct Node' has no member named 'r'
   31 | for(i=0;i<n;i++)T[i].p = T[i].l = T[i].r = NIL;
      |                                        ^
a.cc:36:11: error: 'struct Node' has no member named 'r'
   36 | else T[l].r = c;
      |           ^
Language: C++

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

struct Node {int p,l.r;};
Node T[MAX];
int n,D[MAX];
void print (int u){
int i,c;
cout<<"node"<<u<<":";
cout<<"parent="<<T[u].p<<",";
cout<<"depth="<<D[u]<<",";
if(T[u].p == NIL)cout<<root,";
else if(T[u].l ==)cout<<"reaf,";
else cout << "internal node,";
cout<<"";
for(i=0,c=T[u].l==NIL; i++,C = T[c].r ){
if(i)cout<<",";
cout<<c;
}
cout<<"]"<<endl;
}
int rec(int u,int p){
D[u] = p;
if(T[u].r != NIL )rec(T[u].r,p);
if(T[u].l != NIL )rec(T[u].r,p+1);	
}
int main(){
int i,j,d,v,c,l,r;
cin >> n;
for(i=0;i<n;i++)T[i].p = T[i].l = T[i].r = NIL;
for(i=0;i<n;i++){
cin>>v>>d;
for(j=0;j<d;j++){
if(j==0)T[v].l = c;
else T[l].r = c;
l=c;
T[c].p = v;
}
}
for(i=0;i<n;i++){
if(T[i].p==NIL)r=i;
}
rec(r,0);
for(i=0;i<0;i++)print(i);
return 0;
}


Compiler output:
a.cc:14:29: warning: missing terminating " character
   14 | if(T[u].p == NIL)cout<<root,";
      |                             ^
a.cc:14:29: error: missing terminating " character
   14 | if(T[u].p == NIL)cout<<root,";
      |                             ^~
a.cc:6:20: error: expected ';' at end of member declaration
    6 | struct Node {int p,l.r;};
      |                    ^
      |                     ;
a.cc:6:21: error: expected unqualified-id before '.' token
    6 | struct Node {int p,l.r;};
      |                     ^
a.cc: In function 'void print(int)':
a.cc:14:24: error: 'root' was not declared in this scope
   14 | if(T[u].p == NIL)cout<<root,";
      |                        ^~~~
a.cc:15:1: error: expected primary-expression before 'else'
   15 | else if(T[u].l ==)cout<<"reaf,";
      | ^~~~
a.cc:18:28: error: 'C' was not declared in this scope
   18 | for(i=0,c=T[u].l==NIL; i++,C = T[c].r ){
      |                            ^
a.cc:18:37: error: 'struct Node' has no member named 'r'
   18 | for(i=0,c=T[u].l==NIL; i++,C = T[c].r ){
      |                                     ^
a.cc:18:38: error: expected ';' before ')' token
   18 | for(i=0,c=T[u].l==NIL; i++,C = T[c].r ){
      |                                      ^~
      |                                      ;
a.cc: In function 'int rec(int, int)':
a.cc:26:9: error: 'struct Node' has no member named 'r'
   26 | if(T[u].r != NIL )rec(T[u].r,p);
      |         ^
a.cc:26:28: error: 'struct Node' has no member named 'r'
   26 | if(T[u].r != NIL )rec(T[u].r,p);
      |                            ^
a.cc:27:28: error: 'struct Node' has no member named 'r'
   27 | if(T[u].l != NIL )rec(T[u].r,p+1);
      |                            ^
a.cc:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
   28 | }
      | ^
a.cc: In function 'int main()':
a.cc:32:40: error: 'struct Node' has no member named 'r'
   32 | for(i=0;i<n;i++)T[i].p = T[i].l = T[i].r = NIL;
      |                                        ^
a.cc:37:11: error: 'struct Node' has no member named 'r'
   37 | else T[l].r = c;
      |           ^
Language: C++

#include<stdio.h>

int depth(int node,int a[]){
	int count = 0;
	while(a[node]!=-1){
		int parent = a[node];
		node = parent;
		count++;
	}
	return count;
}
void check_type(int a[], int node,int n){
	int tag = 0;//0: leaf, 1: internal
	if(a[node]==-1) printf("root, ");
	else{
		for(int i = 0; i<n; i++){
			if(a[i] == node) tag = 1;
		}
		if(tag==1) printf("internal node, ");
		else printf("leaf, ");
	}	
}

void check_children(int b[], int mark[], int node,int n){
	int index = mark[node]; //
	int count = b[index]; //how many children
	printf("[");
	for(int i = 0; i<count-1; i++){
		printf("%d, ",b[index+i+1]);
	}
	if(count!=0)
	printf("%d]",b[index+count]);
	else printf("]");
}
int main(){
	int n;
	scanf("%d",&n);
	int a[n];
	int b[100001];
	int depth[n];
	for(int i = 0; i<n; i++){
		a[i] = -1;
		depth[i] = 0;
	}
	int index = 0;
	int mark[n];
	for(int i = 0; i<n; i++){
		int parent;
		scanf("%d",&parent);
		//printf("parent: %d",parent);
		int k;scanf("%d",&k);
		//printf("parent: %d",k);
		mark[parent] = index;
		b[index++] = k;
		int child;
		for(int j = 0; j<k; j++){
			scanf("%d",&child);
			b[index++] = child;
			a[child] = parent;
		}
	}
	
	//print
	for(int i = 0; i<n; i++){
		printf("node %d: parent = %d, depth = %d, ",i,a[i],depth(i,a));
		check_type(a,i,n);
		check_children(b,mark,i,n);
		printf("\n");	
	}
	
	
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:73: error: 'depth' cannot be used as a function
   65 |                 printf("node %d: parent = %d, depth = %d, ",i,a[i],depth(i,a));
      |                                                                    ~~~~~^~~~~
Language: C++

#include<iostream>
#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:22: error: a function-definition is not allowed here before '{' token
   21 | int getSibling(int u){
      |                      ^
a.cc:29:18: error: a function-definition is not allowed here before '{' token
   29 | void print(int u){
      |                  ^
a.cc:47:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   47 | int main(){
      |         ^~
a.cc:47:9: note: remove parentheses to default-initialize a variable
   47 | int main(){
      |         ^~
      |         --
a.cc:47:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:47:11: error: a function-definition is not allowed here before '{' token
   47 | int main(){
      |           ^
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:13:21: note: to match this '{'
   13 | int setHeight(int u){
      |                     ^
a.cc:63:2: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      |  ^
Language: C++

#include <iostream>
using namespace std;
constexpr int MAX=1000000;
constexpr int NIL=-1;

struct Node{int parent, left, right;};
Node T[MAX];
int n, D[MAX];

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

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

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

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

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

   rec(r, 0);

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

   return 0;
}


Compiler output:
a.cc: In function 'void print(int)':
a.cc:22:32: error: expected ')' before ';' token
   22 |    for(i=0; c=T[u].left; c!=NIL; i++, c=T[c].right){
      |       ~                        ^
      |                                )
a.cc:22:51: error: expected ';' before ')' token
   22 |    for(i=0; c=T[u].left; c!=NIL; i++, c=T[c].right){
      |                                                   ^
      |                                                   ;
a.cc: In function 'int rec(int, int)':
a.cc:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
   33 | }
      | ^
a.cc: In function 'int main()':
a.cc:38:54: error: 'struct Node' has no member named 'r'
   38 |    for(i=0; i<n; i++) T[i].parent = T[i].left = T[i].r = NIL;
      |                                                      ^
Language: C++

#include <bits/stdc++.h>
#define inf (1<<29)
#define sq(n) ((n)*(n))
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define MEMSET(a) memset(a,0,sizeof(a))
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
using ll = long long;

#define MAX 100005
#define NIL -1

struct node{int p,l,r;};
node t[MAX];
int n,d[MAX];

void print(int u){
	cout<<"node "<<u<<": ";
	cout<<"parent = "<<t[u].p<<", ";
	cout<<"depth = "<<d[u]<<", ";
	if(t[u].p==NIL)cout<<"root, ";
	else if(t[u].l==NIL)cout<<"leaf, ";
	else cout<<"internal node, ";
	cout<<"[";
	int i,c;
	for(i=0,c=t[u].l;c!=NIL;i++,c=t[c].r){
		if(i)cout<<", ";
		cout<<c;
	}
	cout<<"]"<<endl;
}

void dep(int u,int p){
	d[u]=p;
	if(t[u].r!=NIL)dep(t[u].r,p);
	if(t[u].l!=NIL)dep(t[u].l,p+1);
}

signed main(){
	cin>>n;
	rep(i,n)t[i].p=t[i].l=t[i].r=NIL;
	rep(i,n){
		int id,k,c;
		cin>>id>>k;
		int l;
		rep(j,k){
			cin>>c;
			if(j)t[l].r=c;
			else t[id].l=c;
			t[c].p=id;
			l=c;
		}
	}
	rep(i,n)if(t[i].p==NIL)r=i;
	dep(r,0);
	rep(i,n)print(i);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:32: error: 'r' was not declared in this scope
   58 |         rep(i,n)if(t[i].p==NIL)r=i;
      |                                ^
a.cc:59:13: error: 'r' was not declared in this scope
   59 |         dep(r,0);
      |             ^
Language: C++

#include<iostream>
#include<vector>

struct Node{
    int parent;
    int depth;
    int num_of_child;
    std::vector<int> children;
    void NewNode(void){
        parent=-1;
        depth=num_of_child=0;
    }    
};

void calcHeight(std::vector<struct Node> &node,int root_id){
    for(int i=0;i<node[root_id].num_of_child;i++){
         node[node[root_id].children[i]]=node[root_id]+1;
        calcHeight(node,node[root_id].children[i]);
    }
}

int GetRootID(std::vector<struct Node> &node){
    for(int i=0;i<node.size();i++)
        if(node[i].parent==-1) return i;
}

int main(void){
    int n,k,id;
    std::cin>>n;
    std::vector<struct Node> node(n);
    for(int i=0;i<n;i++){
        std::cin>>id>>k;
        node[id].num_of_child=k;
        for(int j=0;j<k;j++){
            int child_id;
            std::cin>>child_id;
            node[id].children.push_back(child_id);
            node[child_id].parent=id;
        }

    }
    int root_id=GetRootID(node);
    calcHeight(node,root_id);

    for(int i=0;i<n;i++){
         if(nodes[i].parent == -1){
            printf("node %d: parent = -1, depth = 0, root, ",i);
        }else if(nodes[i].num_of_children == 0){
            printf("node %d: parent = %d, depth = %d, leaf, ",i,nodes[i].parent,nodes[i].depth);
        }else{
            printf("node %d: parent = %d, depth = %d, internal node, ",i,nodes[i].parent,nodes[i].depth);
        }
        printf("[");
        for(int j = 0; j < nodes[i].num_of_children-1; j++){
            printf("%d, ",nodes[i].children[j]);
        }
        if(nodes[i].num_of_children > 0){
            printf("%d",nodes[i].children[nodes[i].num_of_children-1]);
        }
        printf("]\n");
    }
    return 0;
}


Compiler output:
a.cc: In function 'void calcHeight(std::vector<Node>&, int)':
a.cc:17:55: error: no match for 'operator+' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<Node>, Node>::value_type' {aka 'Node'} and 'int')
   17 |          node[node[root_id].children[i]]=node[root_id]+1;
a.cc: In function 'int main()':
a.cc:46:13: error: 'nodes' was not declared in this scope; did you mean 'node'?
   46 |          if(nodes[i].parent == -1){
      |             ^~~~~
      |             node
a.cc:54:28: error: 'nodes' was not declared in this scope; did you mean 'node'?
   54 |         for(int j = 0; j < nodes[i].num_of_children-1; j++){
      |                            ^~~~~
      |                            node
a.cc:57:12: error: 'nodes' was not declared in this scope; did you mean 'node'?
   57 |         if(nodes[i].num_of_children > 0){
      |            ^~~~~
      |            node
a.cc: In function 'int GetRootID(std::vector<Node>&)':
a.cc:25:1: warning: control reaches end of non-void function [-Wreturn-type]
   25 | }
      | ^
Language: C++

#include<iostream>
#include<cstdio>
#include<vector>

struct Node{
    int parent;
    int depth;
    int num_of_child;
    std::vector<int> children;
    void NewNode(void){
        parent=-1;
        depth=num_of_child=0;
    }    
};

void calcHeight(std::vector<struct Node> &node,int root_id){
    for(int i=0;i<node[root_id].num_of_child;i++){
         node[node[root_id].children[i]].depth=node[root_id].depth+1;
        calcHeight(node,node[root_id].children[i]);
    }
}

int GetRootID(std::vector<struct Node> &node){
    for(int i=0;i<node.size();i++)
        if(node[i].parent==-1) return i;
}

int main(void){
    int n,k,id;
    std::cin>>n;
    std::vector<struct Node> node(n);
    for(int i=0;i<n;i++){
        std::cin>>id>>k;
        node[id].num_of_child=k;
        for(int j=0;j<k;j++){
            int child_id;
            std::cin>>child_id;
            node[id].children.push_back(child_id);
            node[child_id].parent=id;
        }

    }
    int root_id=GetRootID(node);
    calcHeight(node,root_id);

    for(int i=0;i<n;i++){
         if(node[i].parent == -1){
            printf("node %d: parent = -1, depth = 0, root, ",i);
        }else if(node[i].num_of_child == 0){
            printf("node %d: parent = %d, depth = %d, leaf, ",i,node[i].parent,node[i].depth);
        }else{
            printf("node %d: parent = %d, depth = %d, internal node, ",i,node[i].parent,node[i].depth);
        }
        printf("[");
        for(int j = 0; j < node[i].num_of_child-1; j++){
            printf("%d, ",node[i].children[j]);
        }
        if(node[i].num_of_children > 0){
            printf("%d",node[i].children[node[i].num_of_child-1]);
        }
        printf("]\n");
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:20: error: '__gnu_cxx::__alloc_traits<std::allocator<Node>, Node>::value_type' {aka 'struct Node'} has no member named 'num_of_children'; did you mean 'num_of_child'?
   58 |         if(node[i].num_of_children > 0){
      |                    ^~~~~~~~~~~~~~~
      |                    num_of_child
a.cc: In function 'int GetRootID(std::vector<Node>&)':
a.cc:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^
Language: C++

#include<iostream>

using namespace std;

#define MAX 100005
#define NIL -1

struct Node {
  int parent;
  int leftChild;
  int rightSibling;
};

Node T[MAX];
int D[MAX]

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

  if (T[u].parent == NIL) {
    cout << "root, ";
  } else if (T[u].leftChild == NIL) {
    cout << "leaf, ";
  } else {
    cout << "internal node, ";
  }

  cout << "[";

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

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

int main() {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    T[i].parent = T[i].leftChild = T[i].rightSibling = NIL;
  }

  int child, d, left;
  for (int i = 0; i < N; i++) {
    cin >> v >> d;
    for (int j = 0; j < d; j++) {
      cin >> child;
      if (j == 0) {
        T[v].leftChild = child;
      } else {
        T[left].rightSibling = child;
      }
      left = child;
      T[child].parent = v;
    }
  }

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

  rec(root, 0);

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

  return 0;
}


Compiler output:
a.cc:17:1: error: expected initializer before 'void'
   17 | void print(int u) {
      | ^~~~
a.cc: In function 'int rec(int, int)':
a.cc:41:3: error: 'D' was not declared in this scope
   41 |   D[u] = p;
      |   ^
a.cc:48:1: warning: no return statement in function returning non-void [-Wreturn-type]
   48 | }
      | ^
a.cc: In function 'int main()':
a.cc:60:12: error: 'v' was not declared in this scope
   60 |     cin >> v >> d;
      |            ^
a.cc:83:5: error: 'print' was not declared in this scope; did you mean 'printf'?
   83 |     print(i);
      |     ^~~~~
      |     printf
Language: C++

#include<iostream>

using namespace std;

#define MAX 100005
#define NIL -1

struct Node {
  int parent;
  int leftChild;
  int rightSibling;
};

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

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

  if (T[u].parent == NIL) {
    cout << "root, ";
  } else if (T[u].leftChild == NIL) {
    cout << "leaf, ";
  } else {
    cout << "internal node, ";
  }

  cout << "[";

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

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

int main() {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    T[i].parent = T[i].leftChild = T[i].rightSibling = NIL;
  }

  int child, d, left;
  for (int i = 0; i < N; i++) {
    cin >> v >> d;
    for (int j = 0; j < d; j++) {
      cin >> child;
      if (j == 0) {
        T[v].leftChild = child;
      } else {
        T[left].rightSibling = child;
      }
      left = child;
      T[child].parent = v;
    }
  }

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

  rec(root, 0);

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

  return 0;
}


Compiler output:
a.cc: In function 'void print(int)':
a.cc:32:51: error: expected ')' before ';' token
   32 |   for (int i = 0; int c = T[u].leftChild; c != NIL; i++, c = T[c].r) {
      |       ~                                           ^
a.cc:32:53: error: 'i' was not declared in this scope
   32 |   for (int i = 0; int c = T[u].leftChild; c != NIL; i++, c = T[c].r) {
      |                                                     ^
a.cc:32:58: error: 'c' was not declared in this scope
   32 |   for (int i = 0; int c = T[u].leftChild; c != NIL; i++, c = T[c].r) {
      |                                                          ^
a.cc: In function 'int rec(int, int)':
a.cc:48:1: warning: no return statement in function returning non-void [-Wreturn-type]
   48 | }
      | ^
a.cc: In function 'int main()':
a.cc:60:12: error: 'v' was not declared in this scope
   60 |     cin >> v >> d;
      |            ^
Language: C++

#include<iostream>

using namespace std;

#define MAX 100005
#define NIL -1

struct Node {
  int parent;
  int leftChild;
  int rightSibling;
};

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

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

  if (T[u].parent == NIL) {
    cout << "root, ";
  } else if (T[u].leftChild == NIL) {
    cout << "leaf, ";
  } else {
    cout << "internal node, ";
  }

  cout << "[";

  for (int i = 0; int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
    if (i) {
      cout << ", ";
    }
    cout << c;
  }
  cout << "]"
}

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

int main() {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    T[i].parent = T[i].leftChild = T[i].rightSibling = NIL;
  }

  int child, d, left;
  for (int i = 0; i < N; i++) {
    cin >> v >> d;
    for (int j = 0; j < d; j++) {
      cin >> child;
      if (j == 0) {
        T[v].leftChild = child;
      } else {
        T[left].rightSibling = child;
      }
      left = child;
      T[child].parent = v;
    }
  }

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

  rec(root, 0);

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

  return 0;
}


Compiler output:
a.cc: In function 'void print(int)':
a.cc:32:51: error: expected ')' before ';' token
   32 |   for (int i = 0; int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |       ~                                           ^
a.cc:32:53: error: 'i' was not declared in this scope
   32 |   for (int i = 0; int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                                                     ^
a.cc:32:58: error: 'c' was not declared in this scope
   32 |   for (int i = 0; int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                                                          ^
a.cc:38:14: error: expected ';' before '}' token
   38 |   cout << "]"
      |              ^
      |              ;
   39 | }
      | ~             
a.cc: In function 'int rec(int, int)':
a.cc:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
   49 | }
      | ^
a.cc: In function 'int main()':
a.cc:61:12: error: 'v' was not declared in this scope
   61 |     cin >> v >> d;
      |            ^
Language: C++

#include<iostream>

using namespace std;

#define MAX 100005
#define NIL -1

struct Node {
  int parent;
  int leftChild;
  int rightSibling;
};

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

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

  if (T[u].parent == NIL) {
    cout << "root, ";
  } else if (T[u].leftChild == NIL) {
    cout << "leaf, ";
  } else {
    cout << "internal node, ";
  }

  cout << "[";

  for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
    if (i) {
      cout << ", ";
    }
    cout << c;
  }
  cout << "]"
}

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

int main() {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    T[i].parent = T[i].leftChild = T[i].rightSibling = NIL;
  }

  int child, v, d, left;
  for (int i = 0; i < N; i++) {
    cin >> v >> d;
    for (int j = 0; j < d; j++) {
      cin >> child;
      if (j == 0) {
        T[v].leftChild = child;
      } else {
        T[left].rightSibling = child;
      }
      left = child;
      T[child].parent = v;
    }
  }

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

  rec(root, 0);

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

  return 0;
}


Compiler output:
a.cc: In function 'void print(int)':
a.cc:32:19: error: expected unqualified-id before 'int'
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                   ^~~
a.cc:32:18: error: expected ';' before 'int'
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                  ^~~~
      |                  ;
a.cc:32:51: error: expected ')' before ';' token
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |       ~                                           ^
a.cc:32:53: error: 'i' was not declared in this scope
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                                                     ^
a.cc:32:58: error: 'c' was not declared in this scope
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                                                          ^
a.cc:38:14: error: expected ';' before '}' token
   38 |   cout << "]"
      |              ^
      |              ;
   39 | }
      | ~             
a.cc: In function 'int rec(int, int)':
a.cc:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
   49 | }
      | ^
Language: C++

#include<iostream>

using namespace std;

#define MAX 100005
#define NIL -1

struct Node {
  int parent;
  int leftChild;
  int rightSibling;
};

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

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

  if (T[u].parent == NIL) {
    cout << "root, ";
  } else if (T[u].leftChild == NIL) {
    cout << "leaf, ";
  } else {
    cout << "internal node, ";
  }

  cout << "[";

  for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
    if (i) {
      cout << ", ";
    }
    cout << c;
  }
  cout << "]";
}

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

int main() {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    T[i].parent = T[i].leftChild = T[i].rightSibling = NIL;
  }

  int child, v, d, left;
  for (int i = 0; i < N; i++) {
    cin >> v >> d;
    for (int j = 0; j < d; j++) {
      cin >> child;
      if (j == 0) {
        T[v].leftChild = child;
      } else {
        T[left].rightSibling = child;
      }
      left = child;
      T[child].parent = v;
    }
  }

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

  rec(root, 0);

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

  return 0;
}


Compiler output:
a.cc: In function 'void print(int)':
a.cc:32:19: error: expected unqualified-id before 'int'
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                   ^~~
a.cc:32:18: error: expected ';' before 'int'
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                  ^~~~
      |                  ;
a.cc:32:51: error: expected ')' before ';' token
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |       ~                                           ^
a.cc:32:53: error: 'i' was not declared in this scope
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                                                     ^
a.cc:32:58: error: 'c' was not declared in this scope
   32 |   for (int i = 0, int c = T[u].leftChild; c != NIL; i++, c = T[c].rightSibling) {
      |                                                          ^
a.cc: In function 'int rec(int, int)':
a.cc:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
   49 | }
      | ^
Language: C++

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

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

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

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

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

  cout << "[";

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

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

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

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

  rec(r, 0);

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

  return 0;
}


Compiler output:
a.cc:15:36: warning: missing terminating " character
   15 |   cout << depth =  " << D[u] << ", ";
      |                                    ^
a.cc:15:36: error: missing terminating " character
   15 |   cout << depth =  " << D[u] << ", ";
      |                                    ^~
a.cc: In function 'void print(int)':
a.cc:14:28: error: 'j' was not declared in this scope
   14 |   cout << "parent = " << T[j].p << ", ";
      |                            ^
a.cc:15:11: error: 'depth' was not declared in this scope
   15 |   cout << depth =  " << D[u] << ", ";
      |           ^~~~~
a.cc:17:3: error: expected primary-expression before 'if'
   17 |   if ( T[u].p == NIL ) cout << "root, ";
      |   ^~
a.cc:18:3: error: 'else' without a previous 'if'
   18 |   else if ( T[u].l == NIL ) cout << "leaf, ";
      |   ^~~~
a.cc:27:14: error: invalid operands of types 'const char [2]' and '<unresolved overloaded function type>' to binary 'operator<<'
   27 |   cout < "]" << endl;
      |          ~~~~^~~~~~~
a.cc: In function 'int rec(int, int)':
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
   34 | }
      | ^
Language: C++

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

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

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

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

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

  cout << "[";

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

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

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

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

  rec(r, 0);

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

  return 0;
}


Compiler output:
a.cc: In function 'void print(int)':
a.cc:14:28: error: 'j' was not declared in this scope
   14 |   cout << "parent = " << T[j].p << ", ";
      |                            ^
a.cc:27:14: error: invalid operands of types 'const char [2]' and '<unresolved overloaded function type>' to binary 'operator<<'
   27 |   cout < "]" << endl;
      |          ~~~~^~~~~~~
a.cc: In function 'int rec(int, int)':
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
   34 | }
      | ^
Language: C++

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

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

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

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

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

  cout << "[";

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

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

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

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

  rec(r, 0);

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

  return 0;
}


Compiler output:
a.cc: In function 'void print(int)':
a.cc:27:14: error: invalid operands of types 'const char [2]' and '<unresolved overloaded function type>' to binary 'operator<<'
   27 |   cout < "]" << endl;
      |          ~~~~^~~~~~~
a.cc: In function 'int rec(int, int)':
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
   34 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
map <int ,int> mpa,mpb;
#define MAX 100005
#define NIL -1

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

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

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

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

int rec(int u,int p){
  D[u]=p;
  if(T[u].r !=NIL) rec(T[u].r,p);//深さを入れてく
  if(T[u].l !=NIL) rec(T[u].l,p+1);
}

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

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

  return 0;
}



Compiler output:
a.cc: In function 'void print(int)':
a.cc:27:22: error: expected ')' before ']' token
   27 |   else if(T[u].l==NIL]) cout << "leaf, ";
      |          ~           ^
a.cc:27:22: error: expected primary-expression before ']' token
a.cc: In function 'int rec(int, int)':
a.cc:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^
a.cc: In function 'int main()':
a.cc:65:2: error: expected '}' at end of input
   65 | }
      |  ^
a.cc:44:11: note: to match this '{'
   44 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
map <int ,int> mpa,mpb;
#define MAX 100005
#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 setHigh(int u){
  int h1=0, h2=0;
  if(T[u].left != NIL) h1=setHigh(T[u].left)+1;
  if(T[u].right != NIL) h1=setHigh(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(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].paretn=v;
  if(r !=NIL) T[r].paretn=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;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:7: error: 'i' was not declared in this scope
   69 |   for(i=0;i<n;i++) T[i].parent=NIL;//初期化
      |       ^
a.cc:71:7: error: 'i' was not declared in this scope
   71 |   for(i=0;i<n;i++){
      |       ^
a.cc:72:23: error: expected primary-expression before '%' token
   72 |   scanf("%d %d %d",&v,%l,&r);
      |                       ^
a.cc:75:20: error: 'struct Node' has no member named 'paretn'; did you mean 'parent'?
   75 |   if(l !=NIL) T[l].paretn=v;
      |                    ^~~~~~
      |                    parent
a.cc:76:20: error: 'struct Node' has no member named 'paretn'; did you mean 'parent'?
   76 |   if(r !=NIL) T[r].paretn=v;
      |                    ^~~~~~
      |                    parent
a.cc:79:7: error: 'i' was not declared in this scope
   79 |   for(i=0;i<n;i++) if(T[i].parent==NIL) root=i;
      |       ^
a.cc:82:3: error: 'setHight' was not declared in this scope; did you mean 'setHigh'?
   82 |   setHight(root);
      |   ^~~~~~~~
      |   setHigh
a.cc:84:7: error: 'i' was not declared in this scope
   84 |   for(i=0;i<n;i++) print(i);
      |       ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
map <int ,int> mpa,mpb;
#define MAX 100005
#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 setHigh(int u){
  int h1=0, h2=0;
  if(T[u].left != NIL) h1=setHigh(T[u].left)+1;
  if(T[u].right != NIL) h1=setHigh(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);
  int i;
  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].paretn=v;
  if(r !=NIL) T[r].paretn=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;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:72:23: error: expected primary-expression before '%' token
   72 |   scanf("%d %d %d",&v,%l,&r);
      |                       ^
a.cc:75:20: error: 'struct Node' has no member named 'paretn'; did you mean 'parent'?
   75 |   if(l !=NIL) T[l].paretn=v;
      |                    ^~~~~~
      |                    parent
a.cc:76:20: error: 'struct Node' has no member named 'paretn'; did you mean 'parent'?
   76 |   if(r !=NIL) T[r].paretn=v;
      |                    ^~~~~~
      |                    parent
a.cc:82:3: error: 'setHight' was not declared in this scope; did you mean 'setHigh'?
   82 |   setHight(root);
      |   ^~~~~~~~
      |   setHigh
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
map <int ,int> mpa,mpb;
#define MAX 100005
#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 setHigh(int u){
  int h1=0, h2=0;
  if(T[u].left != NIL) h1=setHigh(T[u].left)+1;
  if(T[u].right != NIL) h1=setHigh(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);
  int i;
  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].paretn=v;
  if(r !=NIL) T[r].paretn=v;
  }

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

  setDepth(root,0);
  setHigh(root);

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

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:75:20: error: 'struct Node' has no member named 'paretn'; did you mean 'parent'?
   75 |   if(l !=NIL) T[l].paretn=v;
      |                    ^~~~~~
      |                    parent
a.cc:76:20: error: 'struct Node' has no member named 'paretn'; did you mean 'parent'?
   76 |   if(r !=NIL) T[r].paretn=v;
      |                    ^~~~~~
      |                    parent
Language: C++

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

struct Node {
    int p, l, r;
}

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

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";
    
    if(T[u].p == NIL) cout << "root, ";
    else if(T[u].l = NIL) cout << "leaf, ";
    else cout << "internal node, ";
    
    cout << "[";
    for (i=0, c=T[u].l; c!= NIL; c=T[c].r) {
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
} 

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

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


Compiler output:
a.cc:10:6: error: expected initializer before 'T'
   10 | Node T[MAX];
      |      ^
a.cc: In function 'void print(int)':
a.cc:16:28: error: 'T' was not declared in this scope
   16 |     cout << "parent = " << T[u].p << ", ";
      |                            ^
a.cc: In function 'int rec(int, int)':
a.cc:33:9: error: 'T' was not declared in this scope
   33 |     if (T[u].r != NIL) rec(T[u].r, p);
      |         ^
a.cc:34:9: error: 'T' was not declared in this scope
   34 |     if (T[u].l != NIL) rec(T[u].l, p+1);
      |         ^
a.cc:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^
a.cc: In function 'int main()':
a.cc:40:25: error: 'T' was not declared in this scope
   40 |     for (i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
      |                         ^
a.cc:46:22: error: 'T' was not declared in this scope
   46 |             if(j==0) T[v].l = c;
      |                      ^
a.cc:47:18: error: 'T' was not declared in this scope
   47 |             else T[l].r = c;
      |                  ^
a.cc:49:13: error: 'T' was not declared in this scope
   49 |             T[c].p = v;
      |             ^
a.cc:54:12: error: 'T' was not declared in this scope
   54 |         if(T[i].p == NIL) r=i;
      |            ^