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

#include <iostream>
#include <vector>

using namespace std;

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

  Node() : id(), parent(-1), left(-1), right(-1) {}
  };

static vector<Node> TREE(25);

static void inputNode(Node& node, int id) {
  node.id = id;
  cin >> node.left >> node.right;
}

static vector<int> preorder(25), inorder(25);

static void inputOrder(vector<int>& order, int num) {
  for (int i = 0; i < num; i++) {
    cin >> order[i];
  }
}

static int current = 0, outIndex = 0;

static int next() {
  int c = preorder[current];
  current++;
  return c;
}

static int find(int c) {
  auto it = find(inorder.begin(), inorder.end(), c); 
  return distance(inorder.begin(), it);
}

static void reconstruction(int l, int r) {
  if (l >= r) {
    return;
  } 
  int c = next();
  int m = find(c);
  reconstruction(l, m);
  reconstruction(m + 1, r);

  if (outIndex != 0) {
    cout << " " << c;
  } else {
    cout << c;
  }
  outIndex++;
}

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

  inputOrder(preorder, n);
  inputOrder(inorder, n);
  reconstruction(0, n);

  cout << endl;

  return 0;
}



Compiler output:
a.cc: In function 'int find(int)':
a.cc:39:17: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   39 |   auto it = find(inorder.begin(), inorder.end(), c);
      |             ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:39:17: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   39 |   auto it = find(inorder.begin(), inorder.end(), c);
      |             ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:38:12: note: candidate: 'int find(int)'
   38 | static int find(int c) {
      |            ^~~~
a.cc:38:12: note:   candidate expects 1 argument, 3 provided
Language: C++

package Main;

import java.util.Scanner;

class Node {
	int id, left, right, parent = -1;

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

public class Main {

	public static void preorder(int i, Node[] node) {
		System.out.print(" " + node[i].id);
		if (node[i].left != -1) {
			preorder(node[i].left, node);
		}
		if (node[i].right != -1) {
			preorder(node[i].right, node);
		}
	}

	public static void inorder(int i, Node[] node) {
		if (node[i].left != -1) {
			inorder(node[i].left, node);
		}
		System.out.print(" " + node[i].id);
		if (node[i].right != -1) {
			inorder(node[i].right, node);
		}
	}

	public static void postorder(int i, Node[] node) {
		if (node[i].left != -1) {
			postorder(node[i].left, node);
		}
		if (node[i].right != -1) {
			postorder(node[i].right, node);
		}
		System.out.print(" " + node[i].id);
	}

	public static void PrIn(int[] pr, int[] in, Node[] node) {
		int i=0;
		while(true){
			if(pr[i]==in[0])break;
			
			i++;
		}
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i, n;
		n = scan.nextInt();
		Node[] node = new Node[n];
		int[] pr = new int[n];
		int[] in = new int[n];
		for (i = 0; i < n; i++) {
			pr[i] = scan.nextInt();
			in[i] = scan.nextInt();
			node[i] = new Node(i, -1, -1);
		}
		PrIn(pr, in, node);
		for (i = 0; i < n; i++) {
			if (node[i].parent == -1) {
				postorder(i, node);
				System.out.println("");
				break;
			}
		}
		scan.close();
	}
}



Compiler output:
a.cc:1:1: error: 'package' does not name a type
    1 | package Main;
      | ^~~~~~~
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:15: error: expected ':' before 'Node'
    8 |         public Node(int Id, int l, int r) {
      |               ^~~~~
      |               :
a.cc:13:2: error: expected ';' after class definition
   13 | }
      |  ^
      |  ;
a.cc:15:1: error: expected unqualified-id before 'public'
   15 | public class Main {
      | ^~~~~~
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

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

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

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

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

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

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

  solve();

  return 0;
}



Compiler output:
a.cc:11:1: error: expected initializer before 'void'
   11 | void rec(int left, int right) {
      | ^~~~
a.cc: In function 'void solve()':
a.cc:24:3: error: 'rec' was not declared in this scope
   24 |   rec(0, pre.size());
      |   ^~~
a.cc:29:13: error: 'post' was not declared in this scope; did you mean 'pos'?
   29 |     cout << post[i]
      |             ^~~~
      |             pos
Language: C++


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

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

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

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

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

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

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

  solve();

  return 0;
}




Compiler output:
a.cc: In function 'void solve()':
a.cc:30:20: error: expected ';' before '}' token
   30 |     cout << post[i]
      |                    ^
      |                    ;
   31 |   }
      |   ~
Language: C++

#include <iostream>
#include <vector>
#include <climits>

using namespace std;

struct Node {
  int id;
  Node* parent = nullptr;
  Node* left = nullptr;
  Node* right = nullptr;
  int depth;
  int height;

  int calcHeight() {
    int leftHeight = left ? left->calcHeight() : -1;
    int rightHeight = right ? right->calcHeight() : -1;
    height = max(leftHeight, rightHeight) + 1;
    return height;
  }

  void calcDepth() {
    depth = parent ? parent->depth + 1 : 0;
    if (left) left->calcDepth();
    if (right) right->calcDepth();
  }

  int degree() {
    int d = 0;
    if (left) ++d;
    if (right) ++d;
    return d;
  }

  Node* sibling() {
    if (!parent) {
      return nullptr;
    }
    if (parent->left == this) {
      return parent->right;
    } else {
      return parent->left;
    }
  }

  void walkPostorder() {
    static bool isFirst = true;
    if (left) left->walkPostorder();
    if (right) right->walkPostorder();
    if (isFirst) {
      cout << (id + 1);
      isFirst = false;
    } else {
      cout << " " << (id + 1);
    }
  }

  static Node* reconstruct(
    vector<Node>& nodes,
    vector<int>::const_iterator preorderBegin, vector<int>::const_iterator preorderEnd,
    vector<int>::const_iterator inorderBegin, vector<int>::const_iterator inorderEnd
  ) {
    if (inorderBegin == inorderEnd) {
      return nullptr;
    }
    auto root = &nodes[*preorderBegin];
    auto inorderMid = std::find_if(inorderBegin, inorderEnd, [&](int id){ return id == *preorderBegin; });
    auto leftCount = inorderMid - inorderBegin;
    auto left = reconstruct(nodes, preorderBegin + 1, preorderBegin + 1 + leftCount, inorderBegin, inorderMid);
    auto right = reconstruct(nodes, preorderBegin + 1 + leftCount, preorderEnd, inorderMid + 1, inorderEnd);
    root->left = left;
    root->right = right;
    return root;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int nodeCount;
  cin >> nodeCount;
  vector<Node> nodes(nodeCount);
  for (int i = 0; i < nodeCount; ++i) {
    nodes[i].id = i;
  }

  std::vector<int> preorderIDs, inorderIDs;

  for (int i = 0; i < nodeCount; ++i) {
    int id;
    cin >> id;
    preorderIDs.push_back(id - 1);
  }

  for (int i = 0; i < nodeCount; ++i) {
    int id;
    cin >> id;
    inorderIDs.push_back(id - 1);
  }

  auto root = Node::reconstruct(nodes, preorderIDs.begin(), preorderIDs.end(), inorderIDs.begin(), inorderIDs.end());

  root->walkPostorder();
  cout << endl;
}



Compiler output:
a.cc: In static member function 'static Node* Node::reconstruct(std::vector<Node>&, std::vector<int>::const_iterator, std::vector<int>::const_iterator, std::vector<int>::const_iterator, std::vector<int>::const_iterator)':
a.cc:67:28: error: 'find_if' is not a member of 'std'; did you mean 'find'?
   67 |     auto inorderMid = std::find_if(inorderBegin, inorderEnd, [&](int id){ return id == *preorderBegin; });
      |                            ^~~~~~~
      |                            find
Language: C++

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

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

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

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

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


Compiler output:
a.cc:10:15: error: expected ',' or '...' before '.' token
   10 | void rec(int l. int r) {
      |               ^
a.cc: In function 'void rec(int)':
a.cc:11:12: error: 'r' was not declared in this scope
   11 |     if (l>=r) return;
      |            ^
a.cc:14:8: error: too many arguments to function 'void rec(int)'
   14 |     rec(1, m);
      |     ~~~^~~~~~
a.cc:10:6: note: declared here
   10 | void rec(int l. int r) {
      |      ^~~
a.cc:15:14: error: 'r' was not declared in this scope
   15 |     rec(m+1, r);
      |              ^
a.cc: In function 'void solve()':
a.cc:21:8: error: too many arguments to function 'void rec(int)'
   21 |     rec(1, pre.size());
      |     ~~~^~~~~~~~~~~~~~~
a.cc:10:6: note: declared here
   10 | void rec(int l. int r) {
      |      ^~~
Language: Java

#include<stdio.h>

int main(){
    
    return0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include<stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include<stdio.h>
        ^
Main.java:6: error: class, interface, enum, or record expected
}
^
3 errors
Language: Java

import java.util.Scanner;
public class Main{
    static tree[] wd;
    static int root =-1;
	public static void main(String[] args) {
	    int i=0,j,n;
	    String x;
	// TODO Auto-generated method stub
     Scanner sca = new Scanner(System.in);
     n=sca.nextInt();
     wd=new tree[n];
    for(j=0;j<n;j++){
       x=sca.next();
    	if(x.equals("insert")){
	    wd[i]=new tree(sca.nextInt());
	    insert(i);
	    i++;
	 }
    	if(x.equals("print")){
    	    inorder(root);
    	    System.out.println("");
    	    preorder(root);
    	    System.out.println("");  		
    	}
    }
   }
    public static void preorder(int nd){
	System.out.print(" "+wd[nd].getnode());
	if(wd[nd].getleft()!=-1)preorder(wd[nd].getleft());
	if(wd[nd].getright()!=-1)preorder(wd[nd].getright());
    }
    public static void inorder(int nd){
	if(wd[nd].getleft()!=-1)inorder(wd[nd].getleft());
	System.out.print(" "+wd[nd].getnode());
	if(wd[nd].getright()!=-1)inorder(wd[nd].getright());
    }
    public static void insert(int data){//NIL->-1
     int y=-1,x=root;//parent of x
     while(x!=-1){
    	y=x;
    	if(wd[data].getnode()<wd[x].getnode()){
    		x=wd[x].getleft();
    	}else{
    		x=wd[x].getright();
    	}
    }
     wd[data].setpar(y);
     if (y==-1){//it is root
    	 root=data;
     }else if(wd[data].getnode()<wd[y].getnode()){
    	 wd[y].setleft(data);
     }else{
    	 wd[y].setright(data);
     }
    }
}
class tree{
    int node,par,n,i,degree=0;
    int left=-1,right=-1;
    tree(int node){
	this.node=node;
    }
    public int getnode(){
	return node;
    }
    public void setleft(int c){
	left=c;
	if(left!=-1) degree++;
    }
    public int getleft(){
	return left;
    }
    public void setright(int c){
	right=c;
	if(right!=-1) degree++;
    }
    public int getright(){
	return right;
    }
}



Compiler output:
Main.java:47: error: cannot find symbol
     wd[data].setpar(y);
             ^
  symbol:   method setpar(int)
  location: class tree
1 error
Language: Java

import java.util.Scanner;

class Main {
  private final static String INSERT = "insert";
  private static Tree ROOT = null;
  private static Tree END = null;

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int times = Integer.parseInt(sc.next());

    for (int i = 0; i < times; i++) {
      if (sc.next().equals(INSERT)) {
        insert(Integer.parseInt(sc.next());
      } else {
        createBuilderInorder(ROOT);
        System.out.println();
        createBuilderByRoot(ROOT);
        System.out.println();
      }
    }
  }

  public static void insert(int key) {
    Tree y = null;
    Tree x = ROOT;
    Tree z = new Tree();
    z.key = key;

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

    z.parent = y;

    if (y == null) {
      ROOT = z;
    } else if (z.key < y.key) {
      y.left = z;
    } else {
      y.right = z;
    }
  }

  public static void createBuilderInorder(Tree tree) {
    if (tree != null) {
      createBuilderInorder(tree.left);
      System.out.print(" ");
      System.out.print(tree.key);
      createBuilderInorder(tree.right);
    }
  }

  public static void createBuilderByRoot(Tree tree) {
    if (tree != null) {
      System.out.print(" ");
      System.out.print(tree.key);
      createBuilderByRoot(tree.left);
      createBuilderByRoot(tree.right);
    }
  }
}

class Tree {
  public int key;
  public Tree left;
  public Tree right;
  public Tree parent;

  public Tree() { }
}


Compiler output:
Main.java:14: error: ')' or ',' expected
        insert(Integer.parseInt(sc.next());
                                          ^
1 error
Language: Java

import java.util.*;

//二分探索木の節を表すクラスNode
//Javaプログラマのためのアルゴリズムとデータ構造 p.221参照
class Node{
	Integer data;
	Node left;
	Node right;
	Node(Integer data){
		left = null;
		right = null;
		this.data = data;
	}
}

//二分探索木を表すクラスBinarySearchTree
//Javaプログラマのためのアルゴリズムとデータ構造 p.223参照
public class Main{
	Scanner sc = new Scanner(System.in);
	private static Node root;
	//命令の数m
	int m;
	//命令insert or print
	String order;
	//挿入するデータ
	int[] T;
	public ProblemA() {
		root = null;
	}
	//二分探索木にキーkeyを持つ節を挿入するメソッド
	public Node insert(Integer key) {
		Node p = root;
		//parentは現在注目している節の親
		Node parent = null;
		//pがparentの左の子ならtrue,右の子ならfalseを返す
		boolean isLeftChild = false;
		//注目している節がある限り処理を繰り返す
		while(p != null) {
			int result = key.compareTo(p.data);
			//節とキーを比較し、等しければすでに登録されているためnullを返す
			if(result == 0) {
				return null;
			//キーの方が小さければ左部分木
			}else if(result < 0) {
				parent = p;
				isLeftChild = true;
				p = p.left;
			//キーの方が大きければ右部分木
			}else {
				parent = p;
				isLeftChild = false;
				p = p.right;
			}
		}
		//新しい節を適切な場所に挿入する
		//新しい節を割り当てる
		Node newNode = new Node(key);
		if(parent == null) {
			//新しい節は根となるため、rootに新しい節を代入する
			root = newNode;
		}else if(isLeftChild) {
			//節parentの左の子になる
			parent.left = newNode;
		}else {
			//節parentの右の子になる
			parent.right = newNode;
		}
		return newNode;
	}
	//データを入力するメソッド
	public void input() {
		m = sc.nextInt();
		T = new int[m];
		for(int i=0; i<m; i++) {
			order = sc.next();
			if(order.equals("print")) {
				inorder(root);
				System.out.println();
				preorder(root);
			}else {
				T[i] = sc.nextInt();
				insert(T[i]);
			}
		}
	}
	//通りがけ順に出力するメソッド
	//Javaプログラマのためのアルゴリズムとデータ構造 p.242参照
	public void inorder(Node p) {
		if(p == null) {
			return;
		}else {
			inorder(p.left);
			System.out.print(" "+p.data);
			inorder(p.right);
		}
	}
	//行きがけ順に出力するメソッド
	//Javaプログラマのためのアルゴリズムとデータ構造 p.172参照
	public void preorder(Node p) {
		if(p == null) {
			return;
		}else {
			System.out.print(" "+p.data);
			preorder(p.left);
			preorder(p.right);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
	}
}


Compiler output:
Main.java:27: error: invalid method declaration; return type required
	public ProblemA() {
	       ^
1 error
Language: Java

import java.util.*;
//二分探索木の節を表すクラスNode
//Javaプログラマのためのアルゴリズムとデータ構造 p.221参照
class Node{
	Integer data;
	Node left;
	Node right;
	Node(Integer data){
		left = null;
		right = null;
		this.data = data;
	}
}

//二分探索木を表すクラスBinarySearchTree
//Javaプログラマのためのアルゴリズムとデータ構造 p.223参照
public class Main{
	Scanner sc = new Scanner(System.in);
	private static Node root;
	//命令の数m
	int m;
	//命令insert or print
	String order;
	//挿入するデータ
	int[] T;
	public ProblemA() {
		root = null;
	}
	//二分探索木にキーkeyを持つ節を挿入するメソッド
	public Node insert(Integer key) {
		Node p = root;
		//parentは現在注目している節の親
		Node parent = null;
		//pがparentの左の子ならtrue,右の子ならfalseを返す
		boolean isLeftChild = false;
		//注目している節がある限り処理を繰り返す
		while(p != null) {
			int result = key.compareTo(p.data);
			//節とキーを比較し、等しければすでに登録されているためnullを返す
			if(result == 0) {
				return null;
			//キーの方が小さければ左部分木
			}else if(result < 0) {
				parent = p;
				isLeftChild = true;
				p = p.left;
			//キーの方が大きければ右部分木
			}else {
				parent = p;
				isLeftChild = false;
				p = p.right;
			}
		}
		//新しい節を適切な場所に挿入する
		//新しい節を割り当てる
		Node newNode = new Node(key);
		if(parent == null) {
			//新しい節は根となるため、rootに新しい節を代入する
			root = newNode;
		}else if(isLeftChild) {
			//節parentの左の子になる
			parent.left = newNode;
		}else {
			//節parentの右の子になる
			parent.right = newNode;
		}
		return newNode;
	}
	//データを入力するメソッド
	public void input() {
		m = sc.nextInt();
		T = new int[m];
		for(int i=0; i<m; i++) {
			order = sc.next();
			if(order.equals("print")) {
				inorder(root);
				System.out.println();
				preorder(root);
			}else {
				T[i] = sc.nextInt();
				insert(T[i]);
			}
		}
	}
	//通りがけ順に出力するメソッド
	//Javaプログラマのためのアルゴリズムとデータ構造 p.242参照
	public void inorder(Node p) {
		if(p == null) {
			return;
		}else {
			inorder(p.left);
			System.out.print(" "+p.data);
			inorder(p.right);
		}
	}
	//行きがけ順に出力するメソッド
	//Javaプログラマのためのアルゴリズムとデータ構造 p.172参照
	public void preorder(Node p) {
		if(p == null) {
			return;
		}else {
			System.out.print(" "+p.data);
			preorder(p.left);
			preorder(p.right);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
	}
}


Compiler output:
Main.java:26: error: invalid method declaration; return type required
	public ProblemA() {
	       ^
1 error
Language: Java

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

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;
}
}

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++;
}

static void print(){
inorder(root.id);
out.println();
preorder(root.id);
out.println();
}

static void preorder(int now){
if(now<0) return;
out.print(" "+now);
preorder(ns[now].l.id);
preorder(ns[now].r.id);
}
 
static void inorder(int now){
if(now<0) return;
inorder(ns[now].l.id);
out.print(" "+now);
inorder(ns[now].r.id);
}
 
static void postorder(int now){
if(now<0) return;
postorder(ns[now].l.id);
postorder(ns[now].r.id);
out.print(" "+now);
}
}

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

Compiler output:
Main.java:28: error: non-static variable root cannot be referenced from a static context
if(root==null) root=new Node(v);
   ^
Main.java:28: error: non-static variable root cannot be referenced from a static context
if(root==null) root=new Node(v);
               ^
Main.java:33: error: non-static variable root cannot be referenced from a static context
Node x=root;
       ^
Main.java:47: error: non-static variable root cannot be referenced from a static context
inorder(root.id);
        ^
Main.java:49: error: non-static variable root cannot be referenced from a static context
preorder(root.id);
         ^
Main.java:56: error: cannot find symbol
preorder(ns[now].l.id);
         ^
  symbol:   variable ns
  location: class Main.binarySearchTree
Main.java:57: error: cannot find symbol
preorder(ns[now].r.id);
         ^
  symbol:   variable ns
  location: class Main.binarySearchTree
Main.java:62: error: cannot find symbol
inorder(ns[now].l.id);
        ^
  symbol:   variable ns
  location: class Main.binarySearchTree
Main.java:64: error: cannot find symbol
inorder(ns[now].r.id);
        ^
  symbol:   variable ns
  location: class Main.binarySearchTree
Main.java:69: error: cannot find symbol
postorder(ns[now].l.id);
          ^
  symbol:   variable ns
  location: class Main.binarySearchTree
Main.java:70: error: cannot find symbol
postorder(ns[now].r.id);
          ^
  symbol:   variable ns
  location: class Main.binarySearchTree
Main.java:78: error: cannot find symbol
binarySearchTree tree=new binarySearchtree();
                          ^
  symbol:   class binarySearchtree
  location: class Main
12 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;
}
}

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++;
}

static void print(){
inorder(root.id);
out.println();
preorder(root.id);
out.println();
}

static void preorder(int now){
if(now<0) return;
out.print(" "+now);
preorder(ns[now].l.id);
preorder(ns[now].r.id);
}
 
static void inorder(int now){
if(now<0) return;
inorder(ns[now].l.id);
out.print(" "+now);
inorder(ns[now].r.id);
}
 
static void postorder(int now){
if(now<0) return;
postorder(ns[now].l.id);
postorder(ns[now].r.id);
out.print(" "+now);
}
}

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

Compiler output:
Main.java:28: error: non-static variable root cannot be referenced from a static context
if(root==null) root=new Node(v);
   ^
Main.java:28: error: non-static variable root cannot be referenced from a static context
if(root==null) root=new Node(v);
               ^
Main.java:33: error: non-static variable root cannot be referenced from a static context
Node x=root;
       ^
Main.java:47: error: non-static variable root cannot be referenced from a static context
inorder(root.id);
        ^
Main.java:49: error: non-static variable root cannot be referenced from a static context
preorder(root.id);
         ^
Main.java:56: error: cannot find symbol
preorder(ns[now].l.id);
         ^
  symbol:   variable ns
  location: class binarySearchTree
Main.java:57: error: cannot find symbol
preorder(ns[now].r.id);
         ^
  symbol:   variable ns
  location: class binarySearchTree
Main.java:62: error: cannot find symbol
inorder(ns[now].l.id);
        ^
  symbol:   variable ns
  location: class binarySearchTree
Main.java:64: error: cannot find symbol
inorder(ns[now].r.id);
        ^
  symbol:   variable ns
  location: class binarySearchTree
Main.java:69: error: cannot find symbol
postorder(ns[now].l.id);
          ^
  symbol:   variable ns
  location: class binarySearchTree
Main.java:70: error: cannot find symbol
postorder(ns[now].r.id);
          ^
  symbol:   variable ns
  location: class binarySearchTree
Main.java:78: error: cannot find symbol
binarySearchTree tree=new binarySearchtree();
                          ^
  symbol:   class binarySearchtree
  location: class Main
12 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;
}

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++;
}

