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){#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;

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

  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;
  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);
      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 'treeSearch':
main.c:23:26: error: stray '#' in program
   23 |     else if (u->key > k){#include<stdio.h>
      |                          ^
main.c:23:27: error: 'include' undeclared (first use in this function)
   23 |     else if (u->key > k){#include<stdio.h>
      |                           ^~~~~~~
main.c:23:27: note: each undeclared identifier is reported only once for each function it appears in
main.c:23:35: error: 'stdio' undeclared (first use in this function); did you mean 'stdin'?
   23 |     else if (u->key > k){#include<stdio.h>
      |                                   ^~~~~
      |                                   stdin
main.c:27:1: error: expected expression before 'typedef'
   27 | typedef struct node{
      | ^~~~~~~
main.c: In function 'insert':
main.c:100:16: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
  100 |         return treeSearch(u->left, k);
      |                ^~~~~~~~~~~~~~~~~~~~~~
main.c:97:6: note: declared here
   97 | void insert(int k){
      |      ^~~~~~
main.c: In function 'treeSearch':
main.c:102:5: error: expected '}' before 'else'
  102 |     else{
      |     ^~~~
main.c: In function 'insert':
main.c:202:6: error: assignment to 'Node' {aka 'struct node *'} from incompatible pointer type 'Node' {aka 'struct node *'} [-Wincompatible-pointer-types]
  202 |     y=z;
      |      ^
main.c:204:30: error: passing argument 1 of 'treeSuccessor' from incompatible pointer type [-Wincompatible-pointer-types]
  204 |   else y=(Node)treeSuccessor(z);
      |                              ^
      |                              |
      |                              Node {aka struct node *}
main.c:154:25: note: expected 'Node' {aka 'struct node *'} but argument is of type 'Node' {aka 'struct node *'}
  154 | Node treeSuccessor(Node x){
      |                    ~~~~~^
main.c:222:7: warning: comparison of distinct pointer types lacks a cast [-Wcompare-distinct-pointer-types]
  222 |   if(y!=z){
      |       ^~
main.c: In function 'treeDelete':
main.c:227:6: error: redefinition of 'insert'
  227 | void insert(int k){
      |      ^~~~~~
main.c:197:6: note: previous definition of 'insert' with type 'void(int)'
  197 | void insert(int k){
      |      ^~~~~~
main.c:303:1: error: expected declaration or statement at end of input
  303 | }
      | ^