Language: C++

/*! if g++ -g alds_1_8_a.cpp -o alds_1_8_a.out; then ./alds_1_8_a.out < alds_1_8_a.test; fi
 */

#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

class node;
typedef shared_ptr<node> nodep;

class node{
public:
  int id;
  nodep left, right, parent;
  node(int _id, nodep l, nodep r, nodep p): id(_id), left(l), right(r), parent(p) {}
  node(int i): id(i), left(NULL), right(NULL), parent(NULL) {}
};

nodep root(NULL);

void insert(int i){
  nodep z(new node(i));
  nodep y(NULL);
  nodep x = root;
  while(x.get() != NULL){
    y = x;
    if(z->id < x->id){
      x = x->left;
    } else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y.get() == NULL){
    root = z;
  } else if(z->id < y->id){
    y->left = z;
  } else{
    y->right = z;
  }
}

void mid(nodep nd){
  if(nd.get() == NULL){
    return;
  }
  mid(nd->left);
  cout << " " << nd->id;
  mid(nd->right);
}

void pre(nodep nd){
  if(nd.get() == NULL){
    return;
  }
  cout << " " << nd->id;
  pre(nd->left);
  pre(nd->right);
}

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if(s[0] == 'i'){
      int id;
      cin >> id;
      insert(id);
    } else{
      mid(root); cout << endl;
      pre(root); cout << endl;
    }
  }  
  return 0;
}

Compiler output:
a.cc:31:9: error: 'shared_ptr' does not name a type
   31 | typedef shared_ptr<node> nodep;
      |         ^~~~~~~~~~
a.cc:36:3: error: 'nodep' does not name a type; did you mean 'node'?
   36 |   nodep left, right, parent;
      |   ^~~~~
      |   node
a.cc:37:17: error: 'nodep' has not been declared
   37 |   node(int _id, nodep l, nodep r, nodep p): id(_id), left(l), right(r), parent(p) {}
      |                 ^~~~~
a.cc:37:26: error: 'nodep' has not been declared
   37 |   node(int _id, nodep l, nodep r, nodep p): id(_id), left(l), right(r), parent(p) {}
      |                          ^~~~~
a.cc:37:35: error: 'nodep' has not been declared
   37 |   node(int _id, nodep l, nodep r, nodep p): id(_id), left(l), right(r), parent(p) {}
      |                                   ^~~~~
a.cc: In constructor 'node::node(int, int, int, int)':
a.cc:37:54: error: class 'node' does not have any field named 'left'
   37 |   node(int _id, nodep l, nodep r, nodep p): id(_id), left(l), right(r), parent(p) {}
      |                                                      ^~~~
a.cc:37:63: error: class 'node' does not have any field named 'right'
   37 |   node(int _id, nodep l, nodep r, nodep p): id(_id), left(l), right(r), parent(p) {}
      |                                                               ^~~~~
a.cc:37:73: error: class 'node' does not have any field named 'parent'
   37 |   node(int _id, nodep l, nodep r, nodep p): id(_id), left(l), right(r), parent(p) {}
      |                                                                         ^~~~~~
a.cc: In constructor 'node::node(int)':
a.cc:38:23: error: class 'node' does not have any field named 'left'
   38 |   node(int i): id(i), left(NULL), right(NULL), parent(NULL) {}
      |                       ^~~~
a.cc:38:35: error: class 'node' does not have any field named 'right'
   38 |   node(int i): id(i), left(NULL), right(NULL), parent(NULL) {}
      |                                   ^~~~~
a.cc:38:48: error: class 'node' does not have any field named 'parent'
   38 |   node(int i): id(i), left(NULL), right(NULL), parent(NULL) {}
      |                                                ^~~~~~
a.cc: At global scope:
a.cc:41:1: error: 'nodep' does not name a type; did you mean 'node'?
   41 | nodep root(NULL);
      | ^~~~~
      | node
a.cc: In function 'void insert(int)':
a.cc:44:3: error: 'nodep' was not declared in this scope; did you mean 'node'?
   44 |   nodep z(new node(i));
      |   ^~~~~
      |   node
a.cc:45:8: error: expected ';' before 'y'
   45 |   nodep y(NULL);
      |        ^~
      |        ;
a.cc:46:8: error: expected ';' before 'x'
   46 |   nodep x = root;
      |        ^~
      |        ;
a.cc:47:9: error: 'x' was not declared in this scope
   47 |   while(x.get() != NULL){
      |         ^
a.cc:48:5: error: 'y' was not declared in this scope
   48 |     y = x;
      |     ^
a.cc:49:8: error: 'z' was not declared in this scope
   49 |     if(z->id < x->id){
      |        ^
a.cc:55:3: error: 'z' was not declared in this scope
   55 |   z->parent = y;
      |   ^
a.cc:55:15: error: 'y' was not declared in this scope
   55 |   z->parent = y;
      |               ^
a.cc:57:5: error: 'root' was not declared in this scope
   57 |     root = z;
      |     ^~~~
a.cc: At global scope:
a.cc:65:6: error: variable or field 'mid' declared void
   65 | void mid(nodep nd){
      |      ^~~
a.cc:65:10: error: 'nodep' was not declared in this scope; did you mean 'node'?
   65 | void mid(nodep nd){
      |          ^~~~~
      |          node
a.cc:74:6: error: variable or field 'pre' declared void
   74 | void pre(nodep nd){
      |      ^~~
a.cc:74:10: error: 'nodep' was not declared in this scope; did you mean 'node'?
   74 | void pre(nodep nd){
      |          ^~~~~
      |          node
a.cc: In function 'int main(int, char**)':
a.cc:94:11: error: 'root' was not declared in this scope
   94 |       mid(root); cout << endl;
      |           ^~~~
a.cc:94:7: error: 'mid' was not declared in this scope
   94 |       mid(root); cout << endl;
      |       ^~~
a.cc:95:7: error: 'pre' was not declared in this scope
   95 |       pre(root); cout << endl;
      |       ^~~