static void print(){
inorder(root);
out.println();
preorder(root);
out.println();
}

static void preorder(Node now){
if(now.id<0) return;
out.print(" "+now.id);
preorder(now.l.id);
preorder(now.r.id);
}
 
static void inorder(Node now){
if(now.id<0) return;
inorder(now.l.id);
out.print(" "+now.id);
inorder(now.r.id);
}
 
static void postorder(Node now){
if(now.id<0) return;
postorder(now.l.id);
postorder(now.r.id);
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=Integer.parseInt(st.nextToken());
if("insert".equals(command)) tree.insert(n);
else tree.print();
}
out.flush();
}
}

Compiler output:
Main.java:56: error: incompatible types: int cannot be converted to Node
preorder(now.l.id);
              ^
Main.java:57: error: incompatible types: int cannot be converted to Node
preorder(now.r.id);
              ^
Main.java:62: error: incompatible types: int cannot be converted to Node
inorder(now.l.id);
             ^
Main.java:64: error: incompatible types: int cannot be converted to Node
inorder(now.r.id);
             ^
Main.java:69: error: incompatible types: int cannot be converted to Node
postorder(now.l.id);
               ^
Main.java:70: error: incompatible types: int cannot be converted to Node
postorder(now.r.id);
               ^
Main.java:78: error: cannot find symbol
binarySearchTree tree=new binarySearchtree();
                          ^
  symbol:   class binarySearchtree
  location: class Main
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
7 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;
}

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

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++;
}

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

