stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<cstdio>

#include<vector>

#include<cstdlib>

#include<iostream>

using namespace std;

struct Node{

Node *parent,*left,*right;

int key;

};

Node *NIL,*root;

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;

}



void prin_in(Node* node){

    if(node==NIL)return;

    prin_in(node->left);

    printf(" %d",node->key);

    prin_in(node->right);

}

void prin_pre(Node* node){

    if(node==NIL)return;

    printf(" %d",node->key);

    prin_pre(node->left);

    prin_pre(node->right);



}

void insert(int key)

{

    Node *y=NIL;

    Node *x=root;

    Node *z;

    z=(Node*)malloc(sizeof(Node));

    z->key=key;

    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;

            }

    }

}

int main(){

   int n,i,x;

   string s;

   scanf("%d",&n);

   for(int i=0;i<n;i++)

   {

       cin>>s;

       if(s[0]=='i'){

        scanf("%d",&x);

        insert(x);

       }

       else if(s[0]=='f'){

        scanf("%d",&x);

        Node*t=find(root,x);

        if(t!=NIL)printf("yes\n");

        else printf("no\n");

       }

       else if(s[0]=='p'){

       prin_in(root);

       printf("\n");

       prin_pre(root);

       printf("\n");

       }

   }

   return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.117304759870266x):
#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<ctime>

#define MAXN 500000

struct node

{

	int key;

	node *ch[2];

};

node tree[MAXN+5];

node *Root,*NIL,*ncnt;

//bool first=true;

void Init()

{

	NIL=&tree[0];

	ncnt=&tree[1];

	Root=NIL;

}

inline node *NewNode(int val)

{

	node *p=++ncnt;

	p->key=val;

	p->ch[0]=p->ch[1]=NIL;

	return p;

}

void Insert(node *&rt,int val)

{

	if(rt==NIL)

	{

		rt=NewNode(val);

		return;

	}

	int d=(val>=rt->key);

	Insert(rt->ch[d],val);

}

void PreOrder(node *&rt)

{

	if(rt==NIL)

		return;

//	if(first==true)

//		printf("%d",rt->key),first=false;

//	else

		printf(" %d",rt->key);

	PreOrder(rt->ch[0]);

	PreOrder(rt->ch[1]);

}

void InOrder(node *&rt)

{

	if(rt==NIL)

		return;

	InOrder(rt->ch[0]);

//	if(first==true)

//		printf("%d",rt->key),first=false;

//	else

		printf(" %d",rt->key);

	InOrder(rt->ch[1]);

}

node *Find(node *rt,int val)

{

	if(rt==NIL)

		return NIL;

	if(rt->key==val)

		return rt;

	int d=(val>rt->key);

	return Find(rt->ch[d],val);

}

int main()

