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);
	if(temp != tail){ 
		//temp->next->prev = temp->prev; 
		//temp->prev->next = temp->next; 
		temp->prev->next = temp->next;
		temp->next->prev = temp->prev;
	}
}
nil search(int key){

	nil temp;
	temp = new node;
	temp = head->next;
	while(temp->key != key && temp != 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" ;

}










#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 != tail){ 
		//temp->next->prev = temp->prev; 
		//temp->prev->next = temp->next; 
		temp->prev->next = temp->next;
		temp->next->prev = temp->prev;
	}
}
nil search(int key){

	nil temp;
	temp = new node;
	temp = head->next;
	/*while(temp->key != key && temp != tail ){
		temp = temp->next;
	}
	*/
	for(;temp->key != key && temp != 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:137:8: error: redefinition of 'struct node'
  137 | struct node {
      |        ^~~~
a.cc:4:8: note: previous definition of 'struct node'
    4 | struct node {
      |        ^~~~
a.cc:142:5: error: redefinition of 'node* head'
  142 | nil head;
      |     ^~~~
a.cc:9:5: note: 'node* head' previously declared here
    9 | nil head;
      |     ^~~~
a.cc:143:5: error: redefinition of 'node* tail'
  143 | nil tail;
      |     ^~~~
a.cc:10:5: note: 'node* tail' previously declared here
   10 | nil tail;
      |     ^~~~
a.cc:153:5: error: redefinition of 'int main()'
  153 | int main(void){
      |     ^~~~
a.cc:20:5: note: 'int main()' previously defined here
   20 | int main(void){
      |     ^~~~
a.cc:160:6: error: redefinition of 'void init()'
  160 | void init(){
      |      ^~~~
a.cc:27:6: note: 'void init()' previously defined here
   27 | void init(){
      |      ^~~~
a.cc:168:6: error: redefinition of 'void input()'
  168 | void input(){
      |      ^~~~~
a.cc:35:6: note: 'void input()' previously defined here
   35 | void input(){
      |      ^~~~~
a.cc:198:5: error: redefinition of 'int judge(std::string)'
  198 | int judge(string instruction){
      |     ^~~~~
a.cc:65:5: note: 'int judge(std::string)' previously defined here
   65 | int judge(string instruction){
      |     ^~~~~
a.cc:207:6: error: redefinition of 'void insert(int)'
  207 | void insert(int key){
      |      ^~~~~~
a.cc:74:6: note: 'void insert(int)' previously defined here
   74 | void insert(int key){
      |      ^~~~~~
a.cc:218:6: error: redefinition of 'void delete_(int)'
  218 | void delete_(int key){
      |      ^~~~~~~
a.cc:85:6: note: 'void delete_(int)' previously defined here
   85 | void delete_(int key){
      |      ^~~~~~~
a.cc:229:5: error: redefinition of 'node* search(int)'
  229 | nil search(int key){
      |     ^~~~~~
a.cc:96:5: note: 'node* search(int)' previously defined here
   96 | nil search(int key){
      |     ^~~~~~
a.cc:241:6: error: redefinition of 'void deleteFirst()'
  241 | void deleteFirst(){
      |      ^~~~~~~~~~~
a.cc:106:6: note: 'void deleteFirst()' previously defined here
  106 | void deleteFirst(){
      |      ^~~~~~~~~~~
a.cc:247:6: error: redefinition of 'void deleteLast()'
  247 | void deleteLast(){
      |      ^~~~~~~~~~
a.cc:112:6: note: 'void deleteLast()' previously defined here
  112 | void deleteLast(){
      |      ^~~~~~~~~~
a.cc:253:6: error: redefinition of 'void print()'
  253 | void print(){
      |      ^~~~~
a.cc:118:6: note: 'void print()' previously defined here
  118 | void print(){
      |      ^~~~~