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

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

Compiler output:
a.cc: In function 'Node* minimum(Node*)':
a.cc:9:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    9 |   while(x->key!=NIL) x=x->left;
      |         ~~~~~~^~~~~
a.cc: At global scope:
a.cc:28:6: error: expected unqualified-id before 'delete'
   28 | void delete(Node *x){
      |      ^~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'void treedelete(Node*)':
a.cc:29:12: error: declaration of 'Node* x' shadows a parameter
   29 |   Node *y,*x;
      |            ^
a.cc:28:23: note: 'Node* x' previously declared here
   28 | void treedelete(Node *x){
      |                 ~~~~~~^
a.cc:30:6: error: 'z' was not declared in this scope
   30 |   if(z->left==NIL||z->right==NIL) y=z;
      |      ^
a.cc:40:9: error: 'z' was not declared in this scope
   40 |   if(y!=z) z->key=y->key;
      |         ^
Language: C++

#include<cstdio>
#include<algorithm>
using namespace std;

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

typedef struct Node_tag Node;

Node *root;
Node *nil = (Node *)malloc(sizeof(Node));

void init(){
	nil->parent = nil->left = nil->right = nil;
	root = nil;
}

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

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

void insert(Node *z){
	Node *x = root, *y = 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(Node *x, int k){
	while(x != nil && k != x->key){
		if(k < x->key)
			x = x->left;
		else
			x = x->right;
	}
	return x;
}

Node* getMinimum(Node *x){
	while(x->left != nil)
		x = x->left;
	return x;
}

Node* getSuccessor(Node *x){
	if(x->right != nil)
		return getMinimum(x->right);
	Node *y = x->parent;
	while(y != nil && x == y->right){
		x = y;
		y = y->right;
	}
	return y;
}

deleteNode(Node *z){
	Node *x, *y;
	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;
}

int main(void){
	int m, i, key;
	char S[10];
	init();
	scanf("%d", &m);
	for(i = 0;i < m;i++){
		scanf("%s", S);
		if(S[0] == 'p'){
			inParse(root);
			printf("\n");
			preParse(root);
			printf("\n");
		} else {
			scanf("%d", &key);
			if(S[0] == 'i'){
				Node *z = (Node *)malloc(sizeof(Node));
				z->key = key;
				z->left = z->right = nil;
				insert(z);
			} else if(S[0] == 'f'){
				if(find(root, key) != nil)
					printf("yes\n");
				else
					printf("no\n");
			} else
				deleteNode(find(root, key));	//??¨????????¨?????????key????????????????????´?????¨??????????????????????????????
		}
	}
	return 0;
}

Compiler output:
a.cc:82:1: error: ISO C++ forbids declaration of 'deleteNode' with no type [-fpermissive]
   82 | deleteNode(Node *z){
      | ^~~~~~~~~~
a.cc: In function 'int deleteNode(Node*)':
a.cc:106:1: warning: no return statement in function returning non-void [-Wreturn-type]
  106 | }
      | ^
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#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 *treeMinimum(Node *x) {
	while (x->left != NIL)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;
		}
	}
}

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

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

	scanf("%d", &n);

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

	return 0;
}

Compiler output:
a.cc: In function 'Node* treeMinimum(Node*)':
a.cc:16:35: error: expected primary-expression before '->' token
   16 |         while (x->left != NIL)x = ->left;
      |                                   ^~
Language: C++

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

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;
}
  
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=treeMinimum(z->right);
    
  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;
  
  node z(k);
  
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;   
}
 
 
void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
 
int main(){
  int n,x;
  char str[20];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s", str);
    if(str[0]=='f'){
      scanf("%d",&x);
      Node t=treeSearch(root,x);
      if (t!=NIL) printf("yes\n");
      else printf("no\n");
    }else 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]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }
 
  return 0;
}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:59:8: error: conflicting declaration 'node z'
   59 |   node z(k);
      |        ^
a.cc:57:8: note: previous declaration as 'node* z'
   57 |   Node z;
      |        ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'node' was not declared in this scope
    9 |     node root = NULL;
      |     ^~~~
a.cc:16:13: error: 'root' was not declared in this scope
   16 |             root = insert(root,val);
      |             ^~~~
a.cc:16:20: error: 'insert' was not declared in this scope
   16 |             root = insert(root,val);
      |                    ^~~~~~
a.cc:19:13: error: 'res' was not declared in this scope
   19 |             res = 0;
      |             ^~~
a.cc:20:18: error: 'root' was not declared in this scope
   20 |             find(root, val);
      |                  ^~~~