Compiler output:
Main.java:84: error: variable declaration not allowed here
if(st.hasMoreTokens()) int n=Integer.parseInt(st.nextToken());
                           ^
1 error
Language: Java


class Node():
	def __init__(self, key):
		self.parent = None
		self.left = None
		self.right = None
		self.key = key

class Tree():
	def __init__(self):
		self.root = None
	def insert(self, key):
		z = Node(key)
		y = None
		x = self.root
		while x:
			y = x
			if z.key < x.key:
				x = x.left
			else:
				x = x.right
		z.parent = y
		if y == None:
			self.root = z;
		elif z.key < y.key:
			y.left = z
		else:
			y.right = z
	def pre_order(self, node):
		print(" {}".format(node.key), end = "")
		if node.left:
			self.pre_order(node.left)
		if node.right:
			self.pre_order(node.right)
	def in_order(self, node):
		if node.left:
			self.in_order(node.left)
		print(" {}".format(node.key), end = "")
		if node.right:
			self.in_order(node.right)
	def out(self):
		self.in_order(self.root)
		print("")
		self.pre_order(self.root)

tree = Tree()
n = int(input())
for i in range(n):
	c = input().split()
	if c[0] == "insert":
		tree.insert(int(c[1]))
	else:
		tree.out()

Compiler output:
Main.java:2: error: '{' expected
class Node():
          ^
