Language: C++

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;
const int NIL = -1;
const int MAXN = 100005;

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

int n, D[MAXN], H[MAXN];

int getDegree(int u){
	int degree = 0;
	if(T[u].l != NIL)	degree++;
	if(T[u].r != NIL)	degree++;
	return degree;
}

int getSibling(int u){
	if(T[u].p == NIL)	return NIL;
	if(T[T[u].p].l != u)	return T[T[u].p].l;
	else	return T[T[u].p].r;
}

void print(int u){
	cout << "node " << u << ": parent = " << T[u].p;
	cout << ", sibling = " << getSibling(u);
	cout << ", degree = " << getDegree(u);
	cout << ", depth = " << D[u];
	cout << ", height = " << H[u] <<", ";
	if(T[u].p == NIL)	cout <<"root";
	else if(T[u].l == NIL)	cout << "leaf";
	else	cout << "internal node";
	cout << endl;
}

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

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if(T[u].l != NIL)
		h1 = setHeight(T[u].l) + 1;
	if(T[u].r != NIL)
		h2 = setHeight(T[u].r) + 1;
	return H[u] = max(h1, h2);
}

int main(){
	cin >> n;
	int p, l, r, loc;
	for(int i = 0; i < n; i++)	T[i].p = NIL;	
	for(int i = 0; i < n; i++){
		cin >> p >> l >> r;
		T[p].l = l;
		T[p].r = r;
		if(l != NIL)	T[l].p = p;
		if(r != NIL)	T[r].p = p;
	}
	for(int i = 0; i < n; i++)
		if(T[i].p == NIL)
			loc = i;
	setDepth(loc, 0);
	setHeight(loc);
	for(int i = 0; i < n; i++)	print(i);
	return 0;
}#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;
const int NIL = -1;
const int MAXN = 100005;

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

int n, D[MAXN], H[MAXN];

int getDegree(int u){
	int degree = 0;
	if(T[u].l != NIL)	degree++;
	if(T[u].r != NIL)	degree++;
	return degree;
}

int getSibling(int u){
	if(T[u].p == NIL)	return NIL;
	if(T[T[u].p].l != u)	return T[T[u].p].l;
	else	return T[T[u].p].r;
}

void print(int u){
	cout << "node " << u << ": parent = " << T[u].p;
	cout << ", sibling = " << getSibling(u);
	cout << ", degree = " << getDegree(u);
	cout << ", depth = " << D[u];
	cout << ", height = " << H[u] <<", ";
	if(T[u].p == NIL)	cout <<"root";
	else if(T[u].l == NIL)	cout << "leaf";
	else	cout << "internal node";
	cout << endl;
}

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

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if(T[u].l != NIL)
		h1 = setHeight(T[u].l) + 1;
	if(T[u].r != NIL)
		h2 = setHeight(T[u].r) + 1;
	return H[u] = max(h1, h2);
}

int main(){
	cin >> n;
	int p, l, r, loc;
	for(int i = 0; i < n; i++)	T[i].p = NIL;	
	for(int i = 0; i < n; i++){
		cin >> p >> l >> r;
		T[p].l = l;
		T[p].r = r;
		if(l != NIL)	T[l].p = p;
		if(r != NIL)	T[r].p = p;
	}
	for(int i = 0; i < n; i++)
		if(T[i].p == NIL)
			loc = i;
	setDepth(loc, 0);
	setHeight(loc);
	for(int i = 0; i < n; i++)	print(i);
	return 0;
}

Compiler output:
a.cc:75:2: error: stray '#' in program
   75 | }#include <iostream>
      |  ^
a.cc:75:3: error: 'include' does not name a type
   75 | }#include <iostream>
      |   ^~~~~~~
a.cc:82:11: error: redefinition of 'const int INF'
   82 | const int INF = 0x3f3f3f3f;
      |           ^~~
a.cc:8:11: note: 'const int INF' previously defined here
    8 | const int INF = 0x3f3f3f3f;
      |           ^~~
a.cc:83:11: error: redefinition of 'const int NIL'
   83 | const int NIL = -1;
      |           ^~~
a.cc:9:11: note: 'const int NIL' previously defined here
    9 | const int NIL = -1;
      |           ^~~
a.cc:84:11: error: redefinition of 'const int MAXN'
   84 | const int MAXN = 100005;
      |           ^~~~
a.cc:10:11: note: 'const int MAXN' previously defined here
   10 | const int MAXN = 100005;
      |           ^~~~
a.cc:86:8: error: redefinition of 'struct Node'
   86 | struct Node{ int p, l, r;}T[MAXN];
      |        ^~~~
a.cc:12:8: note: previous definition of 'struct Node'
   12 | struct Node{ int p, l, r;}T[MAXN];
      |        ^~~~
a.cc:86:27: error: conflicting declaration 'int T [100005]'
   86 | struct Node{ int p, l, r;}T[MAXN];
      |                           ^
a.cc:12:27: note: previous declaration as 'Node T [100005]'
   12 | struct Node{ int p, l, r;}T[MAXN];
      |                           ^
a.cc:88:5: error: redefinition of 'int n'
   88 | int n, D[MAXN], H[MAXN];
      |     ^
a.cc:14:5: note: 'int n' previously declared here
   14 | int n, D[MAXN], H[MAXN];
      |     ^
a.cc:88:8: error: redefinition of 'int D [100005]'
   88 | int n, D[MAXN], H[MAXN];
      |        ^
a.cc:14:8: note: 'int D [100005]' previously declared here
   14 | int n, D[MAXN], H[MAXN];
      |        ^
a.cc:88:17: error: redefinition of 'int H [100005]'
   88 | int n, D[MAXN], H[MAXN];
      |                 ^
a.cc:14:17: note: 'int H [100005]' previously declared here
   14 | int n, D[MAXN], H[MAXN];
      |                 ^
a.cc:90:5: error: redefinition of 'int getDegree(int)'
   90 | int getDegree(int u){
      |     ^~~~~~~~~
a.cc:16:5: note: 'int getDegree(int)' previously defined here
   16 | int getDegree(int u){
      |     ^~~~~~~~~
a.cc:97:5: error: redefinition of 'int getSibling(int)'
   97 | int getSibling(int u){
      |     ^~~~~~~~~~
a.cc:23:5: note: 'int getSibling(int)' previously defined here
   23 | int getSibling(int u){
      |     ^~~~~~~~~~
a.cc:103:6: error: redefinition of 'void print(int)'
  103 | void print(int u){
      |      ^~~~~
a.cc:29:6: note: 'void print(int)' previously defined here
   29 | void print(int u){
      |      ^~~~~
a.cc:115:6: error: redefinition of 'void setDepth(int, int)'
  115 | void setDepth(int u, int p){
      |      ^~~~~~~~
a.cc:41:6: note: 'void setDepth(int, int)' previously defined here
   41 | void setDepth(int u, int p){
      |      ^~~~~~~~
a.cc:122:5: error: redefinition of 'int setHeight(int)'
  122 | int setHeight(int u){
      |     ^~~~~~~~~
a.cc:48:5: note: 'int setHeight(int)' previously defined here
   48 | int setHeight(int u){
      |     ^~~~~~~~~
a.cc:131:5: error: redefinition of 'int main()'
  131 | int main(){
      |     ^~~~
a.cc:57:5: note: 'int main()' previously defined here
   57 | int main(){
      |     ^~~~