Buggy python submission (verdict: Runtime Error):
def operation(command, num, arrey):
    if command == 'insert':
        arrey.insert(0,num)
        return arrey
    elif command == 'delete':
        if num in arrey:
            arrey.remove(num)
    elif command == 'deleteFirst':
        arrey.pop(0)
    elif command == 'deleteLast':
        arrey.pop(-1)


n = int(input())
list = []

for i in range(n):
    command, num = input().split()
    operation(command,num,list)

for i in range(len(list)):
    print(list[i]+' ',end='')

Fixed submission:
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))

Buggy python submission (verdict: Time Limit Exceeded):
def operation(command, arrey):
    if command[0] == 'insert':
        arrey.insert(0,command[1])
        return arrey
    elif command[0] == 'delete':
        if command[1] in arrey:
            arrey.remove(command[1])
    elif command[0] == 'deleteFirst':
        arrey.pop(0)
    elif command[0] == 'deleteLast':
        arrey.pop(-1)


n = int(input())
list = []

for i in range(n):
    command = input().split()
    operation(command,list)

for i in range(len(list)):
    print(list[i]) if i == len(list)-1 else print(list[i]+' ',end='')

Fixed submission:
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))

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

def operation(command, arrey):
    if command[0] == 'insert':
        arrey.insert(0,command[1])
        return arrey
    elif command[0] == 'delete':
        if command[1] in arrey:
            arrey.remove(command[1])
    elif command[0] == 'deleteFirst':
        arrey.pop(0)
    elif command[0] == 'deleteLast':
        arrey.pop(-1)


n = int(input())
list = deque()

for i in range(n):
    command = input().split()
    operation(command,list)

for i in range(len(list)):
    print(list[i]) if i == len(list)-1 else print(list[i]+' ',end='')

Fixed submission:
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))

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

def operation(command, arrey):
    if command[0] == 'insert':
        arrey.insert(0,command[1])
        return arrey
    elif command[0] == 'delete':
        if command[1] in arrey:
            arrey.remove(command[1])
    elif command[0] == 'deleteFirst':
        arrey.popleft()
    elif command[0] == 'deleteLast':
        arrey.pop()


n = int(input())
list = deque()

for i in range(n):
    command = input().split()
    operation(command,list)

for i in range(len(list)):
    print(list[i]) if i == len(list)-1 else print(list[i]+' ',end='')

Fixed submission:
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))

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

def operation(command, arrey):
    if command[0] == 'insert':
        arrey.insert(0,command[1])
        return arrey
    elif command[0] == 'delete':
        if command[1] in arrey:
            arrey.remove(command[1])
    elif command[0] == 'deleteFirst':
        arrey.popleft()
    elif command[0] == 'deleteLast':
        arrey.pop()


n = int(input())
list = deque()

for i in range(n):
    command = input().split()
    operation(command,list)

for i in range(len(list)):
    print(' '.join(list))

Fixed submission:
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))

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

def operation(command, arrey):
    if command[0] == 'insert':
        arrey.insert(0,command[1])
        return arrey
    elif command[0] == 'delete':
        if command[1] in arrey:
            arrey.remove(command[1])
    elif command[0] == 'deleteFirst':
        arrey.popleft()
    elif command[0] == 'deleteLast':
        arrey.pop()


n = int(input())
list = deque()

for i in range(n):
    command = input().split()
    operation(command,list)

print(' '.join(list))

Fixed submission:
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))

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

def operation(command, arrey):
    if command[0] == 'insert':
        arrey.insert(0,command[1])
        return arrey
    elif command[0] == 'delete':
        if command[1] in arrey:
            arrey.remove(command[1])
    elif command[0] == 'deleteFirst':
        arrey.popleft()
    elif command[0] == 'deleteLast':
        arrey.pop()


n = int(input())
list = deque()

for i in range(n):
    command = input().split()
    operation(command,list)

print(' '.join(list))

Fixed submission:
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))

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


def operation(command, arrey):
    if command[0] == 'insert':
        arrey.insert(0,command[1])
        return arrey
    elif command[0] == 'delete':
        if command[1] in arrey:
            arrey.remove(command[1])
    elif command[0] == 'deleteFirst':
        arrey.popleft()
    elif command[0] == 'deleteLast':
        arrey.pop()


n = int(input())
list = deque()

for i in range(n):
    command = input().split()
    operation(command,list)

print(' '.join(list))

Fixed submission:
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))

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

def operation(command, arrey):
    if command[0] == 'insert':
        arrey.insert(0,command[1])
        return arrey
    elif command[0] == 'delete':
        if command[1] in arrey:
            arrey.remove(command[1])
    elif command[0] == 'deleteFirst':
        arrey.popleft()
    elif command[0] == 'deleteLast':
        arrey.pop()


n = int(sys.stdin.readline())
list = deque()

for i in range(n):
    command = sys.stdin.readline().split()
    operation(command,list)

print(' '.join(list))

Fixed submission:
from collections import deque
import sys
 
n = int(sys.stdin.readline())
q = deque()
 
for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()
 
print(' '.join(q))