Main.java:9: error: '{' expected
class Tree():
          ^
Main.java:18: error: class, interface, enum, or record expected
			if z.key < x.key:
			         ^
Main.java:25: error: class, interface, enum, or record expected
		elif z.key < y.key:
		^
4 errors
Language: Java

import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scaner scan = new Scanner(System.in);

    int input1 = scan.nextInt();

    Tree main = new Tree(-2147483648);

    for(int loopCount = 0; loopCount < input1; loopCount++) {
      char[] s = scan.next().toCharArray();
      if(s[0]=='i') main.insert(scan.nextInt());
      else if(s[0]=='p') {
        if(main.right != null) {
          main.right.printMiddle();
          System.out.println();
          main.right.printFirst();
          System.out.println();
        }
      }
    }
  }
}

class Tree{
  int key;
  Tree left,right;

  Tree(int _key) {
    this.key = _key;
  }

  void insert(int _num) {
    if(key<_num) {
      if(right == null) {
        right = new Tree(_num);
      }else {
        right.insert(_num);
      }
    }else if(key>_num) {
      if(left == null) {
        left = new Tree(_num);
      }else {
        left.insert(_num);
      }
    }
  }

  String find(int _num) {
    if(key == _num) return "YES";
    else {
      if(key > _num) return left.find(_num);
      if(key < _num) return right.find(_num);
      return "NO";
    }
  }

