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

#include<cstdio>
#include<algorithm>
#define scanf scanf_s
using namespace std;
struct Node {
	int id;
	int dim;
	Node* pparent;
	int* child;
	bool operator<(Node n) {
		return id < n.id;
	};
	bool operator==(Node n) {
		return id == n.id;
	};
	bool operator>(Node n) {
		return id > n.id;
	};
};

int main() {
	int i, j, k, n, depth;
	bool flag;
	Node node[100000], nullnode;
	Node* ptmpn;
	nullnode.id = -1;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &node[i].id, &node[i].dim);
		node[i].child = new int[node[i].dim];
		for(j = 0; j < node[i].dim; j++) {
			scanf("%d", &node[i].child[j]);
		}
	}
	sort(node, node + n);
	for (i = 0; i < n; i++) {
		j = 0;
		flag = false;
		while (j < n && flag == false) {
			k = 0;
			while (k < node[j].dim && flag == false) {
				if (node[j].child[k] == node[i].id)flag = true;
				k++;
			}
			j++;
		}
		if(flag == true)node[i].pparent = &node[--j];
		else node[i].pparent = &nullnode;
	}
	for (i = 0; i < n; i++) {
		printf("node %d: parent = %d", node[i].id, node[i].pparent->id);
		depth = 0;
		ptmpn = &node[i];
		while (ptmpn->pparent->id != -1) {
			ptmpn = ptmpn->pparent;
			depth++;
		}
		printf(", depth = %d, ", depth);
		if (depth == 0)printf("root, [");
		else if (node[i].dim != 0)printf("internal node, [");
		else printf("leaf, [");
		for (j = 0; j < node[i].dim; j++) {
			printf("%d", node[i].child[j]);
			if (j != node[i].dim - 1)printf(", ");
		}
		printf("]\n");
	}
	for (i = 0; i < n; i++) {
		delete[] node[i].child;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:15: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
    3 | #define scanf scanf_s
      |               ^~~~~~~
a.cc:27:9: note: in expansion of macro 'scanf'
   27 |         scanf("%d", &n);
      |         ^~~~~
Language: C++

#include<cstdio>
#include<algorithm>
#define scanf scanf_s
using namespace std;
struct Node {
	int id;
	int dim;
	Node* pparent;
	int* child;
	bool operator<(Node n) {
		return id < n.id;
	};
	bool operator==(Node n) {
		return id == n.id;
	};
	bool operator>(Node n) {
		return id > n.id;
	};
};

int main() {
	int i, j, k, n, depth;
	bool flag;
	Node node[100], nullnode;
	Node* ptmpn;
	nullnode.id = -1;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &node[i].id, &node[i].dim);
		node[i].child = new int[node[i].dim];
		for(j = 0; j < node[i].dim; j++) {
			scanf("%d", &node[i].child[j]);
		}
	}
	sort(node, node + n);
	for (i = 0; i < n; i++) {
		j = 0;
		flag = false;
		while (flag == false && j < n) {
			k = 0;
			while (flag == false && k < node[j].dim) {
				if (node[j].child[k] == node[i].id)flag = true;
				k++;
			}
			j++;
		}
		if(flag == true)node[i].pparent = &node[--j];
		else node[i].pparent = &nullnode;
	}
	for (i = 0; i < n; i++) {
		printf("node %d: parent = %d", node[i].id, node[i].pparent->id);
		depth = 0;
		ptmpn = &node[i];
		while (ptmpn->pparent->id != -1) {
			ptmpn = ptmpn->pparent;
			depth++;
		}
		printf(", depth = %d, ", depth);
		if (depth == 0)printf("root, [");
		else if (node[i].dim != 0)printf("internal node, [");
		else printf("leaf, [");
		for (j = 0; j < node[i].dim; j++) {
			printf("%d", node[i].child[j]);
			if (j != node[i].dim - 1)printf(", ");
		}
		printf("]\n");
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:15: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
    3 | #define scanf scanf_s
      |               ^~~~~~~
a.cc:27:9: note: in expansion of macro 'scanf'
   27 |         scanf("%d", &n);
      |         ^~~~~
Language: C++

#include <iostream>
using namespace std;

const long MAX = 100001;
const long NIL = -1;

struct Node{
	long parent, leftChild, rightSibling;
};

struct Node T[MAX];
long n, Depth[MAX];

void print(long id){
	cout << "node " << id << ": ";
	cout << "parent = " << T[id].parent << ", ";
	cout << "depth = " << Depth[id] << ", ";

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

	cout << "[";

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

long setDepth(long id, long parent){
	Depth[id] = parent;
	if (T[id].rightSibling != NIL) setDepth(T[id].rightSibling, p);
	if (T[id].leftChild != NIL) setDepth(T[id].leftChild, p + 1);
}

int main(){
	long degree, id, child, leftChild, rightSibling;
	cin >> n;
	for (long i = 0; i < n; i++){
		T[i].parent = T[i].leftChild = T[i].rightSibling = NIL;
	}
	for (long i = 0; i < n; i++){
		cin >> id >> degree;
		for (long j = 0; j < degree; j++){
			cin >> child;
			if (j == 0) T[id].leftChild = child;
			else T[leftChild].rightSibling = child;
			leftChild = child;
			T[child].parent = id; 
		}
	}
	for (long i = 0; i < n; i++){
		if (T[i].parent == NIL) rightSibling = i;
	}

	setDepth(rightSibling, 0);

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

	return 0;
}

Compiler output:
a.cc: In function 'long int setDepth(long int, long int)':
a.cc:34:69: error: 'p' was not declared in this scope
   34 |         if (T[id].rightSibling != NIL) setDepth(T[id].rightSibling, p);
      |                                                                     ^
a.cc:35:63: error: 'p' was not declared in this scope
   35 |         if (T[id].leftChild != NIL) setDepth(T[id].leftChild, p + 1);
      |                                                               ^
a.cc:36:1: warning: no return statement in function returning non-void [-Wreturn-type]
   36 | }
      | ^
Language: C++

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		new Main().solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();// the number of nodes
		Rooted_tree rt = new Rooted_tree(n);
		for (int i = 0; i < n; i++) {
			int id = sc.nextInt();
			int k = sc.nextInt();
			int l = -1;
			for (int j = 0; j < k; j++) {
				if (j == 0) {
					rt.T[id].left = sc.nextInt();
					l = rt.T[id].left;
					rt.T[l].parent = id;
				} else {
					rt.T[l].right = sc.nextInt();
					l = rt.T[l].right;
					rt.T[l].parent = id;
				}
			}
		}
		int root = -1;
		for (int i = 0; i < n; i++) {
			if (rt.T[i].parent == -1)
				root = i;
		}
		rt.setDepth(root, 0);
		for (int i = 0; i < n; i++) {
			System.out.print("node " + i + ": parent = " + rt.T[i].parent + ", depth = " + rt.D[i] + ", ");
			if (rt.T[i].parent == -1)
				System.out.print("root,");
			else if (rt.T[i].left == -1)
				System.out.print("leaf,");
			else
				System.out.print("internal node,");
			System.out.print(" [");
			int u = rt.T[i].left;
			while (u != -1) {
				System.out.print(u);
				u = rt.T[u].right;
				if (u != -1) {
					System.out.print(", ");
				}
			}
			System.out.println("]");
		}
	}

	class Rooted_tree {
		int NIL = -1;
		Node[] T;
		int[] D;

		// n is the number of vertex
		Rooted_tree(int n) {
			T = new Node[n];
			for (int i = 0; i < n; i++) {
				T[i] = new Node();
			}
			D = new int[n];
		}

		// ????????\????????±???????±??????????
		int getDepth(int u) {
			int d = 0;
			while (T[u].parent != NIL) {
				u = T[u].parent;
				d++;
			}
			return d;
		}

		// ??¨?????¨????????\????????±???????±??????????
		// u???root
		void setDepth(int u, int p) {
			D[u] = p;
			if (T[u].right != NIL) {
				setDepth(T[u].right, p);
			}
			if (T[u].left != NIL) {
				setDepth(T[u].left, p + 1);
			}
		}

		// ????????????????????¨??????
		void printChildren(int u) {
			int c = T[u].left;
			while (c != NIL) {
				System.out.println(c);
				c = T[c].right;
			}
		}

		class Node {
			int parent = NIL, left = NIL, right = NIL;

			Node() {
			}

			Node(int parent, int left, int right) {
				this.parent = parent;
				this.left = left;
				this.right = right;
			}
		}
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: expected unqualified-id before 'public'
    2 | public class Main {
      | ^~~~~~
Language: C++

#include<iostream>
#include<stdlib.h>

#define MAX_DEPTH 20
#define MAX_NUM 1000000

using namespace std;

typedef struct {
  int node_number;
  int size;
  int children[MAX_DEPTH];
} vertex;

int n;

int getParent(vertex A[],int key){

  int i;
  int j;

  for(i = 0;i < n;i++){
    for(j = 0;j < A[i].size;j++){
      if(A[i].children[j] == key){
	return A[i].node_number;
      }
    }
  }

  return -1;
}

int getDepth(vertex A[],int key){

  int depth = 0;
  int parent = key;

  while(1){
    parent = getParent(A,parent);

    if(parent == -1){
      break;
    }
    depth++;
  }

  return depth;
}

char *getState(vertex A[],vertex v){

  if(getParent(A,v.node_number) == -1){
    return "root";
  }
  else if(v.size == 0){
    return "leaf";
  }
  else {
    return "internal node";
  }

  return "None State";
}

void printChildren(vertex v){

  int i;

  cout << "[";

    for(i = 0;i < v.size-1;i++){
      cout << v.children[i] << ", ";
    }
    cout << v.children[i] << "]";
}

int main(){

  int i;
  int j;
  int k;
  int l;
  int size;
  int num;
  int parent;
  vertex *A;
  char source[256];
  char temp[5];

  scanf("%d",&n);

  A = (vertex *)malloc(sizeof(vertex)*n);

  for(i = 0;i < n;i++){
    scanf("%d",&num);
    scanf("%d",&size);
    A[num].node_number = num;
    A[num].size = size;
    for(j = 0;j < A[num].size;j++){
      scanf("%d",&A[num].children[j]);
    }
  }

  for(i = 0;i < n;i++){
    printf("node %d: ",A[i].node_number);
    parent = getParent(A,A[i].node_number);
    printf("parent = %d",parent);
    printf("depth = %d",getDepth(A,A[i].node_number));
    if(parent == -1){
      printf("root, ");
    }
    else if(v.size == 0){
      printf("leaf, ");
    }
    else {
      printf("internal node, ");
    }
    printf("[");
    for(j = 0;j < v.size-1;j++){
      printf("%d, ",v.children[j]);
    }
    printf("]\n");
  }

  return 0;

}

  //　　(　゜д゜)
  //＿(__つ/‾‾‾/＿
  //　　＼/　　　　/
  //
  //　　( ゜д゜ )
  //＿(__つ/‾‾‾/＿
  //　　＼/　　　　/

Compiler output:
a.cc: In function 'char* getState(vertex*, vertex)':
a.cc:53:12: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   53 |     return "root";
      |            ^~~~~~
a.cc:56:12: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   56 |     return "leaf";
      |            ^~~~~~
a.cc:59:12: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   59 |     return "internal node";
      |            ^~~~~~~~~~~~~~~
a.cc:62:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   62 |   return "None State";
      |          ^~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:112:13: error: 'v' was not declared in this scope
  112 |     else if(v.size == 0){
      |             ^
a.cc:119:19: error: 'v' was not declared in this scope
  119 |     for(j = 0;j < v.size-1;j++){
      |                   ^
Language: C++

#include<iosteam>
using namespace std;
#define MAX 100000
#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 c,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:9: fatal error: iosteam: No such file or directory
    1 | #include<iosteam>
      |         ^~~~~~~~~
compilation terminated.
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++){
    if(T[i].p==NIL)r=i;
  }

  rec(r,0);

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

  return 0;
}

Compiler output:
a.cc:6:21: error: expected ';' at end of member declaration
    6 | struct Node {int p, l r;};
      |                     ^
      |                      ;
a.cc:6:23: error: 'r' does not name a type
    6 | struct Node {int p, l r;};
      |                       ^
a.cc: In function 'void print(int)':
a.cc:23:49: error: 'struct Node' has no member named 'r'
   23 |   for( i = 0,c = T[u].l;c != NIL; i++, c = T[c].r) {
      |                                                 ^
a.cc: In function 'int rec(int, int)':
a.cc:32:13: error: 'struct Node' has no member named 'r'
   32 |   if ( T[u].r != NIL ) rec(T[u].r, p);
      |             ^
a.cc:32:33: error: 'struct Node' has no member named 'r'
   32 |   if ( T[u].r != NIL ) rec(T[u].r, p);
      |                                 ^
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
   34 | }
      | ^
a.cc: In function 'int main()':
a.cc:39:39: error: 'struct Node' has no member named 'r'
   39 |   for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
      |                                       ^
Language: C++

//#define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
using namespace std;

#define MAX 100000
//#define MAX_ 1000

int cou = 0;
struct tree
{
	int id;
	tree *pp;
	tree *next;
	tree *pchbegin, *pchend;
};
int main(void)
{
	int n, xid, xk, xdeep = 0, xc1, xc2;
	int depth, cou = 0,parent;
	tree node[MAX], first;
	first.id = -1;
	bool node_b[MAX] = { false };
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf_s("%d %d", &xid, &xk);
		node[xid].id = xid;
		if (node_b[xid] == false) { node[xid].pp = &first; }
		node[xid].pchbegin = node[xid].pchend;
		for (int j = 0; j < xk; ++j) {
			scanf_s("%d", &xc1);
			node[xc1].pp = &node[xid];
			node_b[xc1] = true;
			if (j == 0) {
				node[xid].pchbegin = &node[xc1];
				node[xc1].next = node[xid].pchend;
			}
			else {
				node[xc2].next = &node[xc1];
				node[xc1].next = node[xid].pchend;
			}
			xc2 = xc1;
		}
	}
	for (int i = 0; i < n; ++i) {
		depth = 0;
		for (tree *p = node[i].pp; p != &first; p = p->pp) { ++depth; }
		printf("node %d: parent = %d, depth = %d, ", node[i].id, node[i].pp->id, depth);
		if (node[i].pchbegin == node[i].pchend && node[i].pp->id != -1) { printf("leaf, ["); }
		else {
			if (node[i].pp->id == -1) { printf("root, ["); }
			else { printf("internal node, ["); }
			for (tree *j = node[i].pchbegin; j != node[i].pchend; j = j->next) {
				if (j == node[i].pchbegin) { printf("%d", j->id); }
				else printf(", %d", j->id);
			}
		}
		printf("]\n");
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   32 |         scanf_s("%d", &n);
      |         ^~~~~~~
      |         scanf
Language: C++

#include <bits/stdc++.h>
#define Z -1
using namespace std;
struct NO{int p,l,r};
struct NO T[100000];
int D[100000]={Z};
int rec(int u,int p){
  D[u]=p;
  if(T[u].r!=Z)rec(T[u].r,p);
  if(T[u].l!=Z)rec(T[u].l,p+1);
}
int main(){
  int a,b,c,n,l.r,j,k;
  for(cin>>n,i=0;i<n;i++)T[i].p=T[i].l=T[i].m=Z;
  for(i=0;i<n;i++)for(cin>>a>>b,j=0;j<b;j++){
    cin>>c;
    if(!j)T[a].l=c;
    else T[l].r=c;
    l=c;
    T[l].p=a;
  }
  for(i=0;i<n;i++)if(T[i].p==Z)r=i;
  rec(r,0);
for(i=0;i<n;i++){
  printf("node %d:parent = %d,depth = %d, ",i,T[i].p,D[i]);
  if(T[i].p==Z)cout<<"root, [";
  else if(T[i].l==Z)cout<<"lesf, [";
  else cout<<"internal node, [";
  for(j=0,c=T[i].l;c!=Z;c=T[i].r){
    if(i)cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}
}

Compiler output:
a.cc:4:19: error: expected ';' at end of member declaration
    4 | struct NO{int p,l,r};
      |                   ^
      |                    ;
a.cc: In function 'int rec(int, int)':
a.cc:11:1: warning: no return statement in function returning non-void [-Wreturn-type]
   11 | }
      | ^
a.cc: In function 'int main()':
a.cc:13:16: error: expected initializer before '.' token
   13 |   int a,b,c,n,l.r,j,k;
      |                ^
a.cc:14:14: error: 'i' was not declared in this scope
   14 |   for(cin>>n,i=0;i<n;i++)T[i].p=T[i].l=T[i].m=Z;
      |              ^
a.cc:15:7: error: 'i' was not declared in this scope
   15 |   for(i=0;i<n;i++)for(cin>>a>>b,j=0;j<b;j++){
      |       ^
a.cc:15:33: error: 'j' was not declared in this scope
   15 |   for(i=0;i<n;i++)for(cin>>a>>b,j=0;j<b;j++){
      |                                 ^
a.cc:18:12: error: 'l' was not declared in this scope
   18 |     else T[l].r=c;
      |            ^
a.cc:19:5: error: 'l' was not declared in this scope
   19 |     l=c;
      |     ^
a.cc:22:7: error: 'i' was not declared in this scope
   22 |   for(i=0;i<n;i++)if(T[i].p==Z)r=i;
      |       ^
a.cc:22:32: error: 'r' was not declared in this scope
   22 |   for(i=0;i<n;i++)if(T[i].p==Z)r=i;
      |                                ^
a.cc:23:7: error: 'r' was not declared in this scope
   23 |   rec(r,0);
      |       ^
a.cc:24:5: error: 'i' was not declared in this scope
   24 | for(i=0;i<n;i++){
      |     ^
a.cc:29:7: error: 'j' was not declared in this scope
   29 |   for(j=0,c=T[i].l;c!=Z;c=T[i].r){
      |       ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
??
int main(){
????int a,b,c,d,p[100001],n,k;
????vector<int> e[100001];
????cin>>a;
????for(int i=0;i<=a;i++)p[i]=-1;
????for(int i=0;i<a;i++){
????????cin>>b>>c;
????????for(int j=0;j<c;j++){
????????????cin>>d;
????????????p[d]=b;
????????????e[b].push_back(d);
????????}
????}
????for(int i=0;i<a;i++){
????????n=i;
????????k=0;
????????while(p[n]!=-1){
????????????n=p[n];
????????????k++;
????????}
????????cout<<"node "<<i<<": parent = "<<p[i];
????????cout<<", depth = "<<k;
????????if(p[i]==-1)cout<<", root, [";
????????else if(e[i].size()==0)cout<<", leaf, [";
????????else cout<<", internal node, [";
??
????????for(int j=0;j<e[i].size();j++){
????????????cout<<e[i][j];
????????????if(e[i].size()-j==1);
????????????else cout<<", ";
????????}
????????cout<<"]\n";
??????????
????}
????return 0;
}

Compiler output:
a.cc:4:1: error: expected unqualified-id before '?' token
    4 | ??
      | ^
Language: C++

#include <iostream>
#incude <stdio.h>

using namespace std;

#define N_MAX 100000
#define NIL -1

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

Node T[N_MAX];

int main()
{
    int n, i, j, v, d, x, y;
    cin >> n;

    //??¨????????????
    for (i = 0; i < N_MAX; i++) {
        T[i].p = -1;
        T[i].r = T[i].l = NIL;
    }

    //??¨?????\???
    for (i = 0; i < n; i++) {
         cin >> v >> d; // value, degree

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

    }

    //??¨?????????
    for (i = 0; i < n; i++) {
        v = i;
        j = 0;
        while (T[v]. p != -1) {
            v = T[v].p;
            j++;
        }
        printf("node %d: parent = %d, depth = %d,", i, T[i].p, j);

        if (T[i].p == -1) {
            printf("root, ");
        } else if (T[i].l == NIL) {
            printf("leaf, ");
        } else {
            printf("internal node, ");
        }

        printf("[");
        if (T[i].l == NIL) {
            printf("]\n");
            continue;
        } else {
            printf("%d", T[i].l);
            v = T[i].l;
        }

        while (T[v].r != NIL) {
            printf(", %d", T[v].r);
            v = T[v].r;
        }
        printf("]\n");
    }

    return 0;
}

Compiler output:
a.cc:2:2: error: invalid preprocessing directive #incude; did you mean #include?
    2 | #incude <stdio.h>
      |  ^~~~~~
      |  include
Language: C++

#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long int int;

struct Node {
	int parent;
	int depth;
	string state;
	vector<int> children;
	Node():parent(-1),depth(0){
	}
};
struct faster_io{
	faster_io() {
		cin.tie(0);
		ios::sync_with_stdio(false);
	}
};

void set_depth(vector<Node> &Nodes, Node &node, int depth) {
	node.depth = depth;
	for (int i = 0; i < node.children.size(); i++) {
		set_depth(Nodes, Nodes[node.children[i]], depth + 1);
	}
}


int main() {
	int const N_MAX = 100000;
	faster_io io;

	int n;
	cin >> n;

	vector<Node> Nodes;
	Nodes.resize(N_MAX);

	for (int i = 0; i < n; i++) {
		int id, k;
		cin >> id >> k;
		Node &x = Nodes[id];
		for (int j = 0; j < k; j++) {
			int c;
			cin >> c;
			x.children.push_back(c);
			Nodes[c].parent = id;
		}
	}

	Node root;
	for (int i = 0; i < n; i++) {
		Node &x = Nodes[i];
		if (x.parent == -1) {
			x.state = "root";
			root = x;
		}
		else if (x.children.size() == 0) {
			x.state = "leaf";
		}
		else {
			x.state = "internal node";
		}
	}

	set_depth(Nodes, root, 0);

	for (int i = 0; i < n; i++) {
		Node x = Nodes[i];
		cout << "node " << i
			<< ": parent = " << x.parent
			<< ", depth = " << x.depth
			<< ", " << x.state
			<< ", [";
		for (int j = 0; j < x.children.size(); j++)	{
			if (j != x.children.size() - 1) cout << x.children[j] << ", ";
			else cout << x.children[j];
		}
		cout << "]\n";
	}
}

Compiler output:
a.cc:6:19: error: multiple types in one declaration
    6 | typedef long long int int;
      |                   ^~~
a.cc:6:23: error: declaration does not declare anything [-fpermissive]
    6 | typedef long long int int;
      |                       ^~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int parent;
  int left;
  int right;
}Node;

int main(){
  int n,k,id,h,r,depth,p,i,j;
  Node *T;

  scanf("%d", &n);

  T=malloc(sizeof(Node)*n);

  for(i=0;i<n;i++){
    T[i].parent=-1;
    T[i].left=-1;
    T[i].right=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d %d", &id, &k);
    for(j=0;j<k;j++){
      scanf("%d",&h);
      T[h].parent=id;

      if(j==0) T[id].left=h;
      else if(j>0) T[r].right = h;
      r=h;
    }
  }

  for(j=0;j<n;j++){
    depth=0;
    p=T[j].parent;

    while(p!=-1){
      p=T[p].parent;
      depth++;
    }

    if(depth==0){
      printf("node %d: parent = -1, depth = 0, root, [", j);
    }
    
    else if(T[j].left == -1){
      printf("node %d: parent = %d, depth = %d, leaf, [", j, T[j].parent, depth);
    }
    else{
      printf("node %d: parent = %d, depth = %d, internal node, [", j, T[j].parent, depth);
    }
 
    p = T[j].left;
    if(p != -1) printf("%d", p);
 
    while(p != -1){
      p = T[p].right;
      if(p != -1) printf(", %d", p);
    }
    printf("]\n");
  }
 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:11: error: invalid conversion from 'void*' to 'Node*' [-fpermissive]
   15 |   T=malloc(sizeof(Node)*n);
      |     ~~~~~~^~~~~~~~~~~~~~~~
      |           |
      |           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];

int main(){
int i,j;
int 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;
}

dep(r,0);

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

return 0;
}

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 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);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:15: error: expected primary-expression before ')' token
   30 | if(T[i].p==NIL)r=i;
      |               ^
a.cc:33:1: error: 'dep' was not declared in this scope
   33 | dep(r,0);
      | ^~~
a.cc:35:17: error: 'print' was not declared in this scope; did you mean 'printf'?
   35 | for(i=0;i<n;i++)print(i);
      |                 ^~~~~
      |                 printf
a.cc: In function 'void print(int)':
a.cc:46:15: error: expected primary-expression before ')' token
   46 | if(T[u].p==NIL)cout <<"root, ";
      |               ^
a.cc:47:20: error: expected primary-expression before ')' token
   47 | else if(T[u].l==NIL)cout <<"leaf, ";
      |                    ^
a.cc:4:15: error: expected ')' before ';' token
    4 | #define NIL -1;
      |               ^
a.cc:52:21: note: in expansion of macro 'NIL'
   52 | for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |                     ^~~
a.cc:52:4: note: to match this '('
   52 | for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |    ^
a.cc:52:37: error: expected ';' before ')' token
   52 | for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |                                     ^
      |                                     ;
a.cc: In function 'int dep(int, int)':
a.cc:61:15: error: expected primary-expression before ')' token
   61 | if(T[u].r!=NIL)dep(T[u].r,p);
      |               ^
a.cc:62:15: error: expected primary-expression before ')' token
   62 | if(T[u].l!=NIL)dep(T[u].l,p+1);
      |               ^
a.cc:63:1: warning: no return statement in function returning non-void [-Wreturn-type]
   63 | }
      | ^
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];

int main(){
int i,j;
int 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;
}

dep(r,0);

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

return 0;
}

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 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);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:1: error: 'dep' was not declared in this scope
   33 | dep(r,0);
      | ^~~
