Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
struct node {
	int key;
	struct node *prev,*next;
};
typedef struct node *nil;
nil head;
nil tail;
void init(void);
void input(void);
int judge(string);
void insert(int);
void delete_(int);
nil search(int);
void deleteFirst(void);
void deleteLast(void);
void print(void);
int main(void){
		
	init();
	input();
	return 0 ;

}
void init(){

	head = new node ;
	tail = new node ;
	head->next = tail;
	tail->prev = head; 

}
void input(){

	int num;
	cin >> num;
	rep(i,num){
		string instruction;
		int value;
		cin >> instruction;
		if(instruction == "insert"  || instruction == "delete") cin >> value;
		//cout << s << " "<<  value << endl;
		switch(judge(instruction)) {
			case 1:
				insert(value);
				break;
			case 2:
				delete_(value);
				break;
			case 3:
				deleteFirst();
				break;
			case 4:
				deleteLast();
				break;	
			default:
				break;
		}

	}
	print();
}
int judge(string instruction){

	if(instruction == "insert") return 1;
	else if(instruction == "delete") return 2;
	else if(instruction == "deleteFirst") return 3;
	else if(instruction == "deleteLast") return 4;
	else return 0;
		
}
void insert(int key){

	nil temp;
	temp = new node;
	temp->key = key;
	head->next->prev = temp;
	temp->next = head->next;
	head->next = temp;
	temp->prev = head;
	
}
void delete_(int key){

	nil temp;
	temp = search(key);
	temp->next->prev = temp->prev; 
	temp->prev->next = temp->next; 

}
nil search(int key){

	nil temp;
	temp = new node;
	temp = head->next;
	while(temp->key != key){
		temp = temp->next;
	}
	return temp;
}
void deleteFirst(){

	head->next = head->next->next;
	head->next->prev = head;

}	
void deleteLast(){
	tail->prev = tail->prev->prev;
	tail->prev->next = tail;

}
void print(){

	nil temp;
	for(temp = head->next; temp != tail; temp = temp->next) temp->next != tail ? cout << temp->key << " ":cout << temp->key << "\n" ;

}




#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
struct node {
	int key;
	struct node *prev,*next;
};
typedef struct node *nil;
nil head;
nil tail;
void init(void);
void input(void);
int judge(string);
void insert(int);
void delete_(int);
nil search(int);
void deleteFirst(void);
void deleteLast(void);
void print(void);
int main(void){
		
	init();
	input();
	return 0 ;

}
void init(){

	head = new node ;
	tail = new node ;
	head->next = tail;
	tail->prev = head; 

}
void input(){

	int num;
	cin >> num;
	rep(i,num){
		string instruction;
		int value;
		cin >> instruction;
		if(instruction == "insert"  || instruction == "delete") cin >> value;
		//cout << s << " "<<  value << endl;
		switch(judge(instruction)) {
			case 1:
				insert(value);
				break;
			case 2:
				delete_(value);
				break;
			case 3:
				deleteFirst();
				break;
			case 4:
				deleteLast();
				break;	
			default:
				break;
		}

	}
	print();
}
int judge(string instruction){

	if(instruction == "insert") return 1;
	else if(instruction == "delete") return 2;
	else if(instruction == "deleteFirst") return 3;
	else if(instruction == "deleteLast") return 4;
	else return 0;
		
}
void insert(int key){

	nil temp;
	temp = new node;
	temp->key = key;
	head->next->prev = temp;
	temp->next = head->next;
	head->next = temp;
	temp->prev = head;
	
}
void delete_(int key){

	nil temp;
	temp = search(key);
	if(temp->next != tail){ 
		temp->next->prev = temp->prev; 
		temp->prev->next = temp->next; 
	}
}
nil search(int key){

	nil temp;
	temp = new node;
	temp = head->next;
	while(temp->key != key && temp->next != tail ){
		temp = temp->next;
	}
	return temp;
}
void deleteFirst(){

	head->next = head->next->next;
	head->next->prev = head;

}	
void deleteLast(){
	tail->prev = tail->prev->prev;
	tail->prev->next = tail;

}
void print(){

	nil temp;
	for(temp = head->next; temp != tail; temp = temp->next) temp->next != tail ? cout << temp->key << " ":cout << temp->key << "\n" ;

}

Compiler output:
a.cc:127:8: error: redefinition of 'struct node'
  127 | struct node {
      |        ^~~~
a.cc:4:8: note: previous definition of 'struct node'
    4 | struct node {
      |        ^~~~
a.cc:132:5: error: redefinition of 'node* head'
  132 | nil head;
      |     ^~~~
a.cc:9:5: note: 'node* head' previously declared here
    9 | nil head;
      |     ^~~~
a.cc:133:5: error: redefinition of 'node* tail'
  133 | nil tail;
      |     ^~~~
a.cc:10:5: note: 'node* tail' previously declared here
   10 | nil tail;
      |     ^~~~
a.cc:143:5: error: redefinition of 'int main()'
  143 | int main(void){
      |     ^~~~
a.cc:20:5: note: 'int main()' previously defined here
   20 | int main(void){
      |     ^~~~
a.cc:150:6: error: redefinition of 'void init()'
  150 | void init(){
      |      ^~~~
a.cc:27:6: note: 'void init()' previously defined here
   27 | void init(){
      |      ^~~~
a.cc:158:6: error: redefinition of 'void input()'
  158 | void input(){
      |      ^~~~~
a.cc:35:6: note: 'void input()' previously defined here
   35 | void input(){
      |      ^~~~~
a.cc:188:5: error: redefinition of 'int judge(std::string)'
  188 | int judge(string instruction){
      |     ^~~~~
a.cc:65:5: note: 'int judge(std::string)' previously defined here
   65 | int judge(string instruction){
      |     ^~~~~
a.cc:197:6: error: redefinition of 'void insert(int)'
  197 | void insert(int key){
      |      ^~~~~~
a.cc:74:6: note: 'void insert(int)' previously defined here
   74 | void insert(int key){
      |      ^~~~~~
a.cc:208:6: error: redefinition of 'void delete_(int)'
  208 | void delete_(int key){
      |      ^~~~~~~
a.cc:85:6: note: 'void delete_(int)' previously defined here
   85 | void delete_(int key){
      |      ^~~~~~~
a.cc:217:5: error: redefinition of 'node* search(int)'
  217 | nil search(int key){
      |     ^~~~~~
a.cc:93:5: note: 'node* search(int)' previously defined here
   93 | nil search(int key){
      |     ^~~~~~
a.cc:227:6: error: redefinition of 'void deleteFirst()'
  227 | void deleteFirst(){
      |      ^~~~~~~~~~~
a.cc:103:6: note: 'void deleteFirst()' previously defined here
  103 | void deleteFirst(){
      |      ^~~~~~~~~~~
a.cc:233:6: error: redefinition of 'void deleteLast()'
  233 | void deleteLast(){
      |      ^~~~~~~~~~
a.cc:109:6: note: 'void deleteLast()' previously defined here
  109 | void deleteLast(){
      |      ^~~~~~~~~~
a.cc:238:6: error: redefinition of 'void print()'
  238 | void print(){
      |      ^~~~~
a.cc:114:6: note: 'void print()' previously defined here
  114 | void print(){
      |      ^~~~~