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

#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;

typedef struct node* treepointer;
struct node{
	int data;
	treepointer leftchild,rightchild;
};
void inorder(treepointer ptr){
	if(ptr){
		inorder(ptr->leftchild);
		cout<<" "<<ptr->data;
		inorder(ptr->rightchild);
	}
}
void preorder(treepointer ptr){
	if(ptr){
		cout << " " << ptr->data;
		inorder(ptr->leftchild);
		inorder(ptr->rightchild);
	}
}
void lastorder(treepointer ptr){
	if(ptr){
		inorder(ptr->leftchild);
		inorder(ptr->rightchild);
		cout << " " << ptr->data;
		
	}
}
int main(){
	int n;
	cin >> n;
	vector<node> tree(n);
	int x, y, z,root;
	for (int i = 0; i < n; i++) {
		cin >> z>> x>> y;
		if (i == 0)
			root = z;
		tree[z].data = z;
		if (x == -1)
			tree[z].leftchild = NULL;
		else
			tree[z].leftchild = &tree[x];
		if (y == -1)
			tree[z].rightchild = NULL;
		else
			tree[z].rightchild = &tree[y];
	}
	cout << "Preorder" << endl;
	treepointer m = &tree[root];
	preorder(m);
	cout << endl << "Inorder" << endl;
	inorder(m);
	cout << endl << "Postorder" << endl;
	lastorder(m);
	cout << endl;
	return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:60:18: error: expected '}' at end of input
   60 |         return 0;
      |                  ^
a.cc:33:11: note: to match this '{'
   33 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;

typedef struct node* treepointer;
struct node{
	int data;
	treepointer leftchild,rightchild;
};
void inorder(treepointer ptr){
	if(ptr){
		inorder(ptr->leftchild);
		cout<<" "<<ptr->data;
		inorder(ptr->rightchild);
	}
}
void preorder(treepointer ptr){
	if(ptr){
		cout << " " << ptr->data;
		preorder(ptr->leftchild);
		preorder(ptr->rightchild);
	}
}
void lastorder(treepointer ptr){
	if(ptr){
		lastorder(ptr->leftchild);
		lastorder(ptr->rightchild);
		cout << " " << ptr->data;
		
	}
}
int main(){
	int n;
	cin >> n;
	vector<node> tree(n);
	int x, y, z,root;
	for (int i = 0; i < n; i++) {
		cin >> z>> x>> y;
		tree[z].data = z;
		if (x == -1)
			tree[z].leftchild = NULL;
		else {
			tree[x].parent = &tree[z];
			tree[z].leftchild = &tree[x];
		}
		if (y == -1)
			tree[z].rightchild = NULL;
		else {
			tree[z].rightchild = &tree[y];
			tree[y].parent = &tree[z];
		}
	}
	cout << "Preorder" << endl;
	treepointer m = &tree[0];
	while (m->parent) m = m->parent;
	preorder(m);
	cout << endl << "Inorder" << endl;
	inorder(m);
	cout << endl << "Postorder" << endl;
	lastorder(m);
	cout << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:33: error: '__gnu_cxx::__alloc_traits<std::allocator<node>, node>::value_type' {aka 'struct node'} has no member named 'parent'
   44 |                         tree[x].parent = &tree[z];
      |                                 ^~~~~~
a.cc:51:33: error: '__gnu_cxx::__alloc_traits<std::allocator<node>, node>::value_type' {aka 'struct node'} has no member named 'parent'
   51 |                         tree[y].parent = &tree[z];
      |                                 ^~~~~~
a.cc:56:19: error: 'struct node' has no member named 'parent'
   56 |         while (m->parent) m = m->parent;
      |                   ^~~~~~
a.cc:56:34: error: 'struct node' has no member named 'parent'
   56 |         while (m->parent) m = m->parent;
      |                                  ^~~~~~
Language: C++

#include<iostream>
#include<string>
using namespace std;
int pro(int now);
int ino(int now);
int poo(int now);
typedef struct{
  int p,l,r;
}node;
int pr[100001],in[100001],po[100001];
node tree[100001];
int main(){
  cin.tie(0);
  memset(tree,-1,sizeof(tree));
  int n,v,r,l;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>v;
    cin>>r;
    cin>>l;
    tree[v].r=r;
    tree[v].l=l;
    if(tree[v].r!=-1) tree[r].p=v;
    if(tree[v].l!=-1) tree[l].p=v;
  }
  int rt;
  for(int i=0;i<n;++i){
    if(tree[i].p==-1){
    rt=i;
    }
  }
  cout<<"Preorder"<<endl;
  pro(rt);
  cout<<endl;
  cout<<"Inoreder"<<endl;
  ino(rt);
  cout<<endl;
  cout<<"Postorder"<<endl;
  poo(rt);
  cout<<endl;
  return 0;
}
int pro(int now){
  if(now==-1)return 0;
  cout<<" "<<now;
  pro(tree[now].r);
  pro(tree[now].l);
}    
int ino(int now){
  if(now==-1) return 0;
  ino(tree[now].r);
  cout<<" "<<now;
  ino(tree[now].l);
}
int poo(int now){
  if(now==-1) return 0;
  poo(tree[now].r);
  poo(tree[now].l);
  cout<<" "<<now;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'memset' was not declared in this scope
   14 |   memset(tree,-1,sizeof(tree));
      |   ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #include<string>
a.cc: In function 'int pro(int)':
a.cc:47:6: warning: control reaches end of non-void function [-Wreturn-type]
   47 |   pro(tree[now].l);
      |   ~~~^~~~~~~~~~~~~
a.cc: In function 'int ino(int)':
a.cc:53:6: warning: control reaches end of non-void function [-Wreturn-type]
   53 |   ino(tree[now].l);
      |   ~~~^~~~~~~~~~~~~
a.cc: In function 'int poo(int)':
a.cc:59:14: warning: control reaches end of non-void function [-Wreturn-type]
   59 |   cout<<" "<<now;
      |              ^~~
Language: C++

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

typedef struct{
  int num;
  int left;
  int right;
} nodeinfo;

vector<nodeinfo> nodes;

void output_preorder(int from, int n){
  if(from == -1) return;
  for(int i = 0; i < n; i++) if(nodes[i].num == from) from = i;
  int left = nodes[from].left;
  int right = nodes[from].right;
  cout << " " << from;
  output_preorder(left);
  output_preorder(right);
}

void output_inorder(int from, int n){
  if(from == -1) return;
  for(int i = 0; i < n; i++) if(nodes[i].num == from) from = i;
  int left = nodes[from].left;
  int right = nodes[from].right;
  output_inorder(left);
  cout << " " << from;
  output_inorder(right);
}

void output_postorder(int from, int n){
  if(from == -1) return;
  for(int i = 0; i < n; i++) if(nodes[i].num == from) from = i;
  int left = nodes[from].left;
  int right = nodes[from].right;
  output_postorder(left);
  output_postorder(right);
  cout << " " << from;
}

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    nodeinfo node;
    int num, left, right;
    cin >> num >> left >> right;
    node.num = num;
    node.left = left;
    node.right = right;
    nodes.push_back(node);
  }
  cout << "Preorder" << endl;
  output_preorder(0, n);
  cout << endl;
  cout << "Inorder" << endl;
  output_inorder(0, n);
  cout << endl;
  cout << "Postorder" << endl;
  output_postorder(0, n);
  cout << endl;
  return 0;
}