{

	Init();

	int n,x;

	char op[100];

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%s",op);

		if(op[0]=='i')

			scanf("%d",&x),Insert(Root,x);

		else if(op[0]=='p')

		{

			InOrder(Root);

			printf("\n");

			PreOrder(Root);

			printf("\n");

		}

		else if(op[0]=='f')

		{

			scanf("%d",&x);

			if(Find(Root,x)==NIL)

				printf("no\n");

			else

				printf("yes\n");

		}

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

struct Node{

	int data;

	Node *left;

	Node *right;

	Node(int val=0){

		data=val;

		left=NULL;

		right=NULL;

	}

};

Node *root;

void insert(Node *&root,int x){

	if(root==NULL){

		root=new Node(x);

		return;

	}

	else{

		if(x==root->data) return;

		else if(x<root->data) insert(root->left,x);

		else insert(root->right,x);

	}

	return;

}

void Inorder(Node *node){

	if(node==NULL) return;

	Inorder(node->left);

	cout<<' '<<node->data;

	Inorder(node->right);

}

void Preorder(Node *node){

	if(node==NULL) return;

	cout<<' '<<node->data;

	Preorder(node->left);

	Preorder(node->right);

}

bool find(Node *&root,int x){

	if(root==NULL) return false;

	if(root->data==x) return true;

	else if(root->data<x){

		return find(root->right,x);

	}

	else{

		return find(root->left,x);

	}

}

int main(){

	root=NULL;

	int m;

	cin>>m;

	while(m--){

		string str;

		cin>>str;

		if(str[0]=='i'){

			int data;

			cin>>data;

			insert(root,data);

		}

		else if(str[0]=='f'){

			int data;

			cin>>data;

			if(find(root,data)) cout<<"yes"<<endl;

			else cout<<"no"<<endl;

		}

		else{

			Inorder(root);

			cout<<endl;

			Preorder(root);

			cout<<endl;

		}

	}

} 

// Faster C++ solution for the same problem (measured speedup: 5.176588814435349x):
#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<ctime>

#define MAXN 500000

struct node

{

	int key;

	node *ch[2];

};

node tree[MAXN+5];

node *Root,*NIL,*ncnt;

//bool first=true;

void Init()

{

	NIL=&tree[0];

	ncnt=&tree[1];

	Root=NIL;

}

inline node *NewNode(int val)

{

	node *p=++ncnt;

	p->key=val;

	p->ch[0]=p->ch[1]=NIL;

	return p;

}

void Insert(node *&rt,int val)

{

	if(rt==NIL)

	{

		rt=NewNode(val);

		return;

	}

	int d=(val>=rt->key);

	Insert(rt->ch[d],val);

}

void PreOrder(node *&rt)

{

	if(rt==NIL)

		return;

//	if(first==true)

//		printf("%d",rt->key),first=false;

//	else

		printf(" %d",rt->key);

	PreOrder(rt->ch[0]);

	PreOrder(rt->ch[1]);

}

void InOrder(node *&rt)

{

	if(rt==NIL)

		return;

	InOrder(rt->ch[0]);

//	if(first==true)

//		printf("%d",rt->key),first=false;

//	else

		printf(" %d",rt->key);

	InOrder(rt->ch[1]);

}

node *Find(node *rt,int val)

{

	if(rt==NIL)

		return NIL;

	if(rt->key==val)

		return rt;

	int d=(val>rt->key);

	return Find(rt->ch[d],val);

}

int main()

{

	Init();

	int n,x;

	char op[100];

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%s",op);

		if(op[0]=='i')

			scanf("%d",&x),Insert(Root,x);

		else if(op[0]=='p')

		{

			InOrder(Root);

			printf("\n");

			PreOrder(Root);

			printf("\n");

		}

		else if(op[0]=='f')

		{

			scanf("%d",&x);

			if(Find(Root,x)==NIL)

				printf("no\n");

			else

				printf("yes\n");

		}

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

using namespace std;



const int maxn = 500000 + 5;



struct Node{

	int value;

	Node *Left_Child,*Right_Child;

}pool[maxn],*tail = pool;



Node *root,*NUL;



void Insert(int key){

	Node *x = tail++;

	Node *fa = NUL;

	Node *cur = root;

	

	x->value = key;

	x->Left_Child = NUL;

	x->Right_Child = NUL;

	

	while(cur != NUL){

		fa = cur;

		if(cur->value > x->value)cur = cur->Left_Child;

		else cur = cur->Right_Child;

	}

	

	if(fa == NUL)root = x;

	else {

		if(fa->value > x->value)fa->Left_Child = x;

		else fa->Right_Child = x;

	}

}



void Preorder(Node *cur){

	if(cur == NUL)return;

	printf(" %d",cur->value);

	Preorder(cur->Left_Child);

	Preorder(cur->Right_Child);

}



void Inorder(Node *cur){

	if(cur == NUL)return;

	Inorder(cur->Left_Child);

	printf(" %d",cur->value);

	Inorder(cur->Right_Child);

}



bool find(int key){

	Node *cur = root;

	while(cur != NUL){

		if(cur->value > key)cur = cur->Left_Child;

		else if(cur->value < key)cur = cur->Right_Child;

		else return true;

	}

	return false;

}



int main(){

	int n;

	scanf("%d",&n);

	for(int i = 1;i <= n; i++){

		char s[15];

		scanf("%s",s);

		if(strcmp(s,"insert") == 0){

			int key;

			scanf("%d",&key);

			Insert(key);

		}

		else if(strcmp(s,"print") == 0){

			Inorder(root);

			printf("\n");

			Preorder(root);

			printf("\n");

		}

		else {

			int key;

			scanf("%d",&key);

			if(find(key))printf("yes\n");

			else printf("no\n");

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.016420142141292x):
#include<cstdio>

#define MAXN 500000

struct node{

	int key;

	node *ch[2],*fa;

};

node tree[MAXN+5];

node *Root,*NIL,*ncnt;

void Init(){

	NIL=&tree[0];

	NIL->fa=NIL->ch[0]=NIL->ch[1]=NIL;

	ncnt=&tree[1];

	Root=NIL;

}

inline node * NewNode(int val){

	node *p=++ncnt;

	p->key=val;

	p->fa=p->ch[0]=p->ch[1]=NIL;

	return p;

}

void Insert(node *&rt,node *fa,int val){

	if(rt==NIL){

		rt=NewNode(val);

		rt->fa=fa;

		return ;

	}

	int d=(val>=rt->key);

	Insert(rt->ch[d],rt,val);

}

void InOrder(node *rt){

	if(rt==NIL)return ;

	InOrder(rt->ch[0]);

	printf(" %d",rt->key);

	InOrder(rt->ch[1]);

}

void PreOrder(node *rt){

	if(rt==NIL)return ;

	printf(" %d",rt->key);

	PreOrder(rt->ch[0]);

	PreOrder(rt->ch[1]);

}

node *Find(node *rt,int val){

	if(rt==NIL)return NIL;

	if(rt->key==val)return rt;

	int d=(val>=rt->key);

	return Find(rt->ch[d],val);

}

int main(){

	int n,x;

	char op[100];

	Init();

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%s",op);

		if(op[0]=='p')

		{

			InOrder(Root);puts("");

			PreOrder(Root);puts("");

		}

		if(op[0]=='i')

		{

			scanf("%d",&x);

			Insert(Root,NIL,x);

		}

		if(op[0]=='f')

		{

			scanf("%d",&x);

			node *p=Find(Root,x);

			if(p==NIL)puts("no");

			else puts("yes");

		}

		if(op[0]=='d')

		{

			

		}

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<new>

#include<cstdlib>

#include<cstring>

using namespace std;

typedef struct node;

typedef node * tree;

int bianliang=0;

struct node

{

       int data;

       tree lchild,rchild;

};

tree root;

void build(tree &p,int n)

{

     if(p)

     {

          if(n<p->data)

          build(p->lchild,n);

          if(n>p->data)

          build(p->rchild,n);

     }

     else

     {

         p=new node;

         p->data=n;

         p->lchild=NULL;

         p->rchild=NULL;

     }

}    

void find(tree w,int x)

{

     if(w==NULL)bianliang=-1;

     else if(x==w->data)

       bianliang=1;

     else if(x<w->data)

       find(w->lchild,x);

     else if(x>w->data)

       find(w->rchild,x);

}

void beforeorder(tree q)

{

   if(q==NULL)return;

     cout<<" "<<q->data;

     beforeorder(q->lchild);

     beforeorder(q->rchild);

}

void midorder(tree q)

{

     if(q==NULL)return;

       midorder(q->lchild);

       cout<<" "<<q->data;

       midorder(q->rchild);    

}

int main()

{

    int num;

    cin>>num;

    root=NULL;

    for(int i=1;i<=num;i++)

    {  

       string order;

       cin>>order;

       if(order=="insert")

       {

            int leaf;

            cin>>leaf;

            build(root,leaf);

       }

       else if(order=="find")

       {

            int puzzle;

            cin>>puzzle;

            find(root,puzzle);

            if(bianliang==1)cout<<"yes"<<endl;

            else if(bianliang==-1)cout<<"no"<<endl;

       }

       else if(order=="print")

       {

            midorder(root);

            cout<<endl;

            beforeorder(root);

            cout<<endl;

       } 

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.148494379917608x):
#include<cstdio>

#define MAXN 500000

struct node{

	int key;

	node *ch[2],*fa;

};

node tree[MAXN+5];

node *Root,*NIL,*ncnt;

void Init(){

	NIL=&tree[0];

	NIL->fa=NIL->ch[0]=NIL->ch[1]=NIL;

	ncnt=&tree[1];

	Root=NIL;

}

inline node * NewNode(int val){

	node *p=++ncnt;

	p->key=val;

	p->fa=p->ch[0]=p->ch[1]=NIL;

	return p;

}

void Insert(node *&rt,node *fa,int val){

	if(rt==NIL){

		rt=NewNode(val);

		rt->fa=fa;

		return ;

	}

	int d=(val>=rt->key);

	Insert(rt->ch[d],rt,val);

}

void InOrder(node *rt){

	if(rt==NIL)return ;

	InOrder(rt->ch[0]);

	printf(" %d",rt->key);

	InOrder(rt->ch[1]);

}

void PreOrder(node *rt){

	if(rt==NIL)return ;

	printf(" %d",rt->key);

	PreOrder(rt->ch[0]);

	PreOrder(rt->ch[1]);

}

node *Find(node *rt,int val){

	if(rt==NIL)return NIL;

	if(rt->key==val)return rt;

	int d=(val>=rt->key);

	return Find(rt->ch[d],val);

}

int main(){

	int n,x;

	char op[100];

	Init();

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%s",op);

		if(op[0]=='p')

		{

			InOrder(Root);puts("");

			PreOrder(Root);puts("");

		}

		if(op[0]=='i')

		{

			scanf("%d",&x);

			Insert(Root,NIL,x);

		}

		if(op[0]=='f')

		{

			scanf("%d",&x);

			node *p=Find(Root,x);

			if(p==NIL)puts("no");

			else puts("yes");

		}

		if(op[0]=='d')

		{

			

		}

	}

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<vector>

#include<cstdlib>

#include<iostream>

using namespace std;

struct Node{

Node *parent,*left,*right;

int key;

};

Node *NIL,*root;

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;

}



void prin_in(Node* node){

    if(node==NIL)return;

    prin_in(node->left);

    printf(" %d",node->key);

    prin_in(node->right);

}

void prin_pre(Node* node){

    if(node==NIL)return;

    printf(" %d",node->key);

    prin_pre(node->left);

    prin_pre(node->right);



}

void insert(int key)

{

    Node *y=NIL;

    Node *x=root;

    Node *z;

    z=(Node*)malloc(sizeof(Node));

    z->key=key;

    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;

            }

    }

}

int main(){

   int n,i,x;

   string s;

   scanf("%d",&n);

   for(int i=0;i<n;i++)

   {

       cin>>s;

       if(s[0]=='i'){

        scanf("%d",&x);

        insert(x);

       }

       else if(s[0]=='f'){

        scanf("%d",&x);

        Node*t=find(root,x);

        if(t!=NIL)printf("yes\n");

        else printf("no\n");

       }

       else if(s[0]=='p'){

       prin_in(root);

       printf("\n");

       prin_pre(root);

       printf("\n");

       }

   }

   return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.090877100109533x):
#include<cstdio>

#define MAXN 500000

struct node{

	int key;

	node *ch[2],*fa;

};

node tree[MAXN+5];

node *Root,*NIL,*ncnt;

void Init(){

	NIL=&tree[0];

	NIL->fa=NIL->ch[0]=NIL->ch[1]=NIL;

	ncnt=&tree[1];

	Root=NIL;

}

inline node * NewNode(int val){

	node *p=++ncnt;

	p->key=val;

	p->fa=p->ch[0]=p->ch[1]=NIL;

	return p;

}

void Insert(node *&rt,node *fa,int val){

	if(rt==NIL){

		rt=NewNode(val);

		rt->fa=fa;

		return ;

	}

	int d=(val>=rt->key);

	Insert(rt->ch[d],rt,val);

}

void InOrder(node *rt){

	if(rt==NIL)return ;

	InOrder(rt->ch[0]);

	printf(" %d",rt->key);

	InOrder(rt->ch[1]);

}

void PreOrder(node *rt){

	if(rt==NIL)return ;

	printf(" %d",rt->key);

	PreOrder(rt->ch[0]);

	PreOrder(rt->ch[1]);

}

node *Find(node *rt,int val){

	if(rt==NIL)return NIL;

	if(rt->key==val)return rt;

	int d=(val>=rt->key);

	return Find(rt->ch[d],val);

}

int main(){

	int n,x;

	char op[100];

	Init();

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%s",op);

		if(op[0]=='p')

		{

			InOrder(Root);puts("");

			PreOrder(Root);puts("");

		}

		if(op[0]=='i')

		{

			scanf("%d",&x);

			Insert(Root,NIL,x);

		}

		if(op[0]=='f')

		{

			scanf("%d",&x);

			node *p=Find(Root,x);

			if(p==NIL)puts("no");

			else puts("yes");

		}

		if(op[0]=='d')

		{

			

		}

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

struct Node{

	int data;

	Node *left;

	Node *right;

	Node(int val=0){

		data=val;

		left=NULL;

		right=NULL;

	}

};

Node *root;

void insert(Node *&root,int x){

	if(root==NULL){

		root=new Node(x);

		return;

	}

	else{

		if(x==root->data) return;

		else if(x<root->data) insert(root->left,x);

		else insert(root->right,x);

	}

	return;

}

void Inorder(Node *node){

	if(node==NULL) return;

	Inorder(node->left);

	cout<<' '<<node->data;

	Inorder(node->right);

}

void Preorder(Node *node){

	if(node==NULL) return;

	cout<<' '<<node->data;

	Preorder(node->left);

	Preorder(node->right);

}

bool find(Node *&root,int x){

	if(root==NULL) return false;

	if(root->data==x) return true;

	else if(root->data<x){

		return find(root->right,x);

	}

	else{

		return find(root->left,x);

	}

}

int main(){

	root=NULL;

	int m;

	cin>>m;

	while(m--){

		string str;

		cin>>str;

		if(str[0]=='i'){

			int data;

			cin>>data;

			insert(root,data);

		}

		else if(str[0]=='f'){

			int data;

			cin>>data;

			if(find(root,data)) cout<<"yes"<<endl;

			else cout<<"no"<<endl;

		}

		else{

			Inorder(root);

			cout<<endl;

			Preorder(root);

			cout<<endl;

		}

	}

} 

// Faster C++ solution for the same problem (measured speedup: 5.149854989828706x):
#include<cstdio>

#define MAXN 500000

struct node{

	int key;

	node *ch[2],*fa;

};

node tree[MAXN+5];

node *Root,*NIL,*ncnt;

void Init(){

	NIL=&tree[0];

	NIL->fa=NIL->ch[0]=NIL->ch[1]=NIL;

	ncnt=&tree[1];

	Root=NIL;

}

inline node * NewNode(int val){

	node *p=++ncnt;

	p->key=val;

	p->fa=p->ch[0]=p->ch[1]=NIL;

	return p;

}

void Insert(node *&rt,node *fa,int val){

	if(rt==NIL){

		rt=NewNode(val);

		rt->fa=fa;

		return ;

	}

	int d=(val>=rt->key);

	Insert(rt->ch[d],rt,val);

}

void InOrder(node *rt){

	if(rt==NIL)return ;

	InOrder(rt->ch[0]);

	printf(" %d",rt->key);

	InOrder(rt->ch[1]);

}

void PreOrder(node *rt){

	if(rt==NIL)return ;

	printf(" %d",rt->key);

	PreOrder(rt->ch[0]);

	PreOrder(rt->ch[1]);

}

node *Find(node *rt,int val){

	if(rt==NIL)return NIL;

	if(rt->key==val)return rt;

	int d=(val>=rt->key);

	return Find(rt->ch[d],val);

}

int main(){

	int n,x;

	char op[100];

	Init();

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%s",op);

		if(op[0]=='p')

		{

			InOrder(Root);puts("");

			PreOrder(Root);puts("");

		}

		if(op[0]=='i')

		{

			scanf("%d",&x);

			Insert(Root,NIL,x);

		}

		if(op[0]=='f')

		{

			scanf("%d",&x);

			node *p=Find(Root,x);

			if(p==NIL)puts("no");

			else puts("yes");

		}

		if(op[0]=='d')

		{

			

		}

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

using namespace std;



const int maxn = 500000 + 5;



struct Node{

	int value;

	Node *Left_Child,*Right_Child;

}pool[maxn],*tail = pool;



Node *root,*NUL;



void Insert(int key){

	Node *x = tail++;

	Node *fa = NUL;

	Node *cur = root;

	

	x->value = key;

	x->Left_Child = NUL;

	x->Right_Child = NUL;

	

	while(cur != NUL){

		fa = cur;

		if(cur->value > x->value)cur = cur->Left_Child;

		else cur = cur->Right_Child;

	}

	

	if(fa == NUL)root = x;

	else {

		if(fa->value > x->value)fa->Left_Child = x;

		else fa->Right_Child = x;

	}

}



void Preorder(Node *cur){

	if(cur == NUL)return;

	printf(" %d",cur->value);

	Preorder(cur->Left_Child);

	Preorder(cur->Right_Child);

}



void Inorder(Node *cur){

	if(cur == NUL)return;

	Inorder(cur->Left_Child);

	printf(" %d",cur->value);

	Inorder(cur->Right_Child);

}



bool find(int key){

	Node *cur = root;

	while(cur != NUL){

		if(cur->value > key)cur = cur->Left_Child;

		else if(cur->value < key)cur = cur->Right_Child;

		else return true;

	}

	return false;

}



int main(){

	int n;

	scanf("%d",&n);

	for(int i = 1;i <= n; i++){

		char s[15];

		scanf("%s",s);

		if(strcmp(s,"insert") == 0){

			int key;

			scanf("%d",&key);

			Insert(key);

		}

		else if(strcmp(s,"print") == 0){

			Inorder(root);

			printf("\n");

			Preorder(root);

			printf("\n");

		}

		else {

			int key;

			scanf("%d",&key);

			if(find(key))printf("yes\n");

			else printf("no\n");

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.028930421139367x):
#include<cstdio>

#define N 500005

struct mzls

{

	int key;

	mzls *ch[2];

};

mzls tree[N];

bool f1=1;

mzls *root,*NIL,*ncnt;

inline void Init()

{

	NIL=&tree[0];

	NIL->ch[0]=NIL->ch[1]=NIL;

	ncnt=&tree[1];

	root=NIL;

}

inline mzls *newnode(int ml)

{

	mzls *p=++ncnt;

	p->key=ml;

	p->ch[0]=p->ch[1]=NIL;

	return p;

}

inline void Insert(mzls *&rt,int ml)

{

	if(rt==NIL)

	{

		rt=newnode(ml);

		return;

	}

	int d=(ml>=rt->key);

	Insert(rt->ch[d],ml);

}

inline void InOrder(mzls *rt)

{

	if(rt==NIL)

		return;

	InOrder(rt->ch[0]);

	printf(" %d",rt->key);

	InOrder(rt->ch[1]);

}

inline void Preorder(mzls *rt)

{

	if(rt==NIL)

		return;

	printf(" %d",rt->key);

	Preorder(rt->ch[0]);

	Preorder(rt->ch[1]);

}

inline mzls *Find(mzls *rt, int ml) 

{

	if(rt==NIL) return NIL;

	if(rt->key==ml) return rt;

	int d=(ml>=rt->key);

	return Find(rt->ch[d],ml);

}

int main()

{

	int n,x;

	char op[100];

	Init();

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%s",op);

		if(op[0]=='i')

		{

			scanf("%d",&x);

			Insert(root,x);

		}

		else if(op[0]=='f') 

		{

			scanf("%d", &x);

			mzls *p=Find(root, x);

			if(p==NIL)

				puts("no");

			else

				puts("yes");

		}

		else

		{

			InOrder(root);

			puts("");

			Preorder(root);

			puts("");

		}

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<new>

#include<cstdlib>

#include<cstring>

using namespace std;

typedef struct node;

typedef node * tree;

int bianliang=0;

struct node

{

       int data;

       tree lchild,rchild;

};

tree root;

void build(tree &p,int n)

{

     if(p)

     {

          if(n<p->data)

          build(p->lchild,n);

          if(n>p->data)

          build(p->rchild,n);

     }

     else

     {

         p=new node;

         p->data=n;

         p->lchild=NULL;

         p->rchild=NULL;

     }

}    

void find(tree w,int x)

{

     if(w==NULL)bianliang=-1;

     else if(x==w->data)

       bianliang=1;

     else if(x<w->data)

       find(w->lchild,x);

     else if(x>w->data)

       find(w->rchild,x);

}

void beforeorder(tree q)

{

   if(q==NULL)return;

     cout<<" "<<q->data;

     beforeorder(q->lchild);

     beforeorder(q->rchild);

}

void midorder(tree q)

{

     if(q==NULL)return;

       midorder(q->lchild);

       cout<<" "<<q->data;

       midorder(q->rchild);    

}

int main()

{

    int num;

    cin>>num;

    root=NULL;

    for(int i=1;i<=num;i++)

    {  

       string order;

       cin>>order;

       if(order=="insert")

       {

            int leaf;

            cin>>leaf;

            build(root,leaf);

       }

       else if(order=="find")

       {

            int puzzle;

            cin>>puzzle;

            find(root,puzzle);

            if(bianliang==1)cout<<"yes"<<endl;

            else if(bianliang==-1)cout<<"no"<<endl;

       }

       else if(order=="print")

       {

            midorder(root);

            cout<<endl;

            beforeorder(root);

            cout<<endl;

       } 

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.161334034350001x):
#include<cstdio>

#define N 500005

struct mzls

{

	int key;

	mzls *ch[2];

};

mzls tree[N];

bool f1=1;

mzls *root,*NIL,*ncnt;

inline void Init()

{

	NIL=&tree[0];

	NIL->ch[0]=NIL->ch[1]=NIL;

	ncnt=&tree[1];

	root=NIL;

}

inline mzls *newnode(int ml)

{

	mzls *p=++ncnt;

	p->key=ml;

	p->ch[0]=p->ch[1]=NIL;

	return p;

}

inline void Insert(mzls *&rt,int ml)

{

	if(rt==NIL)

	{

		rt=newnode(ml);

		return;

	}

	int d=(ml>=rt->key);

	Insert(rt->ch[d],ml);

}

inline void InOrder(mzls *rt)

{

	if(rt==NIL)

		return;

	InOrder(rt->ch[0]);

	printf(" %d",rt->key);

	InOrder(rt->ch[1]);

}

inline void Preorder(mzls *rt)

{

	if(rt==NIL)

		return;

	printf(" %d",rt->key);

	Preorder(rt->ch[0]);

	Preorder(rt->ch[1]);

}

inline mzls *Find(mzls *rt, int ml) 

{

	if(rt==NIL) return NIL;

	if(rt->key==ml) return rt;

	int d=(ml>=rt->key);

	return Find(rt->ch[d],ml);

}

int main()

{

	int n,x;

	char op[100];

	Init();

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%s",op);

		if(op[0]=='i')

		{

			scanf("%d",&x);

			Insert(root,x);

		}

		else if(op[0]=='f') 

		{

			scanf("%d", &x);

			mzls *p=Find(root, x);

			if(p==NIL)

				puts("no");

			else

				puts("yes");

		}

		else

		{

			InOrder(root);

			puts("");

			Preorder(root);

			puts("");

		}

	}

	return 0;

}