Language: C++

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

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

Node T[MAX];
init 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:9:1: error: 'init' does not name a type; did you mean 'int'?
    9 | init n,D[MAX];
      | ^~~~
      | int
a.cc: In function 'void print(int)':
a.cc:15:17: error: 'D' was not declared in this scope
   15 | cout<<"depth="<<D[u]<<",";
      |                 ^
a.cc:17:12: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   17 | if(T[u].p==NIL) cout<<"root, ";
      |            ^~~
      |            NTL
a.cc:23:21: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   23 | for(i=0,c=T[u].l;c!=NIL; i++,c=T[c].r){
      |                     ^~~
      |                     NTL
a.cc: In function 'int rec(int, int)':
a.cc:31:1: error: 'D' was not declared in this scope
   31 | D[u]=p;
      | ^
a.cc:32:12: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   32 | if(T[u].r!=NIL) rec(T[u].r,p);
      |            ^~~
      |            NTL
a.cc:33:12: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   33 | if(T[u].l!=NIL) rec(T[u].l,p+1);
      |            ^~~
      |            NTL
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
   34 | }
      | ^
a.cc: In function 'int main()':
a.cc:38:6: error: 'n' was not declared in this scope
   38 | cin>>n;
      |      ^
a.cc:39:39: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   39 | for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
      |                                       ^~~
      |                                       NTL
a.cc:41:18: error: expected primary-expression before '?' token
   41 | for(i=0;i<n;i++){???
      |                  ^
a.cc:41:19: error: expected primary-expression before '?' token
   41 | for(i=0;i<n;i++){???
      |                   ^
a.cc:41:20: error: expected primary-expression before '?' token
   41 | for(i=0;i<n;i++){???
      |                    ^
a.cc:42:10: error: expected ':' before ';' token
   42 | cin>>v>>d;
      |          ^
      |          :
a.cc:42:10: error: expected primary-expression before ';' token
a.cc:42:10: error: expected ':' before ';' token
   42 | cin>>v>>d;
      |          ^
      |          :
a.cc:42:10: error: expected primary-expression before ';' token
a.cc:42:10: error: expected ':' before ';' token
   42 | cin>>v>>d;
      |          ^
      |          :
a.cc:42:10: error: expected primary-expression before ';' token
a.cc:52:11: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   52 | if(T[i].p=NIL)r=i;
      |           ^~~
      |           NTL