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

#include <stdio.h>
#include <stdlib.h>
struct BinaryTree
{
	int data;
	BinaryTree *lchild,*rchild;
};
int post[40],i;
void pre_in_order(int *pre,int l1,int r1,int *in,int l2,int r2,BinaryTree **root)
{
	int m;
	i=0;
	*root=(BinaryTree *)malloc(sizeof(BinaryTree));
	(*root)->data=pre[l1];
	m=l2;
	while(pre[l1]!=in[m])
	m++;
	if(m==l2)
	(*root)->lchild=NULL;
	else
	pre_in_order(pre,l1+1,m-l2+l1,in,l2,m-1,&(*root)->lchild);
	if(m==r2)
	(*root)->rchild=NULL;
	else
	pre_in_order(pre,m-l2+l1+1,r1,in,m+1,r2,&(*root)->rchild);
}
void postorder(BinaryTree *root)
{
if(root)
{
postorder(root->lchild);
postorder(root->rchild);
post[i]=root->data;
i++;
}
}
int main(int argc, char *argv[])
{
	int pre[40];
	int in[40];
	int n,i;
	BinaryTree *root;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&pre[i]);
	for(i=0;i<n;i++)
	scanf("%d",&in[i]);
	pre_in_order(pre,0,n-1,in,0,n-1,&root);
	postorder(root);
	for(i=0;i<n;i++)
	{
		printf("%d",post[i]);
		if(i+1==n)
		printf("\n");
		else
		printf(" ");
	}
	return 0;
}

Compiler output:
main.c:6:9: error: unknown type name 'BinaryTree'
    6 |         BinaryTree *lchild,*rchild;
      |         ^~~~~~~~~~
main.c:9:64: error: unknown type name 'BinaryTree'
    9 | void pre_in_order(int *pre,int l1,int r1,int *in,int l2,int r2,BinaryTree **root)
      |                                                                ^~~~~~~~~~
main.c:27:16: error: unknown type name 'BinaryTree'
   27 | void postorder(BinaryTree *root)
      |                ^~~~~~~~~~
main.c: In function 'main':
main.c:42:9: error: unknown type name 'BinaryTree'; use 'struct' keyword to refer to the type
   42 |         BinaryTree *root;
      |         ^~~~~~~~~~
      |         struct 
main.c:48:9: error: implicit declaration of function 'pre_in_order' [-Wimplicit-function-declaration]
   48 |         pre_in_order(pre,0,n-1,in,0,n-1,&root);
      |         ^~~~~~~~~~~~
main.c:49:9: error: implicit declaration of function 'postorder' [-Wimplicit-function-declaration]
   49 |         postorder(root);
      |         ^~~~~~~~~
Language: C

#include <cstdio>
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);
}

Compiler output:
main.c:1:10: fatal error: cstdio: No such file or directory
    1 | #include <cstdio>
      |          ^~~~~~~~
compilation terminated.
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:
a.cc: In function 'void solve()':
a.cc:24:11: error: 'cout' was not declared in this scope
   24 |     if(i) cout << " ";
      |           ^~~~
a.cc:5:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include<vector>
  +++ |+#include <iostream>
    5 | using namespace std;
a.cc:25:5: error: 'cout' was not declared in this scope
   25 |     cout << post[i];;
      |     ^~~~
a.cc:25:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:27:3: error: 'cout' was not declared in this scope
   27 |   cout << endl;
      |   ^~~~
a.cc:27:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:27:11: error: 'endl' was not declared in this scope
   27 |   cout << endl;
      |           ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    4 | #include<vector>
  +++ |+#include <ostream>
    5 | using namespace std;
a.cc: In function 'int main()':
a.cc:32:3: error: 'cin' was not declared in this scope
   32 |   cin >> n;
      |   ^~~
a.cc:32:3: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:41:8: error: 'class std::vector<int>' has no member named 'push_push'
   41 |     in.push_push(k);
      |        ^~~~~~~~~
Language: C++

#include<siostream
#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:
a.cc:1:19: error: missing terminating > character
    1 | #include<siostream
      |                   ^
a.cc:1:9: fatal error: siostream: No such file or directory
    1 | #include<siostream
      |         ^
