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

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define llong long long
#define IFY 2000000000
#define MAX 10000
#define NIL -1
struct Node {int parent,left,right;};
Node T[MAX];
int n,D[MAX],H[MAX];
void setdepth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  setdepth(T[u].left,d+1);
  setdepth(T[u].right,d+1);
}
int setheight(int u){
  int h1=0;h2=0;
  if(T[u].left!=NIL) h1=setheight(T[u].left)+1;
  if(T[u].right!=NIl) h2=setdepth(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}
int getsibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=NIL&&T[T[u].parent].left!=u) return T[T[u].parent].left;
  if(T[T[u].parent].right!=NIL&&T[T[u].parent].right!=u) return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getsibling(u));
  int deg=0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  if(T[u].parent==NIL) printf("root\n");
  if(T[u].left==NIL&&T[u].right==NIL) printf("leaf\n");
  else printf("internal node\n");
}
int main(){
  int root=0,l,r
  scanf("%d",&n);
  REP(i,n) T[i].parent==NIL;
  REP(i,n){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }
  REP(i,n) if(T[i].parent==NIL) root=i;
  setdepth(root,0);
  setheight(root);
  REP(i,n) print(i);
  return 0;
}

Compiler output:
a.cc: In function 'int setheight(int)':
a.cc:18:12: error: 'h2' was not declared in this scope; did you mean 'h1'?
   18 |   int h1=0;h2=0;
      |            ^~
      |            h1
a.cc:20:18: error: 'NIl' was not declared in this scope; did you mean 'NIL'?
   20 |   if(T[u].right!=NIl) h2=setdepth(T[u].right)+1;
      |                  ^~~
      |                  NIL
a.cc:20:34: error: too few arguments to function 'void setdepth(int, int)'
   20 |   if(T[u].right!=NIl) h2=setdepth(T[u].right)+1;
      |                          ~~~~~~~~^~~~~~~~~~~~
a.cc:11:6: note: declared here
   11 | void setdepth(int u,int d){
      |      ^~~~~~~~
a.cc: In function 'int main()':
a.cc:45:3: error: expected initializer before 'scanf'
   45 |   scanf("%d",&n);
      |   ^~~~~
a.cc:48:23: error: 'v' was not declared in this scope
   48 |     scanf("%d %d %d",&v,&l,&r);
      |                       ^
a.cc:48:29: error: 'r' was not declared in this scope
   48 |     scanf("%d %d %d",&v,&l,&r);
      |                             ^
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define llong long long
#define IFY 2000000000
#define MAX 10000
#define NIL -1
struct Node {int parent,left,right;};
Node T[MAX];
int n,D[MAX],H[MAX];
void setdepth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  setdepth(T[u].left,d+1);
  setdepth(T[u].right,d+1);
}
int setheight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL) h1=setheight(T[u].left)+1;
  if(T[u].right!=NIL) h2=sethepth(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}
int getsibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=NIL&&T[T[u].parent].left!=u) return T[T[u].parent].left;
  if(T[T[u].parent].right!=NIL&&T[T[u].parent].right!=u) return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getsibling(u));
  int deg=0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  if(T[u].parent==NIL) printf("root\n");
  if(T[u].left==NIL&&T[u].right==NIL) printf("leaf\n");
  else printf("internal node\n");
}
int main(){
  int root=0,v,l,r;
  scanf("%d",&n);
  REP(i,n) T[i].parent==NIL;
  REP(i,n){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }
  REP(i,n) if(T[i].parent==NIL) root=i;
  setdepth(root,0);
  setheight(root);
  REP(i,n) print(i);
  return 0;
}

Compiler output:
a.cc: In function 'int setheight(int)':
a.cc:20:26: error: 'sethepth' was not declared in this scope; did you mean 'setdepth'?
   20 |   if(T[u].right!=NIL) h2=sethepth(T[u].right)+1;
      |                          ^~~~~~~~
      |                          setdepth
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define llong long long
#define IFY 2000000000
#define MAX 10000
#define NIL -1
struct Node {int parent,left,right;};
Node T[MAX];
int n,D[MAX],H[MAX];
void setdepth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  setdepth(T[u].left,d+1);
  setdepth(T[u].right,d+1);
}
void setheight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL) h1=setheight(T[u].left)+1;
  if(T[u].right!=NIL) h2=setheight(T[u].right)+1;
  H[u]=(h1>h2?h1:h2);
}
int getsibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=NIL&&T[T[u].parent].left!=u) return T[T[u].parent].left;
  if(T[T[u].parent].right!=NIL&&T[T[u].parent].right!=u) return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getsibling(u));
  int deg=0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  if(T[u].parent==NIL) printf("root\n");
  else if(T[u].left==NIL&&T[u].right==NIL) printf("leaf\n");
  else printf("internal node\n");
}
int main(){
  int root=0,v,l,r;
  scanf("%d",&n);
  REP(i,n) T[i].parent==NIL;
  REP(i,n){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }
  REP(i,n) if(T[i].parent==NIL) root=i;
  setdepth(root,0);
  setheight(root);
  REP(i,n) print(i);
  return 0;
}

Compiler output:
a.cc: In function 'void setheight(int)':
a.cc:19:45: error: invalid operands of types 'void' and 'int' to binary 'operator+'
   19 |   if(T[u].left!=NIL) h1=setheight(T[u].left)+1;
      |                         ~~~~~~~~~~~~~~~~~~~~^~
      |                                  |           |
      |                                  void        int
