Language: C++

#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int n;

struct node
{
	int id, k, c[20], d;
	node* pn;
	string type;
}N[100005];

void Set()
{
	for (int i = 0; i < n; i++)
	{
		N[i].pn = (node*)malloc(sizeof(node));
		N[i].pn->id = -1;
	}
}

void GetDepth(node& GN)
{
	node temp = GN;
	GN.d = 0;

	while (temp.pn->id != -1)
	{
		GN.d++;
		temp = *temp.pn;
	}
}

void GetType(node& GN)
{
	if (GN.pn->id == -1)
		GN.type = "root";
	else if (GN.k == 0)
		GN.type = "leaf";
	else
		GN.type = "internal node";
}

void print()
{
	for (int i = 0; i < n; i++)
	{
		for (int t = 0; t < n; t++)
		{
			if (N[t].id == i)
			{
				cout << "node " << N[t].id << ": " << "parent = " << N[t].pn->id << ", " << "depth = " << N[t].d << ", " << N[t].type << ", " << "[";

				if (N[t].k != 0)
				{
					for (int j = 0; j < N[t].k - 1; j++)
						cout << N[t].c[j] << ", ";
					cout << N[t].c[N[t].k - 1];
				}

				cout << "]" << endl;
				break;
			}
		}
	}	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> n;
	Set();

	for (int i = 0; i < n; i++)
	{
		cin >> N[i].id >> N[i].k;
		for (int j = 0; j < N[i].k; j++)
		{
			cin >> N[i].c[j];
			for (int t = 0; t < n; t++)
			{
				if (N[i].c[j] == t)
					N[t].pn = &N[i];
			}
		}			
	}

	for (int i = 0; i < n; i++)
		GetDepth(N[i]);

	for (int i = 0; i < n; i++)
		GetType(N[i]);	

	print();

	return 0;
}#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int n;

struct node
{
	int id, k, c[20], d;
	node* pn;
	string type;
}N[100005];

void Set()
{
	for (int i = 0; i < n; i++)
	{
		N[i].pn = (node*)malloc(sizeof(node));
		N[i].pn->id = -1;
	}
}

void GetDepth(node& GN)
{
	node temp = GN;
	GN.d = 0;

	while (temp.pn->id != -1)
	{
		GN.d++;
		temp = *temp.pn;
	}
}

void GetType(node& GN)
{
	if (GN.pn->id == -1)
		GN.type = "root";
	else if (GN.k == 0)
		GN.type = "leaf";
	else
		GN.type = "internal node";
}

void print()
{
	for (int i = 0; i < n; i++)
	{
		for (int t = 0; t < n; t++)
		{
			if (N[t].id == i)
			{
				cout << "node " << N[t].id << ": " << "parent = " << N[t].pn->id << ", " << "depth = " << N[t].d << ", " << N[t].type << ", " << "[";

				if (N[t].k != 0)
				{
					for (int j = 0; j < N[t].k - 1; j++)
						cout << N[t].c[j] << ", ";
					cout << N[t].c[N[t].k - 1];
				}

				cout << "]" << endl;
				break;
			}
		}
	}	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> n;
	Set();

	for (int i = 0; i < n; i++)
	{
		cin >> N[i].id >> N[i].k;
		for (int j = 0; j < N[i].k; j++)
		{
			cin >> N[i].c[j];
			for (int t = 0; t < n; t++)
			{
				if (N[i].c[j] == t)
					N[t].pn = &N[i];
			}
		}			
	}

	for (int i = 0; i < n; i++)
		GetDepth(N[i]);

	for (int i = 0; i < n; i++)
		GetType(N[i]);	

	print();

	return 0;
}


Compiler output:
a.cc:101:2: error: stray '#' in program
  101 | }#include<iostream>
      |  ^
a.cc:101:3: error: 'include' does not name a type
  101 | }#include<iostream>
      |   ^~~~~~~
a.cc:106:5: error: redefinition of 'int n'
  106 | int n;
      |     ^
a.cc:6:5: note: 'int n' previously declared here
    6 | int n;
      |     ^
a.cc:108:8: error: redefinition of 'struct node'
  108 | struct node
      |        ^~~~
a.cc:8:8: note: previous definition of 'struct node'
    8 | struct node
      |        ^~~~
a.cc:113:2: error: conflicting declaration 'int N [100005]'
  113 | }N[100005];
      |  ^
a.cc:13:2: note: previous declaration as 'node N [100005]'
   13 | }N[100005];
      |  ^
a.cc:115:6: error: redefinition of 'void Set()'
  115 | void Set()
      |      ^~~
a.cc:15:6: note: 'void Set()' previously defined here
   15 | void Set()
      |      ^~~
a.cc:124:6: error: redefinition of 'void GetDepth(node&)'
  124 | void GetDepth(node& GN)
      |      ^~~~~~~~
a.cc:24:6: note: 'void GetDepth(node&)' previously defined here
   24 | void GetDepth(node& GN)
      |      ^~~~~~~~
a.cc:136:6: error: redefinition of 'void GetType(node&)'
  136 | void GetType(node& GN)
      |      ^~~~~~~
a.cc:36:6: note: 'void GetType(node&)' previously defined here
   36 | void GetType(node& GN)
      |      ^~~~~~~
a.cc:146:6: error: redefinition of 'void print()'
  146 | void print()
      |      ^~~~~
a.cc:46:6: note: 'void print()' previously defined here
   46 | void print()
      |      ^~~~~
a.cc:170:5: error: redefinition of 'int main()'
  170 | int main()
      |     ^~~~
a.cc:70:5: note: 'int main()' previously defined here
   70 | int main()
      |     ^~~~