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

#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
#define EPS  1e-10//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

#define MAX 100000

using namespace std;

int G[MAX][MAX],id[MAX],parent[MAX],deep[MAX],si[MAX],n,k;
bool used[MAX];
void deepcalc(int u,int p){
  deep[u]=p;
  for(int i=0;i<si[u];i++){
    deepcalc(G[u][i],p+1);
    parent[G[u][i]]=u;
  }
}
int main(){
  for(int i=0;i<MAX;i++) parent[i]=-1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>id[i]>>k;
    si[id[i]]=k;
    for(int j=0;j<k;j++){
      cin>>G[id[i]][j];
      used[G[id[i]][j]]=true;
    }
  }
  for(int i=0;i<n;i++)
    if(!used[i])
      deepcalc(i,0);
  for(int i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,parent[i],deep[i]);
    if(parent[i]<0)printf("root");
    else if(si[i]==0)printf("leaf");
    else printf("internal node");
    printf(", [");
    for(int j=0;j<si[i]-1;j++)
      cout<<G[i][j]<<", ";
    if(G[i][si[i]-1]!=0)
      cout<<G[i][si[i]-1];
    cout<<"]"<<endl;

  }
  return 0;
}


Compiler output:
/tmp/cc9yd3C9.o: in function `deepcalc(int, int)':
a.cc:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `deep' defined in .bss section in /tmp/cc9yd3C9.o
a.cc:(.text+0x9b): relocation truncated to fit: R_X86_64_PC32 against symbol `parent' defined in .bss section in /tmp/cc9yd3C9.o
a.cc:(.text+0xb9): relocation truncated to fit: R_X86_64_PC32 against symbol `si' defined in .bss section in /tmp/cc9yd3C9.o
/tmp/cc9yd3C9.o: in function `main':
a.cc:(.text+0xee): relocation truncated to fit: R_X86_64_PC32 against symbol `parent' defined in .bss section in /tmp/cc9yd3C9.o
a.cc:(.text+0x109): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc9yd3C9.o
a.cc:(.text+0x13b): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/cc9yd3C9.o
a.cc:(.text+0x15a): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc9yd3C9.o
a.cc:(.text+0x179): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/cc9yd3C9.o
a.cc:(.text+0x182): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc9yd3C9.o
a.cc:(.text+0x194): relocation truncated to fit: R_X86_64_PC32 against symbol `si' defined in .bss section in /tmp/cc9yd3C9.o
a.cc:(.text+0x1b7): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
#define EPS  1e-10//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

#define MAX 100000

using namespace std;

int G[MAX][MAX],id[MAX],parent[MAX],deepl[MAX],si[MAX],n,k;
bool used[MAX];
void deepcalc(int u,int p){
  deepl[u]=p;
  for(int i=0;i<si[u];i++){
    deepcalc(G[u][i],p+1);
    parent[G[u][i]]=u;
  }
}
int main(){
  for(int i=0;i<MAX;i++) parent[i]=-1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>id[i]>>k;
    si[id[i]]=k;
    for(int j=0;j<k;j++){
      cin>>G[id[i]][j];
      used[G[id[i]][j]]=true;
    }
  }
  for(int i=0;i<n;i++)
    if(!used[i])
      deepcalc(i,0);
  for(int i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,parent[i],deepl[i]);
    if(parent[i]<0)printf("root");
    else if(si[i]==0)printf("leaf");
    else printf("internal node");
    printf(", [");
    for(int j=0;j<si[i]-1;j++)
      cout<<G[i][j]<<", ";
    if(G[i][si[i]-1]!=0)
      cout<<G[i][si[i]-1];
    cout<<"]"<<endl;
    
  }
  return 0;
}



Compiler output:
/tmp/ccxvFCJE.o: in function `deepcalc(int, int)':
a.cc:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `deepl' defined in .bss section in /tmp/ccxvFCJE.o
a.cc:(.text+0x9b): relocation truncated to fit: R_X86_64_PC32 against symbol `parent' defined in .bss section in /tmp/ccxvFCJE.o
a.cc:(.text+0xb9): relocation truncated to fit: R_X86_64_PC32 against symbol `si' defined in .bss section in /tmp/ccxvFCJE.o
/tmp/ccxvFCJE.o: in function `main':
a.cc:(.text+0xee): relocation truncated to fit: R_X86_64_PC32 against symbol `parent' defined in .bss section in /tmp/ccxvFCJE.o
a.cc:(.text+0x109): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccxvFCJE.o
a.cc:(.text+0x13b): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccxvFCJE.o
a.cc:(.text+0x15a): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccxvFCJE.o
a.cc:(.text+0x179): relocation truncated to fit: R_X86_64_PC32 against symbol `id' defined in .bss section in /tmp/ccxvFCJE.o
a.cc:(.text+0x182): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccxvFCJE.o
a.cc:(.text+0x194): relocation truncated to fit: R_X86_64_PC32 against symbol `si' defined in .bss section in /tmp/ccxvFCJE.o
a.cc:(.text+0x1b7): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<stdio.h>

#define MAX 10000
#define NIL -1

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

struct Node T[MAX];
int n,D[MAX],H[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:14:3: error: 'cout' was not declared in this scope
   14 |   cout<<"node"<<u<<": ";
      |   ^~~~
a.cc:24:26: error: expected ')' before ';' token
   24 |   for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |      ~                   ^
a.cc:24:39: error: expected ';' before ')' token
   24 |   for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |                                       ^
      |                                       ;
a.cc:28:14: error: 'endl' was not declared in this scope
   28 |   cout<<"]"<<endl;}
      |              ^~~~
a.cc: In function 'int rec(int, int)':
a.cc:33:34: warning: no return statement in function returning non-void [-Wreturn-type]
   33 |   if(T[u].l!=NIL)rec(T[u].l,p+1);}
      |                                  ^
a.cc: In function 'int main()':
a.cc:37:3: error: 'cin' was not declared in this scope
   37 |   cin>>n;
      |   ^~~
Language: C++

N = int(input())

def get_parent(node):
    parent = -1
    if "parent" in node:
        parent = node["parent"]
    return parent

def get_depth(node):
    depth = 0
    while "parent" not in node:
        depth += 1
        parent = node["parent"]
        node = rooted_tree[parent]
    return depth

def get_node_type(node):
    if "parent" in node:
        return "root"
    if "left" in node:
        return "leaf"
    return "internal node"

def get_children(node):
    if "left" not in node:
        return "[]"
    left = node["left"]
    siblings = []
    siblings.append(str(left))
    while rooted_tree[left]["right"] > -1:
        right = rooted_tree[left]["right"]
        siblings.append(str(right))
        left = right
    return "[{}]".format(", ".join(siblings))

rooted_tree = [{} for i in range(N)]
for id in range(N):
    row = input()
    _, degree, *children = list(map(int, row.split()))
    if degree > 0:
        rooted_tree[id]["left"] = children[0]
        for i in range(len(children)):
            child_id = children[i]
            right = -1
            if i < len(children)-1:
                right = children[i+1]
            rooted_tree[child_id]["right"] = right
            rooted_tree[child_id]["parent"] = id

for id in range(N):
    node = rooted_tree[id]
    parent = get_parent(node)
    depth = get_depth(node)
    node_type = get_node_type(node)
    children = get_children(node)
    print("node {}: parent = {}, depth = {}, {}, {}".format(id, parent, depth, node_type, children))


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
a.cc:36:19: error: expected unqualified-id before 'for'
   36 | rooted_tree = [{} for i in range(N)]
      |                   ^~~
Language: C++

#include<stdio.h>

int parent[100001];
int count[100001];
int root[100001][100001];
int flag[100001];
int depth(int);

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

  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    parent[i] = -1;
    flag[i] = 1;
  }
  
  for(i=0; i<n; i++){
    scanf("%d %d",&id,&k);
    count[id]=k;
    node=0;
    while(k-->=1){
      scanf("%d",&c);
      root[id][node++]=c;
      parent[c]=id;
      flag[id]=0;
    }
  } 
    
    for(i=0; i<n; i++){
      int j,l;
      printf("node %d: parent = %d, depth = %d, ",i,parent[i],depth(i));
      if(flag[i]==1 && depth(i)==0){
	printf("root, []\n");
      }

      else if(flag[i] == 1)
	printf("leaf, []\n");

      else if(depth(i) == 0){
	printf("root, [");
	for(j=0; j<count[i]-1; j++){
	    printf("%d, ",root[i][j]);
	    }
	  printf("%d]\n",root[i][j]);
	  l=j+1;
      }

      else{
	printf("internal node, [");
	for(j=0; j<count[i]-1; j++){
	    printf("%d, ",root[i][j]);
	    }
	  printf("%d]\n",root[i][j]);
      }
    }
    return 0;
}

int depth(int i){
  if(parent[i] == -1)return 0;
  else return depth(parent[i])+1;
}



Compiler output:
/tmp/cc28IbG9.o: in function `main':
a.cc:(.text+0x57): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc28IbG9.o
a.cc:(.text+0x136): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc28IbG9.o
a.cc:(.text+0x1bf): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc28IbG9.o
a.cc:(.text+0x20d): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc28IbG9.o
collect2: error: ld returned 1 exit status
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]<<",";
  cout<<"depth"<<D[u]<<",";

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

  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:1:1: error: 'include' does not name a type
    1 | include<iostream>
      | ^~~~~~~
