MySQL Timeout 30 secondes

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

class node{
    public:
    int data;
    node* next;
    node(int x){
        data=x;
        next=NULL;
    }
   
};
 void insert(int value,node* &head){
     if(head==NULL){
         head=new node(value);
         return;
     }
     else insert(value,head->next);
     
 }
void deletion(int value,node* &head){
    if(head->data==value){
        node* temp=head;
        head=temp->next;
        delete temp;
        return;
    }
    if(head->next->data==value){
        node* temp=head->next;
        head->next=temp->next;
        delete temp;
        return;
        
    }
    else deletion(value,head->next);
}
bool search(int value,node* head){
    if(head==NULL)return false;
    if(head->data==value)return true;
    else{
        return search(value,head->next);
    }
}
void display(node* head){
    while(head!=NULL){
        cout<<head->data<<" ";
        head=head->next;
    }
    cout<<endl;
    return;
}
int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int n;
    cin>>n;
    node* head=NULL;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        insert(x,head);
    }
    int x;
    while(cin>>x){
        int y;
        if(x==1){
            cin>>y;
            insert(y,head);
            display(head);
        }
        else if(x==2){
            cin>>y;
            deletion(y,head);
            display(head);
        }
        else{
            cin>>y;
            cout<<search(y,head);
            cout<<endl;
        }
    }
    return 0;
}
Obnoxious Ostrich