  void printFirst() {
    System.out.print(" "+key);
    if(left!=null) left.printFirst();
    if(right!=null) right.printFirst();
  }

  void printMiddle() {
    if(left!=null) left.printMiddle();
    System.out.print(" "+key);
    if(right!=null) right.printMiddle();
  }
}

Compiler output:
Main.java:5: error: cannot find symbol
    Scaner scan = new Scanner(System.in);
    ^
  symbol:   class Scaner
  location: class Main
1 error
Language: Java

import java.util.Scanner;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

class Node {
  Node left;
  Node right;
  int value;

  public Node (int x) {
    this.value = x;
    this.left = null;
    this.right = null;
  }

  public void insert(int x) {
    if (x < this.value) {
      if (left == null) {
        left = new Node(x);
        return;
      } else {
        left.insert(x);
        return;
      }
    } else {
      if (right == null) {
        right = new Node(x);
        return;
      } else {
        right.insert(x);
        return;
      }
    }
  }

  public void getStringInOrder(StringBuilder buf){
    if (left != null) {
      left.getStringInOrder(buf);
    }

    process(buf);

    if (right != null) {
      right.getStringOrder(buf);
    }
  }

  public void getStringPreOrder(StringBuilder buf){
    process(buf);

    if (left != null) {
      left.getStringPreOrder(buf);
    }

    if (right != null) {
      right.getStringPreOrder(buf);
    }
  }


