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

#include<stdio.h>
#include<stdlib.h>
 
typedef struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}node;
typedef node* Node;
#define NIL NULL
 
Node root;
 void insert(int key){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = (Node)malloc(sizeof(node));
  z->key = key;
  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 treeSearch(Node u, int key){
  while (u != NIL && u->key != key) {
    if (key < u->key) u = u->left;
    else u = u->right;
  }
   return u;
} 

  
 Node treeSuccessor(Node x){
   Node y;
  
   if (x->right != NIL) return treeMinimum(x->right);
  
   y = x->parent;
  
   while (y != NIL && x == y->right) {
     x = y;
     y = y->parent;
   }
  
   return y;
 }
  
 void treeDelete(Node z){
   Node y; // node to be deleted
   Node x; // child of y
  
   if (z->left == NIL || z->right == NIL) y = z;
   else y = treeSuccessor(z);
  
   if (y->left != NIL) x = y->left;
   else x = y->right;
  
   if (x != NIL) x->parent = y->parent;
  
   if (y->parent == NIL) root = x;
   else if (y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  
  if (y != z) z->key = y->key;
 
}

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

 

void preorder(Node u){
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}
 void inorder(Node u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
 
int main(){
       int n, i, key;
       char com[20];
       scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( *com == 'f' ){
      scanf("%d", &key);
      Node t = treeSearch(root, key);
      if ( t != NIL ) puts("yes");
      else puts("no");
    } else if ( *com == 'i' ){
      scanf("%d", &key);
      insert(key);
    } else if ( *com == 'p' ){
      inorder(root);
      puts("");
      preorder(root);
      puts("");
    } else if ( *com == 'd' ){
      scanf("%d", &key);
      treeDelete(treeSearch(root, key));
    }
  }
  
  return 0;
}

Compiler output:
main.c: In function 'treeSuccessor':
main.c:50:32: error: implicit declaration of function 'treeMinimum' [-Wimplicit-function-declaration]
   50 |    if (x->right != NIL) return treeMinimum(x->right);
      |                                ^~~~~~~~~~~
main.c:50:32: error: returning 'int' from a function with return type 'Node' {aka 'node *'} makes pointer from integer without a cast [-Wint-conversion]
   50 |    if (x->right != NIL) return treeMinimum(x->right);
      |                                ^~~~~~~~~~~~~~~~~~~~~
main.c: At top level:
main.c:82:6: error: conflicting types for 'treeMinimum'; have 'node *(node *)'
   82 | Node treeMinimum(Node x){
      |      ^~~~~~~~~~~
main.c:50:32: note: previous implicit declaration of 'treeMinimum' with type 'int()'
   50 |    if (x->right != NIL) return treeMinimum(x->right);
      |                                ^~~~~~~~~~~
Language: C

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

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

struct Node *root,*NIL;

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

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

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

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

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

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

void delete(struct Node *z){
  struct Node *y=NIL;
  struct Node *x=NIl;

  if(z.left==NIL || z.right==NIL){
    y=z;
  } else {
      y=getSuccessor(z);
    }
    if(y->left!=NIL){
      x=x->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 inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

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

int main(){
  int n,i,x;
  struct Node *fi;
  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);
      fi=find(root,x);
      if(fi==NIL) printf("no\n");
      else printf("yes\n");
    }
    else if(str[0]='d'){
      scanf("%d",&x);
      delete(find(root,x));
    }
  }
  return 0;
}

Compiler output:
main.c: In function 'getSuccessor':
main.c:50:12: error: 'NIl' undeclared (first use in this function); did you mean 'NIL'?
   50 |   while(y!=NIl&&x==y->right){
      |            ^~~
      |            NIL
main.c:50:12: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'delete':
main.c:59:18: error: 'NIl' undeclared (first use in this function); did you mean 'NIL'?
   59 |   struct Node *x=NIl;
      |                  ^~~
      |                  NIL
main.c:61:7: error: 'z' is a pointer; did you mean to use '->'?
   61 |   if(z.left==NIL || z.right==NIL){
      |       ^
      |       ->
main.c:61:22: error: 'z' is a pointer; did you mean to use '->'?
   61 |   if(z.left==NIL || z.right==NIL){
      |                      ^
      |                      ->
Language: C

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

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

struct Node *root,*NIL;

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

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

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

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

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

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

void delete(struct Node *z){
  struct Node *y=NIL;
  struct Node *x=NIL;

  if(z.left==NIL || z.right==NIL){
    y=z;
  } else {
      y=getSuccessor(z);
    }
    if(y->left!=NIL){
      x=x->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 inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

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

int main(){
  int n,i,x;
  struct Node *fi;
  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);
      fi=find(root,x);
      if(fi==NIL) printf("no\n");
      else printf("yes\n");
    }
    else if(str[0]='d'){
      scanf("%d",&x);
      delete(find(root,x));
    }
  }
  return 0;
}

Compiler output:
main.c: In function 'delete':
main.c:61:7: error: 'z' is a pointer; did you mean to use '->'?
   61 |   if(z.left==NIL || z.right==NIL){
      |       ^
      |       ->
main.c:61:22: error: 'z' is a pointer; did you mean to use '->'?
   61 |   if(z.left==NIL || z.right==NIL){
      |                      ^
      |                      ->
Language: C

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

struct node {
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};
typedef struct node * Node;
Node root;
void Insert(int );
void inorder(Node );
void preorder(Node );
Node search(Node, int);
Node treeSuccessor(Node );
void treeDelete(Node );
Node treeMinimum(Node);
int main()
{
  int i,j,k,yflag=0,nflag=0;
  char c[10];
  Node a;
  scanf("%d",&k);

  for(i=0;i<k;i++)
    {
      scanf("%s",&c[0]);
      if(c[0]=='f')
        {
          scanf("%d",&j);
          a=search(root,j);
          if(a!=NIL) printf("yes\n");
          else printf("no\n");
        }
      if(c[0]=='i')
        {
          scanf("%d",&j);
          Insert(j);
        }
else if(c[0]=='p')
        {
          inorder(root);
          printf("\n");
          preorder(root);
          printf("\n");
        }
else if(c[0]=='d')
        {
          scanf("%d",&x);
          treeDelete(search(root,x));
        }

    }
  return 0;
}

void Insert(int p)
{
  Node x=root;
  Node y=NIL;
  Node z;

  z=(Node )malloc(sizeof(struct node));
  z->key=p;
  z->left=NIL;
  z->right=NIL;

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

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

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

void preorder(Node x)
{
  if(x==NIL) return;
  printf(" %d",x->key);
  preorder(x->left);
  preorder(x->right);
}
Node search(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)
{
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL&&x==y->right)
    {
      x=y;
      y=y->parent;
    }
  return y;
}
void treeDelete(Node z)
{
  Node y,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);
}

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

Compiler output:
main.c: In function 'main':
main.c:51:23: error: 'x' undeclared (first use in this function)
   51 |           scanf("%d",&x);
      |                       ^
main.c:51:23: note: each undeclared identifier is reported only once for each function it appears in
Language: C

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

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

Node* tree;

void insert(int);
void inorder(Node*);
void preorder(Node*);
void delete(Node*);
Node* find(Node*,int);
Node* Minimum(Node*);
Node* Successor(Node*);

int main(){
  int m,i,k;
  char hairetu[10];
  Node* f;

  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",hairetu);
    if(s[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(hairetu[0]=='p'){
      inorder(tree);
      printf("\n");
      preorder(tree);
      printf("\n");
    }
    
    else if(s[0]=='f'){
      scanf("%d",&k);
      f=find(tree,k);
      if(f!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(hairetu[0]=='d'){
      scanf("%d",&k);
      if((f=find(tree,k))!=NIL) delete(f);
    }
  }

  return 0;
}

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

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

  if(y==NIL) tree=z;
  else if(z->k < y->k) y->left=z;
  else y->right=z;
  
  return;
}

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

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

Node* find(Node* tree,int f){
  if(tree != NIL){
    if(tree->k == f) return tree;
    if(tree->k > f) return find(tree->left,f);
    else return find(tree->right,f);
  }
  
  else return NIL;
}

void delete(Node* z){
  Node* y;
  Node* 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) tree=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right = x;

  if(y!=z){
    z->k = y->k;
  }
  
  return;
}

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

Node* Successor(Node* x){
  Node* y;

  if(x->right != NIL) return Minimum(x->right);

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

Compiler output:
main.c: In function 'main':
main.c:31:8: error: 's' undeclared (first use in this function)
   31 |     if(s[0]=='i'){
      |        ^
main.c:31:8: note: each undeclared identifier is reported only once for each function it appears in
Language: C

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

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

Node* tree;

void insert(int);
void inorder(Node*);
void preorder(Node*);
void delete(Node*);
Node* find(Node*,int);
Node* Minimum(Node*);
Node* Successor(Node*);

int main(){
  int m,i,k;
  char hairetu[10];
  Node* f;

  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",hairetu);
    if(s[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(hairetu[0]=='p'){
      inorder(tree);
      printf("\n");
      preorder(tree);
      printf("\n");
    }
    
    else if(hairetu[0]=='f'){
      scanf("%d",&k);
      f=find(tree,k);
      if(f!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(hairetu[0]=='d'){
      scanf("%d",&k);
      if((f=find(tree,k))!=NIL) delete(f);
    }
  }

  return 0;
}

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

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

  if(y==NIL) tree=z;
  else if(z->k < y->k) y->left=z;
  else y->right=z;
  
  return;
}

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

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

Node* find(Node* tree,int f){
  if(tree != NIL){
    if(tree->k == f) return tree;
    if(tree->k > f) return find(tree->left,f);
    else return find(tree->right,f);
  }
  
  else return NIL;
}

void delete(Node* z){
  Node* y;
  Node* 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) tree=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right = x;

  if(y!=z){
    z->k = y->k;
  }
  
  return;
}

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

Node* Successor(Node* x){
  Node* y;

  if(x->right != NIL) return Minimum(x->right);

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

Compiler output:
main.c: In function 'main':
main.c:31:8: error: 's' undeclared (first use in this function)
   31 |     if(s[0]=='i'){
      |        ^
main.c:31:8: note: each undeclared identifier is reported only once for each function it appears in
Language: C

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

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

Node root;

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

  return y;

}

Node treeMaximum(Node x){
 Node y;
  y=x;
  while(y->left!=NIL) y=y->right;

  return y;

}

Node treeSearch(Node u, int k){
  Node x;
  x=u;

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

  return x;

}

Node treeSuccessor(Node x){
  Node y;

  if(x->right!=NIL)return treeMinimum(x->right);

  y=x->p;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->p;
  }
  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->p=y->p;
  if(y->p==root)root=x;
  else if(y == y->p->left)y->p->left=x;
  else y->p->right=x;

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

}

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(k < x->key)x=x->left;
    else x=x->right;
  }
  z->p=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;
  char com[20];
  Node t;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
       t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");!.

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

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:133:28: error: expected expression before '.' token
  133 |       else printf("no\n");!.
      |                            ^
Language: C

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

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

nodeinfo root = NULL;

void insert(int key){
  nodeinfo x = root;
  nodeinfo y = NULL;
  nodeinfo t;
  t = (nodeinfo)malloc(sizeof(*t));
  t->key = key;
  t->left = NULL;
  t->right = NULL;
  while(x != NULL){
    y = x;
    if(t->key < x->key) x = x->left;
    else x = x->right;
  }
  t->parent = y;
  if(y == NULL) root = t;
  else if(t->key < y->key) y->left = t;
  else y->right = t;
}

int find(nodeinfo x, int key){
  if(key == x->key) return 1;
  else if(key < x->key){
    if(x->left == NULL) return 0;
    else return find(x->left, key);
  }
  else{
    if(x->right == NULL) return 0;
    else return find(x->right, key);
  }
  return 0;
}

nodeinfo getNext(nodeinfo x){
  if(x->left != NULL) return getNext(x->left);
  if(x->right != NULL) return getNext(x->right);
  if(x->left == NULL && x->right == NULL) return x;
}

void remove(nodeinfo x, int key){
  if(key == x->key){
    nodeinfo child;
    if(x->left == NULL && x->right == NULL) child = NULL;
    else if(x->left != NULL && x->right != NULL){
      nodeinfo dst = getNext(x->right);
      x->key = dst->key;
      remove(dst, dst->key);
      return;
    }
    else{
      if(x->left != NULL) child = x->left;
      else child = x->right;
    }
    nodeinfo parent = x->parent;
    if(parent->left != NULL && parent->left->key == key) parent->left = child;
    if(parent->right != NULL && parent->right->key == key) parent->right = child;
    if(!(x->left == NULL && x->right == NULL)) child->parent = parent;
    free(x);
  }
  else if(key < x->key) remove(x->left, key);
  else remove(x->right, key);
}

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

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

int main() {
  int i, n, key;
  char command[7];
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", command);
    if(command[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      continue;
    }
    scanf("%d", &key);
    if(command[0] == 'i') insert(key);
    else if(command[0] == 'f'){
      if(find(root, key) == 1) printf("yes\n");
      else printf("no\n");
    }
    else remove(root, key);
  }
  return 0;
}


Compiler output:
main.c:52:6: error: conflicting types for 'remove'; have 'void(struct node *, int)'
   52 | void remove(nodeinfo x, int key){
      |      ^~~~~~
In file included from main.c:1:
/usr/include/stdio.h:158:12: note: previous declaration of 'remove' with type 'int(const char *)'
  158 | extern int remove (const char *__filename) __THROW;
      |            ^~~~~~
Language: C

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
//NIL is NULL
#define NIL NULL
//Node structure
struct Node{
  int key;
  struct Node *parent;
  struct Node *leftc;
  struct Node *rightc;
};
//define Nodepointer
typedef struct Node * Nodepointer;
 
//root        
Nodepointer root;
 
//function insert
void insert(int k){
  Nodepointer x,y,z;
  y=NIL;
  x=root;
  //make memory
  z=new struct Node();
 
  z->key=k;
  z->leftc=NIL;
  z->rightc=NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->leftc;
    else x=x->rightc;
  }
 
  z->parent=y;
 
  if(y==NIL) root=z;
 
  else if(z->key<y->key) y->leftc=z;
 
  else y->rightc=z;
 
 
}
 
//function search
Nodepointer find(Nodepointer now,int data){
  if(now==NIL||data==now->key) return now;
  if(data<now->key) return find(now->leftc,data);
  else return find(now->rightc,data);
}
 
//function treeminimum
Nodepointer treeminimum(Nodepointer x){
  while(x->leftc!=NIL){
    x=x->leftc;
  }
  return x;
}
//function treesuccerssor
Nodepointer treesuccessor(Nodepointer x){
  Nodepointer y;
  if(x->rightc!=NIL) return treeminimum(x->rightc);
  y=x->parent;
  while(y!=NIL && x==x->rightc){
    x=y;
    y=y->parent;
  }
  return y;
}
//function treedelete
void treedelete(Nodepointer z){
  Nodepointer x,y;
  if(z->leftc==NIL ||z->rightc==NIL)y=z;
  else y=treesuccessor(z);
 
  if(y->leftc!=NIL)x=y->leftc;
  else x=y->rightc;
  
  if(x!=NIL)x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else if(y==y->parent->leftc) y->parent->leftc=x;
  else y->parent->rightc=x;
  if(y!=z) z->key=y->key;
}
 
//print
void inorderprint(Nodepointer now){
  if(now!=NIL){
    inorderprint(now->leftc);
    printf(" %d",now->key);
    inorderprint(now->rightc);
  }
}
 
void preorderprint(Nodepointer now){
  if(now!=NIL){
    printf(" %d",now->key);
    preorderprint(now->leftc);
    preorderprint(now->rightc);
  }
}
 
 
int main(){
 
  int n,i,j,data;
  Nodepointer del;
  char str[10];
  //load n
  scanf("%d",&n);
  //load commnad and key
  for(i=0;i<n;i++){
    scanf("%s",str);
    //insert
    if(strcmp(str,"insert")==0) {
      scanf("%d",&data);
      insert(data);
    }
    //find
    else if(strcmp(str,"find")==0){
      scanf("%d",&data);
      if(find(root,data)!=NIL) printf("yes\n");
      else printf("no\n");
    }
    //delete
    else if(strcmp(str,"delete")==0){
      scanf("%d",&data);
      del=find(root,data);
      treedelete(del);
    }
    //print
    else if(strcmp(str,"print")==0){
      inorderprint(root);
      cout <<endl;
      preorderprint(root);
      cout <<endl;
    }
  }
 
  return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

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

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

Node root;

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

Node treeSearch(Node u, int k){
     if (u == NIL){return NIL;}
    if (u->key == k){ return u; }
    else if (u->key > k){
        return treeSearch(u->left, k);
    }
    else{
        return treeSearch(u->right, k);
    }
}

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

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL){
    y=z;
  }
  else y=(Node)treeSuccessor(z);
  
  if(y->left!=NIL){
    x=y->left;
  }
  else x =y->right;

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

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

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

Compiler output:
main.c: In function 'insert':
main.c:76:3: error: expected declaration or statement at end of input
   76 |   Node y = NIL;
      |   ^~~~
Language: C

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

void pre(Node);
void ino(Node);
void ins(int);
void tD(Node);
Node tSuc(Node);
Node tM(Node);
Node tS(Node,int);

int main(){
  int n, i, x;
  char c[20];
 
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", c);
    if ( c[0] == 'f' ){
      scanf(" %d", &x);
       
      Node t = tS(root, x);
       
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } 
    else if ( c[0] == 'i' ){
      scanf("%d", &x);
      ins(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      tD(tS(root, x));
    }
  }
   
  return 0;
}


Node tM(Node x){
  while(x->l != NIL){
    x = x->l;
  }
  return x;
}
 
Node tS(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->l;
    else u = u->r;
  }
  return u;
}
 
Node tSuc(Node x){
  Node y;
 
  if(x->r != NIL) return tM(x->r);
   
  y = x->parent;
   
  while(y != NIL && x == y->r){
    x = y;
    y = y->parent;
  }
  return y;
}
 
void tD(Node z){
  Node y; 
  Node x; 
   
  if(z->l == NIL || z->r == NIL) y = z;
  else y = tSuc(z);
   
  if(y->l != NIL) x = y->l;
  else x = y->r;
   
  if(x != NIL) x->parent = y->parent;
   
  if(y->parent == NIL) root = x;
  else if(y == y->parent->l) y->parent->l = x;
  else y->parent->r = x;
   
  if(y != z){
    z->key = y->key;
     
  }  
}
 
void ins(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->parent = y;
   
  if(y == NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;  
}
 
void ino(Node k){
  if(u != NIL){
    ino(k->l);
    printf(" %d", k->key);
    ino(k->r);
  }
}
 
void pre(Node k){
  if(k != NIL){
    printf(" %d", k->key);
    pre(k->l);
    pre(k->r);
  }
}
 
 

Compiler output:
main.c: In function 'main':
main.c:45:15: error: 'com' undeclared (first use in this function)
   45 |     else if ( com[0] == 'p' ){
      |               ^~~
main.c:45:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:46:7: error: implicit declaration of function 'inorder' [-Wimplicit-function-declaration]
   46 |       inorder(root);
      |       ^~~~~~~
main.c:48:7: error: implicit declaration of function 'preorder' [-Wimplicit-function-declaration]
   48 |       preorder(root);
      |       ^~~~~~~~
main.c: In function 'ino':
main.c:136:6: error: 'u' undeclared (first use in this function)
  136 |   if(u != NIL){
      |      ^
Language: C

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

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

typedef struct node * Node;
#define NIL NULL

Node root;

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

Node treeSearch(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){
  Node y;
  if((*x).right != NIL)
    return treeMinimum((*x).right);
  y = (*x).perent;
  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;
      z = y;
    }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if((*z).key < (*x).key)
      x = (*x).left;
    else x = (*x).right;
    (*z).parent = y;
  }
  if(y == NIL)
    root = z;
  else if( (*z).key < (*y).key )
    (*y).left = z;
  else (*y).right = z; 
}

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

void preorder(Node u){
  if(u != NIL)
    {   
      printf(" %d",(*u).key);

      preorder((*u).left);
      
      preorder((*u).right);
    }
}


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

Compiler output:
main.c: In function 'treeSuccessor':
main.c:40:12: error: 'struct node' has no member named 'perent'; did you mean 'parent'?
   40 |   y = (*x).perent;
      |            ^~~~~~
      |            parent
Language: C

#include<stdio.h>
#include<stdlib.h>
  
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
  
Node root;
  
Node tree_minimum(Node x){
  
    while(x->left != NULL){
      x = x->left;
    }
    return x;
}
  
Node tree_search(Node u, int k){
  
    if(u->key > k){
        if(u->left==NIL){  /* もし左側になければ，keyはない */
            return NIL;
        }
        return tree_search(u->left, k);
    }
    /* 自分より大きい値ならば，右側 */
    if(u->key < k){
        if(u->right == NULL){
            return NULL;      /* もし右側になければ，keyはない */
        }
        return tree_search(u->right, k);
    }
  
    return u;
}
 
Node tree_successor(Node x){
  Node y;
  if (x->right != NIL){
    return tree_minimum(x->right);
  }
  y = x->parent;
  while (y != NIL && x == y->right){
    x = y;
    y = y->parent;
    return y;
  }
}

  
void tree_delete(Node z){
  Node x,y;
  if(z != NIL){
    if(z->left == NIL || z->right == NIL){
         /* 左か右，どちらかがNULLであった場合(両方NULLの場合も含む) */
          y = z;
    } else {
          y = tree_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;
        z->parent = y->parent;
        z->left = y->left;
        z->right = y->right;
      }
}
  
void insert(int k){
  
  Node y = NIL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;


    while(x != NIL){
        y = x;
        if (z->key < x->key){
            x = x->left;
        }else {
            x = x->right;
        }
    }
    z->parent = y;
 
    if (y == NIL){
        root = z ; 
    } else if (z->key < y->key){
        y->left = z;
    } else {
        y->right = z;
    }
}
  
void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf("%2d", u->key);
    inorder(u->right);
  }
}
  
void preorder(Node u){
  
  if (u != NIL){
    printf("%2d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
  
  
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = tree_search(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      tree_delete(tree_search(root, x));
    }
  }
  return 0;
}

Compiler output:
main.c: In function 'tree_delete':
main.c:72:20: error: 'y' is a pointer; did you mean to use '->'?
   72 |       x->parent = y.parent;
      |                    ^
      |                    ->
main.c:164:1: error: expected declaration or statement at end of input
  164 | }
      | ^
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;
  }
  reutrn 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* treeSuccessor(Node*)':
a.cc:34:3: error: 'reutrn' was not declared in this scope
   34 |   reutrn y;
      |   ^~~~~~
a.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
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 * teeSuccessor(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->let!=NIL){
    x = y->left;
  }else{
    x = y->right;
  }
  if(x!=NIL){
    x->parent = y->parent;
  }

  if(->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 'void treeDelete(Node*)':
a.cc:42:12: error: 'treeSuccessor' was not declared in this scope; did you mean 'teeSuccessor'?
   42 |   else y = treeSuccessor(z);
      |            ^~~~~~~~~~~~~
      |            teeSuccessor
a.cc:44:9: error: 'struct Node' has no member named 'let'; did you mean 'left'?
   44 |   if(y->let!=NIL){
      |         ^~~
      |         left
a.cc:53:6: error: expected primary-expression before '->' token
   53 |   if(->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){
  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->let!=NIL){
    x = y->left;
  }else{
    x = y->right;
  }
  if(x!=NIL){
    x->parent = y->parent;
  }

  if(->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 'void treeDelete(Node*)':
a.cc:44:9: error: 'struct Node' has no member named 'let'; did you mean 'left'?
   44 |   if(y->let!=NIL){
      |         ^~~
      |         left
a.cc:53:6: error: expected primary-expression before '->' token
   53 |   if(->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){
  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(->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 'void treeDelete(Node*)':
a.cc:53:6: error: expected primary-expression before '->' token
   53 |   if(->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){
  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;
  }
  reutrn y;
}

void treeDelete(Node *z){
  Node *y,*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* treeSuccessor(Node*)':
a.cc:34:3: error: 'reutrn' was not declared in this scope
   34 |   reutrn y;
      |   ^~~~~~
a.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^