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

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

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

Node *root, *NIL;

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

    z -> key = k;
    z -> left = NIL;
    z -> right = NIL;

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

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

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

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

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

    scanf("%d", &n);

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

    return 0;
}


Compiler output:
a.cc: In function 'void insert(int)':
a.cc:18:12: error: found ':' in nested-name-specifier, expected '::'
   18 |     Node *z:
      |            ^
      |            ::
a.cc:18:11: error: 'z' has not been declared
   18 |     Node *z:
      |           ^
a.cc:20:7: error: qualified-id in declaration before '=' token
   20 |     z = new Node;
      |       ^
a.cc:22:5: error: 'z' was not declared in this scope
   22 |     z -> key = k;
      |     ^
Language: C++

#include<stdio.h>
#include<stdlib.h>
 #define MAX 500001
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node r;
 
void insert(int);
void inorder(Node);
void preorder(Node);
 
void insert(int k){
  Node y = NULL;
  Node x = r;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;
 
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
    z->parent = y;
  }
 
  if(y == NULL) r = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
 
}
 
void inorder(Node u){
    if(u->left != NULL) inorder(u->left);
    printf(" %d", u->key);
    if(u->right != NULL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NULL) preorder(u->left);
  if(u->right != NULL) preorder(u->right);
}
 
 
int main(){
  int i,j,n;
  int x[MAX];
  char com[MAX][7];
  Node t;
 
  scanf("%d", &n);
 
  for( i = 0, j = 0;i < n;i++){
    scanf("%s", com[i]);
    if(com[i][0] == 'i'){
      scanf("%d", &x[j]);
      j++;
    }
  }
   
  r= malloc(sizeof(struct node));
  t = malloc(sizeof(struct node));
  r->left = NULL;
  r->right = NULL;
  r->parent = NULL;
 
  t = r;
 
  for( i = 0,j = 0;i < n;i++){
    if(com[i][0] == 'i' && i == 0){
      r->key = x[j];
      j++;
    }
    else if(com[i][0] == 'i'){
      insert(x[j]);
      j++;
    }
    else {
      inorder(t);
      printf("\n");
      preorder(t);
      printf("\n");
    }
  }
 
  free(r);
  return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:22:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   22 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
a.cc: In function 'int main()':
a.cc:68:12: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   68 |   r= malloc(sizeof(struct node));
      |      ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |            |
      |            void*
a.cc:69:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   69 |   t = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

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

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

void insert(struct node*, int, int);
void print1(struct node*, int);
void print2(struct node*, int);

int main()
{
	char s[10];
	struct node *t;
	int m, a;

	scanf("%d", &m);
	t=(struct node*)malloc(sizeof(struct node)*m);

	for(int i=0; i<m; i++){
		scanf("%s %d", &s, &a);
		if(s[0]=='i') insert(t, i, a);
		if(s[0]=='p'){
			print1(t, 0); print("\n");
			print2(t, 0); print("\n");
		}
	}

	/*for(int i=0; i<m; i++){
		printf("%d %d %d %d\n", t[i].key, t[i].left, t[i].right, t[i].parent);
	}*/
	
	return 0;

}

void print1(struct node *t, int p)
{
	if(t[p].left>=0) print1(t, t[p].left);
	printf("%d ", t[p].key);
	if(t[p].right>=0) print1(t, t[p].right);
}

void print2(struct node *t, int p)
{
	printf("%d ", t[p].key);
	if(t[p].left>=0) print2(t, t[p].left);
	if(t[p].right>=0) print2(t, t[p].right);
}

void insert(struct node *t, int count, int z)
{
	int x, y;
	if(count<1){ x=-1; y=-1; }

	t[count].key = z;
	t[count].left = -1;
	t[count].right= -1;

	while(x>=0){
		y = x; // ???????¨????
		if(z < t[x].key)
			x = t[x].left; // ?????????????§????
		else 
			x = t[x].right; // ?????????????§????
	}
	t[count].parent = y;

	if(count<1){}
	else if(z < t[y].key){
		t[y].left = count; // z ??? y ?????????????????????
	}
	else {
		t[y].right = count; // z ??? y ?????????????????????
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:39: error: 'print' was not declared in this scope; did you mean 'printf'?
   28 |                         print1(t, 0); print("\n");
      |                                       ^~~~~
      |                                       printf
Language: C++

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

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

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
/*
Node treeMinimum(Node x){
    
    
}

Node treeSearch(Node u, int k){
    
    
}

Node treeSuccessor(Node x){
    
    
}

void treeDelete(Node z){
    Node y; // node to be deleted
    Node x; // child of y
    
    
    
}
*/

void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct 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;
    
    if (u->left != NIL) inorder(u->left);
    
    printf(" %d", u->key);
    
    if(u->right != NIL) inorder(u->right);
    
}

//?????????
void pre_order(Node u){
    if (u == NIL) return;
    
    printf(" %d", u->key);
    if(u->left != NIL) pre_order(u->left);
    if(u->right != NIL) pre_order(u->right);
}


int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'f' ){
            scanf("%d", &x);
            /*Node t = treeSearch(root, x);
            if ( t != NIL ) printf("yes\n");
            else printf("no\n");*/
        } else if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            pre_order(root);
            printf("\n");
        } else if ( com[0] == 'd' ){
            scanf("%d", &x);
            /*treeDelete(treeSearch(root, x));*/
        }
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:52:15: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   52 |     z = malloc(sizeof(struct node));
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |               |
      |               void*
