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

#include <iostream>
#include <stdio>

using namespace std;

struct Node{
  int key;
  Node* left;
  Node* right;
  Node(){
    left = right = NULL;
  }
};

class Tree{
  Node* root;
  public:
  void insert(Node* n){
    Node* y=NULL;
    Node* x = root;
    while(x!=NULL){
      y = x;
      if(n->key < x->key){
        x = x->left;
      }else{
        x = x->right;
      }
    }
    if(y==NULL){
      root = n;
    }else if(n->key < y->key){
      y->left = n;
    }else{
      y->right = n;
    }
  }

  void print(){
    print_inorder(root);
    printf("\n");
    print_preorder(root);
    printf("\n");
  }

  void print_preorder(Node* n){
    if(n==NULL) return;
    printf(" %d",n->key);
    print_preorder(n->left);
    print_preorder(n->right);
  }
  void print_inorder(Node* n){
    if(n==NULL) return;
    print_inorder(n->left);
    printf(" %d",n->key);
    print_inorder(n->right);
  }

};

int main(){
  int n;cin>>n;
  Tree t;
  for(int i=0;i<n;i++){
    string ope; cin>>ope;
    if(ope=="insert"){
      int k; cin>>k;
      Node* node = new Node();
      node->key = k; 
      t.insert(node);
    }else if(ope=="print"){
      t.print(); 
    }
  }
}

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

#include <bits/stdc++.h>
using namespace std;

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