a.cc:20:47: error: invalid operands of types 'void' and 'int' to binary 'operator+'
   20 |   if(T[u].right!=NIL) h2=setheight(T[u].right)+1;
      |                          ~~~~~~~~~~~~~~~~~~~~~^~
      |                                   |            |
      |                                   void         int
Language: C++

#include <iostream><font></font>
#include <algorithm><font></font>
using namespace std;<font></font>
<font></font>
const int MAX = 100000;<font></font>
int n, pa[MAX], le[MAX], ri[MAX], cnt;<font></font>
<font></font>
void dfs_h(int a, int res){<font></font>
  cnt = max(cnt,res);<font></font>
  if(le[a] != -1) dfs_h(le[a], res+1);<font></font>
  if(ri[a] != -1) dfs_h(ri[a], res+1);<font></font>
}<font></font>
<font></font>
void solve(){<font></font>
  for(int i=0;i<n;i++){<font></font>
    cout << "node " << i << ": parent = " << pa[i] << flush;<font></font>
<font></font>
    if(pa[i] == -1) cout << ", sibling = " << -1 << flush;<font></font>
    else if(le[pa[i]] != i) cout << ", sibling = " << le[pa[i]] << flush;<font></font>
    else cout << ", sibling = " << ri[pa[i]] << flush;<font></font>
<font></font>
    cnt = 0;<font></font>
    if(le[i] != -1) cnt++;<font></font>
    if(ri[i] != -1) cnt++;<font></font>
    cout << ", degree = " << cnt << flush;<font></font>
<font></font>
    cnt = 0;<font></font>
    for(int j=pa[i]; j!=-1; j=pa[j]) cnt++;<font></font>
    cout << ", depth = " << cnt << flush;<font></font>
<font></font>
    cnt = 0;<font></font>
    dfs_h(i,0);<font></font>
    cout << ", height = " << cnt << flush;<font></font>
<font></font>
    if(pa[i] == -1) cout << ", root" << endl;<font></font>
    else if(le[i] == -1 && ri[i] == -1) cout << ", leaf" << endl;<font></font>
    else cout << ", internal node" << endl;<font></font>
  }<font></font>
<font></font>
}<font></font>
<font></font>
int main(){<font></font>
  cin >> n;<font></font>
  fill(pa,pa+MAX,-1);<font></font>
  fill(le,le+MAX,-1);<font></font>
  fill(ri,ri+MAX,-1);<font></font>
  for(int i=0;i<n;i++){<font></font>
    int a,b,c;<font></font>
    cin >> a >> b >> c;<font></font>
    le[a] = b;<font></font>
    ri[a] = c;<font></font>
    pa[b] = a;<font></font>
    pa[c] = a;<font></font>
  }<font></font>
  solve();<font></font>
}<font></font>
<font></font>
<font></font>

Compiler output:
a.cc:1:20: warning: extra tokens at end of #include directive
    1 | #include <iostream><font></font>
      |                    ^~~~~~
a.cc:2:21: warning: extra tokens at end of #include directive
    2 | #include <algorithm><font></font>
      |                     ^~~~~~
a.cc:3:21: error: expected unqualified-id before '<' token
    3 | using namespace std;<font></font>
      |                     ^
a.cc:5:24: error: expected unqualified-id before '<' token
    5 | const int MAX = 100000;<font></font>
      |                        ^
a.cc:6:39: error: expected unqualified-id before '<' token
    6 | int n, pa[MAX], le[MAX], ri[MAX], cnt;<font></font>
      |                                       ^
a.cc:12:2: error: expected unqualified-id before '<' token
   12 | }<font></font>
      |  ^
a.cc:40:2: error: expected unqualified-id before '<' token
   40 | }<font></font>
      |  ^
a.cc:56:2: error: expected unqualified-id before '<' token
   56 | }<font></font>
      |  ^
Language: C++

#include<iostream>
using namespace std;
#define MAX100005
#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].p<<",";
 	
 	if(T[u].p==NIL) cout<<"root,";
 	else if(T[u].l==NIL) cout<<"ieaf,";
 	else cout<<"internal node,";
 	
 	cout<<"[";
 	
 	for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r)
 	{
 		if(i)cout<<",";
 		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++)
 		{
 			cin>>v>>d;
 			for(j=0;j<d;j++)
 			{
 				cin>>n;
 				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=1;
 		}
 		
 		rec(r,0);
 		
 		for(i=0;i<n;i++) print(i);
 		
 		return 0;
 }


Compiler output:
a.cc:8:8: error: 'MAX' was not declared in this scope
    8 | Node T[MAX];
      |        ^~~
a.cc:9:9: error: 'MAX' was not declared in this scope
    9 | int n,D[MAX];
      |         ^~~
a.cc: In function 'void print(int)':
a.cc:14:26: error: 'T' was not declared in this scope
   14 |         cout<<"parent="<<T[u].p<<",";
      |                          ^
a.cc:15:25: error: 'D' was not declared in this scope
   15 |         cout<<"depth="<<D[u].p<<",";
      |                         ^
a.cc:31:9: error: a function-definition is not allowed here before '{' token
   31 |         {
      |         ^
a.cc:37:17: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   37 |         int main()
      |                 ^~
a.cc:37:17: note: remove parentheses to default-initialize a variable
   37 |         int main()
      |                 ^~
      |                 --
a.cc:37:17: note: or replace parentheses with braces to value-initialize a variable
a.cc:38:9: error: a function-definition is not allowed here before '{' token
   38 |         {
      |         ^
a.cc:63:3: error: expected '}' at end of input
   63 |  }
      |   ^
a.cc:11:2: note: to match this '{'
   11 |  {
      |  ^
Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

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

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
	if(u==NIL)return;
	D[u]=d;
	setDepth(T[u].left,d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u){
	int h1=0,h2=0;
	if(T[u].left!=NIL) h1=setHeight(T[u].left)+1;
	if(T[u].right!=NIL) h2=setHeught(T[u].right)+1;
	return H[u]=(h1>h2 ? h1:h2);
}

int getSibling(int u){
	if(T[u].parent==NIL) return NIL;
	if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL) return T[T[u].parent].left;
	if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL) return T[T[u],parent].right;
	return NIL;
}