a.cc:35:17: error: 'print' was not declared in this scope; did you mean 'printf'?
   35 | for(i=0;i<n;i++)print(i);
      |                 ^~~~~
      |                 printf
a.cc: In function 'void print(int)':
a.cc:52:24: error: expected ')' before ';' token
   52 | for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |    ~                   ^
a.cc:52:37: error: expected ';' before ')' token
   52 | for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |                                     ^
      |                                     ;
a.cc: In function 'int dep(int, int)':
a.cc:63:1: warning: no return statement in function returning non-void [-Wreturn-type]
   63 | }
      | ^
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];

int main(){
int i,j;
int 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;
}

dep(r,0);

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

return 0;
}

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);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:1: error: 'dep' was not declared in this scope
   33 | dep(r,0);
      | ^~~
a.cc:35:17: error: 'print' was not declared in this scope; did you mean 'printf'?
   35 | for(i=0;i<n;i++)print(i);
      |                 ^~~~~
      |                 printf
a.cc: In function 'void print(int)':
a.cc:52:24: error: expected ')' before ';' token
   52 | for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |    ~                   ^
a.cc:52:37: error: expected ';' before ')' token
   52 | for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |                                     ^
      |                                     ;
a.cc: In function 'int rec(int, int)':
a.cc:63:1: warning: no return statement in function returning non-void [-Wreturn-type]
   63 | }
      | ^
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];