  private void process(StringBuilder buf) {
    buf.append(value);
    buf.append(" ");
  }
}

class BinaryTree {
  Node root;

  public BinaryTree() {}

  public void insert(int x) {
    if (root == null) {
      root = new Node(x);
      return;
    }

    if (x < root.value) {
      if (root.left == null) {
        root.left = new Node(x);
        return;
      } else {
        root.left.insert(x);
        return;
      }
    } else {
      if (root.right == null) {
        root.right = new Node(x);
        return;
      } else {
        root.right.insert(x);
        return;
      }
    }
  }

  public void printInOrder() {
    if (root != null) {
      StringBuilder buf = new StringBuilder();
      root.getStringInOrder(buf);
      System.out.println(buf.toString().trim());
    }
  }

  public void printPreOrder() {
    if (root != null) {
      StringBuilder buf = new StringBuilder();
      root.getStringPreOrder(buf);
      System.out.println(buf.toString().trim());
    }
  }

  public void print() {
    printInOrder();
    printPreOrder();
  }
}



public class Main {
  private static int N;
  final static String INSERT = "insert";
  final static String PRINT = "print";

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    BinaryTree tree = new BinaryTree();

    for (int i = 0; i < N; i++) {
      String cmd = in.next();
      switch(cmd) {
        case INSERT:
          tree.insert(in.nextInt());
          break;
        case PRINT:
          tree.print();
          break;
        default:
          System.out.println("Error");
          System.exit(1);
      }
    }
  }
}

Compiler output:
Main.java:45: error: cannot find symbol
      right.getStringOrder(buf);
           ^
  symbol:   method getStringOrder(StringBuilder)
  location: variable right of type Node
1 error
Language: Java

11
insert 8
insert 2
insert 3
insert 7
insert 22
insert 1
insert 10
insert 9
insert 15
insert 13
print
 1 2 3 7 8 9 10 13 15 22
 8 2 1 3 7 22 10 9 15 13