void print(int u){
	printf("Node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg=0;
	if(T[u].left!=NIL) deg++;
	if(T[u].right!=NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, "H[u]);
	
	if(T[u].parent == NIL){
		printf("root\n");
	}
	else if(T[u].left==NIL && T[u].right==NIL) {
		printf("leaf\n");
	}
	else{
		printf("internal node\n");
	}
}

int main(){
	int v,l,r,root=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		sacanf("%d %d %d",&v,&l,&r);
		T[v].left=l;
		T[v].right=r;
		if(l!=NIL) T[l].parent=v;
		if(r!=NIL) T[r].parent=v;
	}
	for(int i=0,i<n;i++) if(T[i].parent==NIL) root=1;
	setDepth(root,0);
	setHeight(root);
	for(int i=0;i<n;i++) print(i);
	return 0;
}


Compiler output:
a.cc: In function 'int setHeight(int)':
a.cc:20:32: error: 'setHeught' was not declared in this scope; did you mean 'setHeight'?
   20 |         if(T[u].right!=NIL) h2=setHeught(T[u].right)+1;
      |                                ^~~~~~~~~
      |                                setHeight
a.cc: In function 'int getSibling(int)':
a.cc:27:78: error: 'parent' was not declared in this scope
   27 |         if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL) return T[T[u],parent].right;
      |                                                                              ^~~~~~
a.cc: In function 'void print(int)':
a.cc:40:16: error: unable to find string literal operator 'operator""H' with 'const char [14]', 'long unsigned int' arguments
   40 |         printf("height = %d, "H[u]);
      |                ^~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:57:17: error: 'sacanf' was not declared in this scope; did you mean 'sscanf'?
   57 |                 sacanf("%d %d %d",&v,&l,&r);
      |                 ^~~~~~
      |                 sscanf
a.cc:63:22: error: expected ';' before '<' token
   63 |         for(int i=0,i<n;i++) if(T[i].parent==NIL) root=1;
      |                      ^
      |                      ;
a.cc:63:22: error: expected primary-expression before '<' token
Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

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

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeght(int u){
	int h1 = 0,h2 = 0;
	if(T[u].left != NIL)
		h1 = setHight(T[u].left) + 1;
	if(T[u].right != NIL)
		h2 = setHight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
		return T[T[u].parent].right;
	return NIL;
}

void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg = 0;
	if(T[u].left != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL){
		printf("root\n");
	}else if(T[u].left == NIL && T[u].right == NIL){
		printf("leaf\n");
	}else{
		printf("internal node\n");
	}
}


int main(){
	int v,l,r,root = 0;
	scanf("%d",&n);
	
	for(i = 0;i < n;i++) T[i].parent = NIL;
	
	for(i = 0;i < n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].left = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	for(i = 0;i < n;i++) if (T[i].parent == NIL) root = i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(i = 0;i < n;i++) print(i);
	return 0;
} 


Compiler output:
a.cc: In function 'int setHeght(int)':
a.cc:20:22: error: 'setHight' was not declared in this scope; did you mean 'setHeght'?
   20 |                 h1 = setHight(T[u].left) + 1;
      |                      ^~~~~~~~
      |                      setHeght
a.cc:22:22: error: 'setHight' was not declared in this scope; did you mean 'setHeght'?
   22 |                 h2 = setHight(T[u].right) + 1;
      |                      ^~~~~~~~
      |                      setHeght
a.cc: In function 'int main()':
a.cc:60:13: error: 'i' was not declared in this scope
   60 |         for(i = 0;i < n;i++) T[i].parent = NIL;
      |             ^
a.cc:62:13: error: 'i' was not declared in this scope
   62 |         for(i = 0;i < n;i++){
      |             ^
a.cc:69:13: error: 'i' was not declared in this scope
   69 |         for(i = 0;i < n;i++) if (T[i].parent == NIL) root = i;
      |             ^
a.cc:72:9: error: 'setHeight' was not declared in this scope; did you mean 'setHeght'?
   72 |         setHeight(root);
      |         ^~~~~~~~~
      |         setHeght
a.cc:74:13: error: 'i' was not declared in this scope
   74 |         for(i = 0;i < n;i++) print(i);
      |             ^
Language: C++

#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
 
struct Node { int parent, left, right;};
 
Node T[MAX];
int n, D[MAX];
 
void setDepth(int u,int d){
if (u==NIL) return;
D[u] = d;
setDepth(T[u].left,d+1);
setDepth(T[u].right,d+1);
}
int setHeight(int u){
int h1 = 0,h2 = 0;
if(T[u].left !=NIL)
h1 = setHeigh(T[u].left)+1;
	if(T[u].right !=NIL)
	h2 =setHeight(T[u].right)+1;
	return H[u] = (h1>h2?h1:h2);
}

int getSiblimg(int u){
	if(T[u].parent == NIL)return NIL;
	if(T[T[u].parent].left !=u&&T[T[u].parent].left !=NIL)
	return T[T[u].parent].left;
	if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL);
	return T[T[u].parent].right;
	return NIL;
}
void printf(int u){
	printf("node %d: ",u);
	printf("parent = %d,",T[u].parent);
	printf("sibling  %d,",getSibling(u));
	int deg = 0;
	if(T[u].left !=NIL) deg++;
	if(T[u].right !=NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("hight = %d, ",H[u]);
	
	if(T[u].parent == NIL){
		printf("root\n");
	}else if(T[u].left == NIL && T[u].right == NIL){
		printf("leaf\n");
	}else{
		primtf("internal node\n");
	}}
int main(){
	int v,l,r,root=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)T[i].parent = NIL;
	for(int i=0;i<n;i++){
		T[v].left = l;
		T[v].right = r;
		if(l!=NIL)T[l].parent = v;
		if(r!=NIL)T[r].parent = v;}
	for (int i=0;i<n;i++)if(T[i].parent == NIL) root=i;
	setDepth(root,0);
	setHeight(root);
	
	for(int i=0;i<n;i++)print(i);
	
	return 0;
}


