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

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

vector<vector<int>> T;
vector<long> v;

void in(long k) {
	if (k == -1)
		return;
	else {
		in(T[k][0]);
		cout << " " << v[k];
		in(T[k][1]);
		return;
	}
}

void pre(long k) {
	if (k == -1)
		return;
	else {
		cout << " " << v[k];
		pre(T[k][0]);
		pre(T[k][1]);
		return;
	}
}

int main()
{
	string s;
	long n = 0, t = 0;

	cin >> n;

	T.assign(n, { -1, -1});
	v.assign(n, -2000000001);

	for (long i = 0; i < n; i++) {
		cin >> s;

		if (s == "insert") {
			cin >> v[t];

			long y = -1, x = 0;

			while (x != -1) {
				int m = 1;
				y = x;
				if (v[t] < v[x])
					m = 0;
				x = T[x][m];
			}

			int s = 1;

			if (i > 0 && y != -1) {
				if (v[t] < v[y])
					s = 0;
				T[y][s] = t;
			}
			t++;
		}
		else if (s == "print") {
			in(0);
			cout << endl;
			pre(0);
			cout << endl;
		}
		else if (s == "find") {
			long w = 0;
			cin >> w;
			std::vector<long>::iterator itr = find(v.begin(), v.end(), w);
			if (itr != v.end())
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:75:63: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, long int&)'
   75 |                         std::vector<long>::iterator itr = find(v.begin(), v.end(), w);
      |                                                           ~~~~^~~~~~~~~~~~~~~~~~~~~~~
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:75:63: note:   '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   75 |                         std::vector<long>::iterator itr = find(v.begin(), v.end(), w);
      |                                                           ~~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

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

Node *gRoot,*NIL;

Node *find(Node* u,int value){
    while(u != NIL && value != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int value){
    Node *y = NIL;
    // 親
    Node *x = gRoot;
    // 自身
    Node *z;
    z = (Node*)malloc(sizeof(Node));
    z->key = value;
    z->left = NIL;
    z->right = NIL;
    
    // rootから自身を挿入する場所を探す
    while(x != NIL){
        // rootから検索
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    // 親に子を持たせる
    if(y == NIL){
        gRoot = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}
// 先行順巡回
void preOrder(Node *u){
    if(u == NIL)return;
    printf(" %d",u->key);
    preOrder(u->left);
    preOrder(u->right);
}

// 中間順巡回
void inOrder(Node *u){
    if(u == NIL)return;
    inOrder(u->left);
    printf(" %d",u->key);
    inOrder(u->right);
}

int main(){
    int n,x;
    string com;
    
    cin >> n;
    for(int i = 0;i < n;++i){
        cin >> com;
        if(com[0] == 'f'){
            cin >> x;
            Node *t = find(gRoot,x);
            if(t != NIL) cout << "yes\n";
            else cout << "no\n";
        }
        if(com == "insert"){
            cin >> x;
            insert(x);
        }
        else if(com == "print"){
            inOrder(gRoot);
            cout << "\n";
            preOrder(gRoot);
            cout << "\n";
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'Node* find(Node*, int)':
a.cc:15:12: error: 'k' was not declared in this scope
   15 |         if(k < u->key) u = u->left;
      |            ^
Language: C++

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

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

Node *root,*NIL;

Node *find(Node *u,int k){
  while(u!=NIL && k!= u->key){
    if(k < u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

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[0]=="f"){
      scanf("%d",&x);
      Node*t=find(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
    }else 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:73:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   73 |     if(com[0]=="f"){
Language: C++

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

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

Node *root, *NIL;

Node * find(Node *u, int k){
	while(u!=NUL && k!=u->key){
		if(k < u->key) u=u->left;
		else u=u->right;
	}
	return u;
}




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(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com[0] == 'f') {
			scanf("%d",&x);
			Node *t=find(root, x);
			if(t!=NIL) printf("yes\n");
			else printf("no\n");
		} else if(com == "insert") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


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

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

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

Node *root, *NIL;

Node *find(Node *u, int k) {
	while ( u != NIL && k != u->key ) {
		if( k < u->key ) {
			u = u->left;
		} else {
			u = u->right;
		}
	}
	return u;
}

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);
	inorder(u->left);
	inorder(u->right);
}

int main() {
	int n, i, x;
	string com;
	
	scanf("%d",&n);
	
	for ( i = 0; i < n; i++ ) {
		cin >> com;
		if ( com[0]== 'f' ) {
			scanf("%d",&x);
			Node *t = find(root, x);
			if ( t != NIL ) {
				printf("yes\n");
			} else {
				printf("no\n");
		} else 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:85:19: error: expected '}' before 'else'
   85 |                 } else if ( com == "insert" ) {
      |                   ^~~~
a.cc:78:37: note: to match this '{'
   78 |                 if ( com[0]== 'f' ) {
      |                                     ^
Language: C++

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

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

Node *root, *NIL;

Node * find(Node *u,int k){
while(u!=NIL && k!=u->key){
if(k<u->key)u=u->left;
else u=u->right;
}
return u;} 

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(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com[0]=='f'){
		scanf("%d",&x);
		Node *t = find(root,x);
		if(t!=NIL)printf("yes\n");
		else printf("no\n");
		}else i(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:76:24: error: 'i' cannot be used as a function
   76 |                 }else i(com == "insert"){
      |                       ~^~~~~~~~~~~~~~~~~
a.cc:79:18: error: 'else' without a previous 'if'
   79 |                 }else if(com == "print"){
      |                  ^~~~
Language: C++

#include<bits/stdc++.h> using namespace std; #define bstN 500000 struct bst{ int size; int t[bstN]; int lc[bstN]; int rc[bstN]; void init(){ size=0; } void insert(int v){ int i=0; while(0<=i&&i<size){ int& child=(v<t[i]?lc[i]:rc[i]); if(child==-1)child=size; i=child; } lc[size]=rc[size]=-1; t[size++]=v; } bool find(int v){ int i=0; while(0<=i&&i<size){ if(t[i]==v)return true; i=(v<t[i]?lc[i]:rc[i]); } return false; } void preord(int pos){ if(pos==-1||pos==size)return; preord(lc[pos]); printf(" %d",t[pos]); preord(rc[pos]); } void inord(int pos){ if(pos==-1||pos==size)return; printf(" %d",t[pos]); inord(lc[pos]); inord(rc[pos]); } }; bst T; int main(){ T.init(); int n,a; char str[100]; scanf("%d",&n); while(n--){ scanf("%s",str); if(str[0]=='i'){ scanf("%d",&a); T.insert(a); }else if(str[0]=='f'){ scanf("%d",&a); if(T.find(a))printf("yes\n"); else printf("no\n"); }else{ T.preord(0); printf("\n"); T.inord(0); printf("\n"); } } return 0; } 


Compiler output:
a.cc:1:25: warning: extra tokens at end of #include directive
    1 | #include<bits/stdc++.h> using namespace std; #define bstN 500000 struct bst{ int size; int t[bstN]; int lc[bstN]; int rc[bstN]; void init(){ size=0; } void insert(int v){ int i=0; while(0<=i&&i<size){ int& child=(v<t[i]?lc[i]:rc[i]); if(child==-1)child=size; i=child; } lc[size]=rc[size]=-1; t[size++]=v; } bool find(int v){ int i=0; while(0<=i&&i<size){ if(t[i]==v)return true; i=(v<t[i]?lc[i]:rc[i]); } return false; } void preord(int pos){ if(pos==-1||pos==size)return; preord(lc[pos]); printf(" %d",t[pos]); preord(rc[pos]); } void inord(int pos){ if(pos==-1||pos==size)return; printf(" %d",t[pos]); inord(lc[pos]); inord(rc[pos]); } }; bst T; int main(){ T.init(); int n,a; char str[100]; scanf("%d",&n); while(n--){ scanf("%s",str); if(str[0]=='i'){ scanf("%d",&a); T.insert(a); }else if(str[0]=='f'){ scanf("%d",&a); if(T.find(a))printf("yes\n"); else printf("no\n"); }else{ T.preord(0); printf("\n"); T.inord(0); printf("\n"); } } 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 <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <list>
#include <cmath>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#define sf scanf
#define pf printf
using namespace std;
typedef long long ll;
const int maxn=1000;
const int vmaxn=10000;
const int inf=1e9+5;

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

struct node *root,*NIL;

void inser(int k)
{
    struct node *z,*x,*y=NIL;
    z=(struct node *)malloc(sizeof(struct node));
    z->key=k;
    z->left=NIL,z->right=NIL;
    x=root;
    while(x!=NIL)
    {
        y=x;
        if(x->key>k)
            x=x->left;
        else
            x=x->right;
    }
    z->parent=y;
    if(y==NIL)root=z;
    else if(y->key>z->key)y->left=z;
    else y->right=z;
}
/*
bool fin(int k)
{
    struct node *x,*z;
    z=(struct node *)malloc(sizeof(struct node));
    z->left=NIL,z->right=NIL,z->key=k;
    x=root;
    while(x!=NIL&&z->key!=x->key)
    {
        if(z->key<x->key)x=x->left;
        else if(z->key<x->key)x=x->right;
    }
    if(x==NIL)return 0;
    else return 1;
}*/

struct node *fin(struct node *u,int k)
{
    while(u!=NIL&&k!=u->key)
    {
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
};

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

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


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

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

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

Node *root, *NIL;

Node * find(Node *x, int k) {
	while ( x != NIL && k != x.key) {
		if ( k < x.key) {
			x = x.left
		} else {
			x = x.right
		}
		return x;
	}
}

void insert (int k ) {
	Node *y = NIL; // yは親、xは現在地のノードを表す
	Node *x = root; // rootから探索する
	Node *z; // zは挿入したいノード

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

	while ( x != NIL) { //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 == "find" ) {
			scanf("%d", &x);
			Node *t = find(root, x);
			if ( t != NIL ) printf("yes\n");
			else printf("no\n");
		} else if ( com == "print" ) {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}



Compiler output:
a.cc: In function 'Node* find(Node*, int)':
a.cc:15:36: error: request for member 'key' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   15 |         while ( x != NIL && k != x.key) {
      |                                    ^~~
a.cc:16:28: error: request for member 'key' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   16 |                 if ( k < x.key) {
      |                            ^~~
a.cc:17:31: error: request for member 'left' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   17 |                         x = x.left
      |                               ^~~~
a.cc:19:31: error: request for member 'right' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   19 |                         x = x.right
      |                               ^~~~~
a.cc:23:1: warning: control reaches end of non-void function [-Wreturn-type]
   23 | }
      | ^
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;

Node* find(Node* u, int k) {
  while (u != NIL && k != u->key) {
    if (k < u->key) {
      u = u->left;
    } else {
      u = u->right;
    }
  }
  return u;
}

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 == "find") {
      Node* f = find(root, x);
      if (t != NIL) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    } else if (com == "print") {
      inOrder(root);
      cout << endl;
      preOrder(root);
      cout << endl;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:89:11: error: 't' was not declared in this scope
   89 |       if (t != NIL) {
      |           ^
Language: C++

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

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

Node *root, *NIL;

Node * find(Node *u, int k){
  while ( u != NIL && k != u->key ) {
    if ( k < u->key ) {
      u = u->left;
    } else
      u = u->right; 
    }
  return u;
}

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->right = NIL;
  z->left = 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 [0] == "f" ) {
      scanf("%d", &x );
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else 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:37:5: error: expected '}' before 'else'
   37 |     else {
      |     ^~~~
a.cc:35:28: note: to match this '{'
   35 |     if ( z->key < x->key ) {
      |                            ^
a.cc:40:5: error: request for member 'parent' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   40 |   z.parent = y;
      |     ^~~~~~
a.cc:53:22: error: a function-definition is not allowed here before '{' token
   53 | void inorder(Node *u){
      |                      ^
a.cc:60:24: error: a function-definition is not allowed here before '{' token
   60 | void preorder(Node *u) {
      |                        ^
a.cc:67:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   67 | int main() {
      |         ^~
a.cc:67:9: note: remove parentheses to default-initialize a variable
   67 | int main() {
      |         ^~
      |         --
a.cc:67:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:67:12: error: a function-definition is not allowed here before '{' token
   67 | int main() {
      |            ^
a.cc:92:2: error: expected '}' at end of input
   92 | }
      |  ^
a.cc:23:20: note: to match this '{'
   23 | void insert(int k) {
      |                    ^
Language: C++

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

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

Node *root, *NIL;

Node * find(Node *u, int k){
  while ( u != NIL && k != u->key ) {
    if ( k < u->key ) {
      u = u->left;
    } else
      u = u->right; 
    }
  return u;
}

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->right = NIL;
  z->left = 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 [0] == "f" ) {
      scanf("%d", &x );
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else 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:40:5: error: request for member 'parent' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   40 |   z.parent = y;
      |     ^~~~~~
a.cc:53:22: error: a function-definition is not allowed here before '{' token
   53 | void inorder(Node *u){
      |                      ^
a.cc:60:24: error: a function-definition is not allowed here before '{' token
   60 | void preorder(Node *u) {
      |                        ^
a.cc:67:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   67 | int main() {
      |         ^~
a.cc:67:9: note: remove parentheses to default-initialize a variable
   67 | int main() {
      |         ^~
      |         --
a.cc:67:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:67:12: error: a function-definition is not allowed here before '{' token
   67 | int main() {
      |            ^
a.cc:92:2: error: expected '}' at end of input
   92 | }
      |  ^
a.cc:23:20: note: to match this '{'
   23 | void insert(int k) {
      |                    ^
Language: C++

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

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

Node *root, *NIL;

Node * find(Node *u, int k){
  while ( u != NIL && k != u->key ) {
    if ( k < u->key ) {
      u = u->left;
    } else
      u = u->right; 
    }
  return u;
}

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->right = NIL;
  z->left = 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 [0] == "f" ) {
      scanf("%d", &x );
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else 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:53:22: error: a function-definition is not allowed here before '{' token
   53 | void inorder(Node *u){
      |                      ^
a.cc:60:24: error: a function-definition is not allowed here before '{' token
   60 | void preorder(Node *u) {
      |                        ^
a.cc:67:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   67 | int main() {
      |         ^~
a.cc:67:9: note: remove parentheses to default-initialize a variable
   67 | int main() {
      |         ^~
      |         --
a.cc:67:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:67:12: error: a function-definition is not allowed here before '{' token
   67 | int main() {
      |            ^
a.cc:92:2: error: expected '}' at end of input
   92 | }
      |  ^
a.cc:23:20: note: to match this '{'
   23 | void insert(int k) {
      |                    ^
Language: C++

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

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

Node *root, *NIL;

Node * find(Node *u, int k){
  while ( u != NIL && k != u->key ) {
    if ( k < u->key ) {
      u = u->left;
    } else
      u = u->right; 
    }
  return u;
}

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->right = NIL;
  z->left = 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 [0] == "f" ) {
      scanf("%d", &x );
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else 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:75:5: error: 'cin' was not declared in this scope
   75 |     cin >> com;
      |     ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<string>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:76:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   76 |     if ( com [0] == "f" ) {
a.cc:82:18: error: invalid operands of types 'const char [3]' and 'int' to binary 'operator&'
   82 |       scanf("%d" &x);
      |             ~~~~ ^~
      |             |     |
      |             |     int
      |             const char [3]
a.cc:86:19: error: expected ';' before 'preorder'
   86 |       printf("\n")
      |                   ^
      |                   ;
   87 |       preorder(root);
      |       ~~~~~~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>

using namespace std;

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

Node *root, *NIL;

Node * find(Node *u, int k){
  while ( u != NIL && k != u->key ) {
    if ( k < u->key ) {
      u = u->left;
    } else
      u = u->right; 
    }
  return u;
}

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->right = NIL;
  z->left = 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 [0] == "f" ) {
      scanf("%d", &x );
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else 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:78:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   78 |     if ( com [0] == "f" ) {
a.cc:84:18: error: invalid operands of types 'const char [3]' and 'int' to binary 'operator&'
   84 |       scanf("%d" &x);
      |             ~~~~ ^~
      |             |     |
      |             |     int
      |             const char [3]
a.cc:88:19: error: expected ';' before 'preorder'
   88 |       printf("\n")
      |                   ^
      |                   ;
   89 |       preorder(root);
      |       ~~~~~~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>

using namespace std;

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

Node *root, *NIL;

Node * find(Node *u, int k){
  while ( u != NIL && k != u->key ) {
    if ( k < u->key ) {
      u = u->left;
    } else
      u = u->right; 
    }
  return u;
}

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->right = NIL;
  z->left = 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[0] == "f" ) {
      scanf("%d", &x );
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else 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:78:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   78 |     if ( com[0] == "f" ) {
a.cc:84:18: error: invalid operands of types 'const char [3]' and 'int' to binary 'operator&'
   84 |       scanf("%d" &x);
      |             ~~~~ ^~
      |             |     |
      |             |     int
      |             const char [3]
a.cc:88:19: error: expected ';' before 'preorder'
   88 |       printf("\n")
      |                   ^
      |                   ;
   89 |       preorder(root);
      |       ~~~~~~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>

using namespace std;

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

Node *root, *NIL;

Node * find(Node *u, int k){
  while ( u != NIL && k != u->key ) {
    if ( k < u->key ) {
      u = u->left;
    } else
      u = u->right; 
    }
  return u;
}

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->right = NIL;
  z->left = 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[0] == 'f' ) {
      scanf("%d", &x );
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else 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:84:18: error: invalid operands of types 'const char [3]' and 'int' to binary 'operator&'
   84 |       scanf("%d" &x);
      |             ~~~~ ^~
      |             |     |
      |             |     int
      |             const char [3]
a.cc:88:19: error: expected ';' before 'preorder'
   88 |       printf("\n")
      |                   ^
      |                   ;
   89 |       preorder(root);
      |       ~~~~~~~~
Language: C++

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

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

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!=NULL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == test) {
        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);
}

Node * find(Node *u, int k) {
    while(u!=NIL && k = u->key) {
        if (k < u->key) {
            u = u->left;
        }else{
            u = u->right;
        }
    }
    return u;
}

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 == "find") {
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        }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:34:13: error: 'test' was not declared in this scope
   34 |     if(y == test) {
      |             ^~~~
a.cc: In function 'Node* find(Node*, int)':
a.cc:60:18: error: lvalue required as left operand of assignment
   60 |     while(u!=NIL && k = u->key) {
      |           ~~~~~~~^~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define MAX 4100005
#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 = new int[MAX];       //    p---|  Unit
int *left2 = new  int[MAX]; // left2 --|--------> T
int *right2 = new int[MAX]; //right2---|
int *key = new int[MAX];     // key----|
bool *FIND = new bool[MAX];
 
void Init(){
  rep(i,MAX){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
    FIND[i]=false;
  }
}
 
 
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;
  long long zr;                     
 
 
  scanf("%d",&n);
  Init();  
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      FIND[val]=true;
      key[zr]=val;         
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
    else if(op == "find"){
      scanf("%d",&val);
      if(FIND[val]){
    printf("yes\n");
      }else{
    printf("no\n");
      }
       
 
    }
  }
 
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
  delete [] FIND; 

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:5: error: 'cin' was not declared in this scope
   76 |     cin >> op;
      |     ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<string>
  +++ |+#include <iostream>
    4 | #define NIL -1
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;
Node(int id){
this.id=id; this.p=null; this.l=null; this.r=null;
}
}
  
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;
}
  
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 boolean delete(int v){
Node x=root;
Node y=null;
boolean isLeftChild=true;
while(true){
if(x==null) return false;
else if(x.id==v) break;
y=x;
if(v<x.id){
x=x.l;
isLeftChild=true;
}
else{
x=x.r;
isLeftChild=false;
}
}
if(x.l==null){
if(x==root) root=x.r;
else if(isLeftChild) y.l=x.r;
else y.r=x.r;
}
else if(x.r==null){
if(x==root) root=x.l;
else if(isLeftChild) y.l=x.l;
else y.r=x.l;
}
else{
y=x;
Node left=x.l;
isLeftChild=true;
while(left.r!=null){
y=left;
left=left.r;
isLeftChild=false;
}
p.id=left.id;
if(isLeftChild) y.l=left.l;
else y.r=left.l;
}
return true;
}

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 if("delete".equals(command)) {
n=Integer.parseInt(st.nextToken());
tree.delete(n);
}
else tree.print();
}
out.flush();
}
}

Compiler output:
Main.java:90: error: cannot find symbol
p.id=left.id;
^
  symbol:   variable p
  location: class binarySearchTree
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{
long id;
Node p;
Node l;
Node r;
Node(long id){
this.id=id; this.p=null; this.l=null; this.r=null;
}
}
  
private static Node root;
  
binarySearchTree(){
root=null;
}
  
public static void insert(long 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;
}
  
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 boolean delete(long v){
Node x=root;
Node y=null;
boolean isLeftChild=true;
while(true){
if(x==null) return false;
else if(x.id==v) break;
y=x;
if(v<x.id){
x=x.l;
isLeftChild=true;
}
else{
x=x.r;
isLeftChild=false;
}
}
if(x.l==null){
if(x==root) root=x.r;
else if(isLeftChild) y.l=x.r;
else y.r=x.r;
}
else if(x.r==null){
if(x==root) root=x.l;
else if(isLeftChild) y.l=x.l;
else y.r=x.l;
}
else{
y=x;
Node left=x.l;
isLeftChild=true;
while(left.r!=null){
y=left;
left=left.r;
isLeftChild=false;
}
x.id=left.id;
if(isLeftChild) y.l=left.l;
else y.r=left.l;
}
return true;
}

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();
long n;
if("insert".equals(command)){
n=Integer.parseLong(st.nextToken());
tree.insert(n);
}
else if("find".equals(command)) {
n=Long.parseLong(st.nextToken());
out.println((tree.find(n))?"yes":"no");
}
else if("delete".equals(command)) {
n=Integer.parseLong(st.nextToken());
tree.delete(n);
}
else tree.print();
}
out.flush();
}
}

Compiler output:
Main.java:136: error: cannot find symbol
n=Integer.parseLong(st.nextToken());
         ^
  symbol:   method parseLong(String)
  location: class Integer
Main.java:141: error: incompatible types: possible lossy conversion from long to int
out.println((tree.find(n))?"yes":"no");
                       ^
Main.java:144: error: cannot find symbol
n=Integer.parseLong(st.nextToken());
         ^
  symbol:   method parseLong(String)
  location: class Integer
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
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;
Node(int id){
this.id=id; this.p=null; this.l=null; this.r=null;
}
}
  
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;
}
  
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 boolean delete(int v){
Node x=root;
Node y=null;
boolean isLeftChild=true;
while(true){
if(x==null) return false;
else if(x.id==v) break;
y=x;
if(v<x.id){
x=x.l;
isLeftChild=true;
}
else{
x=x.r;
isLeftChild=false;
}
}
if(x.l==null){
if(x==root) root=x.r;
else if(isLeftChild) y.l=x.r;
else y.r=x.r;
}
else if(x.r==null){
if(x==root) root=x.l;
else if(isLeftChild) y.l=x.l;
else y.r=x.l;
}
else{
y=x;
Node right=x.r;
isLeftChild=false;
while(right.l!=null){
y=right;
right=right.l;
isLeftChild=true;
}
x.id=right.id;
if(isLeftChild) y.l=right.r;
else y.r=left.r;
}
return true;
}

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());
while(num-->0){
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 if("delete".equals(command)) {
n=Integer.parseInt(st.nextToken());
tree.delete(n);
}
else tree.print();
}
out.flush();
}
}

Compiler output:
Main.java:92: error: cannot find symbol
else y.r=left.r;
         ^
  symbol:   variable left
  location: class binarySearchTree
1 error