int main(){
int i,j;
int 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;
}

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);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:1: error: 'rec' was not declared in this scope
   33 | rec(r,0);
      | ^~~
a.cc:35:17: error: 'print' was not declared in this scope; did you mean 'printf'?
   35 | for(i=0;i<n;i++)print(i);
      |                 ^~~~~
      |                 printf
a.cc: In function 'void print(int)':
a.cc:52:24: error: expected ')' before ';' token
   52 | for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |    ~                   ^
a.cc:52:37: error: expected ';' before ')' token
   52 | for(i=0;c=T[u].l;c!=NIL;i++,c=T[c].r){
      |                                     ^
      |                                     ;
a.cc: In function 'int rec(int, int)':
a.cc:63:1: warning: no return statement in function returning non-void [-Wreturn-type]
   63 | }
      | ^
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];

int main(){
int i,j;
int 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;
}

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);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:1: error: 'rec' was not declared in this scope
   33 | rec(r,0);
      | ^~~
a.cc:35:17: error: 'print' was not declared in this scope; did you mean 'printf'?
   35 | for(i=0;i<n;i++)print(i);
      |                 ^~~~~
      |                 printf
a.cc: In function 'int rec(int, int)':
a.cc:63:1: warning: no return statement in function returning non-void [-Wreturn-type]
   63 | }
      | ^