Compiler output:
a.cc: In function 'int setHeight(int)':
a.cc:20:6: error: 'setHeigh' was not declared in this scope; did you mean 'setHeight'?
   20 | h1 = setHeigh(T[u].left)+1;
      |      ^~~~~~~~
      |      setHeight
a.cc:23:16: error: 'H' was not declared in this scope
   23 |         return H[u] = (h1>h2?h1:h2);
      |                ^
a.cc: In function 'void printf(int)':
a.cc:37:31: error: 'getSibling' was not declared in this scope; did you mean 'getSiblimg'?
   37 |         printf("sibling  %d,",getSibling(u));
      |                               ^~~~~~~~~~
      |                               getSiblimg
a.cc:43:31: error: 'H' was not declared in this scope
   43 |         printf("hight = %d, ",H[u]);
      |                               ^
a.cc:50:17: error: 'primtf' was not declared in this scope; did you mean 'printf'?
   50 |                 primtf("internal node\n");
      |                 ^~~~~~
      |                 printf
a.cc: In function 'int main()':
a.cc:65:29: error: 'print' was not declared in this scope; did you mean 'printf'?
   65 |         for(int i=0;i<n;i++)print(i);
      |                             ^~~~~
      |                             printf
Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

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

Node T[MAX];
int n, D[MAX], H[MAX];
x
void setDepth(int u, int d){
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeight(int u){
	int h1 = 0,h2 = 0;
	if(T[u].left != NIL) 
		h1 = setHeight(T[u].left) + 1;
	if(T[u].right != NIL) 
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}


int getSibling(int u){
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) 
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) 
		return T[T[u].parent].right;
	return NIL;
}

void print(int u){
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("subling = %d, ", getSibling(u));
	int deg = 0;
	if(T[u].left != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);

	if(T[u].parent == NIL){
		printf("root\n");
	} else if (T[u].left == NIL && T[u].right == NIL){ 
		printf("leaf\n");
	}else {
		printf("internal node\n");
	}
}

int main(){
	int v,l,r,root=0;
	scanf("%d",&n);

	for(int i=0;i<n;i++) T[i].parent = NIL;

	for(int i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].left=l;
		T[v].right=r;
		if(l!=NIL) T[l].parent=v;
		if(r != NIL) T[r].parent = v;
	}

	for(int i=0;i<n;i++) if(T[i].parent == NIL) root = i;

	setDepth(root, 0);
	setHeight(root);

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

	return 0;
}


Compiler output:
a.cc:9:1: error: 'x' does not name a type
    9 | x
      | ^
a.cc: In function 'int main()':
a.cc:72:9: error: 'setDepth' was not declared in this scope
   72 |         setDepth(root, 0);
      |         ^~~~~~~~
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;
// node最大量
#define MAX 100005
#define NIL -1

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

// 配列で保持する
Node gNode[MAX];
int gDepth[MAX],gHeight[MAX];

// 兄弟を返す
int getSibiling(int u){
    // rootの場合
    if(gNode[u].parent == NIL)return NIL;
    // 自身が右の子だった場合
    if(gNode[gNode[u].parent].left != u && gNode[gNode[u].parent].left != NIL){
        return gNode[gNode[u].parent].left;
    }
    // 自身が左の子だった場合
    if(gNode[gNode[u].parent].right != u && gNode[gNode[u].parent].right != NIL){
        return gNode[gNode[u].parent].right;
    }
    // 親が一つしか子を持たない状態
    return NIL;
}

void print(int node){
    cout << "node " << node << ": ";
    cout << "parent = " << gNode[node].parent << ", ";
    cout << "sibiling = " << getSibiling(node) << ", ";
    
    int deg = 0;
    if(gNode[node].left != NIL) deg++;
    if(gNode[node].right != NIL) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << gDepth[node] << ", ";
    cout << "height = " << gHeight[node] << ", ";
    
    if(gNode[node].parent == NIL){
        cout << "root\n";
    }else if(gNode[node].left == NIL && gNode[node].right == NIL){
        cout << "leaf\n";
    }else{
        cout << "internal node\n";
    }
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

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

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if ( u == NIL ) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if ( T[u].left != NIL )
    h1 = setHeight(T[u].left) + 1;
  if ( T[u].right != NIL )
    h2 = setHeight(T[u].right) + 1;
  return H[u] = ( h1 > h2 ? h1 : h2);
}

// 節点 u の兄弟を返す
int setSibling(int u) {
  if ( T[u].parent == NIL ) return NIL;
  if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].left != NIL ) deg++;
  if ( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].parent == NIL )
    printf("root\n");
  else if ( T[u].left == NIL && T[u].right == NIL )
    printf("leaf\n");
  else
    printf("internal node\n");
}