compilation terminated.
Language: C++

#include<siostream>
#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:
a.cc:1:9: fatal error: siostream: No such file or directory
    1 | #include<siostream>
      |         ^~~~~~~~~~~
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) 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:
a.cc: In function 'int main()':
a.cc:41:8: error: 'class std::vector<int>' has no member named 'push_push'
   41 |     in.push_push(k);
      |        ^~~~~~~~~
Language: C++

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

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

vec 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:
a.cc:10:1: error: 'vec' does not name a type
   10 | vec rec(int l, int r){
      | ^~~
a.cc: In function 'void solve()':
a.cc:21:3: error: 'rec' was not declared in this scope
   21 |   rec(0, pre.size());
      |   ^~~
a.cc:22:15: error: expected primary-expression before ';' token
   22 |   for(int i = ; i < n ; i++){
      |               ^
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:
a.cc: In function 'void solve()':
a.cc:22:15: error: expected primary-expression before ';' token
   22 |   for(int i = ; i < n ; i++){
      |               ^
Language: C++

#include<iostream>
#include<string> 
#include<algorithm> 
#include<vector> 
using namespace std; 
int n, pos; 
vector<int> pre, in, post; 
void rec(int 1, int r) { 
if ( 1 >= 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 << " " ; 
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:
a.cc:8:14: error: expected ',' or '...' before numeric constant
    8 | void rec(int 1, int r) {
      |              ^
a.cc: In function 'void rec(int)':
a.cc:9:11: error: 'r' was not declared in this scope
    9 | if ( 1 >= r ) return;
      |           ^
a.cc:12:5: error: 'l' was not declared in this scope
   12 | rec(l, m) ;
      |     ^
a.cc:13:13: error: 'r' was not declared in this scope
   13 | rec(m + 1 , r);
      |             ^
a.cc: In function 'void solve()':
a.cc:18:4: error: too many arguments to function 'void rec(int)'
   18 | rec(0, pre . size()) ;
      | ~~~^~~~~~~~~~~~~~~~~
a.cc:8:6: note: declared here
    8 | void rec(int 1, int r) {
      |      ^~~
Language: C++

#include<iostream>
#include<string> 
#include<algorithm> 
#include<vector> 
using namespace std; 
int n, pos; 
vector<int> pre, in, post; 
void rec(int 1, int r) { 
if (1 >= 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 << " " ; 
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:
a.cc:8:14: error: expected ',' or '...' before numeric constant
    8 | void rec(int 1, int r) {
      |              ^
a.cc: In function 'void rec(int)':
a.cc:9:10: error: 'r' was not declared in this scope
    9 | if (1 >= r) return;
      |          ^
a.cc:12:5: error: 'l' was not declared in this scope
   12 | rec(l, m) ;
      |     ^
a.cc:13:13: error: 'r' was not declared in this scope
   13 | rec(m + 1 , r);
      |             ^
a.cc: In function 'void solve()':
a.cc:18:4: error: too many arguments to function 'void rec(int)'
   18 | rec(0, pre . size()) ;
      | ~~~^~~~~~~~~~~~~~~~~
a.cc:8:6: note: declared here
    8 | void rec(int 1, int r) {
      |      ^~~
Language: C++

#include<iostream>
#include<vector>

int n,a=0;

std::vector<int> pre,in,post;

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

int main(){
	int k;
	std::cin>>n;
	for(int i=0;i<n;++i){
		std::cin>>k;
		pre.push_back(k);
	}
	for(int i=0;i<n;++i){
		std::cin>>k;
		in.push_back(k);
	}
	rec(0,n);
	for(int i=0;i<n;++i)
		std::cout<<post[i];
	return 0;
}

Compiler output:
a.cc: In function 'void rec(int, int)':
a.cc:12:39: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   12 |         int m=distance(in.begin(),find(in.begin(),in.end(),root));
      |                                   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:12:39: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   12 |         int m=distance(in.begin(),find(in.begin(),in.end(),root));
      |                                   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
     m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

enum EnDir
{
  D_Left,
  D_Right,
};

void fnInput(vector<int> &rvnPodr, vector<int> &rvnIodrSeq)
{
  int nMaxSiz;

  cin >> nMaxSiz;
  rvnPodr.resize(nMaxSiz);
  rvnIodrSeq.resize(nMaxSiz + 1);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnPodr[i];

  for (int i = 1; i < nMaxSiz + 1; i++)
  {
    int nNode;
    cin >> nNode;
    rvnIodrSeq[nNode] = i;
  }
}

void fnStructTree(const vector<int> &cnrvnPodr, const vector<int> &cnrvnIodrSeq, vector<StNod> &rvoNod)
{
  for (int i = 1; i < cnrvnPodr.size(); i++)
  {
    int nParnt = END;
    int nx = cnrvnPodr[0];
    EnDir enDir;
    while (nx != END)
    {
      nParnt = nx;
      if (cnrvnIodrSeq[ cnrvnPodr[i] ] < cnrvnIodrSeq[nx])
      {
        nx = rvoNod[nx].m_nLeft;
        enDir = D_Left;
      }
      else
      {
        nx = rvoNod[nx].m_nRigt;
        enDir = D_Right;
      }
    }

    rvoNod[ cnrvnPodr[i] ].m_nParnt = nParnt;
    if (enDir == D_Left)
      rvoNod[nParnt].m_nLeft = cnrvnPodr[i];
    else
      rvoNod[nParnt].m_nRigt = cnrvnPodr[i];
  }
}

void fnPostOrder(const vector<StNod> &cnrvoNod, int nx)
{
  static int stnPrt = 0;
  if (nx == END)  return;

  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft, nOCnt);
  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nRigt, nOCnt);
  if (stnPrt++) cout << " ";
  cout << nx;
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  int nx = 1;
  while (cnrvoNod[nx].m_nParnt != END)
    nx = cnrvoNod[nx].m_nParnt;

  fnPostOrder(cnrvoNod, nx);
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPodr, vnIodrSeq;
  vector<StNod> voNod;

  fnInput(vnPodr, vnIodrSeq);

  StNod oNod;
  voNod.resize(vnIodrSeq.size(), oNod);
  fnStructTree(vnPodr, vnIodrSeq, voNod);
  
  int nOCnt = 0;
  fnResult(voNod);
  return 0;
}

Compiler output:
a.cc: In function 'void fnPostOrder(const std::vector<StNod>&, int)':
a.cc:77:47: error: 'nOCnt' was not declared in this scope
   77 |   fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft, nOCnt);
      |                                               ^~~~~
Language: C++

#include <iostream>
#include <cstring>
using namespace std;
int n;
int P[42];
int Pi[42];
int K[42];
int Ki[42];


struct N {
	int id,l, r;
	void setid(int pi);
	void pre();
	void in();
	void post();
};

int root;
N T[25];

/*
5
1 2 3 4 5
3 2 4 1 5

         1
   2        5
 3   4
 
 4 
 1 2 3 4 
 4 3 2 1
        1
     2
   3
 4
*/

// I think this is a O(n) algorizm

void N::setid(int _id)
{
//	cout <<id<<endl;
	id = _id; // 4
	int pid=Pi[id]; // 4
	int kid=Ki[id]; // 1
	int idl=P[pid+1]; // 2
	int kidl=Ki[idl]; // 3
	if (kid>kidl) {
		l=idl;
		T[l].setid(l);
	}
	int idr=K[kid+1];
	int pidr=Pi[idr];
	if(pidr>pid){
		r=idr;
		T[r].setid(r);
	}
//	cout<<id<<' '<<l<<' '<<r<<endl;
}


int main()
{
	memset(T, 0, sizeof(T));
	cin>>n;
	for(int i=1;i<=n;i++) cin>>P[i];
	P[0]=P[n+1]=0;
	for(int i=1;i<=n;i++) Pi[P[i]]=i;
	Pi[0]=Pi[n+1]=-1;
	for(int i=1;i<=n;i++) cin>>K[i];
	K[0]=K[n+1]=0;
	for(int i=1;i<=n;i++) Ki[K[i]]=i;
	Ki[0]=Ki[n+1]=INT_MAX;
	root = P[1];
	
	T[root].setid(root);
	/*
	cout<<"Preorder"<<endl;
	T[root].pre();
	cout<<endl;
	
	cout<<"Inorder"<<endl;
	T[root].in();
	cout<<endl;
	*/
//	cout<<"Postorder"<<endl;
	T[root].post();
	cout<<endl;
}

	
void N::pre()
{
	cout<<' '<<id;
	if(l)T[l].pre();
	if(r)T[r].pre();
}

void N::in()
{
	if(l)T[l].in();
	cout<<' '<<id;
	if(r)T[r].in();
}
bool first = false;
void N::post()
{
	if(l)T[l].post();
	if(r)T[r].post();
	if (first) cout<<' '; else first = true;
	cout<<id;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:23: error: 'INT_MAX' was not declared in this scope
   75 |         Ki[0]=Ki[n+1]=INT_MAX;
      |                       ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <cstring>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

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

const int MAX_N = 40;

int N;
int POS = 0;

vector<int> PRE;
vector<int> IN;
vector<int> POST;

void restore(int l, int r) {
  if (l >= r) return;
  int root = PRE[POS++];
  int m = distance(IN.begin(), find(IN.begin(), IN.end(), root));
  restore(l, m);
  restore(m+1, r);
  POST.push_back(root);
}

void solve() {
  restore(0, N);
}

int main() {
  int t; cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> t;
    PRE.push_back(t);
  }

  for (int i = 0; i < N; i++) {
    cin >> t;
    IN.push_back(t);
  }

  solve();
  for (int i = 0; i < N; i++) {
    if (i) cout << ' ';
    cout << POST[i];
  }
  cout << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'void restore(int, int)':
a.cc:17:36: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   17 |   int m = distance(IN.begin(), find(IN.begin(), IN.end(), root));
      |                                ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:17:36: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   17 |   int m = distance(IN.begin(), find(IN.begin(), IN.end(), root));
      |                                ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
int pre[100000], in[100000], post[100000], n, pos, cnt;
int rec(int l, int r) { if (l >= r) { return; }int root = pre[pos++]; int m = 0; for (int i = 0; i < n; i++) { if (in[i] == root) { m = i; } }rec(l, m); rec(m + 1, r); post[cnt] = root; cnt++; }
int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> pre[i]; }for (int i = 0; i < n; i++) { cin >> in[i]; }rec(0, n); for (int i = 0; i < n; i++) { if (i) { cout << ' '; }cout << post[i]; }cout << endl; return 0; }

Compiler output:
a.cc: In function 'int rec(int, int)':
a.cc:4:39: error: return-statement with no value, in function returning 'int' [-fpermissive]
    4 | int rec(int l, int r) { if (l >= r) { return; }int root = pre[pos++]; int m = 0; for (int i = 0; i < n; i++) { if (in[i] == root) { m = i; } }rec(l, m); rec(m + 1, r); post[cnt] = root; cnt++; }
      |                                       ^~~~~~
a.cc:4:190: warning: control reaches end of non-void function [-Wreturn-type]
    4 | int rec(int l, int r) { if (l >= r) { return; }int root = pre[pos++]; int m = 0; for (int i = 0; i < n; i++) { if (in[i] == root) { m = i; } }rec(l, m); rec(m + 1, r); post[cnt] = root; cnt++; }
      |                                                                                                                                                                                           ~~~^~
Language: C++

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

struct TNode
{
	int Id;
	TNode* Parent;
	TNode* LChild;
	TNode* RChild;
};

vector<int> Input(int n)
{
	vector<int> Tree(n);
	for(int i = 0; i < n; i++){
		cin >> Tree[i];
	}
	return Tree;
}

void PostorderOutput(const TNode* Node)
{
	if(Node == NULL) return;
	PostorderOutput(Node->LChild);
	PostorderOutput(Node->RChild);
	cout << ' ' << Node->Id;
}

TNode* MakeTree(const vector<int>& PreorderRow, const vector<int>& InorderRow)
{
	
}

int main()
{
	int n;
	cin >> n;
	vector<int> PreorderRow = Input(n);
	vector<int> InorderRow  = Input(n);
	TNode* RootNode = MakeTree(PreorderRow, InorderRow);
	PostorderOutput(RootNode);
	cout << endl;
	DeleteNode(RootNode);
    return 0;
}

Compiler output:
a.cc: In function 'TNode* MakeTree(const std::vector<int>&, const std::vector<int>&)':
a.cc:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
   33 | }
      | ^
a.cc: In function 'int main()':
a.cc:44:9: error: 'DeleteNode' was not declared in this scope
   44 |         DeleteNode(RootNode);
      |         ^~~~~~~~~~
Language: C++

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

vector<int> pre, in, post;
int position = 0;

void reconstruction(int left, int right) {
  if (left >= right) return;
  int root = pre[position];
  position++;
  int in_pos = distance(in.begin(), find(in.begin(), in.end(), root));
  reconstruction(left, in_pos);
  reconstruction(in_pos + 1, right);
  post.push_back(root);
}

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

  int n;
  cin >> n;

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

  reconstruction(0, n);

  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << post[i];
  }
  cout << endl;

  return 0;
}

Compiler output:
a.cc: In function 'void reconstruction(int, int)':
a.cc:13:41: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   13 |   int in_pos = distance(in.begin(), find(in.begin(), in.end(), root));
      |                                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:13:41: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   13 |   int in_pos = distance(in.begin(), find(in.begin(), in.end(), root));
      |                                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n,pos;
vector<int> pre,in,post;

void rec(int l,int r){
//	printf("	l=%d r=%d\n",l,r);
	if(l>=r)return;
	int root = pre[pos++];//visit in Preorder
	int m = distance(in.begin(),find(in.begin(),in.end(),root));//return distance between two iterators
//	printf("l = %d root = %d m = %d r = %d\n",l,root,m,r);

	rec(l,m);	
	rec(m+1,r);
	post.push_back(root);//left-right-root,if inOrder,put this above
//	printf("push %d\n\n",root);
}
int main()
{
	int n,k;
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&k);
		pre.push_back(k);
	}
	for(int i=0;i<n;++i){
		scanf("%d",&k);
		in.push_back(k);
	}
 	pos = 0;
 	rec(0,pre.size());
 	for(int i=0;i<n;++i){
	 	if(i)printf(" ");
	 	printf("%d",post[i]);
 	}
    printf("\n");
 
	return 0;
}

Compiler output:
a.cc: In function 'void rec(int, int)':
a.cc:12:41: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   12 |         int m = distance(in.begin(),find(in.begin(),in.end(),root));//return distance between two iterators
      |                                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:12:41: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   12 |         int m = distance(in.begin(),find(in.begin(),in.end(),root));//return distance between two iterators
      |                                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>    // std::copy
#include <iterator>     // std::back_inserter
using namespace std;

struct TNode
{
	int Id;
	TNode* Parent;
	TNode* LChild;
	TNode* RChild;
};

vector<int> Input(int n)
{
	vector<int> Tree(n);
	for(int i = 0; i < n; i++){
		cin >> Tree[i];
	}
	return Tree;
}

void PostorderOutput(const TNode* Node)
{
	if(Node == NULL) return;
	PostorderOutput(Node->LChild);
	PostorderOutput(Node->RChild);
	cout << Node->Id;
	if(Node->Parent){
		cout << ' '
	}else{
		cout << endl;
	}
}

int FindIndex(vector<int> X, int a)
{
	int Count = 0;
	while(Count < X.size()){
		if(X[Count] == a){
			return Count;
		}
		Count++;
	}
	return Count;
}

vector<int> Subvec(vector<int> X, int m, int n)
{
	vector<int> Y;
	for(int i = m; i <= n; i++){
		Y.push_back(X[i]);
	}
	return Y;
}

TNode* MakeTree(const vector<int>& PreorderRow, const vector<int>& InorderRow)
{
	//PreorderRow????????????????´?Root?????¨???*
	int Root = PreorderRow[0];
	
	//InorderRow??????????????????Root??????InorderRowLeft?????¨???
	int RootIndex = FindIndex(InorderRow, Root);
	vector<int> InorderRowLeft = Subvec(InorderRow, 0, RootIndex-1);
	
	//PreorderRow???2??????????????????InorderRowLeft??¨???????????°???PreorderRowLeft?????¨???
	vector<int> PreorderRowLeft = Subvec(PreorderRow, 1, RootIndex);
	
	//PreorderRow??¨InorderRow???????????????PreorderRowRight,InorderRowRight?????¨???
	vector<int> PreorderRowRight = Subvec(PreorderRow, RootIndex+1, PreorderRow.size()-1);
	vector<int> InorderRowRight  = Subvec(InorderRow, RootIndex+1, InorderRow.size()-1);
	
	//ID???Root??¨????????????????????????**
	TNode* RootNode;
	RootNode = new TNode;
	*RootNode = {Root, NULL, NULL, NULL};
	
	//PreorderRowLeft,InorderRowLeft??????*~**??¨????§???????????????????(?????????????´????RootLeft??¨??????)
	if(PreorderRowLeft.size() > 0){
		TNode* LeftNode = MakeTree(PreorderRowLeft, InorderRowLeft);
		//Root??¨RootLeft???????????????
		RootNode->LChild = LeftNode;
		LeftNode->Parent = RootNode;
	}
	
	//PreorderRowRight,InorderRowRight??????*~**??¨????§???????????????????(?????????????´????RootRight??¨??????)
	if(PreorderRowRight.size() > 0){
		TNode* RightNode = MakeTree(PreorderRowRight, InorderRowRight);
		//Root??¨RootRight???????????????
		RootNode->RChild = RightNode;
		RightNode->Parent = RootNode;
	}
	
	return RootNode;
}

int main()
{
	int n;
	cin >> n;
	vector<int> PreorderRow = Input(n);
	vector<int> InorderRow  = Input(n);
	TNode* RootNode = MakeTree(PreorderRow, InorderRow);
	PostorderOutput(RootNode);
//	DeleteNode(RootNode);
    return 0;
}

Compiler output:
a.cc: In function 'void PostorderOutput(const TNode*)':
a.cc:31:28: error: expected ';' before '}' token
   31 |                 cout << ' '
      |                            ^
      |                            ;
   32 |         }else{
      |         ~
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[post++];
    int m = distance(in.begin(),find(in.begin(),in.end(),root));
    rec(l,m);
    rec(m+l,r);
    post.push_back(root);
}

void solve(){
    pos = 0;
    rec(0,pre.size());
    for(int 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_back(k);
    }
    solve();
}

Compiler output:
a.cc: In function 'void rec(int, int)':
a.cc:13:24: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
   13 |     int root = pre[post++];
      |                    ~~~~^~
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 = 0; i < n; i++) {
		if(i) cout << " ";
		cout << post[i]; 
	}
	cout << endl;
}

