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

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

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

Node *root, *NIL;

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

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

Node *treeSuccessor(Node *x){
  if(x->r != NIL) return treeMinimum(x->r);
  Node *y = x->p;
  while(y != NIL && x = y->r){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y, *x;

  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->l != NIL){
    x = y->l;
  }
  else{
    x = y->r;
  }

  if(x != NIL){
    x->p = y->p;
  }

  if(y->p == NIL){
    root = x;
  }
  else{
    if(y == y->p->l){
      y->p->l = x;
    }
    else{
      y->p->r = x;
    }
  }
}

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

void insert(int k){
  Node *x = root,*y = NIL, *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;
  printf(" %d", u->key);
  preoder(u->l);
  preoder(u->r);
}

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


Compiler output:
a.cc: In function 'Node* treeSuccessor(Node*)':
a.cc:30:18: error: lvalue required as left operand of assignment
   30 |   while(y != NIL && x = y->r){
      |         ~~~~~~~~~^~~~
a.cc: At global scope:
a.cc:67:1: error: expected unqualified-id before 'if'
   67 | if(y != z){
      | ^~
a.cc:70:5: error: expected constructor, destructor, or type conversion before '(' token
   70 | free(y);
      |     ^
a.cc:71:1: error: expected declaration before '}' token
   71 | }
      | ^
a.cc: In function 'void inorder(Node*)':
a.cc:108:3: error: 'preoder' was not declared in this scope
  108 |   preoder(u->l);
      |   ^~~~~~~
a.cc: In function 'int main()':
a.cc:129:7: error: 'sacnf' was not declared in this scope; did you mean 'scanf'?
  129 |       sacnf("%d", &x);
      |       ^~~~~
      |       scanf
Language: C++

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

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

Node *root, *NIL;

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

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

Node *treeSuccessor(Node *x){
  if(x->r != NIL) return treeMinimum(x->r);
  Node *y = x->p;
  while(y != NIL && x = y->r){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y, *x;

  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->l != NIL){
    x = y->l;
  }
  else{
    x = y->r;
  }

  if(x != NIL){
    x->p = y->p;
  }

  if(y->p == NIL){
    root = x;
  }
  else{
    if(y == y->p->l){
      y->p->l = x;
    }
    else{
      y->p->r = x;
    }
  }

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

void insert(int k){
  Node *x = root,*y = NIL, *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;
  printf(" %d", u->key);
  preoder(u->l);
  preoder(u->r);
}

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


Compiler output:
a.cc: In function 'Node* treeSuccessor(Node*)':
a.cc:30:18: error: lvalue required as left operand of assignment
   30 |   while(y != NIL && x = y->r){
      |         ~~~~~~~~~^~~~
a.cc: In function 'void inorder(Node*)':
a.cc:107:3: error: 'preoder' was not declared in this scope
  107 |   preoder(u->l);
      |   ^~~~~~~
a.cc: In function 'int main()':
a.cc:128:7: error: 'sacnf' was not declared in this scope; did you mean 'scanf'?
  128 |       sacnf("%d", &x);
      |       ^~~~~
      |       scanf
Language: C++

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

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

Node *root, *NIL;

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

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

Node *treeSuccessor(Node *x){
  if(x->r != NIL) return treeMinimum(x->r);
  Node *y = x->p;
  while(y != NIL && x == y->r){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y, *x;

  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->l != NIL){
    x = y->l;
  }
  else{
    x = y->r;
  }

  if(x != NIL){
    x->p = y->p;
  }

  if(y->p == NIL){
    root = x;
  }
  else{
    if(y == y->p->l){
      y->p->l = x;
    }
    else{
      y->p->r = x;
    }
  }

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

void insert(int k){
  Node *x = root,*y = NIL, *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;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}

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


Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:107:3: error: 'preorder' was not declared in this scope
  107 |   preorder(u->l);
      |   ^~~~~~~~
a.cc: In function 'int main()':
a.cc:128:7: error: 'sacnf' was not declared in this scope; did you mean 'scanf'?
  128 |       sacnf("%d", &x);
      |       ^~~~~
      |       scanf
Language: C++

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

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

Node *root, *NIL;

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

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

Node *treeSuccessor(Node *x){
  if(x->r != NIL) return treeMinimum(x->r);
  Node *y = x->p;
  while(y != NIL && x == y->r){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y, *x;

  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->l != NIL){
    x = y->l;
  }
  else{
    x = y->r;
  }

  if(x != NIL){
    x->p = y->p;
  }

  if(y->p == NIL){
    root = x;
  }
  else{
    if(y == y->p->l){
      y->p->l = x;
    }
    else{
      y->p->r = x;
    }
  }

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

void insert(int k){
  Node *x = root,*y = NIL, *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;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}

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


Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:107:3: error: 'preorder' was not declared in this scope
  107 |   preorder(u->l);
      |   ^~~~~~~~
Language: C++

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

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

Node *root, *NIL;

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

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

Node *treeSuccessor(Node *x){
  if(x->r != NIL) return treeMinimum(x->r);
  Node *y = x->p;
  while(y != NIL && x == y->r){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y, *x;

  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->l != NIL){
    x = y->l;
  }
  else{
    x = y->r;
  }

  if(x != NIL){
    x->p = y->p;
  }

  if(y->p == NIL){
    root = x;
  }
  else{
    if(y == y->p->l){
      y->p->l = x;
    }
    else{
      y->p->r = x;
    }
  }

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

void insert(int k){
  Node *x = root,*y = NIL, *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;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}

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


Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:107:3: error: 'preorder' was not declared in this scope
  107 |   preorder(u->l);
      |   ^~~~~~~~
Language: C++

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

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

Node *root, *NIL;

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

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

Node *treeSuccessor(Node *x){
  if(x->r != NIL) return treeMinimum(x->r);
  Node *y = x->p;
  while(y != NIL && x == y->r){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y, *x;

  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->l != NIL){
    x = y->l;
  }
  else{
    x = y->r;
  }

  if(x != NIL){
    x->p = y->p;
  }

  if(y->p == NIL){
    root = x;
  }
  else{
    if(y == y->p->l){
      y->p->l = x;
    }
    else{
      y->p->r = x;
    }
  }

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

void insert(int k){
  Node *x = root,*y = NIL, *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;
  printf(" %d", u->key);
  //preorder(u->l);
  preorder(u->r);
}

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


Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:108:3: error: 'preorder' was not declared in this scope
  108 |   preorder(u->r);
      |   ^~~~~~~~
Language: C++

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

using namespace std;

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

Node *root, *NIL;

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

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

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

void treeDelete(Node *z)
{
	Node *x,*y;//reserve son ->x,reserve self->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==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 *x,*y,*z;
	z = (Node*)malloc(sizeof(Node));
	z->key=k;
	y=root;
	while(y!=NIL)
	{
		x=y;
		if(y->key>k)
		y=y->left;
		else
		y=y->right
	}
	
	z->parent=x;
	if(y==NIL)
	{
		root=z;
	}
	else if
	{
		if(z->key<x->key)
		x->left=z;
		else
		x->right=z;
	}
	
}


int main()
{
	
}



Compiler output:
a.cc: In function 'void insert(int)':
a.cc:95:27: error: expected ';' before '}' token
   95 |                 y=y->right
      |                           ^
      |                           ;
   96 |         }
      |         ~                  
a.cc:104:9: error: expected '(' before '{' token
  104 |         {
      |         ^
      |         (
Language: C++

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

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

Node *NIL, *root;

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

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

Node *find(int k) {
    Node *x = root;
    while (x!=NIL) {
        if (x->key == k) return x;
        if (x->key > k) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    return NIL;
}

Node *getSuccessor(Node *z) {
    Node *y;
    if (z->right!=NIL) {
        z = z->right;
        while (z!=NIL) z=z->left;
        return z;
    } else {
        y = z->parent;
        while (y!=NIL && y->right==z) {
            z = y;
            y = z->parent;
        }
        return y;
    }
}

void Delete(int k) {
    Node *z, *y, *x;
    z = find(k);

    if (z->left==NIL || z->right==NIL) y = z;
    else y = getSuccessor(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;

    free(y)
}

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

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        cin >> com;
        if (com=="insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com=="find") {
            scanf("%d", &x);
            t = find(x);
            if (t!=NIL) printf("yes\n");
            else printf("no\n");
        } else if (com=="print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com=="delete") {
            scanf("%d", &x);
            Delete(x);
        }
    }

    return 0;
}


Compiler output:
a.cc: In function 'void Delete(int)':
a.cc:103:12: error: expected ';' before '}' token
  103 |     free(y)
      |            ^
      |            ;
  104 | }
      | ~
Language: C++

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

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

Node *NIL, *root;

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

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

Node *find(int k) {
    Node *x = root;
    while (x!=NIL) {
        if (x->key == k) return x;
        if (x->key > k) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    return NIL;
}

Node *getSuccessor(Node *z) {
    Node *y;
    if (z->right!=NIL) {
        z = z->right;
        while (z!=NIL) z=z->left;
        return z;
    } else {
        y = z->parent;
        while (y!=NIL && y->right==z) {
            z = y;
            y = z->parent;
        }
        return y;
    }
}

void Delete(int k) {
    Node *z, *y, *x;
    z = find(k);

    if (z->left==NIL || z->right==NIL) y = z;
    else y = getSuccessor(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;

    delete(y)
}

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

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        cin >> com;
        if (com=="insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com=="find") {
            scanf("%d", &x);
            t = find(x);
            if (t!=NIL) printf("yes\n");
            else printf("no\n");
        } else if (com=="print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com=="delete") {
            scanf("%d", &x);
            Delete(x);
        }
    }

    return 0;
}


Compiler output:
a.cc: In function 'void Delete(int)':
a.cc:103:14: error: expected ';' before '}' token
  103 |     delete(y)
      |              ^
      |              ;
  104 | }
      | ~
Language: C++

#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef node* Node;
#define NIL NULL

node array[500000];
int size=0;

Node root = NIL;
 
Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;
}
 
Node treeSearch(Node u, int k){
  Node i=u;
  while(i!=NIL){
    if(i->key==k)return i;
    else if(i->key<k)i=i->right;
    else i=i->left;     
  }
  return NIL;
}
 
Node treeSuccessor(Node x){
  if(x->right!=NIL)return treeMinimum(x->right);
  Node 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;
   
  //free(y);
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = &array[size++];
  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;   
}

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

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node {
	int key;
	Node *right, *left, *parent;
};
Node *root, *NIL;
Node *treeMinimum(Node *x) {
	while (x->left != NIL)x = x->left;
	return x;
}
Node *find(Node *u, int k) {
	while (u != NIL&&k != u->key) {
		if (k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}
Node *treeSuccessor(Node *x) {
	if (x->right != NIL)return treeMinimum(x->right);
	Node *y = x->parent;
	while (y != NIL&&x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}
void treeDelete(Node *z) {
	Node *y;
	Node *x;
	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;
	free(y);
}
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;
	}
	return;
}
void inorder(Node *u) {
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
	return;
}
void preorder(Node *u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
	return;
}

int main() {
	int n, i, x;
	string com;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			cin >> x;
			Node *t = find(root, x);
			if (t != NIL)puts("yes");
			else puts("no");
		}
		else if (com == "insert") {
			cin >> x;
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com == "delete") {
			cin >> x;
			treeDelete(find(root, x));
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'void treeDelete(Node*)':
a.cc:37:23: error: invalid operands of types 'Node*' and 'std::ios_base&(std::ios_base&)' to binary 'operator-'
   37 |                 x = y - left;
      |                     ~ ^ ~~~~
      |                     |   |
      |                     |   std::ios_base&(std::ios_base&)
      |                     Node*
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <limits>

using namespace std;

int count,minimum;

void pre(vector<vector<int> > &tree,int now)
{
	cout << " " << tree[now][0];
	for(int i=1;i<3;i++)
	{
		if(tree[now][i] != minimum)
		{
			pre(tree,tree[now][i]);
		}
	}
}

void ino(vector<vector<int> > &tree,int now)
{
	int size = tree[now].size();
	if(tree[now][1] == minimum && tree[now][2] == minimum)
	{
		cout << " " << tree[now][0];
	}
	else
	{
		if(tree[now][1]!=minimum)
		{
			ino(tree,tree[now][1]);
		}
		cout << " " << tree[now][0];
		if(tree[now][2]!=minimum)
		{
			ino(tree,tree[now][2]);
		}
	}
}

void print(vector<vector<int> > &tree)
{
	ino(tree,0);
	cout << endl;
	pre(tree,0);
	cout << endl;
}

void insert(vector<vector<int> > &tree,int key,int now)
{
	if(count == 0)					//root none
	{
		tree[0][0] = key;
	}
	else
	{
		if(tree[now][0] > key)		//left
		{
			if(tree[now][1] == minimum)	//child none
			{
				tree[now][1] = count;
				tree[count][0] = key;
			}
			else											//child exist
			{
				insert(tree,key,tree[now][1]);
			}
		}
		else						//right
		{
			if(tree[now][2] == minimum)	//child none
			{
				tree[now][2] = count;
				tree[count][0] = key;
			}
			else
			{
				insert(tree,key,tree[now][2]);
			}
		}
	}
}

int find(vector<vector<int> > &tree, int key,int now)
{
	int position;
	if(tree[now][0]==key)
	{
		cout << "yes" << endl;
		return now;
	}
	if(tree[now][0] > key)
	{
		if(tree[now][1] == minimum)
		{
			cout << "no" << endl;
			return -1;
		}
		else
		{
			position = find(tree,key,tree[now][1]);
		}
	}
	else
	{
		if(tree[now][2] == minimum)
		{
			cout << "no" << endl;
			return -1;
		}
		else
		{
			position = find(tree,key,tree[now][2]);
		}
	}
	return position;
}

void delete(vector<vector<int> > &tree, int key)
{
	tree.erase(vector.begin()+find(tree,key,0));
}

int main(void)
{
	count = 0;
	minimum = numeric_limits<int>::min();
    vector<vector<int> > tree;
	int n,num;
	string command;
	cin >> n;
    tree = vector<vector<int> >(n,vector<int>(3,minimum));

	for(int i=0;i<n;i++)
	{
		cin >> command;
		if(command == "insert")
		{
			cin >> num;		//input node num
			insert(tree,num,0);
			count++;
		}
		else if(command == "print")
		{
			print(tree);
		}
		else if(command == "find")
		{
			cin >> num;
			find(tree,num,0);
		}
		else if(command == "delete")
		{
			delete(tree,num);
		}
	}

	return 0;
}

Compiler output:
a.cc:121:6: error: expected unqualified-id before 'delete'
  121 | void delete(vector<vector<int> > &tree, int key)
      |      ^~~~~~
a.cc: In function 'int main()':
a.cc:156:36: error: type 'int' argument given to 'delete', expected pointer
  156 |                         delete(tree,num);
      |                               ~~~~~^~~~~
Language: C++

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

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

void insert(int);
void inorder(Node *);
void preorder(Node *);
void delete(Node *);
Node * find(Node *,int);
Node * treeMinimum(Node *);
Node * treeSuccessor(Node *);

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

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

void delete(Node *z){
  Node *y;
  Node *x;

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

  free(y);
}

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

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

int main(){
  int m,i,x;
  char com[10];
  
  scanf("%d",&m);
  
  for(i=0;i<m;i++){
    scanf("%s",com);
    if(strcmp(com,"find")==0){
      scanf("%d",&x);
      Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(strcmp(com,"delete")){
	scanf("%d",&x);
	delete(find(root,x));
      }
  } 
  return 0;
}

Compiler output:
a.cc:15:6: error: expected unqualified-id before 'delete'
   15 | void delete(Node *);
      |      ^~~~~~
a.cc:37:6: error: expected unqualified-id before 'delete'
   37 | void delete(Node *z){
      |      ^~~~~~
Language: C++

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

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

void insert(int);
void inorder(Node *);
void preorder(Node *);
void delete(Node *);
Node * find(Node *,int);
Node * treeMinimum(Node *);
Node * treeSuccessor(Node *);

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

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

void delete(Node *z){
  Node *y;
  Node *x;

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

  free(y);
}

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

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

int main(){
  int m,i,x;
  char com[10];
  
  scanf("%d",&m);
  
  for(i=0;i<m;i++){
    scanf("%s",com);
    if(strcmp(com,"find")==0){
      scanf("%d",&x);
      Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(strcmp(com,"delete")==0){
	scanf("%d",&x);
	delete(find(root,x));
      }
  } 
  return 0;
}

Compiler output:
a.cc:15:6: error: expected unqualified-id before 'delete'
   15 | void delete(Node *);
      |      ^~~~~~
a.cc:37:6: error: expected unqualified-id before 'delete'
   37 | void delete(Node *z){
      |      ^~~~~~
Language: C++

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

#define N 500000

int n;

struct Tree{
	int key;
	struct Tree *parent,*left,*right;
};
struct Tree *NILL,*root;

void find(struct Tree *root,int key){
	int flag =0;
	while(root!=NILL){
		if(root->key > key)root = root->left;
		else if(root->key == key) {
			printf("yes\n");
			flag =1;
			break;
		}
		else root = root->right;
	}
	if(!flag)printf("no\n");
}

void insert(struct Tree *z){
	struct Tree *x,*y;
	y = NILL;
	x = root;
	while(x != NILL){
		y = x;
		if(z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if(y == NILL)  {
		root = z;
	}
	else if(z->key < y->key) y->left = z;
	else y->right = z;
}

struct Tree * tm(struct Tree *z){
	while(z->left !=NILL) z = z->left;
	return z;
}

struct Tree * succecer(struct Tree *z){
	if(z->right != NILL) return tm(z->right);
	struct Tree *y = z->parent;
	while(y!=NILL && z==y->right){
		z=y;
		y = y->parent;
	}
	return y;
}

void delete(struct Tree *z){
	struct Tree *y,*x;
	if(z->left == NILL || z->right == NILL) y = z;
	else y = succecer(z);
	if(y->left != NILL){
		x = y->left;
	}
	else{
		x = y->right;
	}
	if(x!=NILL){
		x->parent = y->parent;
	}
	if(y->parent == NILL){
		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 mid(struct Tree *root){
	if(root == NILL) return;
	mid(root->left);
	printf(" %d", root->key);
	mid(root->right);
}

void inorder(struct Tree *root){
	if(root == NILL) return;
	printf(" %d",root->key);
	inorder(root->left);
	inorder(root->right);
}

void print(){
	struct Tree *r;
	r = root;
	mid(r);
	printf("\n");
	inorder(r);
	printf("\n");
}

int main(){
	struct Tree *t;
	scanf("%d",&n);
	int i;
	int key;
	char instruct[7];
	for(i=0;i<n;i++){
		scanf("%s",instruct);
		if(!strcmp(instruct,"insert")){
			scanf("%d",&key);
			t = (struct Tree *)malloc(sizeof(struct Tree));
			t->key = key;
			t->right = NILL;
			t->left = NILL;
			//T[i]->key  = key;
			insert(t);
		}
		else if(!strcmp(instruct,"find")){
			scanf("%d",&key);
			find(root,key);
		}
		else print();
	}
	return 0;
}

Compiler output:
a.cc:61:6: error: expected unqualified-id before 'delete'
   61 | void delete(struct Tree *z){
      |      ^~~~~~
Language: C++

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

#define N 500000

int n;

struct Tree{
	int key;
	struct Tree *parent,*left,*right;
};
struct Tree *NILL,*root;

void find(struct Tree *root,int key){
	int flag =0;
	while(root!=NILL){
		if(root->key > key)root = root->left;
		else if(root->key == key) {
			printf("yes\n");
			flag =1;
			break;
		}
		else root = root->right;
	}
	if(!flag)printf("no\n");
}

struct Tree * find1(struct Tree *root,int key){
	int flag =0;
	while(root!=NILL){
		if(root->key > key)root = root->left;
		else if(root->key == key) {
			flag =1;
			break;
		}
		else root = root->right;
	}
	if(!flag)return NILL;
	return root;
}

void insert(struct Tree *z){
	struct Tree *x,*y;
	y = NILL;
	x = root;
	while(x != NILL){
		y = x;
		if(z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if(y == NILL)  {
		root = z;
	}
	else if(z->key < y->key) y->left = z;
	else y->right = z;
}

struct Tree * tm(struct Tree *z){
	while(z->left !=NILL) z = z->left;
	return z;
}

struct Tree * succecer(struct Tree *z){
	if(z->right != NILL) return tm(z->right);
	struct Tree *y = z->parent;
	while(y!=NILL && z==y->right){
		z=y;
		y = y->parent;
	}
	return y;
}

void delete(struct Tree *z){
	struct Tree *y,*x;
	if(z->left == NILL || z->right == NILL) y = z;
	else y = succecer(z);
	if(y->left != NILL){
		x = y->left;
	}
	else{
		x = y->right;
	}
	if(x!=NILL){
		x->parent = y->parent;
	}
	if(y->parent == NILL){
		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 mid(struct Tree *root){
	if(root == NILL) return;
	mid(root->left);
	printf(" %d", root->key);
	mid(root->right);
}

void inorder(struct Tree *root){
	if(root == NILL) return;
	printf(" %d",root->key);
	inorder(root->left);
	inorder(root->right);
}

void print(){
	struct Tree *r;
	r = root;
	mid(r);
	printf("\n");
	inorder(r);
	printf("\n");
}

int main(){
	struct Tree *t;
	scanf("%d",&n);
	int i;
	int key;
	char instruct[7];
	for(i=0;i<n;i++){
		scanf("%s",instruct);
		if(!strcmp(instruct,"insert")){
			scanf("%d",&key);
			t = (struct Tree *)malloc(sizeof(struct Tree));
			t->key = key;
			t->right = NILL;
			t->left = NILL;
			//T[i]->key  = key;
			insert(t);
		}
		else if(!strcmp(instruct,"find")){
			scanf("%d",&key);
			find(root,key);
		}
		else if(!strcmp(instruct,"delete")){
			scanf("%d",&key);
			delete(find1(root,key));
		}
		else print();
	}
	return 0;
}

Compiler output:
a.cc:75:6: error: expected unqualified-id before 'delete'
   75 | void delete(struct Tree *z){
      |      ^~~~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
  
typedef struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
} Node;
  
typedef Node *NodePointer;
NodePointer root = NULL;
  
NodePointer createNode(){
  NodePointer z = malloc(sizeof(Node));
  z->l = NULL;
  z->r = NULL;
  z->p = NULL;
  z->key = 0;
  return z;
}
  
void insert(int key){
    
  NodePointer z = createNode();
  NodePointer y = NULL;
  NodePointer x = root;
  z->key = key;
    
  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;
}
    
void inorder(NodePointer p){    
  if(p != NULL){
    inorder(p->l);
    printf(" %d",p->key);
    inorder(p->r);
  }
}
  
void preorder(NodePointer p){
  if(p != NULL){
    printf(" %d",p->key);
    preorder(p->l);
    preorder(p->r);
  }
}
 
NodePointer minimum(NodePointer p){
  while(p->l != NULL){
    p = p->l;
  }
  return p;
}
 
NodePointer successor(NodePointer p){
 
  NodePointer x;
 
  if(p->r != NULL) return minimum(p->r);
  x = p->p;
  while(x != NULL && p == x->r){
    p = x;
    x = x->p;
  }
  return x;
}
 
void Delete(NodePointer p){
 
  NodePointer x;
  NodePointer y;
 
  if(p->l == NULL || p->r == NULL)
    x = p;
  else
    x = successor(p);
  if(x->l != NULL)
    y = x->l;
  else
    y = x->r;
  if(y != NULL)
    y->p = x->p;
  if(x->p == NULL)
    root = y;
  else if(x == x->p->l)
    x->p->l = y;
  else
    x->p->r = y;
  if(y != p)
    p->key = x->key;
}
 
 
NodePointer find(NodePointer p, int key){
 
  if(p == NULL) return p;
  else if(p->key == key) return p;
  if(key < p->key)  return find(p->l,key);
  else  return find(p->r,key);
}
  
int main(void){
  
  int i,key,n;
  char str[20];
  NodePointer x;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",str);
  
    if(str[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(str[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(str[0] == 'f'){
      scanf("%d",&key);
    x = find(root,key);
    if(x != NULL) printf("yes\n");
    else printf("no\n");
    }
    else{
      scanf("%d",&key);
      Delete(find(root,key));
 
    }
  }
  return 0;
}

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

#include<stdio.h>
#include<stdlib.h>
 
#define NIL NULL
 
struct node{
  struct node *l;
  struct node *r;
  struct node *p;
  int key;
};
 
typedef struct node * Node;
 
Node root;
 
void Preorder(Node t){
  printf(" %d",t->key);
  if(t!=NIL){
    if(t->l!=NIL)Preorder(t->l);
    if(t->r!=NIL)Preorder(t->r);
  }
}
 
void Inorder(Node t){
   
  if(t!=NIL){
    if(t->l!=NIL){
      Inorder(t->l);
      }
    printf(" %d",t->key);
     
    if(t->r!=NIL){
      Inorder(t->r);
      }
  }
}
 
void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
 
  z = malloc(sizeof(struct 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;
}
 
Node Search(Node t,int k){
  if(t==NIL || k==t->key) return t;
  if(k<t->key) return Search(t->l,k);
  else return Search(t->r,k);
}
 
Node Minimum(Node t){
  while(t->l!=NIL){
    t=t->l;
  }
  return t;
}
 
Node Successor(Node t){
  if(t->r!=NIL)return Minimum(t->r);
  Node y=t->p;
  while(y!=NIL && t==y->r){
    t=y;
    y=y->p;
  }
  return y;
}
 
void Delete(Node z){
  Node y;
  Node x;
 
  if(z->l==NIL || z->r==NIL) y=z;
  else y=Successor(z);
 
  if(y->l!=NIL) x=y->l;
  else x=y->r;
 
  if(x!=NIL) x->p=y->p;
 
  if(y->p==NIL)root=x;
  else if(y==y->p->l) y->p->l=x;
  else  y->p->r=x;
 
  if(y!=z)z->key=y->key;
}
 
 
main(){
  int n, i, x;
  char str[20];
   
  scanf("%d",&n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s",str);
 
    if(str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    } 
    else if(str[0]=='p'){
      Inorder(root);
      printf("\n");
       
      Preorder(root);
      printf("\n");
    }
    else if(str[0]=='f'){
      scanf("%d",&x);
      Node s=Search(root,x);
      if (s!= NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if(str[0]=='d'){
      scanf("%d",&x);
      Delete(Search(root, x));
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:44:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   44 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
a.cc: At global scope:
a.cc:105:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  105 | main(){
      | ^~~~
Language: C++

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

#define Max 500000

typedef struct
{
  int key;
  int p;
  int l[2];
}Node;

Node T[Max];
void insert( int );
void find( int, int );
int successor( int );
void delete( int );
void Preorder( int );
void Inorder( int );


int main(){

  int i, n, k;
  char s[7];

  scanf("%d", &n);

  T[0].key = -1;

  for(i=0; i<n; i++){
      T[i].l[0] = -1;
      T[i].l[1] = -1;
      scanf("%s", s);

      if(strcmp(s, "insert") == 0){
      scanf("%d", &T[i].key);
      insert(i);
    }else if(strcmp(s, "print") == 0){
      Inorder(0);
      printf("\n");
      Preorder(0);
      printf("\n");
    }else if(strcmp(s, "find") == 0){
      scanf("%d", &k);
      find(0, k);
    }else if(strcmp(s, "delete") == 0){
      scanf("%d", &k);
      delete(k);
    }
  }
  return 0;
}


void insert(int z){

  int x, y;
  y = -1;
  x = 0;

  if(z != 0)
    while(x != -1){
    y = x;
    if(T[z].key < T[x].key) x = T[x].l[0];
    else x = T[x].l[1];
    }

  T[z].p = y;

  if(y != -1){
    if(T[z].key < T[y].key) T[y].l[0] = z;
    else T[y].l[1] = z;
  }
}

void find(int x, int k){
  if(x == -1) printf("no\n");
  else if(T[x].key == k) printf("yes\n");
  else if(k < T[x].key) find(T[x].l[0], k);
  else find(T[x].l[1], k);
}

int successor(int x){
  int y;

  if(T[x].l[1] != -1){
    x = T[x].l[1];
    while(T[x].l[0] != -1) x = T[x].l[0];
    return x;
  }else{
    y = T[x].p;
    while(y != -1 && x == T[y].l[1]){
    x = y;
    y = T[y].p;
  }
  return y;
  }
}

void delete(int k){

  int x, y, z = 0;

  while( 1 ){
    if(T[z].key == k) break;
    else if(k < T[z].key) z = T[z].l[0];
    else z = T[z].l[1];
  }

  if(T[z].l[0] == -1 || T[z].l[1] == -1) y = z;
  else y = successor(z);

  if(T[y].l[0] != -1) x = T[y].l[0];
  else x = T[y].l[1];

  if(x != -1) T[x].p = T[y].p;

  if(T[y].p != -1){
    if(y == T[T[y].p].l[0]) T[T[y].p].l[0] = x;
    else T[T[y].p].l[1] = x;
  }
  if(y !=  z) T[z].key = T[y].key;
}


void Preorder(int a){

  printf(" %d", T[a].key);

  if(T[a].l[0] != -1) Preorder(T[a].l[0]);
  if(T[a].l[1] != -1) Preorder(T[a].l[1]);
}


void Inorder(int a){
  if(T[a].l[0] == -1){
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }else{
    Inorder(T[a].l[0]);
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }
}

Compiler output:
a.cc:17:6: error: expected unqualified-id before 'delete'
   17 | void delete( int );
      |      ^~~~~~
a.cc: In function 'int main()':
a.cc:49:14: error: type 'int' argument given to 'delete', expected pointer
   49 |       delete(k);
      |             ~^~
a.cc: At global scope:
a.cc:101:6: error: expected unqualified-id before 'delete'
  101 | void delete(int k){
      |      ^~~~~~
Language: C++

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
struct o{
	int key;
	o *r,*l,*p;
};
o *root,*NIL;

o *find(o *u,int k)
{
	while(u!=NIL&&k!=u->key)
	{
		if(k<u->key)u=u->l;
		else        u=u->r;
	}
	return u;
}
o *Min(o *x)
{
	while(x->l!=NIL)x=x->l;
	return x; 
}
o *successor(o *x)
{
  if(x->r!=NIL)return  Min(x->r);
  o *y=x->p;
  while(y!=NIL&&x==y->r)
  {
  	x=y;
  	y=y->p;
  }	
  return y;
}

o *delet(o *bt)
{
	if(bt->l==NULL&&bt->r==NULL)
	  {
	  	if(bt==bt->p->l)bt->p->l=NULL;
	    else if(bt==bt->p->r)bt->p->r=NULL;
	    free(bt);
	  }
	else if((bt->r==NULL&&bt->l!=NULL))
	   {
	   	if(bt->p==NULL)
	   	  {	
			root=bt->l;
	   	  	bt->l->p=NULL;
			free(bt);
	   	  }
	   	else
	   	  {
	   	  	bt->l->p=bt->p;
	   	  	bt->p->l=bt->l;
	   	  	free(bt);
	   	  }
       }
    else if(bt->l==NULL&&bt->r!=NULL)
       {
    	if(bt->p==NULL)
	   	  {	
			root=bt->r;
	   	  	bt->r->p=NULL;
			free(bt);
	   	  }
	   	else
	   	  {
	   	  	bt->r->p=bt->p;
	   	  	bt->p->r=bt->r;
	   	  	free(bt);
	   	  }
       }
    else 
       {
    	 bt->k=bt->r->k;
    	 delet(bt->r);
       }
}


void insert(int k){
	o *y=NIL;
	o *x=root;
	o *z;
	z=(o *)malloc(sizeof(o));
	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(o *u)
{
	if(u==NIL)return;
	inorder(u->l);
	printf(" %d",u->key);
	inorder(u->r);
}
void preorder(o *u)
{
	if(u==NIL)return;
    printf(" %d",u->key);	
	preorder(u->l);
	preorder(u->r);
}

int main()
{
	int n,i,x;
	string c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
    {
    	cin>>c;
    	if(c=="insert")
    	{
    		scanf("%d",&x);
    		insert(x);
		}
		else if(c=="print")
		{
			inorder(root);
			cout<<endl;
			preorder(root);
			cout<<endl;
		}
		else if(c=="find")
		{
			scanf("%d",&x);
			o *t=find(root,x);
			if(t!=NIL)printf("yes\n");
			else       printf("no\n");
		}
    	else if(c=="delete")
    	{
    		scanf("%d",&x);
    		delet(find(root,x));
    		
		}
    }
    return 0;
}

Compiler output:
a.cc: In function 'o* delet(o*)':
a.cc:81:14: error: 'struct o' has no member named 'k'
   81 |          bt->k=bt->r->k;
      |              ^
a.cc:81:23: error: 'struct o' has no member named 'k'
   81 |          bt->k=bt->r->k;
      |                       ^
a.cc:84:1: warning: no return statement in function returning non-void [-Wreturn-type]
   84 | }
      | ^