Compiler output:
a.cc: In function 'void output_preorder(int, int)':
a.cc:19:18: error: too few arguments to function 'void output_preorder(int, int)'
   19 |   output_preorder(left);
      |   ~~~~~~~~~~~~~~~^~~~~~
a.cc:13:6: note: declared here
   13 | void output_preorder(int from, int n){
      |      ^~~~~~~~~~~~~~~
a.cc:20:18: error: too few arguments to function 'void output_preorder(int, int)'
   20 |   output_preorder(right);
      |   ~~~~~~~~~~~~~~~^~~~~~~
a.cc:13:6: note: declared here
   13 | void output_preorder(int from, int n){
      |      ^~~~~~~~~~~~~~~
a.cc: In function 'void output_inorder(int, int)':
a.cc:28:17: error: too few arguments to function 'void output_inorder(int, int)'
   28 |   output_inorder(left);
      |   ~~~~~~~~~~~~~~^~~~~~
a.cc:23:6: note: declared here
   23 | void output_inorder(int from, int n){
      |      ^~~~~~~~~~~~~~
a.cc:30:17: error: too few arguments to function 'void output_inorder(int, int)'
   30 |   output_inorder(right);
      |   ~~~~~~~~~~~~~~^~~~~~~
a.cc:23:6: note: declared here
   23 | void output_inorder(int from, int n){
      |      ^~~~~~~~~~~~~~
a.cc: In function 'void output_postorder(int, int)':
a.cc:38:19: error: too few arguments to function 'void output_postorder(int, int)'
   38 |   output_postorder(left);
      |   ~~~~~~~~~~~~~~~~^~~~~~
a.cc:33:6: note: declared here
   33 | void output_postorder(int from, int n){
      |      ^~~~~~~~~~~~~~~~
a.cc:39:19: error: too few arguments to function 'void output_postorder(int, int)'
   39 |   output_postorder(right);
      |   ~~~~~~~~~~~~~~~~^~~~~~~
a.cc:33:6: note: declared here
   33 | void output_postorder(int from, int n){
      |      ^~~~~~~~~~~~~~~~
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

#define MAX 100
#define NIL -1

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

Node T[MAX];
int preorder[MAX], inorder[MAX], postorder[MAX];

int count_pre = 0;
void preOrder(int n) {
    preorder[count_pre] = n;
    count_pre++;
    if(T[n].left!=NIL) {
        preOrder(T[n].left);
    }
    if(T[n].right!=NIL) {
        preOrder(T[n].right);
    }
}

int count_in = 0;
void inOrder(int n) {
    if(T[n].left!=NIL) {
        inOrder(T[n].left);
    }
    inorder[count_in] = n;
    count_in++;
    if(T[n].right!=NIL) {
        inOrder(T[n].right);
    }
}

int count_post = 0;
void postOrder(int n) {
    if(T[n].left!=NIL) {
        postOrder(T[n].left);
    }
    if(T[n].right!=NIL) {
        postOrder(T[n].right);
    }
    postorder[count_post] = n;
    count_post++;
}

int main() {
    int n;
    int id, l, r, p;
    cin >> n;
    for(int i=0; i<n; i++) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }
    for(int i=0; i<n; i++) {
        cin >> id >> l >> r;
        //idの左右の子供を入力する
        T[id].left = l;
        T[id].right = r;
        //逆に左右の子供の親としてidを登録する
        //左右の子供の兄弟としてお互いを登録する
        if(l!=NIL) {
            T[l].parent = id;
        }
        if(r!=NIL) {
            T[r].parent = id;
        }
    }
    //根の番号を特定する
    for(int i=0; i<n; i++) {
        if(T[i].parent==NIL) {
            p = i;
        }
    }

    preOrder(p);
    cout << "Preorder\n";
    cout << " "
    for(int i=0; i<n; i++) {
        cout << preorder[i];
        if(i!=n-1) {
            cout << " ";
        }
    }
    cout << endl;

    inOrder(p);
    cout << "Inorder\n";
    cout << " "
    for(int i=0; i<n; i++) {
        cout << inorder[i];
        if(i!=n-1) {
            cout << " ";
        }
    }
    cout << endl;

    postOrder(p);
    cout << "Postorder\n";
    cout << " "
    for(int i=0; i<n; i++) {
        cout << postorder[i];
        if(i!=n-1) {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:83:16: error: expected ';' before 'for'
   83 |     cout << " "
      |                ^
      |                ;
   84 |     for(int i=0; i<n; i++) {
      |     ~~~         
a.cc:84:18: error: 'i' was not declared in this scope
   84 |     for(int i=0; i<n; i++) {
      |                  ^
a.cc:94:16: error: expected ';' before 'for'
   94 |     cout << " "
      |                ^
      |                ;
   95 |     for(int i=0; i<n; i++) {
      |     ~~~         
a.cc:105:16: error: expected ';' before 'for'
  105 |     cout << " "
      |                ^
      |                ;
  106 |     for(int i=0; i<n; i++) {
      |     ~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>

#define Lens 250
#define Nil -1
using namespace std;

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

int N,sum;
Node Tr[Lens];
4
void maketree()
{
	int m, l, r;
	for (int i = 0; i < N; i++)
	{
		cin >> m >> l >> r;
		Tr[m].l = l;
		Tr[l].p = m;
		Tr[m].r = r;
		Tr[r].p = m;
	}
}

void Preorder(int i)
{
	if (i == Nil)
		return;
	cout << ' '<< i;
	Preorder(Tr[i].l);
	Preorder(Tr[i].r);
}

void Inorder(int i)
{
	if (i == Nil)
		return;
	Inorder(Tr[i].l);
	cout << ' ' << i;
	Inorder(Tr[i].r);
}

void Postorder(int i)
{
	if (i == Nil)
		return;
	Inorder(Tr[i].l);
	Inorder(Tr[i].r);
	cout << ' ' << i;
}

int main()
{
	int root;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		Tr[i].p = Tr[i].l = Tr[i].r = Nil;
	}
	maketree();
	for (int i = 0; i < N; i++)
	{
		if (Tr[i].p == Nil)
			root = i;
	}
	cout << "Preorder" << endl;
	Preorder(root);
	cout << endl;
	cout << "Inorder" << endl;
	Inorder(root);
	cout << endl;
	cout << "Postorder" << endl;
	Postorder(root);
	cout << endl;


	return 0;
}


Compiler output:
a.cc:17:1: error: expected unqualified-id before numeric constant
   17 | 4
      | ^
a.cc: In function 'int main()':
a.cc:66:9: error: 'maketree' was not declared in this scope
   66 |         maketree();
      |         ^~~~~~~~
Language: C++

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

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

void preParse(int u) {
 if ( u == NIL ) return;
 printf("%d", u);
 preParse(T[u].left);
 preParse(T[u].right);
}

void inParse(int u) {
  if ( u == NIL) return;
  inParse(T[u].left);
  printf("%d", u);
  inParse(T[u].right);
}

void postParse(int u) {
  if ( u == NIL ) return;
  postParse(T[u].left);
  postParse(T[u].right);
  printf("%d", u);
}

int main() {
  int i, v, l, r, root;

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

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

  printf("Preorder\n");
  preParse(root);
  printf("Inorder\n");
  inParse(root);
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}


Compiler output:
a.cc: In function 'void preParse(int)':
a.cc:12:16: error: 'struct Node' has no member named 'left'
   12 |  preParse(T[u].left);
      |                ^~~~
a.cc:13:16: error: 'struct Node' has no member named 'right'
   13 |  preParse(T[u].right);
      |                ^~~~~
a.cc: In function 'void inParse(int)':
a.cc:18:16: error: 'struct Node' has no member named 'left'
   18 |   inParse(T[u].left);
      |                ^~~~
a.cc:20:16: error: 'struct Node' has no member named 'right'
   20 |   inParse(T[u].right);
      |                ^~~~~
a.cc: In function 'void postParse(int)':
a.cc:25:18: error: 'struct Node' has no member named 'left'
   25 |   postParse(T[u].left);
      |                  ^~~~
a.cc:26:18: error: 'struct Node' has no member named 'right'
   26 |   postParse(T[u].right);
      |                  ^~~~~
Language: C++

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

typedef struct pp{int p,l,r;} Node;
Node T[MAX];
int n;

/*先行巡回*/

void preParse(int u){
  if(u==NIL) return;
  printf("%d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL) return;
  inParse(T[u].l);
  printf("%d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf("%d",u);
}

int main(){
  int i,v,l,r,root;
  scanf("%d", %n);
  for(i=0;i<n;i++) T[i].p=NIL;
  for(i=0;i<n;i++){
    scanf("%d %d %d", &v, %l,%r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL) T[l].p=v;
    if(l!=NIL) T[r].p=v;
  }
  
  for(i=0;i<n;i++) if(T[i].p==NIL) root =i;
  printf("Preoder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  PostParse(root);
  printf("\n");
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:15: error: expected primary-expression before '%' token
   34 |   scanf("%d", %n);
      |               ^
a.cc:37:27: error: expected primary-expression before '%' token
   37 |     scanf("%d %d %d", &v, %l,%r);
      |                           ^
a.cc:37:30: error: expected primary-expression before '%' token
   37 |     scanf("%d %d %d", &v, %l,%r);
      |                              ^
a.cc:52:3: error: 'PostParse' was not declared in this scope; did you mean 'postParse'?
   52 |   PostParse(root);
      |   ^~~~~~~~~
      |   postParse
Language: C++

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

typedef struct pp{int p,l,r;} Node;
Node T[MAX];
int n;

/*先行巡回*/

void preParse(int u){
  if(u==NIL) return;
  printf("%d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL) return;
  inParse(T[u].l);
  printf("%d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf("%d",u);
}

int main(){
  int i,v,l,r,root;
  scanf("%d", &n);
  for(i=0;i<n;i++) T[i].p=NIL;
  for(i=0;i<n;i++){
    scanf("%d %d %d", &v, &l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL) T[l].p=v;
    if(l!=NIL) T[r].p=v;
  }
  
  for(i=0;i<n;i++) if(T[i].p==NIL) root =i;
  printf("Preoder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  PostParse(root);
  printf("\n");
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:3: error: 'PostParse' was not declared in this scope; did you mean 'postParse'?
   52 |   PostParse(root);
      |   ^~~~~~~~~
      |   postParse
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;
}

/*
Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0
*/


void preorder(int u, int c) {
    if(u == NIL) return;
    if(c) printf(" ");
    printf("%d", u);
    preorder(T[u].left, c++);
    preorder(T[u].right, c++);
}

void inorder(int u, int c) {
    if(u == NIL) return;
    if(c) printf(" ");
    inorder(T[u].left, c++);
    printf("%d", u);
    inorder(T[u].right, c++);
}

void postorder(int u) {
    if(u == NIL) return;
    if(c) printf(" ");
    inorder(T[u].left, c++);
    inorder(T[u].right, c++);
    printf("%d", u);
}

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);
    
    printf("Preorder\n");
    preorder(root);
    printf("\nInorder\n");
    inorder(root);
    printf("\nPostorder\n");
    postorder(root);
    printf("\n")
    
    return 0;
}


Compiler output:
a.cc: In function 'void postorder(int)':
a.cc:64:8: error: 'c' was not declared in this scope
   64 |     if(c) printf(" ");
      |        ^
a.cc:65:24: error: 'c' was not declared in this scope
   65 |     inorder(T[u].left, c++);
      |                        ^
a.cc: In function 'int main()':
a.cc:90:13: error: too few arguments to function 'void preorder(int, int)'
   90 |     preorder(root);
      |     ~~~~~~~~^~~~~~
a.cc:46:6: note: declared here
   46 | void preorder(int u, int c) {
      |      ^~~~~~~~
a.cc:92:12: error: too few arguments to function 'void inorder(int, int)'
   92 |     inorder(root);
      |     ~~~~~~~^~~~~~
a.cc:54:6: note: declared here
   54 | void inorder(int u, int c) {
      |      ^~~~~~~
a.cc:95:17: error: expected ';' before 'return'
   95 |     printf("\n")
      |                 ^
      |                 ;
   96 | 
   97 |     return 0;
      |     ~~~~~~
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;
}

/*
Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0
*/


void preorder(int u, int c) {
    if(u == NIL) return;
    if(c) printf(" ");
    printf("%d", u);
    preorder(T[u].left, c++);
    preorder(T[u].right, c++);
}

void inorder(int u, int c) {
    if(u == NIL) return;
    if(c) printf(" ");
    inorder(T[u].left, c++);
    printf("%d", u);
    inorder(T[u].right, c++);
}

void postorder(int u) {
    if(u == NIL) return;
    if(c) printf(" ");
    inorder(T[u].left, c++);
    inorder(T[u].right, c++);
    printf("%d", u);
}

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);
    
    printf("Preorder\n");
    preorder(root, 0);
    printf("\nInorder\n");
    inorder(root, 0);
    printf("\nPostorder\n");
    postorder(root, 0);
    printf("\n")
    
    return 0;
}


Compiler output:
a.cc: In function 'void postorder(int)':
a.cc:64:8: error: 'c' was not declared in this scope
   64 |     if(c) printf(" ");
      |        ^
a.cc:65:24: error: 'c' was not declared in this scope
   65 |     inorder(T[u].left, c++);
      |                        ^
a.cc: In function 'int main()':
a.cc:94:14: error: too many arguments to function 'void postorder(int)'
   94 |     postorder(root, 0);
      |     ~~~~~~~~~^~~~~~~~~
a.cc:62:6: note: declared here
   62 | void postorder(int u) {
      |      ^~~~~~~~~
a.cc:95:17: error: expected ';' before 'return'
   95 |     printf("\n")
      |                 ^
      |                 ;
   96 | 
   97 |     return 0;
      |     ~~~~~~
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;
}

/*
Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0
*/


void preorder(int u, int c) {
    if(u == NIL) return;
    if(c) printf(" ");
    printf("%d", u);
    preorder(T[u].left, c++);
    preorder(T[u].right, c++);
}

void inorder(int u, int c) {
    if(u == NIL) return;
    if(c) printf(" ");
    inorder(T[u].left, c++);
    printf("%d", u);
    inorder(T[u].right, c++);
}

void postorder(int u, int c) {
    if(u == NIL) return;
    if(c) printf(" ");
    inorder(T[u].left, c++);
    inorder(T[u].right, c++);
    printf("%d", u);
}

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);
    
    printf("Preorder\n");
    preorder(root, 0);
    printf("\nInorder\n");
    inorder(root, 0);
    printf("\nPostorder\n");
    postorder(root, 0);
    printf("\n")
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:95:17: error: expected ';' before 'return'
   95 |     printf("\n")
      |                 ^
      |                 ;
   96 | 
   97 |     return 0;
      |     ~~~~~~
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;
}

/*
Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0
*/


void preorder(int u) {
    if(u == NIL) return;
    printf(" %d", u);
    preorder(T[u].left);
    preorder(T[u].right);
}

void inorder(int u) {
    if(u == NIL) return;
    inorder(T[u].left);
    printf(" %d", u);
    inorder(T[u].right);
}

void postorder(int u) {
    if(u == NIL) return;
    inorder(T[u].left);
    inorder(T[u].right);
    printf(" %d", u);
}

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);
    
    printf("Preorder\n");
    preorder(root, 0);
    printf("\nInorder\n");
    inorder(root, 0);
    printf("\nPostorder\n");
    postorder(root, 0);
    printf("\n");
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:87:13: error: too many arguments to function 'void preorder(int)'
   87 |     preorder(root, 0);
      |     ~~~~~~~~^~~~~~~~~
a.cc:46:6: note: declared here
   46 | void preorder(int u) {
      |      ^~~~~~~~
a.cc:89:12: error: too many arguments to function 'void inorder(int)'
   89 |     inorder(root, 0);
      |     ~~~~~~~^~~~~~~~~
a.cc:53:6: note: declared here
   53 | void inorder(int u) {
      |      ^~~~~~~
a.cc:91:14: error: too many arguments to function 'void postorder(int)'
   91 |     postorder(root, 0);
      |     ~~~~~~~~~^~~~~~~~~
a.cc:60:6: note: declared here
   60 | void postorder(int u) {
      |      ^~~~~~~~~
Language: Java

public class Main {
    public static int[] pre, in, post;
    public static int position, count;
 
    public static void reconstruct(int left, int right) {
        if (left >= right) return;
        int root = pre[position++];
        int middle = 0;
        while (in[middle] != root) middle++;
        reconstruct(left, middle);
        reconstruct(middle + 1, right);
        post[count++] = root;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        pre = new int[n];
        in = new int[n];
        post = new int[n];
        for (int i = 0; i < n; i++) pre[i] = scanner.nextInt();
        for (int i = 0; i < n; i++) in[i] = scanner.nextInt();
        position = 0;
        count = 0;
        reconstruct(0, n);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(post[i]);
            sb.append(i != n - 1 ? " " : "\n");
        }
        System.out.print(sb);
    }
}

Compiler output:
Main.java:15: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:15: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by sotetsuk on 2016/07/11.
 */
public class ALDS_1_7_D {
    static Scanner sc = new Scanner(System.in);
    static int n, pos;
    static ArrayList<Integer> preorder = new ArrayList<Integer>();
    static ArrayList<Integer> inorder = new ArrayList<Integer>();

    public static BinaryTree reconstruction(int l, int r) {
        if (l >= r) {
            return new BinaryTree();
        }

        int node = preorder.get(pos++);
        int i = inorder.indexOf(node);

        BinaryTree left = reconstruction(l, i);
        BinaryTree right = reconstruction(i + 1, r);

        return new BinaryTree(node, left, right);
    }

    public static void read() {
        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            preorder.add(sc.nextInt());
        }
        for (int i = 0; i < n; i++) {
            inorder.add(sc.nextInt());
        }
    }

    public static void main(String[] args) {
        read();
        pos = 0;
        BinaryTree bt = reconstruction(0, preorder.size());
        bt.show();
    }

    public static class BinaryTree {
        boolean isEmpty;
        int node;
        BinaryTree left;
        BinaryTree right;

        public BinaryTree(int node, BinaryTree left, BinaryTree right) {
            this.isEmpty = false;
            this.node = node;
            this.left = left;
            this.right = right;
        }

        public BinaryTree() {
            this.isEmpty = true;
        }

        public void show() {
            if (this.isEmpty) return;
            this.left.show();
            this.right.show();
            System.out.print(this.node + " ");
        }
    }
}

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

import java.util.ArrayList;
import java.util.Scanner;

public class ALDS1_7_D {
    static Scanner sc = new Scanner(System.in);
    static int n, pos;
    static ArrayList<Integer> preorder = new ArrayList<Integer>();
    static ArrayList<Integer> inorder = new ArrayList<Integer>();

    public static BinaryTree reconstruction(int l, int r) {
        if (l >= r) {
            return new BinaryTree();
        }

        int node = preorder.get(pos++);
        int i = inorder.indexOf(node);

        BinaryTree left = reconstruction(l, i);
        BinaryTree right = reconstruction(i + 1, r);

        return new BinaryTree(node, left, right);
    }

    public static void read() {
        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            preorder.add(sc.nextInt());
        }
        for (int i = 0; i < n; i++) {
            inorder.add(sc.nextInt());
        }
    }

    public static void main(String[] args) {
        read();
        pos = 0;
        BinaryTree bt = reconstruction(0, preorder.size());
        System.out.println(bt);
    }

    public static class BinaryTree {
        boolean isEmpty;
        int node;
        BinaryTree left;
        BinaryTree right;

        public BinaryTree(int node, BinaryTree left, BinaryTree right) {
            this.isEmpty = false;
            this.node = node;
            this.left = left;
            this.right = right;
        }

        public BinaryTree() {
            this.isEmpty = true;
        }

        public String toString() {
            if (this.isEmpty) return "";
            String l = this.left.toString() + " ";
            String r = this.right.toString() + " ";

            if (l.trim().equals("")) {
                l = "";
            }
            if (r.trim().equals("")) {
                r = "";
            }

            return l + r + this.node;
        }
    }
}

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

import java.util.*
public class Main{
        static Scanner sc = new Scanner(System.in);
        static int n, pos;
        static ArrayList<Integer> preorder = new ArrayList<Integer>();
        static ArrayList<Integer> inorder = new ArrayList<Integer>();
        public static BinaryTree reconstruction(int l, int r) {
            if (l >= r){
                return new BinaryTree();
            }
            int node = preorder.get(pos++);
            int i = inorder.indexOf(node);
            BinaryTree left = reconstruction(l, i);
            BinaryTree right = reconstruction(i + 1, r);
            return new BinaryTree(node, left, right); }
            public static void read() { 
            n = sc.nextInt();
            for (int i = 0; i < n; i++){ 
                preorder.add(sc.nextInt());
            } 
            for (int i = 0; i < n; i++) { 
                inorder.add(sc.nextInt()); 
            } 
        } 
        public static void main(String[] args){ 
            read(); 
            pos = 0; 
            BinaryTree bt = reconstruction(0, preorder.size()); 
            System.out.println(bt); 
        } 
        public static class BinaryTree { 
            boolean isEmpty; 
            int node; 
            BinaryTree left; 
            BinaryTree right; 
            public BinaryTree(int node, BinaryTree left, BinaryTree right) { 
                this.isEmpty = false; 
                this.node = node; 
                this.left = left; 
                this.right = right; 
            } 
            public BinaryTree() { 
                this.isEmpty = true; 
            } 
            public String toString() { 
                if (this.isEmpty) 
                    return ""; 
                String l = this.left.toString() + " "; 
                String r = this.right.toString() + " "; 
                if (l.trim().equals("")) { 
                    l = ""; 
                } 
                if (r.trim().equals("")) { 
                    r = ""; 
                } 
                return l + r + this.node; 
            } 
        } 
    }


Compiler output:
Main.java:1: error: ';' expected
import java.util.*
                  ^
1 error
Language: C

#include<stdio.h>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int n,pos;
vector<int> pre,in,post;

void rec(int l, int r){
  if(l>=r) return;
  int root = pre[pos++];
  int m = distance(in.begin(), find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}

void solve(){
  int i;
  pos = 0;
  rec(0,pre.size());
  for(i=0;i<n;i++){
    if(i) cout << " ";
    cout << post[i];;
  }
  cout << endl;
}

int main(){
  int k;
  cin >> n;

  for(int i =0;i<n;i++){
    cin >> k;
    pre.push_back(k);
  }

  for(int i=0;i<n;i++){
    cin >> k;
    in.push_push(k);
  }
  solve();
  return 0;
}


Compiler output:
main.c:2:9: fatal error: string: No such file or directory
    2 | #include<string>
      |         ^~~~~~~~
compilation terminated.
Language: C

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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
  if( l >= r ) return;
  int root = pre[pos++];
  int m = distance(in.begin(), find(in.begin(), in.end(), root));
  rec(l, m);
  rec(m+1, r);
  post.push_back(root);
}

void solve(){
  int i;
  pos = 0;
  rec(0, pre.size());
  for( i = 0 ; i < n ; i++ ){
    if(i) printf(" ");
    printf("%d", post[i]);
  }
  printf("\n");
}

int main(){
  int i, k;

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%d", &k);
    pre.push_back(k);
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d", &k);
    in.push_back(k);
  }

  solve();

  return 0;
}



Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#define N 41

typedef struct node{
  int l, r;
}node;

node c[N];
int a[N], b[N];
int cnt=0;

void postorder(int root,int n){

        if(c[root].l! = -1) postorder(c[root].l, n);
        if(c[root].r != -1) postorder(c[root].r, n);
        if(cnt < n - 1) printf("%d ", root);
        else printf("%d\n", root);

        cnt++;

        return;

}

int reconst(int start,int last,int n){
  int i, j;

  if(start == last) return b[start];
  else if(start > last) return -1;

  else {
    for(i = 1 ; i <= n ; i++){
      for(j = start ; j <= last ; j++){
        if(a[i] == b[j]){
          c[a[i]].l = reconst(start, j - 1, n);
          c[a[i]].r = reconst(j + 1, last, n);
          return a[i];
        }
      }
    }
  }
}


int main(){
  int n,i, root;

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++) scanf("%d",&a[i]);
  for(i = 1 ; i <= n ; i++) scanf("%d",&b[i]);
  for(i = 1 ; i <= n ; i++){
    c[i].l = -1;
    c[i].r = -1;
  }

  root = reconst(1,n,n);

  postorder(root,n);

  return 0;

}


Compiler output:
main.c: In function 'postorder':
main.c:14:21: error: expected ')' before '!' token
   14 |         if(c[root].l! = -1) postorder(c[root].l, n);
      |           ~         ^
      |                     )
Language: C

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

int n,pos;
vector<int> pre, in, post;

void rec(int l, int r){
  if(l >= r) return;
     int root = pre[pos++];
     int m = distance(in.begin(), find(in.begin(), in.end(), root));
     rec(l,m);
     rec(m + 1,r);
     post.push_back(root);
}

void solve(){
  pos = 0;
  rec(0, pre.size());
  for(int i = ; i < n ; i++){
    if(i) cout << " ";
    cout << post[i];
  }
  cout << endl;
}

int main(){
  int k;
  cin >> n;

  for(int i = 0 ; i < n ; i++){
    cin >> k;
    pre.push_back(k);
  }

  for(int i = 0 ; i < n ; i++){
    cin >> k;
    in.push_back(k);
  }

  solve();

  return 0;
}
     



Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

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

int n,pos;
vector<int> pre,in,post;

void rec(int l,int r) {
  if (l>=r) 
    return ;
  int root=pre[pos++];
  int m=distance(in.begin(),find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
  
}
void solve() {
  pos=0;
  rec(0,pre.size());
  for (int i=0; i<n; i++) {
    if (i) 
      cout<<" "<<flush;
    cout<<post[i]<<flush;
  }
  cout<<endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin>>n;
  int s;
  for (int i=0; i<n; i++) {
    cin>>s;
    pre.push_back(s);
  }
  for (int i=0; i<n; i++) {
    cin>>s;
    in.push_back(s);
  }
  
  
  solve();
  return 0;
}



Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#define N 100


 int n,pos,coun=0;
 int pre[N],in[N],post[N];
 
 int find(int in[n],int root);{
     int i;
     for(i=0;i<n;i++){
            if(in[i]==root)return i;
            }
     return in[n-1];
     }

 void rec(int l,int r){
      int root,m;
      if(l>=r)return;
      root=pre[pos++];
      m=find(in,root);
      rec(l,m);
      rec(m+l,r);
      post[count++]=root;
      }

 void solve(){
      int i;
      post=0;
      rec(0,n);
      for(i=0;i<n;i++){
              if(i)printf(" ");
              printf("%d",post[i]);
              }
      printf("\n");
      }

 int main(){
      int i,k;
      scanf("%d",&n);

      for(i=0;i<n;i++){
              scanf("%d",&k);
              pre[i]=k;
              }
      for(i=0;i<n;i++){
              scanf("%d",&k);
              in[i]=k;
              }
      solve();
      return 0;
      }



Compiler output:
main.c:8:31: error: expected identifier or '(' before '{' token
    8 |  int find(int in[n],int root);{
      |                               ^
main.c: In function 'rec':
main.c:23:12: error: 'count' undeclared (first use in this function); did you mean 'coun'?
   23 |       post[count++]=root;
      |            ^~~~~
      |            coun
main.c:23:12: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'solve':
main.c:28:11: error: assignment to expression with array type
   28 |       post=0;
      |           ^
Language: C

#include <stdio.h>

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

int linear_search(int* xs, int size, int x)
{
	int i;
	for (i = 0; i < size; i++) {
		if (xs[i] == x) {
			return i;
		}
	}
	return -1;
}

Node tree[50];

int prewalked[50];
int inwalked[50];

int n;

int reconstruction_tree(int from, int to, int root_pos, int parent)
{
	int i;
	int v;

	for (i = from; i < to; i++) {
		if ((v = inwalked[i]) == prewalked[root_pos]) {
			tree[v].parent = parent;

			tree[v].left = reconstruction_tree(from, i, root_pos + 1, v);
			tree[v].right = reconstruction_tree(i+1, to, root_pos +  (i - from) + 1, v);

			return v;
		}
	}

	return -1;
}

void postorder_walk(int p, int root)
{
	if (p > n || p < 0) {
		return;
	}
	postorder_walk(tree[p].left, 0);
	postorder_walk(tree[p].right, 0);
	if (root = 1) {
		printf("%d", p);
	}
	else {
		printf(" %d", p);
	}
}

int main()
{
	int i;
	int root;

	for (i = 0; i < 50; i++) {
		tree[i].parent = -1;
	}

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &(prewalked[i]));
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &(inwalked[i]));
	}

	root = reconstruction_tree(0, n, 0, -1);

	postorder_walk(root);
	printf("\n");

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:80:9: error: too few arguments to function 'postorder_walk'
   80 |         postorder_walk(root);
      |         ^~~~~~~~~~~~~~
main.c:45:6: note: declared here
   45 | void postorder_walk(int p, int root)
      |      ^~~~~~~~~~~~~~
Language: C

#include <stdio.h>

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

int linear_search(int* xs, int size, int x)
{
	int i;
	for (i = 0; i < size; i++) {
		if (xs[i] == x) {
			return i;
		}
	}
	return -1;
}

Node tree[50];

int prewalked[50];
int inwalked[50];

int n;

int reconstruction_tree(int from, int to, int root_pos, int parent)
{
	int i;
	int v;

	for (i = from; i < to; i++) {
		if ((v = inwalked[i]) == prewalked[root_pos]) {
			tree[v].parent = parent;

			tree[v].left = reconstruction_tree(from, i, root_pos + 1, v);
			tree[v].right = reconstruction_tree(i+1, to, root_pos +  (i - from) + 1, v);

			return v;
		}
	}

	return -1;
}

int result[50];
int resultcnt;

void postorder_walk(int p)
{
	if (p > n || p < 0) {
		return;
	}
	postorder_walk(tree[p].left, 0);
	postorder_walk(tree[p].right, 0);

	result[resultcnt++] = p;
}

int main()
{
	int i;
	int root;

	for (i = 0; i < 50; i++) {
		tree[i].parent = -1;
	}

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &(prewalked[i]));
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &(inwalked[i]));
	}

	root = reconstruction_tree(0, n, 0, -1);

	for (i = 0; i < resultcnt; i++) {
		if (i == 0) {
			printf("%d", result[i]);
		}
		else {
			printf(" %d", result[i]);
		}
	}


	return 0;
}

Compiler output:
main.c: In function 'postorder_walk':
main.c:53:9: error: too many arguments to function 'postorder_walk'
   53 |         postorder_walk(tree[p].left, 0);
      |         ^~~~~~~~~~~~~~
main.c:48:6: note: declared here
   48 | void postorder_walk(int p)
      |      ^~~~~~~~~~~~~~
main.c:54:9: error: too many arguments to function 'postorder_walk'
   54 |         postorder_walk(tree[p].right, 0);
      |         ^~~~~~~~~~~~~~
main.c:48:6: note: declared here
   48 | void postorder_walk(int p)
      |      ^~~~~~~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
  
int preOrder[40],inOrder[40];
 
void solve(int x,int y){
  int i;
  static int p=0;
  if(x>y) return;
  if(x==y){
    if(inOrder[x]==preOrder[0]) printf("%d",inOrder[x]);  
    else printf("%d ",inOrder[x]);
    p++;
    return;
  }
  int x=preOrder[p];
  p++;
  for(i=x;i<=y;i++){
    if(inOrder[i]==x) break;
  }
  solve(x,i-1);
  solve(i+1,y);
  if(x==preOrder[0]) printf("%d",x);
  else printf("%d ",x);
}
  
int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&preOrder[i]);
  for(i=0;i<n;i++) scanf("%d",&inOrder[i]);
  solve(0,n-1);
  printf("\n");
  return 0;
}

Compiler output:
main.c: In function 'solve':
main.c:16:7: error: 'x' redeclared as different kind of symbol
   16 |   int x=preOrder[p];
      |       ^
main.c:6:16: note: previous definition of 'x' with type 'int'
    6 | void solve(int x,int y){
      |            ~~~~^
Language: C



int preorder[40],inorder[40];
void recover(int fp,int lp,int fi,int li){
    int root=fi;
    for(;root<li;root++)if(preorder[fp]==inorder[root])break;
    if(fi<root)recover(fp+1,fp+(root-fi)+1,fi,root);
    if(root<li-1)recover(fp+(root-fi)+1,lp,root+1,li);
    printf(inorder[root]==preorder[0]?"%d\n":"%d ",inorder[root]);
}
main(){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",preorder+i);
    for(i=0;i<n;i++)scanf("%d",inorder+i);
    recover(0,n,0,n);
    return 0;
}
 

 
Compile Error Logs: 

You are not authorized to see the message. 
 
 
Status 
Judge: 20/20  C  CPU: 00.00 sec  Memory: 1828 KB  Length: 495 B  2017-12-01 14:59  2017-12-01 14:59  
Results for testcases 
Case # Verdict CPU Time Memory In Out Case Name 
 Case #1: : Accepted  00.00 sec 1664 KB    
  

Compiler output:
main.c: In function 'recover':
main.c:9:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    9 |     printf(inorder[root]==preorder[0]?"%d\n":"%d ",inorder[root]);
      |     ^~~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf'
  +++ |+#include <stdio.h>
    1 | 
main.c:9:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
    9 |     printf(inorder[root]==preorder[0]?"%d\n":"%d ",inorder[root]);
      |     ^~~~~~
main.c:9:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: At top level:
main.c:11:1: error: return type defaults to 'int' [-Wimplicit-int]
   11 | main(){
      | ^~~~
main.c: In function 'main':
main.c:13:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   13 |     scanf("%d",&n);
      |     ^~~~~
main.c:13:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:13:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
main.c:13:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c: At top level:
main.c:22:1: error: unknown type name 'Compile'
   22 | Compile Error Logs:
      | ^~~~~~~
main.c:22:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Logs'
   22 | Compile Error Logs:
      |               ^~~~
main.c:30:6: error: stray '#' in program
   30 | Case # Verdict CPU Time Memory In Out Case Name
      |      ^
main.c:31:7: error: stray '#' in program
   31 |  Case #1: : Accepted  00.00 sec 1664 KB
      |       ^