int main() {
  int v, l, r, root = 0;
  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) T[i].parent = NIL;

  for ( int i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if ( l != NIL ) T[l].parent = v;
    if ( r != NIL ) T[r].parent = v;
  }

  for ( int i = 0; i < n; i++ ) if ( T[i].parent == NIL ) root = i;

  setDepth(root, 0);
  setHeight(root);

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

  return 0;
}


Compiler output:
a.cc: In function 'void print(int)':
a.cc:39:28: error: 'getSibling' was not declared in this scope; did you mean 'setSibling'?
   39 |   printf("sibling = %d, ", getSibling(u));
      |                            ^~~~~~~~~~
      |                            setSibling
Language: C++


#include <iostream>

using namespace std;
#define NIL -1;

struct Node{int parent, left, right;};
Node T[10000];
int D[10000];
int H[10000];



void setDepth(int u, int d){
    if(u==-1) return;
    D[u]=d;
    setDepth(T[u].right,d+1);
    setDepth(T[u].left,d+1);
}

int setHeight(int u){
    int h1,h2; h1=h2=0;
    if(T[u].right!=-1) h1=setHeight(T[u].right)+1;
    if(T[u].left!=-1) h2=setHeight(T[u].left)+1;

    return H[u] = max(h1,h2);

}

int getSibling(int u){
    if(T[u].parent==-1) return -1;
    if(T[T[u].parent].left!=u and T[T[u].parent].left!=-1) return  T[T[u].parent].left;
    if(T[T[u].parent].right!=u and T[T[u].parent].right!=-1) return  T[T[u].parent].right;
    return -1;

}

void print(int u){
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].parent<<", ";
    cout<<"sibling = "<<getSibling(u)<<", ";
    int deg=0;
    if(T[u].left!=-1) deg++;
    if(T[u].right!=-1) deg++;
    cout<<"degree = "<<deg<<", ";
    cout<<"depth = "<<D[u]<<", ";
    cout<<"height = "<<H[u]<<", ";

    if(T[u].parent==-1)cout<<"root";
    else if(T[u].left==-1 and T[u].rihgt==-1)cout<<"leaf";
    else cout<<"internal node";
    cout<<endl;


}



int main()
{
    int n,i,l,r,v;
    cin>>n;
    for(i=0;i<n;i++)T[i].parent=T[i].left=T[i].right=-1;
    for(i=0;i<n;i++){
        cin>>v;
        cin>>l>>r;
        if (l!=-1){
            T[v].left=l;
            T[l].parent=v;
        }
        if (r!=-1){
            T[v].right=r;
            T[r].parent=v;
        }
    }

    for(i=0;i<n;i++){
        if(T[i].parent==-1) r=i;
    }
    setDepth(r,0);
    setHeight(r);

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

    return 0;
}


Compiler output:
a.cc: In function 'void print(int)':
a.cc:50:36: error: 'struct Node' has no member named 'rihgt'; did you mean 'right'?
   50 |     else if(T[u].left==-1 and T[u].rihgt==-1)cout<<"leaf";
      |                                    ^~~~~
      |                                    right
Language: C++

package main;

import java.util.Scanner;

class Node {
	int i, id, left, right, parent = -1, sibling = -1, degree = 0, depth = 0, hight = 0;

	public Node(int Id, int l, int r) {
		id = Id;
		left = l;
		right = r;
	}

	public void Show() {

		System.out.print("node " + id + ": parent = " + parent + ", sibling = " + sibling +
				", degree = " + degree + ", depth = " + depth + ", hight = " + hight + ", ");
		if(parent==-1) {
			System.out.println("root");
		}else if(degree==0){
			System.out.println("leaf");
		}else {
			System.out.println("internal node");
		}
	}
}

public class Main {
	static Node[] node = new Node[100000];

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i, n, id, l, r,parentid;
		n = scan.nextInt();
		for (i = 0; i < n; i++) {
			id = scan.nextInt();
			l = scan.nextInt();
			r = scan.nextInt();
			node[id] = new Node(id, l, r);
		}
		for (i = 0; i < n; i++) {
			if (node[i].left != -1) {
				node[i].degree++;
				node[node[i].left].depth=node[i].depth+1;
				node[node[i].left].parent=node[i].id;
				node[node[i].left].sibling=node[i].right;
			}
			if (node[i].right != -1) {
				node[i].degree++;
				node[node[i].right].depth=node[i].depth+1;
				node[node[i].right].parent=node[i].id;
				node[node[i].right].sibling=node[i].left;
			}
		}
		for (i = 0; i < n; i++) {
			node[i].Show();
		}
		scan.close();
	}
}


