Language: C++

#include <bits/stdc++.h>
using namesapce std;

struct Node{
Node *r, *l, *p;
int key;
};

Node *T;

void insert(int x){

Node *z;
z.p = z.r = z.l = NIL;
z.p = k;
Node *y = NIL;
Node *x = T;

while(x != NIL){
y = x;
if(z->key < x->key){
x = x.l;
}else if(z -> key > x -> key){
x = x.r;
}

z.p = y;
if(y == NIL){
z = T;
}else if(y -> key < z -> key){
y.r = z;
}else if(y -> key < z -> key){
y.r = z;
}


}

}

void pre_print(int x){
  if(x == -1) return;
  cout << " " << x;
  pre_print(T.l);
  pre_print(T.r);
}
 
void in_print(int x){
  if(x == -1) return;
  in_print(T.l);
  cout << " " << x;
  in_print(T.r);
}



int main(){

int n;
string str;

cin >> n;

for(int i = 0; i < n; i++){
int k;
cin >> str >> k;
if(str == "insert"){
insert(k);
}else if(str == "print"){
in_print();
cout << endl;
pre_print();
cout << endl;
}
}



}

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namesapce'
    2 | using namesapce std;
      |       ^~~~~~~~~
a.cc: In function 'void insert(int)':
a.cc:14:3: error: request for member 'p' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   14 | z.p = z.r = z.l = NIL;
      |   ^
a.cc:14:9: error: request for member 'r' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   14 | z.p = z.r = z.l = NIL;
      |         ^
a.cc:14:15: error: request for member 'l' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   14 | z.p = z.r = z.l = NIL;
      |               ^
a.cc:14:19: error: 'NIL' was not declared in this scope
   14 | z.p = z.r = z.l = NIL;
      |                   ^~~
a.cc:15:3: error: request for member 'p' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   15 | z.p = k;
      |   ^
a.cc:15:7: error: 'k' was not declared in this scope
   15 | z.p = k;
      |       ^
a.cc:17:7: error: declaration of 'Node* x' shadows a parameter
   17 | Node *x = T;
      |       ^
a.cc:11:17: note: 'int x' previously declared here
   11 | void insert(int x){
      |             ~~~~^
a.cc:22:7: error: request for member 'l' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   22 | x = x.l;
      |       ^
a.cc:24:7: error: request for member 'r' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   24 | x = x.r;
      |       ^
a.cc:27:3: error: request for member 'p' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   27 | z.p = y;
      |   ^
a.cc:31:3: error: request for member 'r' in 'y', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   31 | y.r = z;
      |   ^
a.cc:33:3: error: request for member 'r' in 'y', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   33 | y.r = z;
      |   ^
a.cc: In function 'void pre_print(int)':
a.cc:43:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   43 |   cout << " " << x;
      |   ^~~~
      |   std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:44:15: error: request for member 'l' in 'T', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   44 |   pre_print(T.l);
      |               ^
a.cc:45:15: error: request for member 'r' in 'T', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   45 |   pre_print(T.r);
      |               ^
a.cc: In function 'void in_print(int)':
a.cc:50:14: error: request for member 'l' in 'T', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   50 |   in_print(T.l);
      |              ^
a.cc:51:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   51 |   cout << " " << x;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:52:14: error: request for member 'r' in 'T', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   52 |   in_print(T.r);
      |              ^
a.cc: In function 'int main()':
a.cc:60:1: error: 'string' was not declared in this scope
   60 | string str;
      | ^~~~~~
a.cc:60:1: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:62:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   62 | cin >> n;
      | ^~~
      | std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:66:8: error: 'str' was not declared in this scope; did you mean 'std'?
   66 | cin >> str >> k;
      |        ^~~
      |        std
a.cc:70:9: error: too few arguments to function 'void in_print(int)'
   70 | in_print();
      | ~~~~~~~~^~
a.cc:48:6: note: declared here
   48 | void in_print(int x){
      |      ^~~~~~~~
a.cc:71:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   71 | cout << endl;
      | ^~~~
      | std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:71:9: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   71 | cout << endl;
      |         ^~~~
      |         std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:72:10: error: too few arguments to function 'void pre_print(int)'
   72 | pre_print();
      | ~~~~~~~~~^~
a.cc:41:6: note: declared here
   41 | void pre_print(int x){
      |      ^~~~~~~~~