Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i < (int)n; i++)
#define Loopr(i, n) for(int i= (int)n - 1; i >= 0; i--)
using namespace std;
typedef long long int ll;

struct node {
	int parent, left, right;
};

int n;
vector<node> nodes(25, { -1,-1,-1 });

int sib_of(int a) {
	if (nodes[a].parent == -1) return -1;
	else {
		int x = nodes[nodes[a].parent].left;
		int y = nodes[nodes[a].parent].right;
		if (x == a) return y;
		else return x;
	}
}

int deg_of(int a) {
	int ret = 0;
	if (nodes[a].left != -1) ret++;
	if (nodes[a].right != -1) ret++;
	return ret;
}

int depth_of(int a) {
	if (nodes[a].parent == -1) return 0;
	else return depth_of(nodes[a].parent) + 1;
}

int height_of(int a) {
	if (a == -1) return -1;
	else if (deg_of(a) == 0) return 0;
	else return max(height_of(nodes[a].left) + 1, height_of(nodes[a].right) + 1);
}

string type_of(int a) {
	if (nodes[a].parent == -1) return "root";
	else if (deg_of(a) == 0) return "leaf";
	else return "internal node";
}

void print(int a) {
	cout << "node " << a << ": parent = " << nodes[a].parent;
	cout << ", sibling = " << sib_of(a);
	cout << ", degree = " << deg_of(a);
	cout << ", depth = " << depth_of(a);
	cout << ", height = " << height_of(a);
	cout << ", " << type_of(a) << endl;
}

int main() {
	cin >> n;
	Loop(i, n) {
		int id;
		cin >> id;
		int l, r;
		cin >> l >> r;
		nodes[id].left = l;
		nodes[id].right = r;
		if (l != -1)nodes[l].parent = id;
		if (r != -1)nodes[r].parent = id;
	}
	Loop(i, n) {
		print(i);
	}
	return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i < (int)n; i++)
#define Loopr(i, n) for(int i= (int)n - 1; i >= 0; i--)
using namespace std;
typedef long long int ll;

struct node {
	int parent, left, right;
};

int n;
vector<node> nodes(25, { -1,-1,-1 });

int sib_of(int a) {
	if (nodes[a].parent == -1) return -1;
	else {
		int x = nodes[nodes[a].parent].left;
		int y = nodes[nodes[a].parent].right;
		if (x == a) return y;
		else return x;
	}
}

int deg_of(int a) {
	int ret = 0;
	if (nodes[a].left != -1) ret++;
	if (nodes[a].right != -1) ret++;
	return ret;
}

int depth_of(int a) {
	if (nodes[a].parent == -1) return 0;
	else return depth_of(nodes[a].parent) + 1;
}

int height_of(int a) {
	if (a == -1) return -1;
	else if (deg_of(a) == 0) return 0;
	else return max(height_of(nodes[a].left) + 1, height_of(nodes[a].right) + 1);
}

string type_of(int a) {
	if (nodes[a].parent == -1) return "root";
	else if (deg_of(a) == 0) return "leaf";
	else return "internal node";
}

void print(int a) {
	cout << "node " << a << ": parent = " << nodes[a].parent;
	cout << ", sibling = " << sib_of(a);
	cout << ", degree = " << deg_of(a);
	cout << ", depth = " << depth_of(a);
	cout << ", height = " << height_of(a);
	cout << ", " << type_of(a) << endl;
}

int main() {
	cin >> n;
	Loop(i, n) {
		int id;
		cin >> id;
		int l, r;
		cin >> l >> r;
		nodes[id].left = l;
		nodes[id].right = r;
		if (l != -1)nodes[l].parent = id;
		if (r != -1)nodes[r].parent = id;
	}
	Loop(i, n) {
		print(i);
	}
	return 0;
}

Compiler output:
a.cc:114:8: error: redefinition of 'struct node'
  114 | struct node {
      |        ^~~~
a.cc:24:8: note: previous definition of 'struct node'
   24 | struct node {
      |        ^~~~
a.cc:118:5: error: redefinition of 'int n'
  118 | int n;
      |     ^
a.cc:28:5: note: 'int n' previously declared here
   28 | int n;
      |     ^
a.cc:119:14: error: redefinition of 'std::vector<node> nodes'
  119 | vector<node> nodes(25, { -1,-1,-1 });
      |              ^~~~~
a.cc:29:14: note: 'std::vector<node> nodes' previously declared here
   29 | vector<node> nodes(25, { -1,-1,-1 });
      |              ^~~~~
a.cc:121:5: error: redefinition of 'int sib_of(int)'
  121 | int sib_of(int a) {
      |     ^~~~~~
a.cc:31:5: note: 'int sib_of(int)' previously defined here
   31 | int sib_of(int a) {
      |     ^~~~~~
a.cc:131:5: error: redefinition of 'int deg_of(int)'
  131 | int deg_of(int a) {
      |     ^~~~~~
a.cc:41:5: note: 'int deg_of(int)' previously defined here
   41 | int deg_of(int a) {
      |     ^~~~~~
a.cc:138:5: error: redefinition of 'int depth_of(int)'
  138 | int depth_of(int a) {
      |     ^~~~~~~~
a.cc:48:5: note: 'int depth_of(int)' previously defined here
   48 | int depth_of(int a) {
      |     ^~~~~~~~
a.cc:143:5: error: redefinition of 'int height_of(int)'
  143 | int height_of(int a) {
      |     ^~~~~~~~~
a.cc:53:5: note: 'int height_of(int)' previously defined here
   53 | int height_of(int a) {
      |     ^~~~~~~~~
a.cc:149:8: error: redefinition of 'std::string type_of(int)'
  149 | string type_of(int a) {
      |        ^~~~~~~
a.cc:59:8: note: 'std::string type_of(int)' previously defined here
   59 | string type_of(int a) {
      |        ^~~~~~~
a.cc:155:6: error: redefinition of 'void print(int)'
  155 | void print(int a) {
      |      ^~~~~
a.cc:65:6: note: 'void print(int)' previously defined here
   65 | void print(int a) {
      |      ^~~~~
a.cc:164:5: error: redefinition of 'int main()'
  164 | int main() {
      |     ^~~~
a.cc:74:5: note: 'int main()' previously defined here
   74 | int main() {
      |     ^~~~