Node *root,*NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root = z;
    } else {
        if(z->key < y->key){
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s",&com);
        if(com=="insert"){
            scanf("%d",&x)
            insert(x);
        } else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:27: error: expected ';' before 'insert'
   63 |             scanf("%d",&x)
      |                           ^
      |                           ;
   64 |             insert(x);
      |             ~~~~~~
Language: C++

crweeeeeeeeeeeeeeeeeeeeeeeeeeeeeer23rwwrrrrrrrrrrrrrrrrrrrr1 12 17 20 25 30 88
 30 12 1 20 17 25 88

Compiler output:
a.cc:1:1: error: 'crweeeeeeeeeeeeeeeeeeeeeeeeeeeeeer23rwwrrrrrrrrrrrrrrrrrrrr1' does not name a type
    1 | crweeeeeeeeeeeeeeeeeeeeeeeeeeeeeer23rwwrrrrrrrrrrrrrrrrrrrr1 12 17 20 25 30 88
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define llong long long
#define IFY 2000000000
#define NIL -1
using namespace std;
struct Node {int key;Node *right,*left,*parent;};
Node *root,*NIL;
void insert(int k){
  Node *y=NIL,*x=root,*z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}
void inorder(Node *u){
  if(u==NIL) return;
  incorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int n,x;
  string com;
  scanf("%d",&n);
  REP(i,n){
    scanf("%s",com);
    if(com=="insert"){
      scanf("%d",&x);
      insert(x);
    } else if(com=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Compiler output:
a.cc:6:13: error: expected unqualified-id before '-' token
    6 | #define NIL -1
      |             ^
a.cc:9:13: note: in expansion of macro 'NIL'
    9 | Node *root,*NIL;
      |             ^~~
a.cc: In function 'void insert(int)':
a.cc:6:13: error: invalid conversion from 'int' to 'Node*' [-fpermissive]
    6 | #define NIL -1
      |             ^~
      |             |
      |             int
a.cc:11:11: note: in expansion of macro 'NIL'
   11 |   Node *y=NIL,*x=root,*z;
      |           ^~~
a.cc:6:13: error: invalid conversion from 'int' to 'Node*' [-fpermissive]
    6 | #define NIL -1
      |             ^~
      |             |
      |             int
a.cc:14:11: note: in expansion of macro 'NIL'
   14 |   z->left=NIL;
      |           ^~~
a.cc:6:13: error: invalid conversion from 'int' to 'Node*' [-fpermissive]
    6 | #define NIL -1
      |             ^~
      |             |
      |             int
a.cc:15:12: note: in expansion of macro 'NIL'
   15 |   z->right=NIL;
      |            ^~~
a.cc:16:10: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |   while(x!=NIL){
      |          ^
a.cc:22:7: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   22 |   if(y==NIL) root=z;
      |       ^
a.cc: In function 'void inorder(Node*)':
a.cc:29:7: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   29 |   if(u==NIL) return;
      |       ^
a.cc:30:3: error: 'incorder' was not declared in this scope; did you mean 'inorder'?
   30 |   incorder(u->left);
      |   ^~~~~~~~
      |   inorder
a.cc: In function 'void preorder(Node*)':
a.cc:35:7: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   35 |   if(u==NIL) return;
      |       ^
Language: C++

#include <cstdio>
#include <string>
#include <stdlib>
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
struct Node {int key;Node *right,*left,*parent;};
Node *root,*NIL;
void insert(int k){
  Node *y=NIL,*x=root,*z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}
void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int n,x;
  char com[6];
  scanf("%d",&n);
  REP(i,n){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    } else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

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

#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k)
{
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->fight = NIL;
	
	while(x != NIL)
	{
		y = x;
		if(z->key < x->key){
			x = x->left;
		} else {
			x = x->right;
		}
	}
	z->parent = y;
	if(y == NIL){
		root = z;
	} else {
		if(z->key < y->key){
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u)
{
	if(u == NIL) return;
		inorder(u->left);
		printf("%d",u->key);
		inorder(u->right);
}

void preorder(Node *u)
{
	if(u == NIL) return;
	printf("%d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main()
{
	int n,i,x;
	string com;
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++)
	{
		cin >>com;
		if(com == "insert")
		{
			scanf("%d",&x);
			insert(x);
		}
		else if(com == "print")
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	
	return 0;
}


Compiler output:
a.cc: In function 'void insert(int)':
a.cc:23:12: error: 'struct Node' has no member named 'fight'; did you mean 'right'?
   23 |         z->fight = NIL;
      |            ^~~~~
      |            right
Language: C++

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<iostream>
using namespace;

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

Node*root,*NIL;

void insert(int k){
Node*y=NIL;
Node*x=root;
Node*z;

z=(Node *)malloc(sizeof(Node));
z->key=k;
z->left=NIL;
z->right=NIL;

while(x!=NIL){
y=x;
if(z->key < x->key){
x=x->left;
}else{
x=x->right;
}}
z->parent = y;
if(y==NIL){
root=z;
}else{
if(z->key < y->key){
y->left=z;
}else{
y->right=z;
}}}
void inorder(Node *u){
if(u==NIL)return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node *u){
if(u==NIL)return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}

int main(){
int n,i,x;
string com;

scanf("%d", &n);

for(i = 0;i<n;i++){
cin<<com;
if(com == "insert"){
scanf("%d", &x);
insert(x);
}else if(com == "print"){
inorder(root);
printf("\n");
preorder(root);
printf("\n")
}}
rerurn 0;
}


Compiler output:
a.cc:5:16: error: expected identifier before ';' token
    5 | using namespace;
      |                ^
a.cc: In function 'int main()':
a.cc:55:1: error: 'string' was not declared in this scope
   55 | string com;
      | ^~~~~~
a.cc:55:1: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:60:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   60 | cin<<com;
      | ^~~
      | std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:60:6: error: 'com' was not declared in this scope
   60 | cin<<com;
      |      ^~~
a.cc:68:13: error: expected ';' before '}' token
   68 | printf("\n")
      |             ^
      |             ;
   69 | }}
      | ~            
a.cc:70:1: error: 'rerurn' was not declared in this scope
   70 | rerurn 0;
      | ^~~~~~
Language: C++

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<iostream>
using namespace;

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

Node  *root,*NIL;

void insert(int k){
Node*y=NIL;
Node*x=root;
Node*z;

z=(Node *)malloc(sizeof(Node));
z->key=k;
z->left=NIL;
z->right=NIL;

while(x!=NIL){
y=x;
if(z->key < x->key){
x=x->left;
}else{
x=x->right;
}}
z->parent = y;
if(y==NIL){
root=z;
}else{
if(z->key < y->key){
y->left=z;
}else{
y->right=z;
}}}
void inorder(Node *u){
if(u==NIL)return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node *u){
if(u==NIL)return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}

int main(){
int n,i,x;
string com;

scanf("%d", &n);

for(i = 0;i<n;i++){
cin<<com;
if(com == "insert"){
scanf("%d", &x);
insert(x);
}else if(com == "print"){
inorder(root);
printf("\n");
preorder(root);
printf("\n")
}}
rerurn 0;
}


Compiler output:
a.cc:5:16: error: expected identifier before ';' token
    5 | using namespace;
      |                ^
a.cc: In function 'int main()':
a.cc:55:1: error: 'string' was not declared in this scope
   55 | string com;
      | ^~~~~~
a.cc:55:1: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:60:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   60 | cin<<com;
      | ^~~
      | std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:60:6: error: 'com' was not declared in this scope
   60 | cin<<com;
      |      ^~~
a.cc:68:13: error: expected ';' before '}' token
   68 | printf("\n")
      |             ^
      |             ;
   69 | }}
      | ~            
a.cc:70:1: error: 'rerurn' was not declared in this scope
   70 | rerurn 0;
      | ^~~~~~
Language: C++

#include<cstdio>
#include<cstslib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root,*NIL;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
  
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf("%d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf("%d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    cin>>com;
    if(com=="insert"){
      scanf("%d",&x);
      insert(x);
    }else if{(com=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}



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

#include<cstdio>
#include<cstslib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root,*NIL;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
  
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf("%d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf("%d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    cin>>com;
    if(com=="insert"){
      scanf("%d",&x);
      insert(x);
    }else if{(com=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}


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

#include <stdio.h>
typedef struct Node * node;
struct Node{
   int val;
   node left;
   node right; // pointer
   node parent;
};

int main()
{
    int n;
    scanf("%d",&n);
    node root = NULL;
    
    //printf("%d\n",root->val);
    for(int i = 0; i<n; i++){
        char str[10];
        int val;
        scanf("%s %d",&str, &val);
        if(str[0] == 'i'){//insert
            root = insert(root,val);
            
        } else{ // print
            print(root);
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:20: error: 'insert' was not declared in this scope
   22 |             root = insert(root,val);
      |                    ^~~~~~
a.cc:25:13: error: 'print' was not declared in this scope; did you mean 'printf'?
   25 |             print(root);
      |             ^~~~~
      |             printf
Language: C++

#include <stdio.h>
typedef struct Node * node;
struct Node{
   int val;
   node left;
   node right; // pointer
   node parent;
};
node insert(node T, int z){
    //find the parnet
    //printf("%d",T);
    node y = NULL;
    node temp = T;
    while(temp!=NULL){
        y = temp;
        if(z<temp->val){
            temp = temp->left;
        } else {
            temp = temp->right;
        }
    }
    node insert = (node)malloc(sizeof(node));
    insert->val = z;
    if(y==NULL){ //empty tree{
        T = insert;
    }
    else if(z<(y->val)){
        y->left = insert;
    } else {
        y->right = insert;
    }
    return T;
}
void inorder(node root){
    if(root == NULL) return;
    inorder(root->left);
    printf(" %d",root->val);
    inorder(root->right);
}

void preorder(node root){
    if(root == NULL) return;
    printf(" %d",root->val);
    preorder(root->left);
    
    preorder(root->right);
}
void print(node root){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
}
int main()
{
    int n;
    scanf("%d",&n);
    node root = NULL;
    
    //printf("%d\n",root->val);
    for(int i = 0; i<n; i++){
        char str[10];
        int val;
        scanf("%s %d",&str, &val);
        if(str[0] == 'i'){//insert
            root = insert(root,val);
            
        } else{ // print
            print(root);
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'Node* insert(node, int)':
a.cc:22:25: error: 'malloc' was not declared in this scope
   22 |     node insert = (node)malloc(sizeof(node));
      |                         ^~~~~~
a.cc:2:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    1 | #include <stdio.h>
  +++ |+#include <cstdlib>
    2 | typedef struct Node * node;
Language: C++

#include <stdio.h>
typedef struct Node * node;
struct Node{
   int val;
   node left;
   node right; // pointer
   node parent;
};
node insert(node T, int z){
    //find the parnet
    //printf("%d",T);
    node y = NULL;
    node temp = T;
    while(temp!=NULL){
        y = temp;
        if(z<temp->val){
            temp = temp->left;
        } else {
            temp = temp->right;
        }
    }
    node insert = (node)malloc(sizeof(node));
    insert->val = z;
    if(y==NULL){ //empty tree{
        T = insert;
    }
    else if(z<(y->val)){
        y->left = insert;
    } else {
        y->right = insert;
    }
    return T;
}
void inorder(node root){
    if(root == NULL) return;
    inorder(root->left);
    printf(" %d",root->val);
    inorder(root->right);
}

void preorder(node root){
    if(root == NULL) return;
    printf(" %d",root->val);
    preorder(root->left);
    
    preorder(root->right);
}
void print(node root){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
}
int main()
{
    int n;
    scanf("%d",&n);
    node root = NULL;
    for(int i = 0; i<n; i++){
        char str[10];
        int val;
        scanf("%s %d",&str, &val);
        if(str[0] == 'i'){//insert
            root = insert(root,val);
        } else{ // print
            print(root);
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'Node* insert(node, int)':
a.cc:22:25: error: 'malloc' was not declared in this scope
   22 |     node insert = (node)malloc(sizeof(node));
      |                         ^~~~~~
a.cc:2:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    1 | #include <stdio.h>
  +++ |+#include <cstdlib>
    2 | typedef struct Node * node;
Language: C++

#include <iostream>
#include <vector>
#include "ago.h"

template<typename T>
class NodeAllocator {
public:
    NodeAllocator() = default;
    explicit NodeAllocator(int num): reserved_(num), assigned_(0) {
        buf_ = new T[num];
    };

    T* GetAlloc(int num) {
        if (assigned_ + num >= reserved_) {
            return nullptr;
        }
        int retp = assigned_;
        assigned_ += num;
        return buf_ + retp;
    }

    void ReAlloc(int num){
        DeleteAlloc();
        buf_ = new T[num];
        reserved_ = num;
    }

    ~NodeAllocator() {
        DeleteAlloc();
    }

private:
    void DeleteAlloc() {
        if (reserved_ == 0) {
            return;
        }
        if (reserved_ > 1) {
            delete [] buf_;
        }else{
            delete buf_;
        }

        assigned_ = 0;
        reserved_ = 0;
    }

    int reserved_;
    int assigned_;
    T *buf_;
};
struct Node {
    int key;
    Node *p = nullptr;
    Node *l = nullptr;
    Node *r = nullptr;
};

NodeAllocator<Node> Alloc;

Node *root;

void Insert(int v) {
    Node *p= nullptr;
    Node *x = root;
    Node *k = Alloc.GetAlloc(1);
    k->key = v;
    while (x != nullptr) {
        p = x;
        if (k->key < x->key) {
            x = x->l;
        }else{
            x = x->r;
        }
    }
    k->p = p;
    if (p == nullptr) {
        root = k;
    } else if (k->key < p->key) {
        p->l = k;
    } else{
        p->r = k;
    }
}

void Preorder(Node* tgt) {
    if (tgt == nullptr) {
        return;
    }
    std::cout << " " << tgt->key;
    Preorder(tgt->l);
    Preorder(tgt->r);
}

void Inorder(Node* tgt) {
    if (tgt == nullptr) {
        return;
    }
    Inorder(tgt->l);
    std::cout << " " << tgt->key;
    Inorder(tgt->r);
}

int main() {
    int n;
    std::cin >> n;
    Alloc.ReAlloc(n);
    for (int i = 0; i < n; i++) {
        std::string str;
        std::cin >> str;
        if (str == "print") {
            Inorder(root);
            std::cout << std::endl;
            Preorder(root);
            std::cout << std::endl;
            continue;
        }
        int k;
        std::cin >> k;
        if (str == "insert") {
            Insert(k);
        }
//        if (str == "find") {
//        }
    }
}



Compiler output:
a.cc:3:10: fatal error: ago.h: No such file or directory
    3 | #include "ago.h"
      |          ^~~~~~~
compilation terminated.
Language: C++

/*
 * ALDS1_8_A.cpp
 *
 *  Created on: May 2, 2018
 *      Author: 13743
 */

#include<cstdio>;

struct Node {
	int key;
	Node *pa, *lc, *rc;
};

Node* root = NULL;;

void insert(int k) {
	Node* y = NULL;
	Node* x = root;
	Node* z = (Node *)malloc(sizeof(Node));
	while(x != NULL) {
		y = x;
		if(k < y->key) x = y->lc;
		else x = y->rc;
	}
	z->pa = y;
	z->lc = NULL;
	z->rc = NULL;
	if(y == NULL) {
		root = z;
	}
	else if(k < y->key) {
		y->lc = z;
	}
	else {
		y->rc = z;
	}
}

void preorder(Node* u) {
	if(u == NULL) return;
	printf(" %d", u->key);
	preorder(u->lc);
	preorder(u->rc);
}

void inorder(Node* u) {
	if(u == NULL) return;
	inorder(u->lc);
	printf(" %d", u->key);
	inorder(u->rc);
}

void print() {
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
}

int main() {
	int m;
	scanf("%d", &m);
	char* s;
	int ke;
	for(int i=0; i<m; i++) {
		scanf("%s", s);
		if(s[0] == 'i') {
			scanf("%d", &ke);
			insert(ke);
		}
		else {
			print();
		}
	}
}





Compiler output:
a.cc:8:17: warning: extra tokens at end of #include directive
    8 | #include<cstdio>;
      |                 ^
a.cc: In function 'void insert(int)':
a.cc:20:27: error: 'malloc' was not declared in this scope
   20 |         Node* z = (Node *)malloc(sizeof(Node));
      |                           ^~~~~~
a.cc:9:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    8 | #include<cstdio>;
  +++ |+#include <cstdlib>
    9 |
Language: C++

/*
 * ALDS1_8_A.cpp
 *
 *  Created on: May 2, 2018
 *      Author: 13743
 */

#include<cstdio>;
#include<cstdlib>

struct Node {
	int key;
	Node *pa, *lc, *rc;
};

Node* root = NULL;

void insert(int k) {
	Node* y = NULL;
	Node* x = root;
	Node* z = (Node *)malloc(sizeof(Node));
	while(x != NULL) {
		y = x;
		if(k < y->key) x = y->lc;
		else x = y->rc;
	}
	z->pa = y;
	z->lc = NULL;
	z->rc = NULL;
	z->key = k;
	if(y == NULL) {
		root = z;
	}
	else if(k < y->key) {
		y->lc = z;
	}
	else {
		y->rc = z;
	}
}

void preorder(Node* u) {
	if(u == NULL) return;
	printf(" %d", u->key);
	preorder(u->lc);
	preorder(u->rc);
}

void inorder(Node* u) {
	if(u == NULL) return;
	inorder(u->lc);
	printf(" %d", u->key);
	inorder(u->rc);
}

void print() {
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
}

int main() {
	int m;
	scanf("%d", &m);
	char* s;
	int ke;
	for(int i=0; i<m; i++) {
		scanf("%s", s);
		if(s[0] == 'i') {
			scanf("%d", &ke);
			//insert(ke);
		}
		else {
			print()
		}
	}
}





Compiler output:
a.cc:8:17: warning: extra tokens at end of #include directive
    8 | #include<cstdio>;
      |                 ^
a.cc: In function 'int main()':
a.cc:75:32: error: expected ';' before '}' token
   75 |                         print()
      |                                ^
      |                                ;
   76 |                 }
      |                 ~
Language: C++

/*
 * ALDS1_8_A.cpp
 *
 *  Created on: May 2, 2018
 *      Author: 13743
 */

#include<cstdio>;
#include<cstdlib>

struct Node {
	int key;
	Node *pa, *lc, *rc;
};

Node* root = NULL;

void insert(int k) {
	Node* y = NULL;
	Node* x = root;
	Node* z = (Node *)malloc(sizeof(Node));
	while(x != NULL) {
		y = x;
		if(k < y->key) x = y->lc;
		else x = y->rc;
	}
	z->pa = y;
	z->lc = NULL;
	z->rc = NULL;
	z->key = k;
	if(y == NULL) {
		root = z;
	}
	else if(k < y->key) {
		y->lc = z;
	}
	else {
		y->rc = z;
	}
}

void preorder(Node* u) {
	if(u == NULL) return;
	printf(" %d", u->key);
	preorder(u->lc);
	preorder(u->rc);
}

void inorder(Node* u) {
	if(u == NULL) return;
	inorder(u->lc);
	printf(" %d", u->key);
	inorder(u->rc);
}

void print() {
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
}

int main() {
	int m;
	scanf("%d", &m);
	char* s;
	int ke;
	for(int i=0; i<m; i++) {
		scanf("%s", s);
		if(s[0] == 'i') {
			scanf("%d", &ke);
			insert(ke);
		}
		else {
			print()
		}
	}
}





Compiler output:
a.cc:8:17: warning: extra tokens at end of #include directive
    8 | #include<cstdio>;
      |                 ^
a.cc: In function 'int main()':
a.cc:75:32: error: expected ';' before '}' token
   75 |                         print()
      |                                ^
      |                                ;
   76 |                 }
      |                 ~
Language: C++

/*
 * ALDS1_8_A.cpp
 *
 *  Created on: May 2, 2018
 *      Author: 13743
 */

#include<cstdio>
#include<cstdlib>

struct Node {
	int key;
	Node *pa, *lc, *rc;
};

Node* root = NULL;

void insert(int k) {
	Node* y = NULL;
	Node* x = root;
	Node* z = new Node;
	while(x != NULL) {
		y = x;
		if(k < y->key) x = y->lc;
		else x = y->rc;
	}
	z->pa = y;
	z->lc = NULL;
	z->rc = NULL;
	z->key = k;
	if(y == NULL) {
		root = z;
	}
	else if(k < y->key) {
		y->lc = z;
	}
	else {
		y->rc = z;
	}
}

void preorder(Node* u) {
	if(u == NULL) return;
	printf(" %d", u->key);
	preorder(u->lc);
	preorder(u->rc);
}

void inorder(Node* u) {
	if(u == NULL) return;
	inorder(u->lc);
	printf(" %d", u->key);
	inorder(u->rc);
}

void print() {
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
}

int main() {
	int m;
	scanf("%d", &m);
	char *s;
	int ke;
	for(int i=0; i<m; i++) {
		scanf("%s", s);
		//if(*s == 'i') {
		//	scanf("%d", &ke);
			//insert(ke);
		}
		//else {
		//	print();
		//}
	}
}





Compiler output:
a.cc:78:1: error: expected declaration before '}' token
   78 | }
      | ^
Language: C++

#include<cstdlib>
#include<iostream>
#include<string>

using namespace std;

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

Node* root;
Node* NIL;

void insert(int k) {
  Node* y = NIL;
  Node* x = root;
  Node* z;

  z = (Node*) malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void preOrder(Node* u) {
  if (u == NIL) {
    return;
  }
  cout << " " << u->key;
  preOrder(u->left);
  preOrder(u->right);
}

void inOrder(Node* u) {
  if (u == NIL) {
    return;
  }
  inOrder(u->left);
  cout << " " << u->key;
  inOrder(u->right);
}

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

  int x;
  string com;
  for (int i = 0; i < N; i++) {
    cin >> com;
    if (com == "insert") {
      cin >> x;
      insert(x);
    } else if (com == "print") {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:77:7: error: 'inorder' was not declared in this scope; did you mean 'inOrder'?
   77 |       inorder(root);
      |       ^~~~~~~
      |       inOrder
a.cc:79:7: error: 'preorder' was not declared in this scope; did you mean 'preOrder'?
   79 |       preorder(root);
      |       ^~~~~~~~
      |       preOrder
Language: C++

#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

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

Node *root, *NIL;

coid insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z =(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else {
      x=x->right;
    }
  }
  z->parent=y;
  
  if(y==NIL){
    root =z;
  } else{
    if(z->key < y->key){
      y->left =z;
    }else{
      y->right =z;
    }
  }

void Inorder(Node *u){
  if(u==NIL) return;
  Inorder(u->left);
  printf(" %d", u->key );
  Inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d", u->key );
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n );
  for(i=0;i<n;i++){
    cin >> com;
    if(com=="insert"){
      scanf("%d",&x );
      insert(x);
    } else if (com=="print"){
      Inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


Compiler output:
a.cc:14:1: error: 'coid' does not name a type; did you mean 'void'?
   14 | coid insert(int k){
      | ^~~~
      | void
Language: C++

#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z =(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else {
      x=x->right;
    }
  }
  z->parent=y;
  
  if(y==NIL){
    root =z;
  } else{
    if(z->key < y->key){
      y->left =z;
    }else{
      y->right =z;
    }
  }

void Inorder(Node *u){
  if(u==NIL) return;
  Inorder(u->left);
  printf(" %d", u->key );
  Inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d", u->key );
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n );
  for(i=0;i<n;i++){
    cin >> com;
    if(com=="insert"){
      scanf("%d",&x );
      insert(x);
    } else if (com=="print"){
      Inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'void insert(int)':
a.cc:44:22: error: a function-definition is not allowed here before '{' token
   44 | void Inorder(Node *u){
      |                      ^
a.cc:51:23: error: a function-definition is not allowed here before '{' token
   51 | void preorder(Node *u){
      |                       ^
a.cc:58:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   58 | int main(){
      |         ^~
a.cc:58:9: note: remove parentheses to default-initialize a variable
   58 | int main(){
      |         ^~
      |         --
a.cc:58:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:58:11: error: a function-definition is not allowed here before '{' token
   58 | int main(){
      |           ^
a.cc:76:2: error: expected '}' at end of input
   76 | }
      |  ^
a.cc:14:19: note: to match this '{'
   14 | void insert(int k){
      |                   ^
Language: C++

#include <iostream>
using namespace std;

int n;

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

Node *root;

void preorder(Node *nd) {
    if (nd == nullptr) return ;
    preorder(nd->l);
    cout << nd->v << " ";
    preorder(nd->r);
}

void inorder(Node *nd) {
    if (nd == nullptr) return ;
    inorder(nd->l);
    cout << nd->v << " ";
    inorder(nd->r);
}

void print() {
    preorder();
    inorder(root);
}

void insert(int k) {
    Node *z = root;
    Node *y = nullptr;

    while (z != nullptr) {
        if (k <= z->v) {
            y = z;
            z = z->l;
        } else {
            y = z;
            z = z->r;
        }
    }
    if (y == nullptr) {
        root = new Node;
        root->p = root->l = root->r = nullptr;
        root->v = k;
        return;
    }
    z = new Node;
    if (k <= y->v) {
        y->l = z;
    } else{
        y->r = z;
    }
    z->p = y;
    z->l = z->r = nullptr;
    z->v = k;
    return;
}


int main() {
    cin >> n;
    int k; string cmd;
    for (int i = 0; i < n; ++i) {
        cin >> cmd ;
        if (cmd == "insert") {
            cin >> k;
            insert(k); }
        else {
            print();
        }
    }
    return 0;
}



Compiler output:
a.cc: In function 'void print()':
a.cc:28:13: error: too few arguments to function 'void preorder(Node*)'
   28 |     preorder();
      |     ~~~~~~~~^~
a.cc:13:6: note: declared here
   13 | void preorder(Node *nd) {
      |      ^~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int p[5000005];    //    p---|  Unit
int left2[5000005]; // left2 --|--------> T
int right2[5000005];//right2---|
int key[5000005];  // key----|

void Init(){
  rep(i,5000005){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}


int FindRoot(){
  rep(i,n){
    if(p[i] == NIL){
      return i;
    }
  }
}



void TREE_INSERT(int z){
  int y = NIL;  
  int x = root;

  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }

}

void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}

void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}


int main(){
  int val;
  string op;
  int zr;                     


  scanf("%d",&n);
  Init();  
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(strcmp(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;         
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:85:18: error: cannot convert 'bool' to 'const char*'
   85 |     if(strcmp(op == "insert"){
      |               ~~~^~~~~~~~~~~
      |                  |
      |                  bool
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:3:
/usr/include/string.h:156:32: note:   initializing argument 1 of 'int strcmp(const char*, const char*)'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                    ~~~~~~~~~~~~^~~~
a.cc:85:30: error: expected ')' before '{' token
   85 |     if(strcmp(op == "insert"){
      |       ~                      ^
      |                              )
a.cc:96:3: error: expected primary-expression before '}' token
   96 |   }
      |   ^
a.cc: In function 'int FindRoot()':
a.cc:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      final int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();
      int t;

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];

        switch( op ) {
          case "insert" :
            tree.insert(Integer.parseInt(words[k]));
            break;
          case "find" :
            t = Integer.parseInt(words[k]);
            System.out.println( tree.find(t) ? "yes" : "no" );
            break;
          default :
            tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode(-1);
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
    exist = false;
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode(val);

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) )
      root = z;
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  }
  boolean find(int target) {
    BTreeNode x = root;

    while( !x.equals(NIL) ) {
      if( target == x.key )
        return true;
      else if( target < x.key )
        x = x.left;
      else
        x = x.right;
    }

    return false;
  }
  
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  final int key;
  BTreeNode parent,left,right;

  public BTreeNode(final int key) {
    this.key = key;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Compiler output:
Main.java:55: error: cannot find symbol
    exist = false;
    ^
  symbol:   variable exist
  location: class Tree
1 error
Language: Java

mport java.util.Scanner;
public class Main {
static private Scanner s = new Scanner(System.in);
static Node root = null;
static StringBuilder sb = new StringBuilder();
public static void main(String[] args) {
	int n = s.nextInt();
	String str = new String();

	 for(int i = 0;i < n;i++) {
	 str = s.next();
		 if(str.equals("insert")) {
		 Insert(s.nextInt());
		 }else if(str.equals("find")){
			 if(find(root,s.nextInt())) {
				 sb.append("yes\n");
			 }else{
				 sb.append("no\n");
			 }
		 }else if(str.equals("print")){
				 inorder(root);
				 sb.append("\n");
				 preorder(root);
				 sb.append("\n");
			 }
		 }
	 System.out.print(sb);
}

Node mins(int n,Node[] a) {
	Node min = a[0];
	for(int i = 1;i < n;i++) {
		if(min.key > a[i].key) {

		}
	}
	return min;
}

static void Insert(int k) {
	Node y = null;
	Node x = root;
	Node z = new Node();

	z.key = k;
	z.l = null;
	z.r = null;
	while(x != null) {
		y = x;
		if(z.key < x.key) {
			x = x.l;
		}else {
			x = x.r;
		}
	}
	z.parent = y;
	if(y == null) {
		root = z;
	}else if(z.key < y.key) {
		y.l = z;
	}else {
		y.r = z;
	}
}

static void preorder(Node a) {
		if(a ==null)return;
		sb.append(" " + a.key);
		preorder(a.l);
		preorder(a.r);
}

static void inorder(Node a) {
		if(a == null) return;
		inorder(a.l);
		sb.append(" " + a.key);
		inorder(a.r);
}

static boolean find(Node a,int k) {
	while(a != null) {
		if(k == a.key)
		return true;
	if(k < a.key) {
		a = a.l;
	}else {
		a = a.r;
	}
	}
	return false;
}
}

class Node{
	int key;
	Node l = null;
	Node r = null;
	Node parent;


	Node(){
	}
}




Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.Scanner;
^
1 error
Language: Java

import java.io.*;
import java.util.StringTokenizer;
   
class Main{
   
static final PrintWriter out=new PrintWriter(System.out);

static class binarySearchTree{

static class Node{
int id;
Node p;
Node l;
Node r;
int deg;
Node(int id){
this.id=id; this.p=null; this.l=null; this.r=null; this.deg=0;
}
}

private static Node root;

binarySearchTree(){
root=null;
}

private static void insert(int v){
if(root==null) root=new Node(v);
else __insert(new Node(v));
}

private static void __insert(Node z){
Node x=root;
Node y=null;
while(x!=null){
y=x;
if(z.id<x.id) x=x.l;
else x=x.r;
}
z.p=y;
if(z.id<y.id) y.l=z;
else y.r=z;
y.deg++;
}

private static boolean find(int v){
if(root==null) return false;
else return __find(v);
}

private static boolean __find(int v){
Node x=root;
while(true){
if(x.id==v) return true;
if(x==null) return false;
else if(x.id>v) x=x.l;
else x=x.r;
}
}

else __insert(new Node(v));
private static void print(){
inorder(root);
out.println();
preorder(root);
out.println();
}

static void preorder(Node now){
if(now==null) return;
out.print(" "+now.id);
preorder(now.l);
preorder(now.r);
}
 
static void inorder(Node now){
if(now==null) return;
inorder(now.l);
out.print(" "+now.id);
inorder(now.r);
}
 
static void postorder(Node now){
if(now==null) return;
postorder(now.l);
postorder(now.r);
out.print(" "+now.id);
}
}

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
binarySearchTree tree=new binarySearchTree();
int num=Integer.parseInt(br.readLine());
for(int i=0;i<num;i++){
st=new StringTokenizer(br.readLine());
String command=st.nextToken();
if("insert".equals(command)){
int n=Integer.parseInt(st.nextToken());
tree.insert(n);
}
else if("find".equals(command)) {
int n=Integer.parseInt(st.nextToken());
out.println((tree.find(n))?"yes":"no");
}
else tree.print();
}
out.flush();
}
}

Compiler output:
Main.java:61: error: illegal start of type
else __insert(new Node(v));
^
Main.java:61: error: invalid method declaration; return type required
else __insert(new Node(v));
     ^
Main.java:61: error: illegal start of type
else __insert(new Node(v));
              ^
3 errors
Language: Java

import java.io.*;
import java.util.StringTokenizer;
    
class Main{
    
static final PrintWriter out=new PrintWriter(System.out);
 
static class binarySearchTree{
 
static class Node{
int id;
Node p;
Node l;
Node r;
int deg;
Node(int id){
this.id=id; this.p=null; this.l=null; this.r=null; this.deg=0;
}
}
 
private static Node root;
 
binarySearchTree(){
root=null;
}
 
public static void insert(int v){
if(root==null) root=new Node(v);
else __insert(new Node(v));
}
 
private static void __insert(Node z){
Node x=root;
Node y=null;
while(x!=null){
y=x;
if(z.id<x.id) x=x.l;
else x=x.r;
}
z.p=y;
if(z.id<y.id) y.l=z;
else y.r=z;
y.deg++;
}
 
public static boolean __find(int v){
Node x=root;
while(x!=null){
if(x.id==v) return true;
else if(x.id>v) x=x.l;
else x=x.r;
}
return false;
}
 
public static void print(){
inorder(root);
out.println();
preorder(root);
out.println();
}
 
private static void preorder(Node now){
if(now==null) return;
out.print(" "+now.id);
preorder(now.l);
preorder(now.r);
}
  
private static void inorder(Node now){
if(now==null) return;
inorder(now.l);
out.print(" "+now.id);
inorder(now.r);
}
  
private static void postorder(Node now){
if(now==null) return;
postorder(now.l);
postorder(now.r);
out.print(" "+now.id);
}
}
 
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
binarySearchTree tree=new binarySearchTree();
int num=Integer.parseInt(br.readLine());
for(int i=0;i<num;i++){
st=new StringTokenizer(br.readLine());
String command=st.nextToken();
int n;
if("insert".equals(command)){
n=Integer.parseInt(st.nextToken());
tree.insert(n);
}
else if("find".equals(command)) {
n=Integer.parseInt(st.nextToken());
out.println((tree.find(n))?"yes":"no");
}
else tree.print();
}
out.flush();
}
}

Compiler output:
Main.java:100: error: cannot find symbol
out.println((tree.find(n))?"yes":"no");
                 ^
  symbol:   method find(int)
  location: variable tree of type binarySearchTree
1 error