Language: C++

#include <stdio.h>
 

#define MAX 100000
#define NIL -1
 

void printTree(int);
void depth(int, int);
 

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

int main(){
  int i,j,node,degree,child,left,right;
   
 
  scanf("%d",&n);
   
 
  for(i=0;i<n;i++) { 
    Tree[i].parent = NIL;
    Tree[i].left = NIL;
    Tree[i].right = NIL;
  }
   

  for(i=0;i<n;i++){
    scanf("%d%d",&node, &degree);
    for(j=0;j<degree;j++){ 
      scanf("%d", &child);
      if(j==0) {
        Tree[node].left = child; 
      }else {
        Tree[left].right = child; 
      }
      left = child;
      Tree[child].parent = node; 
    }
  }
 
 
  for(i=0;i<n;i++) {
    if(Tree[i].parent == NIL) {
      right = i;
    }
  }
  getDepth(right, 0);
     
 
  for(i=0;i<n;i++) {
    printTree(i); 
  }
 
  return 0;
}
 

void printTree(int u) { 
  int i, c;

  printf("node %d: ",u); 
  printf("parent = %d, ", Tree[u].parent);
  printf("depth = %d, ", D[u]);
   

  if(Tree[u].parent == NIL) {
    printf("root, ");
  }else if(Tree[u].left == NIL) {
    printf("leaf, ");
  }else {
    printf("internal node, ");
  }
   
 
  printf("[");
  c = Tree[u].left;
  while(c!=NIL){
    if(c==Tree[u].left){
      printf("%d",c);
    }else {
      printf(", %d", c); 
    }
    c = Tree[c].right;
  }
  printf("]\n");
}
 
 
void depth(int u, int d){ 
  D[u] = d;
  if(Tree[u].right!=NIL) { 
    getDepth(Tree[u].right, d);
  }
  if(Tree[u].left!=NIL) {
    getDepth(Tree[u].left, d+1);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:3: error: 'getDepth' was not declared in this scope
   53 |   getDepth(right, 0);
      |   ^~~~~~~~
a.cc: In function 'void depth(int, int)':
a.cc:98:5: error: 'getDepth' was not declared in this scope
   98 |     getDepth(Tree[u].right, d);
      |     ^~~~~~~~
a.cc:101:5: error: 'getDepth' was not declared in this scope
  101 |     getDepth(Tree[u].left, d+1);
      |     ^~~~~~~~
Language: C++

 
struct Node T[N];
int count =0;
int depth(int);
void degree(int);
 
int main(){
  int i,j,n,k,left,right,node,m,c;
   
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].left = T[i].right = -1;
  for(i=0;i<n;i++){
    scanf("%d%d",&node,&m);
    for(j=0;j<m;j++){
      scanf("%d",&c);
      T[c].p = node;
      if(j!=0) T[left].right = c;
      else T[node].left = c;
      left = c;
    }
  }
   
  for(i=0;i<n;i++){
    count = 0;
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth(i));
    if(T[i].p == -1) printf("root, [");
    else if(T[i].left == -1) printf("leaf, [");
    else  printf("internal node, [");
    count = 0;
    degree(T[i].left);
    printf("]\n");
  }
  return 0;
}
   