Compiler output:
a.cc:1:1: error: 'package' does not name a type
    1 | package main;
      | ^~~~~~~
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:15: error: expected ':' before 'Node'
    8 |         public Node(int Id, int l, int r) {
      |               ^~~~~
      |               :
a.cc:14:15: error: expected ':' before 'void'
   14 |         public void Show() {
      |               ^~~~~
      |               :
a.cc:26:2: error: expected ';' after class definition
   26 | }
      |  ^
      |  ;
a.cc: In member function 'void Node::Show()':
a.cc:16:17: error: 'System' was not declared in this scope
   16 |                 System.out.print("node " + id + ": parent = " + parent + ", sibling = " + sibling +
      |                 ^~~~~~
a.cc:16:47: error: invalid operands of types 'const char*' and 'const char [12]' to binary 'operator+'
   16 |                 System.out.print("node " + id + ": parent = " + parent + ", sibling = " + sibling +
      |                                  ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
      |                                          |      |
      |                                          |      const char [12]
      |                                          const char*
a.cc: At global scope:
a.cc:28:1: error: expected unqualified-id before 'public'
   28 | public class Main {
      | ^~~~~~
Language: C++

#include<iostream>

using namespace std;

#define MAX 10000
#define NIL -1

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

Node T[MAX];
int D[MAX], H[MAX];

void setDepth(int u, int d) {
  if (u == NIL) {
    return;
  }
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1)
}

int setHeight(int u) {
  int h1 = 0; h2 = 0;
  if (T[u].left != NIL) {
    h1 = setHeight(T[u].left) + 1;
  }
  if (T[u].right != NIL) {
    h2 = setHeight(T[u].right) + 1;
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
  if (T[u].parent == NIL) {
    return NIL;
  }
  if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) {
    return T[T[u].parent].left;
  }
  if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
    return T[T[u].parent].right;
  }
  return NIL;
}

void print(int u) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "sibling = " << getSibling(u) << ", ";
  int deg = 0;
  if (T[u].left != NIL) {
    deg++;
  }
  if (T[u].right != NIL) {
    deg++;
  }

  cout << "degree = " << deg << ", ";
  cout << "depth = " << D[u] << ", ";
  cout << "height = " << H[u] << ", ";

  if (T[u].parent == NIL) {
    cout << "root" << endl;
  } else if (T[u].left == NIL && T[u].right == NIL) {
    cout << "leaf" << endl;
  } else {
    cout << "internal node" << endl;
  }
}

int main() {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    T[i].parent = NIL;
  }

  int v, left, right;
  for (int i = 0; i < N; i++) {
    cin >> v >> left, right;
    T[v].left = left;
    T[v].right = right;
    if (left != NIL) {
      T[left].parent = v;
    }
    if (right != NIL) {
      T[right].parent = v;
    }
  }

  int root = 0;
  for (int i = 0; i < N; i++) {
    if(T[i].parent == NIL) {
      root = i;
    }
  }

  setDepth(root, 0);
  setHeight(root);

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

  return 0;
}


Compiler output:
a.cc: In function 'void setDepth(int, int)':
a.cc:23:30: error: expected ';' before '}' token
   23 |   setDepth(T[u].right, d + 1)
      |                              ^
      |                              ;
   24 | }
      | ~                             
a.cc: In function 'int setHeight(int)':
a.cc:27:15: error: 'h2' was not declared in this scope; did you mean 'h1'?
   27 |   int h1 = 0; h2 = 0;
      |               ^~
      |               h1
Language: C++

#include<iostream>

using namespace std;

#define MAX 10000
#define NIL -1

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

Node T[MAX];
int D[MAX], H[MAX];

void setDepth(int u, int d) {
  if (u == NIL) {
    return;
  }
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0; h2 = 0;
  if (T[u].left != NIL) {
    h1 = setHeight(T[u].left) + 1;
  }
  if (T[u].right != NIL) {
    h2 = setHeight(T[u].right) + 1;
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
  if (T[u].parent == NIL) {
    return NIL;
  }
  if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) {
    return T[T[u].parent].left;
  }
  if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
    return T[T[u].parent].right;
  }
  return NIL;
}

void print(int u) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "sibling = " << getSibling(u) << ", ";
  int deg = 0;
  if (T[u].left != NIL) {
    deg++;
  }
  if (T[u].right != NIL) {
    deg++;
  }

  cout << "degree = " << deg << ", ";
  cout << "depth = " << D[u] << ", ";
  cout << "height = " << H[u] << ", ";

  if (T[u].parent == NIL) {
    cout << "root" << endl;
  } else if (T[u].left == NIL && T[u].right == NIL) {
    cout << "leaf" << endl;
  } else {
    cout << "internal node" << endl;
  }
}

int main() {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    T[i].parent = NIL;
  }

  int v, left, right;
  for (int i = 0; i < N; i++) {
    cin >> v >> left, right;
    T[v].left = left;
    T[v].right = right;
    if (left != NIL) {
      T[left].parent = v;
    }
    if (right != NIL) {
      T[right].parent = v;
    }
  }

  int root = 0;
  for (int i = 0; i < N; i++) {
    if(T[i].parent == NIL) {
      root = i;
    }
  }

  setDepth(root, 0);
  setHeight(root);

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

  return 0;
}


Compiler output:
a.cc: In function 'int setHeight(int)':
a.cc:27:15: error: 'h2' was not declared in this scope; did you mean 'h1'?
   27 |   int h1 = 0; h2 = 0;
      |               ^~
      |               h1
Language: C++

#include<stdio>
#define MAX 10000
#define NIL -1

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

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if ( u == NIL ) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if ( T[u].left != NIL ) h1 = setHeight(T[u].left) + 1;
  if ( T[u].right != NIL ) h2 = setHeight(T[u].right) + 1;
  return H[u] = ( h1 > h2 ? h1 : h2 );
}

int getSibling(int u) {
  if ( T[u].parent == NIL ) return NIL;
  if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL ) {
    return T[T[u].parent].left;
  }
  if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
    return T[T[u].parent].right;
  }
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].left != NIL ) deg++;
  if ( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].parent == NIL ) {
    printf("root\n");
  } else if ( T[u].left == NIL && T[u].right == NIL ) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main() {
  int v, l, r, root = 0;
  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if ( l != NIL ) T[l].parent = v;
    if ( r != NIL ) T[r].parent = v;
  }

  for ( int i = 0; i < n; i++ ) if ( T[i].parent == NIL ) root = i;

  setDepth(root, 0);
  setHeight(root);

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

  return 0;
}


