Buggy python submission (verdict: Time Limit Exceeded):
class Node():
    def __init__(self, key):
        self.prev = None
        self.next = None
        self.key = key
    
class Solution:
    def display(self):
        result = []
        cur = nil.next
        while True:
            if cur == nil:
                break
            result.append(cur.key)
            cur = cur.next
        return result
    
    def insert(self, key):
        x = Node(key)

        if nil.next == None:
            nil.next = x
            nil.prev = x
            x.prev = nil
            x.next = nil
        else:
            x.next = nil.next
            nil.next.prev = x
            nil.next = x
            x.prev = nil

    def listSearch(self, key):
        cur = nil.next
        while cur != nil:
            if cur.key == key:
                break
            cur = cur.next
        return cur
    
    def deleteNode(self, node):
        if node == nil:
            return
        node.prev.next = node.next
        node.next.prev = node.prev

    def delete(self, key):
        self.deleteNode(self.listSearch(key))
    
    def deleteFirst(self):
        self.deleteNode(nil.next)
    
    def deleteLast(self):
        self.deleteNode(nil.prev)


myList = Solution()
nil = Node(None)

for _ in range(int(input())):
    s = input()
    try:
        com, val = s.split()
        val = int(val)
    except ValueError:
        com = s
    
    if com == 'insert':
        myList.insert(val)
    elif com == 'delete':
        myList.delete(val)
    elif com == 'deleteFirst':
        myList.deleteFirst()
    elif com == 'deleteLast':
        myList.deleteLast()

print(*myList.display())



Fixed submission:
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a)

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

for _ in range(int(input())):
    s = input()
    try:
        com, val = s.split()
        val = int(val)
    except ValueError:
        com = s
    
    if com == 'insert':
        d.appendleft(val)
    elif com == 'delete':
        d.remove(val)
    elif com == 'deleteFirst':
        d.popleft()
    elif com == 'deleteLast':
        d.pop()

print(*d)



Fixed submission:
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a)

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

for _ in range(int(input())):
    s = input()
    try:
        com, val = s.split()
        val = int(val)
    except ValueError:
        com = s
    
    if com == 'insert':
        d.appendleft(val)
    elif com == 'delete':
        try:
            d.remove(val)
        except:
            pass
    elif com == 'deleteFirst':
        d.popleft()
    elif com == 'deleteLast':
        d.pop()

print(*d)



Fixed submission:
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a)

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

for _ in range(int(input())):
    s = input().split()
    
    if s[0] == 'insert':
        d.appendleft(int(s[1]))
    elif s[0] == 'delete':
        try:
            d.remove(int(s[1]))
        except:
            pass
    elif s[0] == 'deleteFirst':
        d.popleft()
    elif s[0] == 'deleteLast':
        d.pop()

print(*d)



Fixed submission:
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a)