Buggy python submission (verdict: Runtime Error):
class DoublyLinkedListNode:
    def __init__(self, num):
        self.num  = num
        self.next = None
        self.prev = None

    def setNext(self, node):
        self.next = node

    def setPrev(self, node):
        self.prev = node

    def getNum(self):
        return self.num

    def getNext(self):
        return self.next

    def getPrev(self):
        return self.prev

class DoublyLinkedList:
    def __init__(self):
        self.first = None
        self.last  = None

    def insert(self, x):
        node = DoublyLinkedListNode(x)

        if self.first == None:
            self.first = node
            self.last  = node
            return

        self.first.setPrev(node)
        node.setNext(self.first)

        self.first = node

    def delete(self, x):
        node = self.first

        while node != None:
            if node.getNum() == x:
                if id(node) == id(self.first):
                    self.deleteFirst()
                    break

                if id(node) == id(self.last):
                    self.deleteLast()
                    break

                pnode = node.getPrev()
                nnode = node.getNext()

                if pnode != None:
                    pnode.setNext(nnode)
                if nnode != None:
                    nnode.setPrev(pnode)

                break

            node = node.getNext()

    def deleteFirst(self):
        node = self.first.getNext()
        node.setPrev(None)
        self.first = node

    def deleteLast(self):
        node = self.last.getPrev()
        node.setNext(None)
        self.last = node

    def __iter__(self):
        self._it = self.first
        return self

    def __next__(self):
        node = self._it
        if node == None:
            raise StopIteration

        self._it = self._it.getNext()
        return node.getNum()

def main():
    n = int(input())

    lst = DoublyLinkedList()

    for _ in range(n):
        cmds = input().split()

        if 'insert' == cmds[0]:
            lst.insert(int(cmds[1]))
        if 'delete' == cmds[0]:
            lst.delete(int(cmds[1]))
        if 'deleteFirst' == cmds[0]:
            lst.deleteFirst()
        if 'deleteLast' == cmds[0]:
            lst.deleteLast()

    print(" ".join([str(x) for x in lst]))

if __name__ == '__main__':
    main()



Fixed submission:
from collections import deque

def main():
    lst = deque()

    n = int(input())

    for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

    sep = ''
    for n in lst:
        print(sep+n, end='')
        sep = ' '
    print()

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
class DoublyLinkedListNode:
    def __init__(self, num):
        self.num  = num
        self.next = None
        self.prev = None

    def setNext(self, node):
        self.next = node

    def setPrev(self, node):
        self.prev = node

    def getNum(self):
        return self.num

    def getNext(self):
        return self.next

    def getPrev(self):
        return self.prev

class DoublyLinkedList:
    def __init__(self):
        self.first = None
        self.last  = None

    def insert(self, x):
        node = DoublyLinkedListNode(x)

        if self.first == None:
            self.first = node
            self.last  = node
            return

        self.first.setPrev(node)
        node.setNext(self.first)

        self.first = node

    def delete(self, x):
        node = self.first

        while node != None:
            if node.getNum() == x:
                if id(node) == id(self.first):
                    self.deleteFirst()
                    break

                if id(node) == id(self.last):
                    self.deleteLast()
                    break

                pnode = node.getPrev()
                nnode = node.getNext()

                if pnode != None:
                    pnode.setNext(nnode)
                if nnode != None:
                    nnode.setPrev(pnode)

                break

            node = node.getNext()

    def deleteFirst(self):
        node = self.first.getNext()

        if node == None:
            self.first = None
            self.last  = None
            return

        node.setPrev(None)
        self.first = node

    def deleteLast(self):
        node = self.last.getPrev()
        if node == None:
            self.first = None
            self.last  = None
            return

        node.setNext(None)
        self.last = node

    def __iter__(self):
        self._it = self.first
        return self

    def __next__(self):
        node = self._it
        if node == None:
            raise StopIteration

        self._it = self._it.getNext()
        return node.getNum()

def main():
    n = int(input())

    lst = DoublyLinkedList()

    for _ in range(n):
        cmds = input().split()

        if 'insert' == cmds[0]:
            lst.insert(int(cmds[1]))
        if 'delete' == cmds[0]:
            lst.delete(int(cmds[1]))
        if 'deleteFirst' == cmds[0]:
            lst.deleteFirst()
        if 'deleteLast' == cmds[0]:
            lst.deleteLast()

    print(" ".join([str(x) for x in lst]))

if __name__ == '__main__':
    main()



Fixed submission:
from collections import deque

def main():
    lst = deque()

    n = int(input())

    for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

    sep = ''
    for n in lst:
        print(sep+n, end='')
        sep = ' '
    print()

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
class DoublyLinkedListNode:
    def __init__(self, num):
        self.num  = num
        self.next = None
        self.prev = None

    def setNext(self, node):
        self.next = node

    def setPrev(self, node):
        self.prev = node

    def getNum(self):
        return self.num

    def getNext(self):
        return self.next

    def getPrev(self):
        return self.prev

class DoublyLinkedList:
    def __init__(self):
        self.first = None
        self.last  = None

    def insert(self, x):
        node = DoublyLinkedListNode(x)

        if self.first == None:
            self.first = node
            self.last  = node
            return

        self.first.setPrev(node)
        node.setNext(self.first)

        self.first = node

    def delete(self, x):
        node = self.first

        while node != None:
            if node.getNum() == x:
                if id(node) == id(self.first):
                    self.deleteFirst()
                    break

                if id(node) == id(self.last):
                    self.deleteLast()
                    break

                pnode = node.getPrev()
                nnode = node.getNext()

                if pnode != None:
                    pnode.setNext(nnode)
                if nnode != None:
                    nnode.setPrev(pnode)

                break

            node = node.getNext()

    def deleteFirst(self):
        node = self.first.getNext()

        if node == None:
            self.first = None
            self.last  = None
            return

        node.setPrev(None)
        self.first = node

    def deleteLast(self):
        node = self.last.getPrev()
        if node == None:
            self.first = None
            self.last  = None
            return

        node.setNext(None)
        self.last = node

    def __iter__(self):
        self._it = self.first
        return self

    def __next__(self):
        node = self._it
        if node == None:
            raise StopIteration

        self._it = self._it.getNext()
        return node.getNum()

def main():
    n = int(input())

    lst = DoublyLinkedList()

    for _ in range(n):
        cmds = input().split()

        if 'insert' == cmds[0]:
            lst.insert(int(cmds[1]))
        if 'delete' == cmds[0]:
            lst.delete(int(cmds[1]))
        if 'deleteFirst' == cmds[0]:
            lst.deleteFirst()
        if 'deleteLast' == cmds[0]:
            lst.deleteLast()

    sep = ''
    for n in lst:
        print(sep+str(n), end='')
        sep = ' '
    print()

if __name__ == '__main__':
    main()



Fixed submission:
from collections import deque

def main():
    lst = deque()

    n = int(input())

    for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

    sep = ''
    for n in lst:
        print(sep+n, end='')
        sep = ' '
    print()

if __name__ == '__main__':
    main()