ozawa@ozamac-2:~/workspace/algo$ cat Main.java 
import java.util.Scanner;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

class Node {
  Node left;
  Node right;
  int value;

  public Node (int x) {
    this.value = x;
    this.left = null;
    this.right = null;
  }

  public void insert(int x) {
    if (x < this.value) {
      if (left == null) {
        left = new Node(x);
        return;
      } else {
        left.insert(x);
        return;
      }
    } else {
      if (right == null) {
        right = new Node(x);
        return;
      } else {
        right.insert(x);
        return;
      }
    }
  }

  public void printInOrder(){
    if (left != null) {
      left.printInOrder();
    }

    process();

    if (right != null) {
      right.printInOrder();
    }
  }

  public void printPreOrder(){
    process();

    if (left != null) {
      left.printPreOrder();
    }

    if (right != null) {
      right.printPreOrder();
    }
  }


  private void process() {
    System.out.print(" ");
    System.out.print(value);
  }
}

class BinaryTree {
  Node root;

  public BinaryTree() {}

  public void insert(int x) {
    if (root == null) {
      root = new Node(x);
      return;
    }

    if (x < root.value) {
      if (root.left == null) {
        root.left = new Node(x);
        return;
      } else {
        root.left.insert(x);
        return;
      }
    } else {
      if (root.right == null) {
        root.right = new Node(x);
        return;
      } else {
        root.right.insert(x);
        return;
      }
    }
  }

  public void printInOrder() {
    if (root != null) {
      root.printInOrder();
    }
    System.out.println();
  }

  public void printPreOrder() {
    if (root != null) {
      root.printPreOrder();
    }
    System.out.println();
  }

  public void print() {
    printInOrder();
    printPreOrder();
  }
}



public class Main {
  private static int N;
  final static String INSERT = "insert";
  final static String PRINT = "print";

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    BinaryTree tree = new BinaryTree();

    for (int i = 0; i < N; i++) {
      String cmd = in.next();
      switch(cmd) {
        case INSERT:
          tree.insert(in.nextInt());
          break;
        case PRINT:
          tree.print();
          break;
        default:
          System.out.println("Error");
          System.exit(1);
      }
    }
  }
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
11
^
Main.java:15: error: class, interface, enum, or record expected
ozawa@ozamac-2:~/workspace/algo$ cat Main.java 
            ^
Main.java:17: error: class, interface, enum, or record expected
import java.lang.Integer;
^
Main.java:18: error: class, interface, enum, or record expected
import java.lang.StringBuilder;
^
Main.java:19: error: class, interface, enum, or record expected
import java.lang.Math;
^
5 errors
Language: Java

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

public class Main {
	public static Node root;
	public static final String INSERT = "insert";
	
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n =Integer.parseInt(br.readLine());
		
		for(int i = 0 ; i < n ; i++){
			String tmp = br.readLine();
			if(tmp.startsWith(INSERT)){
				insert(new Node(Integer.parseInt((tmp.substring(INSERT.length() + 1)))));
			}else if(tmp.startsWith("print")){
				print();
			}else{
				System.out.print("Error!!");
				System.exit(1);
			}
		}
		
	}
	
	private static void insert(Node node){
		if(root == null){
			root = node;
			return;
		}else{
			Node currentNode = root;
			Node parent = null;
			while(currentNode != null){
				parent = currentNode;
				if(node.id < currentNode.id){
					currentNode = currentNode.left;
				}else{
					currentNode = currentNode.right;
				}
			}
			
			node.parent = parent;
			
			if(node.id < parent.id){
				parent.left = node;
			}else{
				parent.right = node;
			}
		}
	}
	
	private static void print(){
		StringBuffer isb = new StringBuffer();
		inorderPrint(root,isb);
		System.out.println(isb.toString());
		StringBuffer psb = new StringBuffer();
		postorderPrint(root,psb);
		System.out.print(psb.toString());
	}
	
	private static void inorderPrint(Node node,StringBuffer sb){
		if(node == null){
			return;
		}
		inorderPrint(node.left,sb);
		sb.append(" ");
		sb.append(node.id);
		inorderPrint(node.right,sb);
	}
	
	private static void postorderPrint(Node node,StringBuffer sb){
		if(node == null){
			return;
		}
		sb.append(" ");
		sb.append(node.id);
		postorderPrint(node.left,sb);
		postorderPrint(node.right,sb);
	}
	
}

Compiler output:
Main.java:5: error: cannot find symbol
	public static Node root;
	              ^
  symbol:   class Node
  location: class Main
