Buggy python submission (verdict: Runtime Error):
n = int(input())
li = []
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        li.insert(0, command[1])
    elif command[0] == 'delete':
        li.remove(command[1])
    elif command[0] == 'deleteFirst':
        li.pop(0)
    else:
        li.pop()
print(*li)

Fixed submission:
from collections import deque
import sys
 
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
 
for i in range(num):
 
    order = line[i].split()
 
    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])
 
print(' '.join(dq))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        li.insert(0, command[1])
    elif command[0] == 'delete':
        if command[1] in li:
            li.remove(command[1])
    elif command[0] == 'deleteFirst':
        li.pop(0)
    else:
        li.pop()
print(*li)

Fixed submission:
from collections import deque
import sys
 
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
 
for i in range(num):
 
    order = line[i].split()
 
    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])
 
print(' '.join(dq))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        li.insert(0, command[1])
    elif command[0] == 'delete':
        if command[1] in li:
            li.remove(command[1])
    elif command[0] == 'deleteFirst':
        li.pop(0)
    else:
        li.pop()
print(*li)

Fixed submission:
from collections import deque
import sys
 
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
 
for i in range(num):
 
    order = line[i].split()
 
    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])
 
print(' '.join(dq))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        li.insert(0, command[1])
    elif command[0] == 'delete':
        if command[1] in li:
            li.remove(command[1])
    elif command[0] == 'deleteFirst':
        li.pop(0)
    else:
        li.pop()
print(*li)

Fixed submission:
from collections import deque
import sys
 
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
 
for i in range(num):
 
    order = line[i].split()
 
    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])
 
print(' '.join(dq))

Buggy python submission (verdict: Runtime Error):
from collections import deque
    
n = int(input())
dll = deque()
    
for i in range(n):
    input_line = input().split()
    if input_line[0] == "insert":
        dll.appendleft(input_line[1])
    elif input_line[0] == "delete":
        try:
            dll.remove(input_line[1])
        except:
            pass
    elif input_line[0] == "deleteFirst":
        dll.popleft()
    else:
        dll.pop()
            
print(*dll

Fixed submission:
from collections import deque
import sys
 
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
 
for i in range(num):
 
    order = line[i].split()
 
    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])
 
print(' '.join(dq))

Buggy python submission (verdict: Runtime Error):
from collections import deque

n = int(input())
dq = deque()

for _ in range(n):
    command = input().split()
    if command[0] == 'delete':
        dq.remove(int(command[1]))
    elif command[0] == 'insert':
        dq.appendleft(int(command[1]))
    elif command[0] == 'deleteFirst':
        dq.popleft()
    else:
        dq.pop()

print(*list(dq))

Fixed submission:
from collections import deque
import sys
 
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
 
for i in range(num):
 
    order = line[i].split()
 
    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])
 
print(' '.join(dq))