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 treeMinumum(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 'Node* treeSuccessor(Node*)':
a.cc:37:12: error: 'treeMinumum' was not declared in this scope; did you mean 'treeMinimum'?
   37 |     return treeMinumum(x->right);
      |            ^~~~~~~~~~~
      |            treeMinimum
a.cc: In function 'void treeDelete(Node*)':
a.cc:50:9: error: declaration of 'Node* x' shadows a parameter
   50 |   Node* x; // child of node y
      |         ^
a.cc:47:23: note: 'Node* x' previously declared here
   47 | void treeDelete(Node* x)
      |                 ~~~~~~^
a.cc:52:7: error: 'z' was not declared in this scope
   52 |   if (z->left == NIL || z->right == NIL) {
      |       ^
a.cc:79:5: error: 'z' was not declared in this scope
   79 |     z->key = y->key;
      |     ^