Compiler output:
a.cc:1:9: fatal error: stdio: No such file or directory
    1 | #include<stdio>
      |         ^~~~~~~
compilation terminated.
Language: C++

#include <cstdio>
#define NIL -1
#define MAX 10000

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

Node T[MAX];
int n, D[MAX]; H[MAX];

void setDepth(int u, int d) {
    if(u==NIL) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u) {
    int h1=0, h2=0;
    if(T[u].left != NIL)  h1 = setHeight(T[u].left) + 1;
    if(T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
    
    return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
        return T[T[u].parent].left;
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
        return T[T[u].parent].right;
    return NIL;
}

/*
node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
node 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node
node 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf
*/

void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    printf("degree = %d, ", D[u]);
    printf("height = %d, ", H[u]);
    
    if(T[u].parent == NIL) {
        printf("root\n");
    }else if(T[u].left == NIL && T[u].right == NIL) {
        printf("leaf\n");
    }else{
        printf("internal node\n");
    }
}

void main() {
    int v, l, r, root=0;
    scanf("%d", &n);
    
    for (int i=0; i<n; i++) T[i].parent = NIL;
    
    for (int i=0; i<n; i++) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if (l != NIL) T[l].parent = v;
        if (r != NIL) T[r].parent = v;
    }
    
    for (int i=0; i<n; i++) if(T[i].parent == NIL) root = i;
    
    setDepth(root, 0);
    setHeight(root);
    
    for (int i=0; i<n; i++) print(i);
    
    return 0;
}


Compiler output:
a.cc:10:16: error: 'H' does not name a type
   10 | int n, D[MAX]; H[MAX];
      |                ^
a.cc: In function 'int setHeight(int)':
a.cc:24:12: error: 'H' was not declared in this scope
   24 |     return H[u] = (h1 > h2 ? h1 : h2);
      |            ^
a.cc: In function 'void print(int)':
a.cc:47:29: error: 'H' was not declared in this scope
   47 |     printf("height = %d, ", H[u]);
      |                             ^