Main.java:26: error: cannot find symbol
	private static void insert(Node node){
	                           ^
  symbol:   class Node
  location: class Main
Main.java:61: error: cannot find symbol
	private static void inorderPrint(Node node,StringBuffer sb){
	                                 ^
  symbol:   class Node
  location: class Main
Main.java:71: error: cannot find symbol
	private static void postorderPrint(Node node,StringBuffer sb){
	                                   ^
  symbol:   class Node
  location: class Main
Main.java:15: error: cannot find symbol
				insert(new Node(Integer.parseInt((tmp.substring(INSERT.length() + 1)))));
				           ^
  symbol:   class Node
  location: class Main
Main.java:31: error: cannot find symbol
			Node currentNode = root;
			^
  symbol:   class Node
  location: class Main
Main.java:32: error: cannot find symbol
			Node parent = null;
			^
  symbol:   class Node
  location: class Main
7 errors
Language: Java

import java.io.*;
public class Main {
        static NODE node;
        static NODE root;
        public static void main(String[] args) throws IOException{
                BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 
                int n=Integer.parseInt(br.readLine());
                
                for(int i=0;i<n;i++){
                        String[] str=br.readLine().split(" ");
                
                        if("print".equals(str[0])) {
                                inorder(root);
                                System.out.println(""); 
                                preorder(root);
                                System.out.println(""); 
                        }
                        else if("insert".equals(str[0])){
                                int key=Integer.parseInt(str[1]);
                                NODE newnode=new NODE();
                                newnode.key=key;
                                insert(newnode);
                        }

                }
        }

        static void inorder(NODE node){
                if(node==null) return;
                inorder(node.left);
                System.out.print(" " + node.key);
                inorder(node.right);
        }
        
        static void preorder(NODE node){                
                if(node==null) return;
                System.out.print(" " + node.key);
                preorder(node.left);
                preorder(node.right);   
        }
        
        static void insert(NODE node){
        if(root==null){
            root = node;
            return;
        }
        NODE tnode = root;
        NODE parent = null;
        while(tnode != null) {
            parent = tnode;
            if(tnode.key > node.key)
                tnode = tnode.left;
            else
                tnode = tnode.right;
        }
        if(parent.key > node.key)
            parent.left = node;
        else
            parent.right = node;
                
        }
}

class NODE{
        int key;
        NODE left;
        NODE right;;
        NODE(){
                key=-1;
                left=null;
                right=null;
        }

Compiler output:
Main.java:72: error: reached end of file while parsing
        }
         ^
1 error
Language: Java

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

public class Main {
	
	public static final String INSERT = "insert";
	public static final String PRINT = "print";
	public static Node root; 

	public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //????????°?????????
        int commandNum =Integer.parseInt(br.readLine());
        //root(????????????)
        root = null;
        //????????°?????????????????????
        for(int i = 0 ; i < commandNum; i++){
                	execute(br);
        }
	}
	
	private static void execute(BufferedReader br) throws Exception{
		String tmp = br.readLine();
		
			insert(Integer.parseInt(tmp.substring(INSERT.length() + 1)));
			print();
		}
		
	}
	
	private static void insert(int key){
		Node node = makeNode(key);
		if(root == null){
			root = node;
		}else{
			Node comparisonNode = root;
			Node parentNode = null;
			LR LRFlag = null;
			
			while(comparisonNode != null){
				parentNode = comparisonNode;
				if(node.getKey() < comparisonNode.getKey()){
					comparisonNode = comparisonNode.getLeft();
					LRFlag = LR.LEFT;
				}else if(node.getKey() > comparisonNode.getKey()){
					comparisonNode = comparisonNode.getRight();
					LRFlag = LR.RIGHT;
				}
			}
			
			node.setParent(parentNode);
			
			if(LRFlag == LR.LEFT){
				parentNode.setLeft(node);
			}else if(LRFlag == LR.RIGHT){
				parentNode.setRight(node);
			}
		}
	}
	
	private static Node makeNode(int key){
		return new Node(key);
	}
	
	private static void print(){
		StringBuffer sb = new StringBuffer();
		
		inorderPrint(root,sb);
		System.out.println(sb.toString());
		
		sb.delete(0,sb.length() - 1);
		
		preorderPrint(root,sb);
		System.out.print(sb.toString());
	}
	
	private static void inorderPrint(Node node,StringBuffer sb){
		if(node == null){
			return;
		}
		inorderPrint(node.getLeft(),sb);
		sb.append(" ");
		sb.append(node.getKey());
		inorderPrint(node.getRight(),sb);
	}
	
	private static void preorderPrint(Node node,StringBuffer sb){
		if(node == null){
			return;
		}
		sb.append(" ");
		sb.append(node.getKey());
		preorderPrint(node.getLeft(), sb);
		preorderPrint(node.getRight(), sb);
	}
	
	enum LR{
		LEFT,RIGHT;
	}

}

class Node{
	
	private int key;
	private Node left;
	private Node right;
	private Node parent;
	
	public Node(int key){
		this.key = key;
	}
	
	public int getKey() {
		return key;
	}
	public void setKey(int key) {
		this.key = key;
	}
	public Node getLeft() {
		return left;
	}
	public void setLeft(Node left) {
		this.left = left;
	}
	public Node getRight() {
		return right;
	}
	public void setRight(Node right) {
		this.right = right;
	}
	public Node getParent() {
		return parent;
	}
	public void setParent(Node parent) {
		this.parent = parent;
	}
}

Compiler output:
Main.java:31: error: unnamed classes are a preview feature and are disabled by default.
	private static void insert(int key){
	               ^
  (use --enable-preview to enable unnamed classes)
Main.java:101: error: class, interface, enum, or record expected
}
^
2 errors