int main() {
	int k;
	cin >> ;
	
	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:
a.cc: In function 'int main()':
a.cc:31:16: error: expected primary-expression before ';' token
   31 |         cin >> ;
      |                ^
Language: C++

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

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

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

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


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

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

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

  solve();

  return 0;
}

Compiler output:
a.cc: In function 'void reconstruction(int, int)':
a.cc:11:36: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   11 |   int m = distance(in.begin(), find(in.begin(), in.end(), root));
      |                                ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:11:36: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   11 |   int m = distance(in.begin(), find(in.begin(), in.end(), root));
      |                                ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int j=0,k=0;
vector<int> in,pre;

int search(int n)
{
	int i=0;
	while(in[i]!=n)
	{
		i++;
	}
	return i;
}

void rec(int l,int r)
{
	int c,m;
	
	if(l>r) return;
	c=pre[j];
	j++;
	if(l==r)
	{
		if(++k>1) printf(" ");
		printf("%d",in[l]);
		return;
	}
	m=search(c);
	rec(l,m-1);
	rec(m+1,r);
	if(++k>1) printf(" ");
	printf("%d",in[m]);
	return;
}

int main()
{
	int i,n,temp;
	
	cin >> n;
	
	for(i=0;i<=n-1;i++)
	{
		cin >> temp;
		pre.push_back(temp);
	}
	for(i=0;i<=n-1;i++)
	{
		cin >> temp;
		in.push_back(temp);
	}
	rec(0,n-1);
	printf("\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'cin' was not declared in this scope
   43 |         cin >> n;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<vector>
  +++ |+#include <iostream>
    3 | using namespace std;
Language: C++

#include <bits/stdc++.h>
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(int.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}
void solve(){
  pos=0;
  rec(0,pre.size());
  REP(int i=0;i<n;i++){
    if(i) printf(" ");
    printf("%d",post[i]);
  }
  printf("\n");
}
int main(){
  int k;
  scanf("%d",&n);
  REP(i,n) {scanf("%d",&k);pre.pusf_back(k);}
  REP(i,n) {scanf("%d",&k);in.pusf_back(k);}
  solve();
  return 0;
}

Compiler output:
a.cc: In function 'void rec(int, int)':
a.cc:7:22: error: expected ',' or ';' before ':' token
    7 |   int root=pre[pos++]:
      |                      ^
a.cc:9:9: error: 'm' was not declared in this scope
    9 |   rec(l,m);
      |         ^
a.cc: In function 'void solve()':
a.cc:16:7: error: expected primary-expression before 'int'
   16 |   REP(int i=0;i<n;i++){
      |       ^~~
a.cc:16:15: error: 'i' was not declared in this scope
   16 |   REP(int i=0;i<n;i++){
      |               ^
a.cc: In function 'int main()':
a.cc:25:7: error: 'i' was not declared in this scope
   25 |   REP(i,n) {scanf("%d",&k);pre.pusf_back(k);}
      |       ^
a.cc:25:3: error: 'REP' was not declared in this scope
   25 |   REP(i,n) {scanf("%d",&k);pre.pusf_back(k);}
      |   ^~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
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(int.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}
void solve(){
  pos=0;
  rec(0,pre.size());
  REP(i,n){
    if(i) printf(" ");
    printf("%d",post[i]);
  }
  printf("\n");
}
int main(){
  int k;
  scanf("%d",&n);
  REP(i,n) {scanf("%d",&k);pre.pusf_back(k);}
  REP(i,n) {scanf("%d",&k);in.pusf_back(k);}
  solve();
  return 0;
}

Compiler output:
a.cc: In function 'void rec(int, int)':
a.cc:9:34: error: expected primary-expression before 'int'
    9 |   int m=distance(in.begin(),find(int.begin(),in.end(),root));
      |                                  ^~~
a.cc: In function 'int main()':
a.cc:26:32: error: 'class std::vector<int>' has no member named 'pusf_back'; did you mean 'push_back'?
   26 |   REP(i,n) {scanf("%d",&k);pre.pusf_back(k);}
      |                                ^~~~~~~~~
      |                                push_back
a.cc:27:31: error: 'class std::vector<int>' has no member named 'pusf_back'; did you mean 'push_back'?
   27 |   REP(i,n) {scanf("%d",&k);in.pusf_back(k);}
      |                               ^~~~~~~~~
      |                               push_back
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,pos;
vector<int>pre,in,post;
void rec(int l,int r){
if(l>=r)return 0;
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<<" ";
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:
a.cc: In function 'void rec(int, int)':
a.cc:6:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
    6 | if(l>=r)return 0;
      |                ^
Language: C++

#include<bits/stdc++>
using namespace std;
int n,pos;
vector<int>pre,in,post;
void rec(int l,int r){
if(l>=r)return 0;
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<<" ";
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:
a.cc:1:9: fatal error: bits/stdc++: No such file or directory
    1 | #include<bits/stdc++>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#incldude<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 0;
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<<" ";
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:
a.cc:2:2: error: invalid preprocessing directive #incldude; did you mean #include?
    2 | #incldude<string>
      |  ^~~~~~~~
      |  include
a.cc: In function 'void rec(int, int)':
a.cc:9:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
    9 | if(l>=r)return 0;
      |                ^
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 0;
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<<" ";
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:
a.cc: In function 'void rec(int, int)':
a.cc:9:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
    9 | if(l>=r)return 0;
      |                ^
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=0;i<n;i++){
if(i)cout<<" ";
cout<<post[i];
}
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:
a.cc: In function 'void solve()':
a.cc:23:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   23 | int main(){
      |         ^~
a.cc:23:9: note: remove parentheses to default-initialize a variable
   23 | int main(){
      |         ^~
      |         --
a.cc:23:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:23:11: error: a function-definition is not allowed here before '{' token
   23 | int main(){
      |           ^
a.cc:36:2: error: expected '}' at end of input
   36 | }
      |  ^
a.cc:16:13: note: to match this '{'
   16 | void solve(){
      |             ^
Language: C++

#include<iostream> using namespace std; int n,m=0,a[40],b[40],c[41]; void solve(int l,int r){ if(l>r)return; int x=a[m++]; solve(l,c[x]-1); solve(c[x]+1,r); cout<<x<<(x==a[0]?"\n":" "); } int main(){ cin>>n; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++)cin>>b[i],c[b[i]]=i; solve(0,n-1); return 0; } 


Compiler output:
a.cc:1:20: warning: extra tokens at end of #include directive
    1 | #include<iostream> using namespace std; int n,m=0,a[40],b[40],c[41]; void solve(int l,int r){ if(l>r)return; int x=a[m++]; solve(l,c[x]-1); solve(c[x]+1,r); cout<<x<<(x==a[0]?"\n":" "); } int main(){ cin>>n; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++)cin>>b[i],c[b[i]]=i; solve(0,n-1); return 0; }
      |                    ^~~~~
/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<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 = 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_back(k);
  }

  solve();

  return 0;
}


Compiler output:
a.cc: In function 'void rec(int, int)':
a.cc:14:3: error: expected ',' or ';' before 'rec'
   14 |   rec(l, m);
      |   ^~~
Language: C++


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
 
using namespace std;
 
struct Node {
    int left;
    int right;
};
 
Node T[100];
int PreOrder[100], InOrder[100];
int NumOfNode;
 
 
 
void printPost(int node) {
    if (node == -1) {
        ;
    }
    else {
        printPost(T[node].left);
        printPost(T[node].right);
        if (NumOfNode-- != 1) {
            printf("%d ", node);
        }
        else {
            printf("%d\n", node);
        }
    }
}
 
 
 
void makeTree(int PreBegin, int PreEnd, int InBegin, int InEnd) {
    int root = PreOrder[PreBegin];
    int PreLeftSubtreeBegin, PreLeftSubtreeEnd, PreRightSubtreeBegin, PreRightSubtreeEnd, InLeftSubtreeBegin, InLeftSubtreeEnd, InRightSubtreeBegin, InRightSubtreeEnd;
    for (int i = InBegin; i <= InEnd; ++i) {
        if (InOrder[i] == root) {
            PreLeftSubtreeBegin = PreBegin + 1;
            PreLeftSubtreeEnd = PreBegin + i - InBegin;
            PreRightSubtreeBegin = PreLeftSubtreeEnd + 1;
            PreRightSubtreeEnd = PreEnd;
            InLeftSubtreeBegin = InBegin;
            InLeftSubtreeEnd = i - 1;
            InRightSubtreeBegin = i + 1;
            InRightSubtreeEnd = InEnd;
            break;
        }
    }
    if (PreLeftSubtreeBegin > PreLeftSubtreeEnd) {
        //the left subtree is empty
        T[root].left = -1;
    }
    else {
        //the left subtree is not empty
        T[root].left = PreOrder[PreLeftSubtreeBegin];
        makeTree(PreLeftSubtreeBegin, PreLeftSubtreeEnd, InLeftSubtreeBegin, InLeftSubtreeEnd);
    }
 
    if (PreRightSubtreeBegin > PreRightSubtreeEnd) {
        //the right subtree is empty
        T[root].right = -1;
    }
    else {
        //the right subtree is not empty
        T[root].right = PreOrder[PreRightSubtreeBegin];
        makeTree(PreRightSubtreeBegin, PreRightSubtreeEnd, InRightSubtreeBegin, InRightSubtreeEnd);
    }
}
 
int main() {
    int n;
    scanf("%d", &n);
    NumOfNode = n;
 
    for (int i = 0; i < n; i++) {
        scanf("%d", &PreOrder[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &InOrder[i]);
    }
 
    makeTree(0, n - 1, 0, n - 1);
    printPost(PreOrder[0]);
 
    return 0;
}


Compiler output:
a.cc:2:1: error: expected unqualified-id before numeric constant
    2 | 1
      | ^