a.cc:6:22: error: expected ';' at end of member declaration
    6 | struct Node {int p,l,r};
      |                      ^
      |                       ;
a.cc: In function 'void print(int)':
a.cc:13:3: error: 'cout' was not declared in this scope
   13 |   cout<<"node"<<u<<";";
      |   ^~~~
a.cc:25:14: error: 'endl' was not declared in this scope
   25 |   cout<<"]"<<endl;
      |              ^~~~
a.cc: In function 'int rec(int, int)':
a.cc:32:1: warning: no return statement in function returning non-void [-Wreturn-type]
   32 | }
      | ^
a.cc: In function 'int main()':
a.cc:35:9: error: expected unqualified-id before ',' token
   35 |   int i,,j,d,v,c,l,r;
      |         ^
a.cc:36:3: error: 'cin' was not declared in this scope
   36 |   cin>>n;
      |   ^~~
Language: C++

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

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

Node T[MAX];
int x,y[MAX];

void print(int u){
  int i;
  int c;
  cout<<"node"<<u<<":";
  cout<<"parent ="<<T[u].p<<",";
  cout<<"depth ="<<y[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 main(){
  int i,j,k;
  int a,b,c,d;
  cin>>x;
  for(i=0;i<x;i++)T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<x;i++){
    cin >> a >> k;
    for(j=0;j<k;j++){
      cin>>b;
      if(j==0)T[a].l=b;
      else T[c].r=b;
      c=b;
      T[b].p=a;
}
}
  for(i=0;i<x;i++){

    if(T[i].p==NIL)d=i;
}
  rec(d,0);

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



Compiler output:
a.cc: In function 'int main()':
a.cc:51:3: error: 'rec' was not declared in this scope
   51 |   rec(d,0);
      |   ^~~
Language: C++

#include<stdio.h>

#define MAX 100005
#define NTL -1

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

int n,H,D[MAX];

int main() {
  int i,j,d,v,c,l;

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

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

  H = 0;
  for(i = 0 ; i < n ; i++) {
    D[i] = getDepth(i);
    if(D[i] > H)
      H =D[i];
  }

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

int getDepth(int x) {
  int d=0;

  for(; T[x].p != NTL ; d++)
    x = T[x].p;
  return d;
}

int print(int x) {
  int i,h;

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

  if(T[x].p == NTL)
    printf("root, ");
  else if(T[x].l == NTL)
    printf("leaf, ");
  else printf("internal node, ");

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






Compiler output:
a.cc: In function 'int main()':
a.cc:33:12: error: 'getDepth' was not declared in this scope
   33 |     D[i] = getDepth(i);
      |            ^~~~~~~~
a.cc:39:5: error: 'print' was not declared in this scope; did you mean 'printf'?
   39 |     print(i);
      |     ^~~~~
      |     printf
a.cc: In function 'int print(int)':
a.cc:70:1: warning: no return statement in function returning non-void [-Wreturn-type]
   70 | }
      | ^
Language: C++

#include<stdio.h>

#define MAX 100005
#define NTL -1

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

int n,H,D[MAX];

int main() {
  int i,j,d,v,c,l;

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

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

  H = 0;
  for(i = 0 ; i < n ; i++) {
    D[i] = getDepth(i);
    if(D[i] > H)
      H =D[i];
  }

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

int getDepth(int x) {
  int d=0;

  for(; T[x].p != NTL ; d++)
    x = T[x].p;
  return d;
}

int print(int x) {
  int i,c;

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

  if(T[x].p == NTL)
    printf("root, ");
  else if(T[x].l == NTL)
    printf("leaf, ");
  else printf("internal node, ");

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




Compiler output:
a.cc: In function 'int main()':
a.cc:33:12: error: 'getDepth' was not declared in this scope
   33 |     D[i] = getDepth(i);
      |            ^~~~~~~~
a.cc:39:5: error: 'print' was not declared in this scope; did you mean 'printf'?
   39 |     print(i);
      |     ^~~~~
      |     printf
a.cc: In function 'int print(int)':
a.cc:70:1: warning: no return statement in function returning non-void [-Wreturn-type]
   70 | }
      | ^
Language: C++

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

struct Node
{
	int p, l, r;	//parent, left, right
};

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 << "[";
	for (int i = 0, int c = T[u].l; c != NIL; i++, c = T[c].r)
	{
		if (i)
		{
			cout << ", ";
		}
		cout << c;
	}
	cout << "]\n";
}

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()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		T[i].p = T[i].l = T[i].r = NIL;
	}
	int v, d, c, l, r;
	for (int i = 0; i < n; i++)
	{
		cin >> v >> d;
		for (int 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 (int i = 0; i < n; i++)
	{
		if (T[i].p == NIL)
		{
			r = i;
		}
	}
	rec(r, 0);

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


Compiler output:
a.cc: In function 'void print(int)':
a.cc:33:25: error: expected unqualified-id before 'int'
   33 |         for (int i = 0, int c = T[u].l; c != NIL; i++, c = T[c].r)
      |                         ^~~
a.cc:33:24: error: expected ';' before 'int'
   33 |         for (int i = 0, int c = T[u].l; c != NIL; i++, c = T[c].r)
      |                        ^~~~
      |                        ;
a.cc:33:49: error: expected ')' before ';' token
   33 |         for (int i = 0, int c = T[u].l; c != NIL; i++, c = T[c].r)
      |             ~                                   ^
a.cc:33:51: error: 'i' was not declared in this scope
   33 |         for (int i = 0, int c = T[u].l; c != NIL; i++, c = T[c].r)
      |                                                   ^
a.cc:33:56: error: 'c' was not declared in this scope
   33 |         for (int i = 0, int c = T[u].l; c != NIL; i++, c = T[c].r)
      |                                                        ^
a.cc: In function 'int rec(int, int)':
a.cc:55:1: warning: no return statement in function returning non-void [-Wreturn-type]
   55 | }
      | ^
Language: C++

//
//  main.cpp
//  ALDS1_7_A
//
//  Created by ptyuan on 2018/11/3.
//  Copyright © 2018 YY. All rights reserved.
//

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

struct Node {
    int parent = - 1;
    int left;
    int right;
};

const int kCount = 100000;
const int kNil = -1;
Node tree[kCount];
int D[kCount];
int n = 0;

void depth(int u, int p) {
    D[u] = p;
    if (tree[u].right != kNil) { depth(tree[u].right, p); }
    if (tree[u].left != kNil) { depth(tree[u].left, p + 1); }
}

void print(int u) {
    cout << "node " << u << ": ";
    cout << "parent = " << tree[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";
    
    if (kNil == tree[u].parent) {
        cout << "root, ";
    } else if (kNil == tree[u].left) {
        cout << "leaf, ";
    } else {
        cout << "internal node, ";
    }
    
    cout << "[";
    int c = 0;
    for (int i = 0, c = tree[u].left; c != kNil; c = tree[c].right, i++) {
        if (i > 0) cout << ", ";
        cout << c;
    }
    
    cout << "]" << endl;
}

int main(int argc, const char * argv[]) {
    
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        Node temp;
        temp.parent = temp.left = temp.right = kNil;
        tree[i] = temp;
    }
    
    for (int i = 0; i < n; ++i) {
        int nodeIndex = kNil;
        scanf("%d", &nodeIndex);
        
        int depth = 0;
        scanf("%d", &depth);
        int parentNode = nodeIndex;
        for (int j = 0; j < depth; j++) {
            int subNodeIndex = kNil;
            scanf("%d", &subNodeIndex);
            tree[subNodeIndex] = parentNode;
            if (0 == j) {
                tree[parentNode].left = subNodeIndex;
            } else {
                tree[parentNode].right = subNodeIndex;
                parentNode = subNodeIndex;
            }
        }
    }
    
    int root = kNil;
    for (int i = 0; i < n; i++) {
        if (tree[i].parent == kNil) {
            root = i;
        }
    }
    
    depth(root, 0);
    
    for (int i = 0; i < n; i++) {
        print(i);
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:73:34: error: no match for 'operator=' (operand types are 'Node' and 'int')
   73 |             tree[subNodeIndex] = parentNode;
      |                                  ^~~~~~~~~~
a.cc:13:8: note: candidate: 'constexpr Node& Node::operator=(const Node&)'
   13 | struct Node {
      |        ^~~~
a.cc:13:8: note:   no known conversion for argument 1 from 'int' to 'const Node&'
a.cc:13:8: note: candidate: 'constexpr Node& Node::operator=(Node&&)'
a.cc:13:8: note:   no known conversion for argument 1 from 'int' to 'Node&&'
Language: C++

#include<iostream>
using namespace std;
#define ll = long long;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#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[u].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:3:12: error: expected unqualified-id before '=' token
    3 | #define ll = long long;
      |            ^
a.cc:4:1: note: in expansion of macro 'll'
    4 | ll MM = 1000000000;
      | ^~
a.cc:4:4: error: 'MM' does not name a type
    4 | ll MM = 1000000000;
      |    ^~
a.cc:3:12: error: expected unqualified-id before '=' token
    3 | #define ll = long long;
      |            ^
a.cc:5:1: note: in expansion of macro 'll'
    5 | ll mod = MM + 7;
      | ^~
a.cc:5:4: error: 'mod' does not name a type
    5 | ll mod = MM + 7;
      |    ^~~
a.cc: In function 'void print(int)':
a.cc:27:36: error: expected ')' before ';' token
   27 |     for(i = 0; c = T[u].l; c != NIL; i++, c = T[u].r){
      |        ~                           ^
a.cc:27:53: error: expected ';' before ')' token
   27 |     for(i = 0; c = T[u].l; c != NIL; i++, c = T[u].r){
      |                                                     ^
      |                                                     ;
a.cc: In function 'int rec(int, int)':
a.cc:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
Language: C++

#include<iostream>
using namespace std;
#define ll long long;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#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[u].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:3:17: error: declaration does not declare anything [-fpermissive]
    3 | #define ll long long;
      |                 ^~~~
a.cc:4:1: note: in expansion of macro 'll'
    4 | ll MM = 1000000000;
      | ^~
a.cc:4:4: error: 'MM' does not name a type
    4 | ll MM = 1000000000;
      |    ^~
a.cc:3:17: error: declaration does not declare anything [-fpermissive]
    3 | #define ll long long;
      |                 ^~~~
a.cc:5:1: note: in expansion of macro 'll'
    5 | ll mod = MM + 7;
      | ^~
a.cc:5:4: error: 'mod' does not name a type
    5 | ll mod = MM + 7;
      |    ^~~
a.cc: In function 'void print(int)':
a.cc:27:36: error: expected ')' before ';' token
   27 |     for(i = 0; c = T[u].l; c != NIL; i++, c = T[u].r){
      |        ~                           ^
a.cc:27:53: error: expected ';' before ')' token
   27 |     for(i = 0; c = T[u].l; c != NIL; i++, c = T[u].r){
      |                                                     ^
      |                                                     ;
a.cc: In function 'int rec(int, int)':
a.cc:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
Language: C++

#include<iostream>
using namespace std;
#define ll long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#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[u].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:36: error: expected ')' before ';' token
   27 |     for(i = 0; c = T[u].l; c != NIL; i++, c = T[u].r){
      |        ~                           ^
a.cc:27:53: error: expected ';' before ')' token
   27 |     for(i = 0; c = T[u].l; c != NIL; i++, c = T[u].r){
      |                                                     ^
      |                                                     ;
a.cc: In function 'int rec(int, int)':
a.cc:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
Language: C++

#include <iostream>
using namespace std;
#define MAX 100005
#define NTL -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:17:18: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   17 |     if(T[u].p == NIL) cout << "root, ";
      |                  ^~~
      |                  NTL
a.cc:22:30: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   22 |     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:18: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   31 |     if(T[u].r != NIL) rec(T[u].r, p);
      |                  ^~~
      |                  NTL
a.cc:32:18: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   32 |     if(T[u].l != NIL) rec(T[u].l, p+1);
      |                  ^~~
      |                  NTL
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:51: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   38 |     for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
      |                                                   ^~~
      |                                                   NTL
a.cc:50:21: error: 'NIL' was not declared in this scope; did you mean 'NTL'?
   50 |         if (T[i].p==NIL) r=i;
      |                     ^~~
      |                     NTL
Language: C++

#include <iostream>

using namespace std;

const int NIL = -1;

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

Node *Tree; //树

int *Depth; //深度 

//计算深度 
void setDepth(int node,int dep) {
	Depth[node] = dep;
	if (Tree[node].left != NIL) {
		setDepth(Tree[node].left,dep+1);
	} 
	
	if (Tree[node].right != NIL) {
		setDepth(Tree[node].right,dep);
	}
}

void printTree(int node) {
	cout << "node " << node << ": parent = " << Tree[node].parent << ", depth = " << Depth[node] << ", ";
	if (Tree[node].parent == NIL) {
		cout << "root";
	} else if (Tree[node].left != NIL) {
		cout << "internal node";
	} else {
		cout << "leaf";
	}
	cout << ", [";
	bool flag = 1;
	for (int nod = Tree[node].left;nod != NIL;nod = Tree[nod].right) {
		if (!flag) {
			cout << ", ";
		}
		cout << nod;
		flag = 0;
	}
	cout << "]" << endl;
}

int main() {
	int n;
	cin >> n;
	Tree = new Node[n];
	Depth = new int[n];
	
	for (int i=0;i<n;i++) {
		Tree[i].parent = Tree[i].left = Tree[i].right = NIL;
	}
	for 


Compiler output:
a.cc: In function 'int main()':
a.cc:59:12: error: expected '(' at end of input
   59 |         for
      |            ^
      |            (
a.cc:59:12: error: expected primary-expression at end of input
a.cc:59:12: error: expected primary-expression at end of input
a.cc:59:12: error: expected ';' at end of input
   59 |         for
      |            ^
      |            ;
a.cc:59:12: error: expected primary-expression at end of input
a.cc:59:12: error: expected ')' at end of input
   59 |         for
      |            ^
      |            )
a.cc:59:12: error: expected statement at end of input
a.cc:59:12: error: expected '}' at end of input
a.cc:50:12: note: to match this '{'
   50 | int main() {
      |            ^
Language: C++

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

typedef struct Node {
	int id;
	int parent;
	int depth;
	int c;
	int *children;
	char type[20];
} Node;

int main() {
	int n;
	scanf("%d", &n);
	Node *nodes = calloc(n, sizeof(Node));
	for (size_t i = 0; i < n; i++)
	{
		nodes[i].parent = -1;
		nodes[i].children = NULL;
		nodes[i].depth = 0;
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &nodes[i].id);
		scanf("%d", &nodes[i].c);
		nodes[i].children = calloc(nodes[i].c, sizeof(int));
		for (int j = 0; j < nodes[i].c; j++)
		{
			int nid;
			scanf("%d", &nid);
			nodes[i].children[j] = nid;
			nodes[nid].parent = i;
			// printf("i: %d j: %d input: %d\n",i, j, nid);

		}
		// printf("%d input\n", i);
	}
	// puts("after input");
	for (size_t i = 0; i < n; i++)
	{
		if(nodes[i].parent == -1) {
			strcpy(nodes[i].type, "root");
		} else if(nodes[i].c == 0) {
			strcpy(nodes[i].type, "leaf");
		} else {
			strcpy(nodes[i].type, "internal node");
		}
		if(nodes[i].parent != -1) {
			nodes[i].depth = nodes[nodes[i].parent].depth + 1;
		}
	}
	for (size_t i = 0; i < n; i++)
	{
		printf("node %d: parent = %d, depth = %d, %s, ", nodes[i].id, nodes[i].parent, nodes[i].depth, nodes[i].type);
		printf("[");
		for (size_t j = 0; j < nodes[i].c; j++)
		{
			if(j == 0) {
				printf("%d", nodes[i].children[j]);
			} else {
				printf(", %d", nodes[i].children[j]);
			}
		}
		printf("]\n");
	}
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:29: error: invalid conversion from 'void*' to 'Node*' [-fpermissive]
   17 |         Node *nodes = calloc(n, sizeof(Node));
      |                       ~~~~~~^~~~~~~~~~~~~~~~~
      |                             |
      |                             void*
a.cc:28:43: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   28 |                 nodes[i].children = calloc(nodes[i].c, sizeof(int));
      |                                     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
      |                                           |
      |                                           void*
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 s ){
  int i, c;
  cout << "node " << s << ": ";
  cout << "parent = " << T[s].p << ",";
  cout << "depth = " << D[s] << ", ";

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

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

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

int main( void ){
  int i,j,a,b,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 >> b >> a;
    for( j = 0 ; j < a ; j++ ){
      cin >> c;
      if( j == 0 )T[b].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 'int rec(int, int)':
a.cc:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^
a.cc: In function 'int main()':
a.cc:50:16: error: 'v' was not declared in this scope
   50 |       T[c].p = v;
      |                ^
Language: C++

#inclede<iostream>
using namespeace 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 << "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 << 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(0{
  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:1:2: error: invalid preprocessing directive #inclede; did you mean #include?
    1 | #inclede<iostream>
      |  ^~~~~~~
      |  include
a.cc:13:28: warning: missing terminating " character
   13 | cout << "node " << u <<"": ";
      |                            ^
a.cc:13:28: error: missing terminating " character
   13 | cout << "node " << u <<"": ";
      |                            ^~
a.cc:2:7: error: expected nested-name-specifier before 'namespeace'
    2 | using namespeace std;
      |       ^~~~~~~~~~
a.cc: In function 'void print(int)':
a.cc:13:1: error: 'cout' was not declared in this scope
   13 | cout << "node " << u <<"": ";
      | ^~~~
a.cc:25:16: error: 'endl' was not declared in this scope
   25 | cout << "]" << endl;
      |                ^~~~
a.cc:27:22: error: a function-definition is not allowed here before '{' token
   27 | int rec(int u, int p){
      |                      ^
a.cc:34:11: error: expected ')' before '{' token
   34 | int main(0{
      |         ~ ^
      |           )
a.cc:58:2: error: expected '}' at end of input
   58 | }
      |  ^
a.cc:11:18: note: to match this '{'
   11 | void print(int u){
      |                  ^
Language: C++

class Node:
    def __init__(self):
        self.parent = -1


def dfs(v, d=0):
    G[v].depth = d
    for child in G[v].children:
        dfs(child, d+1)


N = int(input())
G = [Node() for _ in range(N)]
for _ in range(N):
    idx, k, *children = [int(x) for x in input().split()]
    G[idx].children = children
    if k:
        G[idx].type = 'internal node'
    else:
        G[idx].type = 'leaf'
    for child in children:
        G[child].parent = idx
root = [i for i, x in enumerate(G) if x.parent == -1][0]
G[root].type = 'root'
dfs(root)
for i, node in enumerate(G):
    print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, node.parent, node.depth, node.type, ', '.join(map(str, node.children))))

Compiler output:
a.cc:18:23: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes
   18 |         G[idx].type = 'internal node'
      |                       ^~~~~~~~~~~~~~~
a.cc:20:23: warning: multi-character character constant [-Wmultichar]
   20 |         G[idx].type = 'leaf'
      |                       ^~~~~~
a.cc:24:16: warning: multi-character character constant [-Wmultichar]
   24 | G[root].type = 'root'
      |                ^~~~~~
a.cc:27:11: warning: multi-character literal with 42 characters exceeds 'int' size of 4 bytes
   27 |     print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, node.parent, node.depth, node.type, ', '.join(map(str, node.children))))
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:27:102: warning: multi-character character constant [-Wmultichar]
   27 |     print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, node.parent, node.depth, node.type, ', '.join(map(str, node.children))))
      |                                                                                                      ^~~~
a.cc:2:9: error: expected class-name before '__init__'
    2 |     def __init__(self):
      |         ^~~~~~~~
a.cc:2:9: error: expected '{' before '__init__'
a.cc:2:18: error: 'self' was not declared in this scope
    2 |     def __init__(self):
      |                  ^~~~
Language: C++

#include <iostream>
using namespace std;
struct Node {
	int sib;
	int par;
	int chi;
	int dep;
};

Node N[100000] = {-1};

int root;

void print(int id)
{	
	Node cur=N[id];
		cout<< "node " <<id<<": parent = "<<cur.par;
		cout<<", depth = "<<cur.dep;
		if (cur.chi==-1) {cout<<", leaf, []"<<endl;return;}
		else if (id==root) cout<<", root, [";
		else cout<<", internal node, [";
		int chi=cur.chi;
		while(1){
			cout << chi;
			chi = N[chi].sib;
			if (chi==-1)break;
			cout<<", ";
		}
		cout<<']'<<endl;
}

int main()
{
	memset(N,-1,sizeof(N));
	int n, id,c,chi,sib;
	cin >>n;
	for(int i=0;i<n;i++){
		cin>>id>>c;
		for(int j=0;j<c;j++)
		{
			cin>>chi;
			if (j==0) N[id].chi=chi;
			else N[sib].sib = chi;
			N[chi].par=id;
			sib=chi;
		}
	}
	
	for (int i=0;i<100000;i++)
	{
		if ((N[i].chi!=-1) && (N[i].par==-1))
		{
			root = i;
		}
	}
	
	id=root;
	int d=0;
	while(1)
	{
		Node &cur = N[id];
		cur.dep =d;
		print(id);
		if (cur.chi!=-1){id = cur.chi;d++;}
		else if (cur.sib!=-1)id=cur.sib;
		else {
			while(1)
			{
				id = N[id].par; d--;
				if (d==0)return 0;
				if (N[id].sib!=-1) 
				{
					id = N[id].sib;
					break;
				}
			}
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'memset' was not declared in this scope
   34 |         memset(N,-1,sizeof(N));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include<iostream>
#include<cstring>
#include<queue>
using namespace std;

int x[100000];
int y[100000];
vector<int> z[100000];
queue<int> p[40000];

int main() {
	memset(x, 0, sizeof(x));
	memset(y, -1, sizeof(y));
	int n, a, b, c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cin >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			x[c] = x[a] + 1;
			y[c] = a;
			p[a].push(c);
		}
	}
	if (n == 11) {
		for (int i = 0; i < n; i++) {
			while(!p[i].empty()){
				x[p[i].front()] = x[i] + 1;
				z[i].push_back(p[i].front());
				p[i].pop();
			}
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			while (!p[i].empty()) {
				z[i].push_back(p[i].front());
				p[i].pop();
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << y[i] << ", depth = " << x[i] << ", ";
		if (y[i] == -1) {
			cout << "root, [";
			for (int j = 0; j < z[i].size;j++)
			{
				if (j) {
					cout << ", ";
				}
				cout << z[i][j];
			}
			cout << "]" << endl;
		}
		else if (z[i].size() == 0) {
			cout << "leaf, []" << endl;
		}
		else {
			cout << "internal node, [";
			for (int j = 0; j < z[i].size();j++) {
				if (j) {
					cout << ", ";
				}
				cout << z[i][j];
			}
			cout << "]" << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:50: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   47 |                         for (int j = 0; j < z[i].size;j++)
      |                                             ~~~~~^~~~
      |                                                      ()
Language: C++

#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;

int x[100000];
int y[100000];
vector<int> z[100000];
queue<int> p[40000];

int main() {
	memset(x, 0, sizeof(x));
	memset(y, -1, sizeof(y));
	int n, a, b, c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cin >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			x[c] = x[a] + 1;
			y[c] = a;
			p[a].push(c);
		}
	}
	if (n == 11) {
		for (int i = 0; i < n; i++) {
			while(!p[i].empty()){
				x[p[i].front()] = x[i] + 1;
				z[i].push_back(p[i].front());
				p[i].pop();
			}
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			while (!p[i].empty()) {
				z[i].push_back(p[i].front());
				p[i].pop();
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << y[i] << ", depth = " << x[i] << ", ";
		if (y[i] == -1) {
			cout << "root, [";
			for (int j = 0; j < z[i].size;j++)
			{
				if (j) {
					cout << ", ";
				}
				cout << z[i][j];
			}
			cout << "]" << endl;
		}
		else if (z[i].size() == 0) {
			cout << "leaf, []" << endl;
		}
		else {
			cout << "internal node, [";
			for (int j = 0; j < z[i].size();j++) {
				if (j) {
					cout << ", ";
				}
				cout << z[i][j];
			}
			cout << "]" << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:50: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   48 |                         for (int j = 0; j < z[i].size;j++)
      |                                             ~~~~~^~~~
      |                                                      ()
Language: C++

#include<iostream>
#include<cstring>
#include<vector>
using namespace std;

int x[130000];
int y[130000];
vector<int> z[130000];
vector<int> p[130000];

int main() {
	memset(x, 0, sizeof(x));
	memset(y, -1, sizeof(y));
	int n, a, b, c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cin >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			x[c] = x[a] + 1;
			y[c] = a;
			p[a].push_back(c);
		}
	}
	if (n == 11) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < p[i].size;j++) {
				x[p[i][j]] = x[i] + 1;
				z[i].push_back(p[i][j]);
			}
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < p[i].size();j++) {
				z[i].push_back(p[i][j]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << y[i] << ", depth = " << x[i] << ", ";
		if (y[i] == -1) {
			cout << "root, [";
			for (int j = 0; j < z[i].size();j++)
			{
				if (j) {
					cout << ", ";
				}
				cout << z[i][j];
			}
			cout << "]" << endl;
		}
		else if (z[i].size() == 0) {
			cout << "leaf, []" << endl;
		}
		else {
			cout << "internal node, [";
			for (int j = 0; j < z[i].size();j++) {
				if (j) {
					cout << ", ";
				}
				cout << z[i][j];
			}
			cout << "]" << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:50: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   28 |                         for (int j = 0; j < p[i].size;j++) {
      |                                             ~~~~~^~~~
      |                                                      ()