Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)
#define NIL -1
using namespace std;
 
typedef struct{
    int key;
    int right;
    int left;
    int parent;
}node;
 
void insert(vector<node> &T, int i, int *root) {
    int x=*root, y = NIL;
    while(x != NIL){
        y = x;
        T[i].key<T[x].key?x=T[x].left:x=T[x].right;
    }
    T[i].parent = y;
    if(y == NIL) *root = i;
    else if(T[i].key < T[y].key) T[y].left = i;
    else T[y].right = i;
}
 
void inorder(vector<node> &T, int i){
    if(T[i].left != NIL) 
        inorder(T,T[i].left);
    cout << " " << T[i].key;
    if(T[i].right != NIL)
        inorder(T,T[i].right);
}
 
void preorder(vector<node> &T, int i){
    cout << " " << T[i].key;
    if(T[i].left != NIL)
        preorder(T,T[i].left);
    if(T[i].right != NIL)
        preorder(T,T[i].right);
}
 
bool find(vector<node> &T, int i, int k) {
    int result = false;
    if(T[i].key == k) return true;
    else if(T[i].key > k) {
        if(T[i].left != NIL)
            result = find(T,T[i].left,k);
    } else if(T[i].key < k) {
        if(T[i].right != NIL)
            result = find(T,T[i].right,k);
    }
    return result;
}

void erase(vector<node> &T,int *root, int z){
    int x,y;
    T[z].left==NIL||T[z].right==NIL?y=z:y=successor(T,z);
    T[y].left!=NIL?x=T[y].left:x=T[y].right;

    if(x != NIL) T[x].parent = T[y].parent;
    if(T[y].parent = NIL) *root=x;
    else if(y == T[T[y].parent].left) T[T[y].parent].left = x;
    else T[T[y].parent].right = x;

    if(y!=z) T[z].key = T[y].key;
    T.erase(T.begin() + y);
}

int successor(vector<node> &T, int z){
    int x = T[z].parent,y;
    if(T[key].right != NIL) return mini(T,T[z].right);
    while(1) {
        if(x != NIL && T[x].right == z) break;
        y = x;
        x = T[x].parent;
    }
    return x;
}

int mini(vector<node> &T,int a){
    while(T[a].left != NIL) z = T[a].left;
    return a;
}

int main(void) {
    int n,i,x,root=NIL;
    string od;
    bool judge;
    vector<node> T;
    cin >> n;
    T.resize(n);
    rep(i,n) {
        T[i].key = 0;
        T[i].right = NIL;
        T[i].left = NIL;
        T[i].parent = NIL;
    }
    rep(i,n){
        cin >> od;
        if(od == "insert"){
            cin >> T[i].key;
            insert(T,i,&root);
        } else if(od == "print") {
            inorder(T,root);
            cout << endl;
            preorder(T,root);
            cout << endl;
        } else if(od == "find") {
            cin >> x;
            judge = find(T,root,x);
            if(judge) cout << "yes";
            else cout << "no";
            cout << endl;
        } else if(od == "delete"){
            cin >> x;
            judge = find(T,root,x);
            if(judge) erase(T,&root,x);
    }
    return 0;
}

Compiler output:
a.cc: In function 'void erase(std::vector<node>&, int*, int)':
a.cc:56:43: error: 'successor' was not declared in this scope
   56 |     T[z].left==NIL||T[z].right==NIL?y=z:y=successor(T,z);
      |                                           ^~~~~~~~~
a.cc: In function 'int successor(std::vector<node>&, int)':
a.cc:70:10: error: 'key' was not declared in this scope
   70 |     if(T[key].right != NIL) return mini(T,T[z].right);
      |          ^~~
a.cc:70:36: error: 'mini' was not declared in this scope
   70 |     if(T[key].right != NIL) return mini(T,T[z].right);
      |                                    ^~~~
a.cc: In function 'int mini(std::vector<node>&, int)':
a.cc:80:29: error: 'z' was not declared in this scope
   80 |     while(T[a].left != NIL) z = T[a].left;
      |                             ^
a.cc: In function 'int main()':
a.cc:119:2: error: expected '}' at end of input
  119 | }
      |  ^
a.cc:84:16: note: to match this '{'
   84 | int main(void) {
      |                ^