a.cc: At global scope:
a.cc:58:1: error: '::main' must return 'int'
   58 | void main() {
      | ^~~~
Language: C++

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <boost/format.hpp>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 1000000;

vector<int> tree[N_MAX];
int used[N_MAX];

int parent[N_MAX];
int sibl[N_MAX];
int deg[N_MAX];
int dep[N_MAX];
int height[N_MAX];
string type[N_MAX];

int find_depth(int node_id){
  if(node_id == -1) return 0;
  return 1 + max(find_depth(tree[node_id][0]),
		 find_depth(tree[node_id][1]));
}

void _height_dfs(int node_id, int h){
  if(node_id == -1) return;
  height[node_id] = max(h, height[node_id]);
  _height_dfs(parent[node_id], h+1);
}

void fill_height(int n){
  // find children
  rep(i, 0, n){
    if(type[i] == "leaf") _height_dfs(i, 0);
  }
}

void dfs(int node_id, int depth){
    int left_id = tree[node_id][0];
    int right_id = tree[node_id][1];

    deg[node_id] = (left_id != -1) + (right_id != -1);
    dep[node_id] = depth;

    // root
    if(depth==0){
      parent[node_id] = -1;
      sibl[node_id] = -1;
      type[node_id] = "root";
    }
    
    // if both children
    if(left_id != -1 && right_id != -1){
      parent[left_id] = node_id;
      parent[right_id] = node_id;
      sibl[left_id] = right_id;
      sibl[right_id] = left_id;
      if(depth > 0) type[node_id] = "internal node";

      dfs(left_id, depth+1);
      dfs(right_id, depth+1);
      
    }
    else if(left_id * right_id < 0){
      true;
    }
    else{
      type[node_id] = "leaf";
    }

    
}

int main(){
  int n;
  cin >> n;
  
  memset(used, 0, N_MAX*sizeof(used[0]));
  memset(height, 0, N_MAX*sizeof(height[0]));
  
  rep(i, 0, n){
    int node, left, right;
    cin >> node >> left >> right; 
    tree[i].push_back(left);
    tree[i].push_back(right);
    used[left] = 1;
    used[right] = 1;
  }
  
  int root_id = -1;
  rep(i, 0, n){
    root_id = (used[i] == 0 ? i : root_id);
  }

  // find depth
  // int t_height = find_depth(root_id);

  // fill infos
  dfs(root_id, 0);

  // fill height
  fill_height(n);

  // print array
  rep(i, 0, n){
    cout << boost::format("node %1%: parent = %2%, sibling = %3%, degree = %4%, depth = %5%, height = %6%, %7%")% i % parent[i] % sibl[i] % deg[i] % dep[i] % height[i] % type[i] << endl;
    
  }

  // node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {type}
  
  return 0;
}



Compiler output:
a.cc:14:10: fatal error: boost/format.hpp: No such file or directory
   14 | #include <boost/format.hpp>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.Scanner;
public class prog3{
    static tree[] wd;
	public static void main(String[] args) {
	    int x,i,j,n,root = 0,hz;
	// TODO Auto-generated method stub
     Scanner sca = new Scanner(System.in);
     n=sca.nextInt();
     wd=new tree[n];
     int[]checkmap=new int[n+1];
    for(j=0;j<n;j++){
    	x=sca.nextInt();
	if(j==0)root=x;
	wd[x]=new tree(x);
	for(i=0;i<2;i++){
	    hz=sca.nextInt();
	    if(i==0){
            wd[x].setleft(hz);
	    }else{
	    wd[x].setright(hz);
	    }
	    if(hz==-1)hz=n;
	checkmap[hz]=1;
	}
    }
    for(j=0;j<n;j++){
	if(checkmap[j]!=1)root=j;
    }
    chain(root,-1);
    System.out.println("Preorder");
    preorder(root);
    System.out.println("\nInorder");
    inorder(root);
    System.out.println("\nPostorder");
    postorder(root);
    System.out.println("");
   }
    public static void preorder(int nd){
	System.out.print(" "+wd[nd].getnode());
	if(wd[nd].getleft()!=-1)preorder(wd[nd].getleft());
	if(wd[nd].getright()!=-1)preorder(wd[nd].getright());
    }
    public static void inorder(int nd){
	if(wd[nd].getleft()!=-1)inorder(wd[nd].getleft());
	System.out.print(" "+wd[nd].getnode());
	if(wd[nd].getright()!=-1)inorder(wd[nd].getright());
    }
    public static void postorder(int nd){
	if(wd[nd].getleft()!=-1)postorder(wd[nd].getleft());
	if(wd[nd].getright()!=-1)postorder(wd[nd].getright());
	System.out.print(" "+wd[nd].getnode());
    }
    public static void chain(int chi,int p){
	int i;
	wd[chi].setpar(p);
	if(wd[chi].getdeg()==0)return;
	if(wd[chi].getleft()!=-1) chain(wd[chi].getleft(),chi);
	if(wd[chi].getright()!=-1)chain(wd[chi].getright(),chi);
	}
}
class tree{
    int node,par,n,i,degree=0;
    int left,right;
    tree(int node){
	this.node=node;
    }
    public int getnode(){
	return node;
    }
    public void setleft(int c){
	left=c;
	if(left!=-1) degree++;
    }
    public int getleft(){
	return left;
    }
    public void setright(int c){
	right=c;
	if(right!=-1) degree++;
    }
    public int getright(){
	return right;
    }
    public void setpar(int p){
	par=p;
    }
    public int getpar(){
	return par;
    }
    public int getdeg(){
	return degree;
    }
    
}



Compiler output:
Main.java:2: error: class prog3 is public, should be declared in a file named prog3.java
public class prog3{
       ^
1 error
Language: Java

import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args)
            IOException {
        new Main().run();
    }
 
    private void run() throws NumberFormatException, IOException {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node();
        }
        for (int i = 0; i < n; i++) {
            int v = scanner.nextInt();
            int l = scanner.nextInt();
            int r = scanner.nextInt();
            nodes[v].l = l;
            nodes[v].r = r;
            if (l != -1)
                nodes[l].p = v;
            if (r != -1)
                nodes[r].p = v;
        }
 
        int root = 0;
        for (int i = 0; i < n; i++) {
            if (nodes[i].p == -1) {
                root = i;
            }
        }
        System.out.println("Preorder");
        preParse(root, nodes);
        System.out.println();
        System.out.println("Inorder");
        inParse(root, nodes);
        System.out.println();
        System.out.println("Postorder");
        postParse(root, nodes);
        System.out.println();
    }
 
    private void postParse(int u, Node[] nodes) {
        if (u == -1)
            return;
        postParse(nodes[u].l, nodes);
        postParse(nodes[u].r, nodes);
        System.out.print(" " + u);
    }
 
    private void inParse(int u, Node[] nodes) {
        if (u == -1)
            return;
        inParse(nodes[u].l, nodes);
        System.out.print(" " + u);
        inParse(nodes[u].r, nodes);
    }
 
    private void preParse(int u, Node[] nodes) {
        if (u == -1)
            return;
        System.out.print(" " + u);
        preParse(nodes[u].l, nodes);
        preParse(nodes[u].r, nodes);
    }
 
    class Node {
        int p = -1, l, r;
    }
}

Compiler output:
Main.java:6: error: ';' expected
    public static void main(String[] args)
                                          ^
1 error
Language: Java

import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        new Main().run();
    }
 
    private void run() throws NumberFormatException, IOException {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node();
        }
        for (int i = 0; i < n; i++) {
            int id = scanner.nextInt();
            int left = scanner.nextInt();
            int right = scanner.nextInt();
            nodes[id].left = left;
            nodes[id].right = right;
            if (left != -1)
                nodes[left].p = v;
            if (right != -1)
                nodes[right].p = v;
        }
 
        int root = 0;
        for (int i = 0; i < n; i++) {
            if (nodes[i].p == -1) {
                root = i;
            }
        }
        System.out.println("Preorder");
        preParse(root, nodes);
        System.out.println();
        System.out.println("Inorder");
        inParse(root, nodes);
        System.out.println();
        System.out.println("Postorder");
        postParse(root, nodes);
        System.out.println();
    }
 
    private void postParse(int id, Node[] nodes) {
        if (id == -1) //
            return;
        postParse(nodes[id].left, nodes);
        postParse(nodes[id].right, nodes);
        System.out.print(" " + id);
    }
 
    private void inParse(int id, Node[] nodes) {
        if (id == -1)
            return;
        inParse(nodes[id].left, nodes);
        System.out.print(" " + id);
        inParse(nodes[id].right, nodes);
    }
 
    private void preParse(int id, Node[] nodes) {
        if (id == -1)
            return;
        System.out.print(" " + id);
        preParse(nodes[id].left, nodes);
        preParse(nodes[id].right, nodes);
    }
 
    class Node {
        int p = -1, left, right;
    }
}

Compiler output:
Main.java:25: error: cannot find symbol
                nodes[left].p = v;
                                ^
  symbol:   variable v
  location: class Main
Main.java:27: error: cannot find symbol
                nodes[right].p = v;
                                 ^
  symbol:   variable v
  location: class Main
2 errors