Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
struct Node{
    int key;
    Node *parent,*left,*right;
};
Node *root,*NIL;
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 inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(){
    int n,x;
    string com;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print"){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'void insert(int)':
a.cc:11:13: error: 'NIl' was not declared in this scope; did you mean 'NIL'?
   11 |     Node *y=NIl;
      |             ^~~
      |             NIL
a.cc:15:32: error: no matching function for call to 'Node::Node(void*)'
   15 |     z=(Node)malloc(sizeof(Node));
      |                                ^
a.cc:5:8: note: candidate: 'Node::Node()'
    5 | struct Node{
      |        ^~~~
a.cc:5:8: note:   candidate expects 0 arguments, 1 provided
a.cc:5:8: note: candidate: 'constexpr Node::Node(const Node&)'
a.cc:5:8: note:   no known conversion for argument 1 from 'void*' to 'const Node&'
a.cc:5:8: note: candidate: 'constexpr Node::Node(Node&&)'
a.cc:5:8: note:   no known conversion for argument 1 from 'void*' to 'Node&&'
a.cc: In function 'int main()':
a.cc:46:5: error: 'string' was not declared in this scope
   46 |     string com;
      |     ^~~~~~
a.cc:46:5: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:49:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   49 |         cin>>com;
      |         ^~~
      |         std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:49:14: error: 'com' was not declared in this scope
   49 |         cin>>com;
      |              ^~~
a.cc:56:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   56 |             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:56:19: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   56 |             cout<<endl;
      |                   ^~~~
      |                   std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~