Language: C++


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

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

Node *root ,*NIL;

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

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

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

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

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

int main(){
    int n,x;
    string com;
    cin >> n;

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

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:17:5: error: 'NOde' was not declared in this scope; did you mean 'Node'?
   17 |     NOde *x = root;
      |     ^~~~
      |     Node
a.cc:17:11: error: 'x' was not declared in this scope
   17 |     NOde *x = root;
      |           ^
Language: C++

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

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

typedef struct node * Node;
Node root;

void insert(int a){

  Node y = NULL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = a;
  z->left = NULL;
  z->right = NULL;

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

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

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

int main(){
  int n, i, x;
  char num[20];
  scanf("%d", &n);
  root = NULL;

  for ( i = 0; i < n; i++ ){
    scanf("%s", num);
    if ( num[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
     else if ( num[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:20:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   20 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

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

#define NIL NULL

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

Node root;

Node treeMinimum(Node);
Node treeSearch(Node, int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

int main(){
  int n, i, x;
  char com[20];
  scanf("%d",&n);

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

  return 0;
}

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)return u;

  if(k < u->key)return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL)x = y->left;
  else x = y->right;

  if(x != NIL)x->parent = y->parent;

  if(y->parent == NIL)root = x;
  else if(y == y->parent->left)y->parent->left = x;
  else y->parent->right = x;

  if(y != z){
    z->key =y->key;

  }
}

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

  z = malloc(sizeof(struct 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);
  
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:100:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
  100 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<istream>

using namespace std;

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

Node *root,*NIL;

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

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

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

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

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

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

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

  scanf("%d",&n);

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

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:69:20: error: expected ';' before ')' token
   69 |   for( i = 0; i < n){
      |                    ^
      |                    ;
a.cc:70:5: error: 'cin' was not declared in this scope
   70 |     cin >> com;
      |     ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include<istream>
  +++ |+#include <iostream>
    5 |
Language: C++

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

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

Node *root, *NIL;

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

void inorder(Node *k){
  if(k == NIL){
    return;
  }
  inorder(k->l);
  cout << " " << k->key;
  inorder(k->r);
}

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<iostream>
using namespace std;

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

Node *nil;
Node *rootl;

void insert(int k) {
	Node *y = nil;
	Node *x = root;
	Node *z = new Node;
	z->key = k;
	z->l = nil;
	z->r = nil;
	while (x != nil) {
		y = x;
		if (z->key < x->key) x = x->l;
		else x = x->r;
	}
	z->p = y;
	if (y == nil) root = z;
	else {
		if (z->key < y->key) y->l = z;
		else y->r = z; 
	}
}

void inorder(Node *root) {
	if (root == nil) return;
	inorder(root->l);
	cout << ' ' << root->key;
	inorder(root->r);
}

void preorder(Node *root) {
	if (root == nil) return;
	cout << ' ' << root->key;
	preorder(root->l);
	preorder(root->r);
}

void print() {
	inorder(root);
	cout << endl;
	preorder(root);
	cout << endl;
}

int main() {
	int n, key;
	char cmd[10];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> cmd;
		if (cmd[0] == 'i') {
			cin >> key;
			insert(key);
		}
		else print();
	}

	return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:14:19: error: 'root' was not declared in this scope; did you mean 'rootl'?
   14 |         Node *x = root;
      |                   ^~~~
      |                   rootl
a.cc: In function 'void print()':
a.cc:47:17: error: 'root' was not declared in this scope; did you mean 'rootl'?
   47 |         inorder(root);
      |                 ^~~~
      |                 rootl
Language: C++

#include <iostream>
#include <string>

struct TNode
{
	int Value;
	TNode* Parent;
	TNode* Left;
	TNode* Right;
	
	TNode();
	TNode(int AValue, TNode* AParent);
};

TNode::TNode()
{
	Value  = INT_MAX;
	Parent = NULL;
	Left   = NULL;
	Right  = NULL;
}

TNode::TNode(int AValue, TNode* AParent)
{
	Value = AValue;
	Parent = AParent;
}

void Delete(TNode* Root)
{
	if(Root == NULL) return;
	Delete(Root->Left);
	Delete(Root->Right);
	delete Root;
}
void Insert(int Key, TNode* Root);

void AddLeft(int Key, TNode* Root)
{
	if(Root->Left == NULL){
		TNode* Left = new TNode(Key, Root);
		Root->Left = Left;
	}else{
		Insert(Key, Root->Left);
	}
}

void AddRight(int Key, TNode* Root)
{
	if(Root->Right == NULL){
		TNode* Right = new TNode(Key, Root);
		Root->Right = Right;
	}else{
		Insert(Key, Root->Right);
	}
}

void Insert(int Key, TNode* Root)
{
	if(Root->Value == Key) return;
	if(Root->Value == INT_MAX){
		Root->Value = Key;
		return;
	}
	if(Root->Value > Key){
		AddLeft(Key, Root);
	}else{
		AddRight(Key, Root);
	}
}

void OutputPreOrder(const TNode* Root)
{
	if(Root == NULL) return;
	std::cout << " " << Root->Value;
	OutputPreOrder(Root->Left);
	OutputPreOrder(Root->Right);
}

void OutputInorder(const TNode* Root)
{
	if(Root == NULL) return;
	OutputInorder(Root->Left);
	std::cout << " " << Root->Value;
	OutputInorder(Root->Right);
}

void Print(const TNode* Node)
{
	OutputInorder(Node);
	std::cout << std::endl;
	OutputPreOrder(Node);
	std::cout << std::endl;
}

void DoOrder(const std::string& Order, TNode* Root)
{
	if(Order == "insert"){
		int Key = 0;
		std::cin >> Key;
		Insert(Key, Root);
	}else if(Order == "print"){
		Print(Root);
	}
}

int main()
{
	int Count = 0;
	std::cin >> Count;
	TNode* Root = new TNode();
	for(int i = 0; i < Count; ++i){
		std::string Order;
		std::cin >> Order;
		DoOrder(Order, Root);
	}
	return 0;
}

Compiler output:
a.cc: In constructor 'TNode::TNode()':
a.cc:17:18: error: 'INT_MAX' was not declared in this scope
   17 |         Value  = INT_MAX;
      |                  ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | #include <string>
a.cc: In function 'void Insert(int, TNode*)':
a.cc:61:27: error: 'INT_MAX' was not declared in this scope
   61 |         if(Root->Value == INT_MAX){
      |                           ^~~~~~~
a.cc:61:27: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include<iostream>
#include<string>
using namespace std;
??
int a;
??
struct NodeDiv2 {
????????int key;
????????NodeDiv2 *parent, *left, *right;
};
??
NodeDiv2 *root, *NIL;
??
void preTreeWalkDiv2(NodeDiv2 *u){
????????if (u == NIL) { return; }
????????cout << ' ' << u->key;
????????preTreeWalkDiv2(u->left);
????????preTreeWalkDiv2(u->right);
}
??
void inTreeWalkDiv2(NodeDiv2 *u) {
????????if (u == NIL) { return; }
????????inTreeWalkDiv2(u->left);
????????cout << ' ' << u->key;
????????inTreeWalkDiv2(u->right);
}
??
void insertDiv2(int k) {
????????NodeDiv2 *y = NIL;
????????NodeDiv2 *x = root;
????????NodeDiv2 *z;
????????z = (NodeDiv2*)malloc(sizeof(NodeDiv2));
????????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; }
}
??
int q;
string S;
??
int main() {
????????cin >> q;
????????for (int i = 0; i < q; i++) {
????????????????cin >> S;
????????????????if (S == "print") {
????????????????????????inTreeWalkDiv2(root); cout << endl;
????????????????????????preTreeWalkDiv2(root); cout << endl;
????????????????}
????????????????else {
????????????????????????cin >> a;
????????????????????????insertDiv2(a);
????????????????}
????????}
????????return 0;
}

Compiler output:
a.cc:4:1: error: expected unqualified-id before '?' token
    4 | ??
      | ^
a.cc:6:1: error: expected unqualified-id before '?' token
    6 | ??
      | ^
a.cc:11:1: error: expected unqualified-id before '?' token
   11 | ??
      | ^
a.cc:13:1: error: expected unqualified-id before '?' token
   13 | ??
      | ^
a.cc:20:1: error: expected unqualified-id before '?' token
   20 | ??
      | ^
a.cc:27:1: error: expected unqualified-id before '?' token
   27 | ??
      | ^
a.cc:46:1: error: expected unqualified-id before '?' token
   46 | ??
      | ^
a.cc:49:1: error: expected unqualified-id before '?' token
   49 | ??
      | ^
Language: C++

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

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

Node *root;
Node *NIL;

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

    z = new Node;
    z->key=k;
    z->left=NIL;
    z->right=NIL;

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

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

}

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

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

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

    scanf("%d",&n);

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

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:30:18: error: invalid conversion from 'int' to 'Node*' [-fpermissive]
   30 |             x=x->key;
      |               ~~~^~~
      |                  |
      |                  int
Language: C++

include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
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 != 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;
  int key;
  string com;

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

  return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:62:3: error: 'string' was not declared in this scope
   62 |   string com;
      |   ^~~~~~
a.cc:5:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
    4 | #include <cstdlib>
  +++ |+#include <string>
    5 | using namespace std;
a.cc:64:3: error: 'cin' was not declared in this scope
   64 |   cin >> n;
      |   ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <cstdlib>
  +++ |+#include <iostream>
    5 | using namespace std;
a.cc:66:12: error: 'com' was not declared in this scope
   66 |     cin >> com;
      |            ^~~
Language: C++

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

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

Node *root,*NIL;

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

z=(Node *)malloc(sizeof(Node));
z->key=k;
z->l=NIL;
z->r=NIL;

while(x!=NIL){
y=x;
if(z->key<x->key){
x=x->l;
}
else{
x=x->r;
}
}
z->parent=y;
if(y==NIL){
root=z;
}else{
if(z->key<y->key){
y->l=z;
}
else{
y->r=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->l);
preorder(u->r);
}

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

scanf("%d",&n);

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

return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:33:4: error: 'struct Node' has no member named 'parent'
   33 | z->parent=y;
      |    ^~~~~~
a.cc: In function 'void inorder(Node*)':
a.cc:48:12: error: 'struct Node' has no member named 'left'
   48 | inorder(u->left);
      |            ^~~~
a.cc:50:12: error: 'struct Node' has no member named 'right'
   50 | inorder(u->right);
      |            ^~~~~
Language: C++

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

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

Node *root,*NIL;

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

z=(Node *)malloc(sizeof(Node));
z->key=k;
z->l=NIL;
z->r=NIL;

while(x!=NIL){
y=x;
if(z->key<x->key){
x=x->l;
}
else{
x=x->r;
}
}
z->p=y;
if(y==NIL){
root=z;
}else{
if(z->key<y->key){
y->l=z;
}
else{
y->r=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->l);
preorder(u->r);
}

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

scanf("%d",&n);

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

return 0;
}

Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:48:12: error: 'struct Node' has no member named 'left'
   48 | inorder(u->left);
      |            ^~~~
a.cc:50:12: error: 'struct Node' has no member named 'right'
   50 | inorder(u->right);
      |            ^~~~~
Language: C++

#include <stdio.h>
#include <string.h>
#define NIL NULL

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

void Insert(int );
void inorder(Node );
void preorder(Node );
Node root;
int main()
{
  int i,j,k;
  char c[10];
  scanf("%d",&k);

  for(i=0;i<k;i++)
    {
      scanf("%s",c);
      if(c[0]=='i')
        {
          scanf("%d",&j);
          Insert(j);
        }
      else
        {
          inorder(root);
          printf("\n");
          preorder(root);
          printf("\n");
        }
    }
  return 0;
}
void Insert(int j)
{
  Node x;
  Node y;

  z=(Node *)malloc(sizeof(Node));
  z->key=j;
  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 *x)
{
  if(x==NIL) return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}

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

Compiler output:
a.cc: In function 'void Insert(int)':
a.cc:46:3: error: 'z' was not declared in this scope
   46 |   z=(Node *)malloc(sizeof(Node));
      |   ^
a.cc:46:13: error: 'malloc' was not declared in this scope
   46 |   z=(Node *)malloc(sizeof(Node));
      |             ^~~~~~
a.cc:3:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    2 | #include <string.h>
  +++ |+#include <cstdlib>
    3 | #define NIL NULL
a.cc:51:10: error: no match for 'operator!=' (operand types are 'Node' and 'long int')
   51 |   while(x!=NIL)
      |          ^
a.cc:54:20: error: base operand of '->' has non-pointer type 'Node'
   54 |       if(z->key < x->key)
      |                    ^~
a.cc:56:14: error: base operand of '->' has non-pointer type 'Node'
   56 |           x=x->left;
      |              ^~
a.cc:60:14: error: base operand of '->' has non-pointer type 'Node'
   60 |           x=x->right;
      |              ^~
a.cc:64:7: error: no match for 'operator==' (operand types are 'Node' and 'long int')
   64 |   if(y==NIL)
      |       ^
a.cc:70:20: error: base operand of '->' has non-pointer type 'Node'
   70 |       if(z->key < y->key)
      |                    ^~
a.cc:72:12: error: base operand of '->' has non-pointer type 'Node'
   72 |           y->left=z;
      |            ^~
a.cc:76:12: error: base operand of '->' has non-pointer type 'Node'
   76 |           y->right=z;
      |            ^~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct Node {
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};
typedef struct Node * node;
node root;
void Insert(int );
void inorder(node );
void preorder(node );

int main()
{
  int i,j,k;
  char c[10];
  scanf("%d",&k);
  
  for(i=0;i<k;i++)
    {
      scanf("%s",c);
      if(c[0]=='i')
	{
	  scanf("%d",&j);
	  Insert(j);
	}
      else if(c[0]=='p') 
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
    }
  return 0;
}

void Insert(int j)
{
  node x,y,z;

  x=root;
  y=NIL;
  
  z=malloc(sizeof(node));
  z->key=j;
  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 x)
{
  if(x==NIL) return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}

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

Compiler output:
a.cc: In function 'void Insert(int)':
a.cc:49:11: error: invalid conversion from 'void*' to 'node' {aka 'Node*'} [-fpermissive]
   49 |   z=malloc(sizeof(node));
      |     ~~~~~~^~~~~~~~~~~~~~
      |           |
      |           void*
Language: C++

#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
struct node {
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};
typedef struct node * Node;
Node root;
void Insert(int );
void inorder(Node );
void preorder(Node );

int main()
{
  int i,j,k;
  char c[10];
  scanf("%d",&k);
  
  for(i=0;i<k;i++)
    {
      scanf("%s",c);
      if(c[0]=='i')
	{
	  scanf("%d",&j);
	  Insert(j);
	}
      if(c[0]=='p') 
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
    }
  return 0;
}

void Insert(int j)
{
  Node x=root,y=NIL,z;
  
  z=malloc(sizeof(Node));
  z->key=j;
  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 x)
{
  if(x!=NIL) return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}

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

Compiler output:
a.cc: In function 'void Insert(int)':
a.cc:45:11: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   45 |   z=malloc(sizeof(Node));
      |     ~~~~~~^~~~~~~~~~~~~~
      |           |
      |           void*
Language: C++

#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node {
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};
typedef struct node * Node;
Node root;
void Insert(int );
void inorder(Node );
void preorder(Node );

int main()
{
  int i,j,k;
  char c[10];
  scanf("%d",&k);
  
  for(i=0;i<k;i++)
    {
      scanf("%s",&c[0]);
      if(c[0]=='i')
	{
	  scanf("%d",&j);
	  Insert(j);
	}
      else if(c[0]=='p') 
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
    }
  return 0;
}

void Insert(int p)
{
  Node x=root;
  Node y=NIL;
  Node z;
  
  z=malloc(sizeof(struct node));
  z->key=p;
  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 x)
{
  if(x==NIL) return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}

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

Compiler output:
a.cc: In function 'void Insert(int)':
a.cc:48:11: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   48 |   z=malloc(sizeof(struct node));
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |           |
      |           void*
Language: C++

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

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

  z = malloc(sizeof(struct 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->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL) inorder(u->right);
}

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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

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

  return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:20:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   20 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
a.cc: At global scope:
a.cc:35:1: error: expected declaration before '}' token
   35 | }
      | ^
Language: C++


#include<stdio.h>

#include<stdlib.h>

 

struct node{

  struct node *p;

  struct node *r;

  struct node *l;

  int key;

};

 

 

typedef struct node * Node;

Node root;

 

void inorder(Node root)

{

 

  if(root != NULL){

    inorder(root->l);

    printf(" %d", root->key);

    inorder(root->r);

  }

}

 

void preorder(Node root)

{

if(root != NULL){

   printf(" %d", root->key);

   preorder(root->l);

   preorder(root->r);

 }

}

 

void insert(int k)

{

  Node y = NULL;

  Node x = root;

  Node z=malloc(sizeof(struct node));

  z->key = k;

  z->l = NULL;

  z->r = NULL;

  while(x!=NULL){

    y = x;

    if(z->key<x->key){

      x=x->l;

    }else{

      x=x->r;

    }

  }

  z->p=y;

  if(y == NULL){

    root=z;

  }else if(z->key<y->key) {

    y->l=z;

  }else{

    y->r=z;

  }

}

 

 

 

 

int main()

{

  int n,i,x;

  char com[20];

 

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%s",com);

    if(com[0]=='i'){

     scanf("%d",&x);

      insert(x);

    }

    else if(com[0]=='p'){

      inorder(root);

      printf("\n");

      preorder(root);

      printf("\n");

    }

  }

  return 0;

}

 

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:76:16: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   76 |   Node z=malloc(sizeof(struct node));
      |          ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                |
      |                void*
Language: C++


#include<stdio.h>

#include<stdlib.h>

 

struct node{

  struct node *p;

  struct node *r;

  struct node *l;

  int key;

};

 

 

typedef struct node * Node;

Node root;

 

void inorder(Node root)

{

 

  if(root != NULL){

    inorder(root->l);

    printf(" %d", root->key);

    inorder(root->r);

  }

}

 

void preorder(Node root)

{

if(root != NULL){

   printf(" %d", root->key);

   preorder(root->l);

   preorder(root->r);

 }

}

 

void insert(int k)

{

  Node y = NULL;

  Node x = root;

  Node z=malloc(sizeof(struct node));

  z->key = k;

  z->l = NULL;

  z->r = NULL;

  while(x!=NULL){

    y = x;

    if(z->key<x->key){

      x=x->l;

    }else{

      x=x->r;

    }

  }

  z->p=y;

  if(y == NULL){

    root=z;

  }else if(z->key<y->key) {

    y->l=z;

  }else{

    y->r=z;

  }

}

 

 

 

 

int main()

{

  int n,i,x;

  char com[100];

 

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%s",com);

    if(com[0]=='i'){

     scanf("%d",&x);

      insert(x);

    }

    else if(com[0]=='p'){

      inorder(root);

      printf("\n");

      preorder(root);

      printf("\n");

    }

  }

  return 0;

}

 

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:76:16: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   76 |   Node z=malloc(sizeof(struct node));
      |          ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                |
      |                void*
Language: C++

#include<stdio.h>
#include<stdlib.h>
#define N NULL

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;

Node root;
void insert(int);
void inorder(Node );
void preorder(Node );

int main(){
  int s, i, x;
  char c[10];

  scanf("%d", &s);

  for(i=0; i<s; i++){
    scanf("%s", c);
    if( c[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }
    if( c[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = N;
  z->r = N;

  while(x != N){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  
  z->p = y;
  if(y == N) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}

void inorder(Node u){
  if(u != N){
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u -> r);
  }
}
void preoder(Node u){
  if(u != N){
    printf(" %d",u->key);
    preorder(u->l);
    preorder(u->r);
  }
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:45:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   45 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

#include<bits/stdc++.h>
using namespace std;
struct Node{
  int key;
  Node *right,*left,*parent;
};
Node *root,*NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}
void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}
void preoder(Node *u){
  if(u==NIL)return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int n,i,x;
  string com;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> com;
    if(com == "insert"){
      cin >> x;
      insert(x);
    }else if(com == "print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'void preoder(Node*)':
a.cc:46:3: error: 'preorder' was not declared in this scope; did you mean 'preoder'?
   46 |   preorder(u->left);
      |   ^~~~~~~~
      |   preoder
a.cc: In function 'int main()':
a.cc:61:7: error: 'preorder' was not declared in this scope; did you mean 'preoder'?
   61 |       preorder(root);
      |       ^~~~~~~~
      |       preoder
Language: C++

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

#define NUL NULL

struct node{struct node *p, *r,*l;int key;};
typedef struct node * Node;
Node root;



void inorder(Node root){
  if(root != NUL){
    inorder(root->l);
    printf(" %d", root->key);
    inorder(root->r);
  }
}



void preorder(Node root){
  if(root != NUL){
   printf(" %d", root->key);
   preorder(root->l);
   preorder(root->r);
 }
}



void insert(int k){
  Node y = NUL, x = root, z=malloc(sizeof(struct node));

  z->key = k;
  z->l = NUL;
  z->r = NUL;

  while(x!=NUL){
    y = x;
    if(z->key<x->key){
      x=x->l;
    }else{
      x=x->r;
    }
  }

  z->p=y;
  if(y == NUL){
    root=z;
  }else if(z->key<y->key) {
    y->l=z;
  }else{
    y->r=z;
  }
}


int main(){
  int n,i,x;
  char option[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",option);
    if(option[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(option[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:33:35: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   33 |   Node y = NUL, x = root, z=malloc(sizeof(struct node));
      |                             ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                                   |
      |                                   void*
Language: C++

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

#define NUL NULL

struct node{struct node *p, *r, *l; int key;};
typedef struct node * Node;
Node root;



void inorder(Node root){
  if(root != NUL){
    inorder(root->l);
    printf(" %d", root->key);
    inorder(root->r);
  }
}



void preorder(Node root){
  if(root != NUL){
   printf(" %d", root->key);
   preorder(root->l);
   preorder(root->r);
 }
}



void insert(int k){
  Node y = NUL, x = root, z=malloc(sizeof(struct node));

  z->key = k;
  z->l = NUL;
  z->r = NUL;

  while(x!=NUL){
    y = x;
    if(z->key<x->key){
      x=x->l;
    }else{
      x=x->r;
    }
  }

  z->p=y;
  if(y == NUL){
    root=z;
  }else if(z->key<y->key) {
    y->l=z;
  }else{
    y->r=z;
  }
}


int main(){
  int n,i,x;
  char option[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",option);
    if(option[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(option[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:33:35: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   33 |   Node y = NUL, x = root, z=malloc(sizeof(struct node));
      |                             ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                                   |
      |                                   void*
Language: C++

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Compiler output:
a.cc:50:1: error: expected declaration before '}' token
   50 | }
      | ^