Buggy python submission (verdict: Runtime Error):
n = int(input().strip())

l = []
for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        l = l[1:]
    elif cmd == "deleteLast":
        l.pop()
    elif cmd.startswith("insert "):
        _, e = cmd.split(" ")
        l.insert(0, e)
    elif cmd.startswith("delete "):
        _, e = cmd.split(" ")
        l.remove(e)

print(" ".join(l)) 

Fixed submission:
from collections import deque

q = deque()

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass
print(" ".join(q))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().strip())

l = []
for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        l = l[1:]
    elif cmd == "deleteLast":
        l.pop()
    elif cmd.startswith("insert "):
        _, e = cmd.split(" ")
        l.insert(0, e)
    elif cmd.startswith("delete "):
        _, e = cmd.split(" ")
        if e in l:
            l.remove(e)

print(" ".join(l))

Fixed submission:
from collections import deque

q = deque()

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass
print(" ".join(q))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().strip())

l = []
for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        l = l[1:]
    elif cmd == "deleteLast":
        l.pop()
    elif cmd.startswith("insert "):
        _, e = cmd.split(" ")
        l = [e] + l
    elif cmd.startswith("delete "):
        _, e = cmd.split(" ")
        if e in l:
            l.remove(e)

print(" ".join(l))

Fixed submission:
from collections import deque

q = deque()

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass
print(" ".join(q))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().strip())

l = []
for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        l = l[1:]
    elif cmd == "deleteLast":
        l.pop()
    elif cmd.startswith("insert "):
        _, e = cmd.split(" ")
        l = [e] + l
    elif cmd.startswith("delete "):
        _, e = cmd.split(" ")
        try:
            l.remove(e)
        except ValueError:
            pass

print(" ".join(l))

Fixed submission:
from collections import deque

q = deque()

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass
print(" ".join(q))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

class E(object):
    def __init__(self, p = None, v = None, n = None):
        self.p = p
        self.v = v
        self.n = n

    def rem(self):
        if self.p is not None:
            self.p.n = self.n
        if self.n is not None:
            self.n.p = self.p

    def ins(self, ne):
        self.p = ne
        ne.n = self

    def prt(self):
        sys.stdout.write(self.v)
        if self.n is not None:
            sys.stdout.write(" ")
            self.n.prt()

fe = le = None

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        if fe is not None:
            fe.rem()
            if fe.n is not None:
                fe = fe.n
            else:
                fe = le = None
    elif cmd == "deleteLast":
        if le is not None:
            le.rem()
            if le.p is not None:
                le = le.p
            else:
                fe = le = None
    elif cmd.startswith("insert "):
        _, v = cmd.split(" ")
        e = E(None, v, None)
        if fe is not None:
            fe.ins(e)
        fe = e
        if le is None:
            le = e
    elif cmd.startswith("delete "):
        _, v = cmd.split(" ")
        e = fe
        while e is not None:
            if e.v == v:
                e.rem()
                if fe == e:
                    fe = e.n
                if le == e:
                    le = e.p
                break
            e = e.n

    #print("F: {}, L: {}".format(fe.v if fe is not None else "None", le.v if le is not None else "None"))

if fe is not None:
    fe.prt()
print("")

Fixed submission:
from collections import deque

q = deque()

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass
print(" ".join(q))

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

q = deque()

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        q.remove(v)
print(" ".join(q))

Fixed submission:
from collections import deque

q = deque()

n = int(input().strip())

for _ in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        q.popleft()
    elif cmd == "deleteLast":
        q.pop()
    elif cmd.startswith("insert "):
        v = cmd[7:]
        q.appendleft(v)
    elif cmd.startswith("delete "):
        v = cmd[7:]
        try:
            q.remove(v)
        except ValueError:
            pass
print(" ".join(q))