int depth(int id){
  if(T[id].p==-1){
 return count;
  }
  else{
    count++;
    return  depth(T[id].p);
  }
}
 
void degree(int id){
  if(id!=-1){
    if(count!=0){
      printf(", ");
    }
    printf("%d",id);
    count++;
    degree(T[id].right);
  }
}

Compiler output:
a.cc:2:15: error: 'N' was not declared in this scope
    2 | struct Node T[N];
      |               ^
a.cc: In function 'int main()':
a.cc:10:3: error: 'scanf' was not declared in this scope
   10 |   scanf("%d",&n);
      |   ^~~~~
a.cc:11:20: error: 'T' was not declared in this scope
   11 |   for(i=0;i<n;i++) T[i].p = T[i].left = T[i].right = -1;
      |                    ^
a.cc:16:7: error: 'T' was not declared in this scope
   16 |       T[c].p = node;
      |       ^
a.cc:25:51: error: 'T' was not declared in this scope
   25 |     printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth(i));
      |                                                   ^
a.cc:25:5: error: 'printf' was not declared in this scope
   25 |     printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth(i));
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | 
a.cc: In function 'int depth(int)':
a.cc:37:6: error: 'T' was not declared in this scope
   37 |   if(T[id].p==-1){
      |      ^
a.cc: In function 'void degree(int)':
a.cc:49:7: error: 'printf' was not declared in this scope
   49 |       printf(", ");
      |       ^~~~~~
a.cc:49:7: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:51:5: error: 'printf' was not declared in this scope
   51 |     printf("%d",id);
      |     ^~~~~~
a.cc:51:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:53:12: error: 'T' was not declared in this scope
   53 |     degree(T[id].right);
      |            ^
Language: C++

#include "stdafx.h"
#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:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

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

#define MAX_N 100000
#define MAX_D 20

class Node
{
    public:
    int parent = -1, depth = MAX_D + 1;
    vector<int> childs;
};

void set_depth(Node nodes[], Node *cur, int depth)
{
    cur->depth = depth++;
    for (auto itr = cur->childs.begin(); itr != cur->childs.end(); ++itr) {
        set_depth(nodes, nodes + *itr, depth);
    }
}

void print_nodes(Node nodes[], int n)
{
    int cnt = 0;
    for (int i = 0; cnt < n; i++) {
        if (nodes[i].depth == MAX_D + 1) continue;
        cout << "node " << i << ": "
        << "parent = " << nodes[i].parent << ", "
        << "depth = " << nodes[i].depth << ", "
        << (nodes[i].childs.size() == 0 ? "leaf" : "internal node") << ", ";
        cout << "[";
        for (auto itr = nodes[i].childs.begin(); itr != nodes[i].childs.end(); itr++) {
            if (itr != nodes[i].childs.begin()) cout << ", ";
            cout << *itr;
        }
        cout << "]" << endl;
        cnt++;
    }
}

int main()
{
    int n, id, k;
    Node nodes[MAX_N + 1], *root;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> id >> k;
        int c[k];
        for (int j = 0; j < k; j++) {
            cin >> c[j];
        }
        sort(c, c + k);
        for (int *p = c; p != c + k; p++) {
            nodes[id].childs.push_back(*p);
            nodes[*p].parent = id;
        }
    }
    root = nodes + id;
    while (root->parent != -1) {
        root = nodes + root->parent;
    }
    set_depth(nodes, root, 0);
    print_nodes(nodes, n);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   53 |         sort(c, c + k);
      |         ^~~~
      |         short
Language: C++

#include<cstdio>
struct N{int p,l,r;};
N T[100000];
int n,d,k,c,x,r,i,j,m,o,D[100000];
R(int r,int d){
  D[r]=d;
  T[r].r+1&&R(T[r].r,d);
  T[r].l+1&&R(T[r].l,d+1);
}
main(){
  scanf("%d",&n);
  for(;j<n;++j)T[j].p=T[j].l=T[j].r=-1;
  for(;i++<n;)
    for(scanf("%d%d",&d,&k),j=0;j<k;x=c){
      scanf("%d",&c);
      T[c].p=d;
      j++?T[x].r=c:T[d].l=c;
    }
  for(;m<n;++m)r=T[m].p+1?r:m;
  R(r,0);
  for(;o<n;++o){
    printf("node %d: parent = %d, depth = %d, ",o,T[o].p,D[o]);
    printf(T[o].p+1?T[o].l+1?"internal node, [":"leaf, [":"root, [");
    for(i=0,j=T[o].l;j+1;)printf(i++?", %d":"%d",j),j=T[j].r;
    printf("]\n");
  }
}

Compiler output:
a.cc:5:1: error: ISO C++ forbids declaration of 'R' with no type [-fpermissive]
    5 | R(int r,int d){
      | ^
a.cc: In function 'int R(int, int)':
a.cc:9:1: warning: no return statement in function returning non-void [-Wreturn-type]
    9 | }
      | ^
a.cc: At global scope:
a.cc:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main(){
      | ^~~~
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:23:36: error: expected ')' before ';' token
   23 |   for ( i = 0; c = T[u].l; c != NIL; i++, c = T[c].r ) {
      |       ~                            ^
a.cc:23:53: error: expected ';' before ')' token
   23 |   for ( i = 0; c = T[u].l; c != NIL; i++, c = T[c].r ) {
      |                                                     ^~
      |                                                     ;
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:23:53: error: expected ')' before ';' token
   23 |   for ( i = 0, c = T[u].l; c != NIL; i++, c = T[c].r; ) {
      |       ~                                             ^
      |                                                     )
a.cc:23:55: error: expected primary-expression before ')' token
   23 |   for ( i = 0, c = T[u].l; c != NIL; i++, c = T[c].r; ) {
      |                                                       ^
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 printf(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].r=T[i].l=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].l=c;
            l=c;
            T[c].p=v;
        }

    }
    for(i=0;i<n;i++)
    {
        if(T[i].p==NIL) r=i;
    }
    re(r,0);
    for(i=0;i<n;i++) printf(i);
    return 0;
}

Compiler output:
a.cc: In function 'int rec(int, int)':
a.cc:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
   31 | }
      | ^