a.cc:20:13: error: 'find' was not declared in this scope
   20 |             find(root, val);
      |             ^~~~
a.cc:23:17: error: 'root' was not declared in this scope
   23 |                 root = delete_bst(root, val);
      |                 ^~~~
a.cc:23:24: error: 'delete_bst' was not declared in this scope
   23 |                 root = delete_bst(root, val);
      |                        ^~~~~~~~~~
a.cc:25:19: error: 'root' was not declared in this scope
   25 |             print(root);
      |                   ^~~~
a.cc:25:13: error: 'print' was not declared in this scope; did you mean 'printf'?
   25 |             print(root);
      |             ^~~~~
      |             printf
Language: C++

#include<stdio.h>
#include<stdlib.h>
#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;	//yの子

	//削除する節点を決める
	if(z->left == NIL || z->right == NIL)
	{
		y = z;
	}
	else
	{
		y = treeSuccessor(z);
	}

	//yの子xを決める
	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);
}

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

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin >> com;
		if(com == "find")
		{
			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:15:20: error: 'node' was not declared in this scope; did you mean 'Node'?
   15 | Node * treeMinimum(node *x)
      |                    ^~~~
      |                    Node
a.cc:15:26: error: 'x' was not declared in this scope
   15 | Node * treeMinimum(node *x)
      |                          ^
a.cc: In function 'Node* treeSuccessor(Node*)':
a.cc:45:35: error: 'treeMinimum' cannot be used as a function
   45 |                 return treeMinimum(x->right);
      |                        ~~~~~~~~~~~^~~~~~~~~~
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;
}
}
x->parent=y;
if(y==NIL){
root=z;
}else{
if(z->key<y->key){
y->left=z;
}else{
y->right=z;
}
}
}
void inorder(Node *u){
if(u==NIL)return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node *u){
if(u==NIL)return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main()
{
int n,i,x;
string com;
scanf("%d",&n);
for(i=0;i<n;i++){
cin>>com;
if(com[0]=='f'){
scanf("%d",&x);
Node *t=find(root,x);
if(t!=NIL)printf(“yes\n");
else printf("no\n");
}else if(com=="insert"){
scanf("%d",&x);
insert(x);
}else if(com=="print"){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}else if(com=="delete"){
scanf("%d",&x);
treeDelete(find(root,x));
}
}
return 0;
}



Compiler output:
a.cc:107:18: error: extended character “ is not valid in an identifier
  107 | if(t!=NIL)printf(“yes\n");
      |                  ^
a.cc:107:22: error: stray '\' in program
  107 | if(t!=NIL)printf(“yes\n");
      |                      ^
a.cc:107:24: warning: missing terminating " character
  107 | if(t!=NIL)printf(“yes\n");
      |                        ^
a.cc:107:24: error: missing terminating " character
  107 | if(t!=NIL)printf(“yes\n");
      |                        ^~~
a.cc: In function 'int main()':
a.cc:107:18: error: '\U0000201cyes' was not declared in this scope
  107 | if(t!=NIL)printf(“yes\n");
      |                  ^~~~
Language: C++

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

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

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

    ~NodeAllocator() {
        DeleteAllAlloc();
    }

//    void DeleteElem(T* e) {
//        return;
//    }

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

        assigned_ = 0;
        reserved_ = 0;
    }

    int reserved_;
    int assigned_;
    T *buf_;
};


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) {
  whlie ( 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;  // yの子

  // 削除する節点を決める
  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  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);
}

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 'Node* treeMinimum(Node*)':
a.cc:15:3: error: 'whlie' was not declared in this scope
   15 |   whlie ( x->left != NIL ) x = x->left;
      |   ^~~~~
a.cc: In function 'void treeDelete(Node*)':
a.cc:52:26: error: expected ';' before 'if'
   52 |     x->parent = y->parent
      |                          ^
      |                          ;
   53 | 
   54 |   if ( y->parent == NIL ) {
      |   ~~
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) {
  whlie ( 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;  // yの子

  // 削除する節点を決める
  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  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);
}

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 'Node* treeMinimum(Node*)':
a.cc:15:3: error: 'whlie' was not declared in this scope
   15 |   whlie ( x->left != NIL ) x = x->left;
      |   ^~~~~
Language: C++

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



Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin>>n;
      |     ^~~
a.cc:9:13: error: 'insert' was not declared in this scope
    9 |             insert(x);
      |             ^~~~~~
a.cc:12:13: error: 'Node' was not declared in this scope
   12 |             Node *t=find(root,x);
      |             ^~~~
a.cc:12:19: error: 't' was not declared in this scope
   12 |             Node *t=find(root,x);
      |                   ^
a.cc:12:26: error: 'root' was not declared in this scope
   12 |             Node *t=find(root,x);
      |                          ^~~~
a.cc:12:21: error: 'find' was not declared in this scope
   12 |             Node *t=find(root,x);
      |                     ^~~~
a.cc:13:19: error: 'NIL' was not declared in this scope
   13 |             if(t!=NIL)printf("yes\n");
      |                   ^~~
a.cc:13:23: error: 'printf' was not declared in this scope
   13 |             if(t!=NIL)printf("yes\n");
      |                       ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int main(){
a.cc:14:18: error: 'printf' was not declared in this scope
   14 |             else printf("no\n");
      |                  ^~~~~~
a.cc:14:18: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:16:21: error: 'root' was not declared in this scope
   16 |             inorder(root);
      |                     ^~~~
a.cc:16:13: error: 'inorder' was not declared in this scope
   16 |             inorder(root);
      |             ^~~~~~~
a.cc:17:13: error: 'putchar' was not declared in this scope; did you mean 'char'?
   17 |             putchar('\n');
      |             ^~~~~~~
      |             char
a.cc:18:13: error: 'preorder' was not declared in this scope
   18 |             preorder(root);
      |             ^~~~~~~~
a.cc:22:29: error: 'root' was not declared in this scope
   22 |             treeDelete(find(root,x));
      |                             ^~~~
a.cc:22:24: error: 'find' was not declared in this scope
   22 |             treeDelete(find(root,x));
      |                        ^~~~
a.cc:22:13: error: 'treeDelete' was not declared in this scope
   22 |             treeDelete(find(root,x));
      |             ^~~~~~~~~~
Language: C++

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

using namespace std;

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

Node* root;
Node* NIL;

Node* 
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* x) 
{
  Node* y; // node to delete
  Node* x; // child of node 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 != x) {
    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 preOrder(Node* u) {
  if (u == NIL) {
    return;
  }
  cout << " " << u->key;
  preOrder(u->left);
  preOrder(u->right);
}

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

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

  int x;
  string com;
  for (int i = 0; i < N; i++) {
    cin >> com;
    if (com == "insert") {
      cin >> x;
      insert(x);
    } else if (com == "find") {
      cin >> x;
      Node* f = find(root, x);
      if (f != NIL) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    } else if (com == "print") {
      inOrder(root);
      cout << endl;
      preOrder(root);
      cout << endl;
    } else if (com == "delete") {
      cin >> x;
      treeDelete(find(root, x));
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'void treeDelete(Node*)':
a.cc:51:9: error: declaration of 'Node* x' shadows a parameter
   51 |   Node* x; // child of node y
      |         ^
a.cc:48:23: note: 'Node* x' previously declared here
   48 | void treeDelete(Node* x)
      |                 ~~~~~~^
a.cc:53:7: error: 'z' was not declared in this scope
   53 |   if (z->left == NIL || z->right == NIL) {
      |       ^
a.cc:80:5: error: 'z' was not declared in this scope
   80 |     z->key = y->key;
      |     ^
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 * 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 *x, *y;
  x = root;
  y = NIL;

  Node *z;

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

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

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

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

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

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

  scanf("%d", &n);

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

  return 0;
}



Compiler output:
a.cc: In function 'Node* find(Node*, int)':
a.cc:20:29: error: 'key' was not declared in this scope
   20 |   while( u != NIL && k != u-key) {
      |                             ^~~
a.cc: In function 'void treeDelete(Node*)':
a.cc:50:12: error: expected primary-expression before '=' token
   50 |   if ( x !== NIL ) {
      |            ^
a.cc: In function 'void inorder(Node*)':
a.cc:106:3: error: 'print' was not declared in this scope; did you mean 'printf'?
  106 |   print("%d", u->key);
      |   ^~~~~
      |   printf
a.cc: In function 'void preorder(Node*)':
a.cc:112:3: error: 'print' was not declared in this scope; did you mean 'printf'?
  112 |   print("%d", u->key);
      |   ^~~~~
      |   printf
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 * 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 *x, *y;
  x = root;
  y = NIL;

  Node *z;

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

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

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

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

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

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

  scanf("%d", &n);

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

  return 0;
}



Compiler output:
a.cc: In function 'void treeDelete(Node*)':
a.cc:50:12: error: expected primary-expression before '=' token
   50 |   if ( x !== NIL ) {
      |            ^
a.cc: In function 'void inorder(Node*)':
a.cc:106:3: error: 'print' was not declared in this scope; did you mean 'printf'?
  106 |   print("%d", u->key);
      |   ^~~~~
      |   printf
a.cc: In function 'void preorder(Node*)':
a.cc:112:3: error: 'print' was not declared in this scope; did you mean 'printf'?
  112 |   print("%d", u->key);
      |   ^~~~~
      |   printf
Language: C++

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

typedef int long long

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

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

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


Compiler output:
a.cc:7:9: error: multiple types in one declaration
    7 | typedef int long long
      |         ^~~
a.cc:12:1: error: declaration does not declare anything [-fpermissive]
   12 | };
      | ^
Language: C++

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

typedef int long long;

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

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

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


Compiler output:
a.cc:7:18: error: declaration does not declare anything [-fpermissive]
    7 | typedef int long long;
      |                  ^~~~
Language: C++

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

#define int long long

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

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

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


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C

#include<stdio.h>
#include<stdlib.h>
struct tree {
  int key;
  int priority;
  struct tree *left;
  struct tree *right;
};
struct tree *root = NULL;
int Search(struct tree *p, int key);
struct tree *Lrotation(struct tree *p);
struct tree *Rrotation(struct tree *p);
struct tree *Insert(struct tree **p, int key, int priority);
struct tree *Delete(struct tree **p, int key);
struct tree *delete(struct tree **p, int key);
void Dispm(struct tree *p);
void Dispp(struct tree *p);
int main(void)
{
  int i, count, key, priority;
  char command[7];
  scanf("%d", &count);
  for (i = 0; i < count; i++) {
    scanf("%*c%s", command);
    switch (command[0]) {
    case 'f':
      scanf("%d", &key);
      if (Search(root, key)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
      break;
    case 'i':
      scanf("%d %d", &key, &priority);
      root = Insert(&root, key, priority);
      break;
    case 'd':
      scanf("%d", &key);
      Delete(&root, key);
      break;
    case 'p':
      Dispm(root);
      putchar('\n');
      Dispp(root);
      putchar('\n');
      break;
    }
  }
  return 0;
}
int Search(struct tree *p, int key)
{
  if (p == NULL) {
    return 0;
  } else if (p->key == key) {
    return 1;
  } else if (p->key > key) {
    return Search(p->left, key);
  } else {
    return Search(p->right, key);
  }
}
struct tree *Lrotation(struct tree *p)
{
  struct tree *q = p->right;
  p->right = q->left;
  q->left = p;
  return q;
}
struct tree *Rrotation(struct tree *p)
{
  struct tree *q = p->left;
  p->left = q->right;
  q->right = p;
  return q;
}
struct tree *Insert(struct tree **p, int key, int priority)
{
  if (*p == NULL) {
    *p = (struct tree*)malloc(sizeof(struct tree));
    (*p)->key = key;
    (*p)->priority = priority;
    (*p)->left = NULL;
    (*p)->right = NULL;
  } else if ((*p)->key > key) {
    (*p)->left = Insert(&(*p)->left, key, priority);
    if ((*p)->priority <  (*p)->left->priority) *p = Rrotation(*p);
  } else if ((*p)->key < key) {
    (*p)->right = Insert(&(*p)->right, key, priority);
    if ((*p)->priority <  (*p)->right->priority) *p = Lrotation(*p);
  }
  return *p;
}
struct tree *Delete(struct tree **p, int key)
{
  if ((*p) == NULL) return NULL;
  if ((*p)->key > key) (*p)->left = Delete(&(*p)->left, key);
  else if ((*p)->key < key) (*p)->right = Delete(&(*p)->right, key);
  else delete(p, key);
  return *p;
}
struct tree *delete(struct tree **p, int key)
{
  if ((*p)->left == NULL && (*p)->right == NULL) return *p = NULL;
  else if ((*p)->left == NULL) *p = Lrotation(*p);
  else if ((*p)->right == NULL) *p = Rrotation(*p);
  else {
    if ((*p)->left->priority > (*p)->right->priority) *p = Rrotation(*p);
    else *p = Lrotation(*p);
  }
  return Delete(p, key);
}
void Dispm(struct tree *p)
{
  if (p != NULL) {
    Dispm(p->left);
    printf(" %d", p->key);
    Dispm(p->right);
  }
}
void Dispp(struct tree *p)
{
  if (p != NULL) {
    printf(" %d", p->key);
    Dispp(p->left);
    Dispp(p->right);
}



Compiler output:
main.c: In function 'Dispp':
main.c:128:1: error: expected declaration or statement at end of input
  128 | }
      | ^