Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
commands = []
for a in range(n):
    raw = input().split()
    try:
        commands.append([raw[0], int(raw[1])])
    except:
        commands.append([raw[0], 'none'])

result = []
for a in commands:
    command, x = a[0], a[1]
    if command == 'insert':
        result.append(x)
    elif command == 'delete':
        if x in result:
            result.reverse()
            result.remove(x)
            result.reverse()
        else:
            continue
    elif command == 'deleteFirst':
        del result[-1]
    else:
        del result[0]

result.reverse()
print(*result)


Fixed submission:
from collections import deque
import sys

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for line in sys.stdin.readlines():
    c = line.split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]()

print(*result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
commands = []
for a in range(n):
    raw = input().split()
    try:
        commands.append([raw[0], int(raw[1])])
    except:
        commands.append([raw[0], 'none'])

result = []
for a in commands:
    command, x = a[0], a[1]
    if command == 'insert':
        result.append(x)
    elif command == 'delete':
        if x in result:
            if result.count(x) == 1:
                result.remove(x)
            else:
                for i in range(len(result)-1, -1, -1):
                    if result[i] == x:
                        del result[i]
                        break
        else:
            continue
    elif command == 'deleteFirst':
        del result[-1]
    else:
        del result[0]

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


Fixed submission:
from collections import deque
import sys

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for line in sys.stdin.readlines():
    c = line.split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]()

print(*result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
result = []
for a in range(n):
    c = input().split()
    if c[0] == 'insert':
        result.append(int(c[1]))
    elif c[0] == 'delete':
        c[1] = int(c[1])
        if c[1] in result:
            if result.count(c[1]) == 1:
                result.remove(c[1])
            else:
                for i in range(len(result)-1, -1, -1):
                    if result[i] == c[1]:
                        del result[i]
                        break
        else:
            continue
    elif c[0] == 'deleteFirst':
        del result[-1]
    else:
        del result[0]

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


Fixed submission:
from collections import deque
import sys

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for line in sys.stdin.readlines():
    c = line.split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]()

print(*result)

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

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for i in range(n):
    c = input().split()
    if len(c) > 1:
        func[c[0]](int(c[1]))
    else:
        func[c[0]]()

print(*result)


Fixed submission:
from collections import deque
import sys

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for line in sys.stdin.readlines():
    c = line.split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]()

print(*result)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for i in range(n):
    c = input().split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]()

print(*result)


Fixed submission:
from collections import deque
import sys

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for line in sys.stdin.readlines():
    c = line.split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]()

print(*result)