a.cc: In function 'int main()':
a.cc:54:5: error: 're' was not declared in this scope; did you mean 'r'?
   54 |     re(r,0);
      |     ^~
      |     r
Language: C++

#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
struct tree{
    vector<int>sons;
    int pos;
    int p;
};
tree map[100000];
void build(int now){
    for(int i=0;i<map[now].sons.size();i++)if(map[now].sons[i]!=map[now].p){
        map[map[now].sons[i]].p=now;
        map[map[now].sons[i]].pos=map[now].pos+1;
        build(map[now].sons[i]);
    }
}
int main(){
    int n,r,k,l,top;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&l,&k);
        if(i==0)top=l;
        for(int j=0;j<k;j++){
            scanf("%d",&r);
            map[l].sons.push_back(r);
        }
    }
    map[top].pos=0;
    map[top].p=-1;
    build(top);
    for(int i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,map[i].p,map[i].pos);
        sort(map[i].sons.begin(),map[i].sons.end());
        if(i==top){
            printf("root, [");
if(map[i].sons.size>0)printf("%d",map[i].sons[0]);
            for(int j=1;j<map[i].sons.size();j++)printf(", %d",map[i].sons[j]);
            printf("]\n");
        }
        else if(map[i].sons.size()>0){
            printf("internal node, [%d",map[i].sons[0]);
            for(int j=1;j<map[i].sons.size();j++)printf(", %d",map[i].sons[j]);
            printf("]\n");
        }
        else printf("leaf, []\n");
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:16: 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 '()' ?)
   37 | if(map[i].sons.size>0)printf("%d",map[i].sons[0]);
      |    ~~~~~~~~~~~~^~~~
      |                    ()