Buggy python submission (verdict: Time Limit Exceeded):
class Deque:
    #??????????????????
    class Node:
        def __init__(self, x, y = None, z = None):
            self.key = x
            self.next = y
            self.prev = z
    def __init__(self):
        head = Deque.Node(None)
        head.next = head
        head.prev = head
        self.size = 0
        self.head = head

    #insert x:??£??????????????????????????????x?????????????´???????????¶????
    def insert(self,x):
        h = self.head
        q = h.next
        p = Deque.Node(x,q,h)
        h.next = p
        q.prev = p
        self.size += 1

    #deleteFirst:??£????????????????????????????´???????????????????
    def deleteFirst(self):
        if self.size == 0: raise IndexError
        h = self.head
        q = h.next
        p = q.next
        p.prev = h
        h.next = p
        self.size -= 1

    #deleteLast:??£???????????????????°????????´???????????????????
    def deleteLast(self):
        if self.size == 0: raise IndexError
        h = self.head
        q = h.prev
        p = q.prev
        p.next = h
        h.prev = p
        self.size -= 1

    #???????????????????????¢?´¢
    def listSearch(self, x):
        h = self.head
        cur = h.next
        while cur != None and cur.key != x:
            cur = cur.next
        return cur

    #delete:x???????????????????´??????????????????°?????¢?´¢???????§?
    def delete(self, x):
        if self.size == 0: raise IndexError
        if x == None: return
        h = self.listSearch(x)
        q = h.next
        p = h.prev
        p.next = q
        q. prev = p
        self.size -=1

    #??????
    def printList(self):
        h = self.head
        cur = h.next
        isf = 0
        while 1:
            if cur == h: break
            if isf > 0: print(" ", end="")
            print(cur.key, end="")
            isf += 1
            cur = cur.next
        print("")

N = int(input())
CL=[]
d = Deque()
for i in range(N):
    CL.append(input().split())
for i in CL:
    if i[0] == "insert":
        x = i[1]
        d.insert(x)
    if i[0] == "delete":
        x = i[1]
        d.delete(x)
    if i[0] == "deleteFirst":
        d.deleteFirst()
    if i[0] =="deleteLast":
        d.deleteLast()
d.printList()

Fixed submission:
from collections import deque
n = int(input())
L = deque()

for i in range(n):
    cmdline = input().split()

    if cmdline[0] == "insert":
        L.appendleft(cmdline[1])
    elif cmdline[0] == "delete":
        try:
            L.remove(cmdline[1])
        except ValueError: pass
    elif cmdline[0] == "deleteFirst":
        L.popleft()
    elif cmdline[0] == "deleteLast":
        L.pop()

print(" ".join(L))

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

if __name__ == '__main__':
	n = int(input())
	L = deque()

	for i in range(n):
		cmdline = input().split()

		if cmdline[0] == "insert":
			L.appendleft(cmdline[1])
		elif cmdline[0] == "delete":
			L.remove(cmdline[1])
		elif cmdline[0] == "deleteFirst":
			L.popleft()
		elif cmdline[0] == "deleteLast":
			L.pop()

	print(" ".join(L))

Fixed submission:
from collections import deque
n = int(input())
L = deque()

for i in range(n):
    cmdline = input().split()

    if cmdline[0] == "insert":
        L.appendleft(cmdline[1])
    elif cmdline[0] == "delete":
        try:
            L.remove(cmdline[1])
        except ValueError: pass
    elif cmdline[0] == "deleteFirst":
        L.popleft()
    elif cmdline[0] == "deleteLast":
        L.pop()

print(" ".join(L))

Buggy python submission (verdict: Time Limit Exceeded):
class Deque:
    #??????????????????
    class Node:
        def __init__(self, x, y = None, z = None):
            self.key = x
            self.next = y
            self.prev = z
    def __init__(self):
        head = Deque.Node(None)
        head.next = head
        head.prev = head
        self.size = 0
        self.head = head

    #insert x:??£??????????????????????????????x?????????????´???????????¶????
    def insert(self,x):
        h = self.head
        q = h.next
        p = Deque.Node(x,q,h)
        h.next = p
        q.prev = p
        self.size += 1

    #deleteFirst:??£????????????????????????????´???????????????????
    def deleteFirst(self):
        if self.size == 0: raise IndexError
        h = self.head
        q = h.next
        p = q.next
        p.prev = h
        h.next = p
        self.size -= 1

    #deleteLast:??£???????????????????°????????´???????????????????
    def deleteLast(self):
        if self.size == 0: raise IndexError
        h = self.head
        q = h.prev
        p = q.prev
        p.next = h
        h.prev = p
        self.size -= 1

    #???????????????????????¢?´¢
    def listSearch(self, x):
        h = self.head
        cur = h.next
        while cur != None and cur.key != x:
            cur = cur.next
        return cur

    #delete:x???????????????????´??????????????????°?????¢?´¢???????§?
    def delete(self, x):
        if self.size == 0: raise IndexError
        if x == None: return
        h = self.listSearch(x)
        q = h.next
        p = h.prev
        p.next = q
        q. prev = p
        self.size -=1

    #??????
    def printList(self):
        h = self.head
        cur = h.next
        isf = 0
        while 1:
            if cur == h: break
            if isf > 0: print(" ", end="")
            print(cur.key, end="")
            isf = 1
            cur = cur.next
        print("")

n = int(input())
d = Deque()
for i in range(n):
    i = input().split()
    if i[0] == "insert":
        x = i[1]
        d.insert(x)
    if i[0] == "delete":
        x = i[1]
        d.delete(x)
    if i[0] == "deleteFirst":
        d.deleteFirst()
    if i[0] =="deleteLast":
        d.deleteLast()
d.printList()

Fixed submission:
from collections import deque
n = int(input())
L = deque()

for i in range(n):
    cmdline = input().split()

    if cmdline[0] == "insert":
        L.appendleft(cmdline[1])
    elif cmdline[0] == "delete":
        try:
            L.remove(cmdline[1])
        except ValueError: pass
    elif cmdline[0] == "deleteFirst":
        L.popleft()
    elif cmdline[0] == "deleteLast":
        L.pop()

print(" ".join(L))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
doubly linked list
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
"""
# 9/10 ??§???????¶????????????????

from collections import namedtuple


class DualLinkList(object):
    def __init__(self):
        self.nil = namedtuple('Node', ['key', 'prev', 'next'])
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def insert(self, key):
        x = namedtuple('Node', ['key', 'prev', 'next'])
        x.key = key
        x.next = self.nil.next
        self.nil.next.prev = x
        self.nil.next = x
        x.prev = self.nil

    def listSearch(self, key):
        cur = self.nil.next
        while cur != self.nil and cur.key != key:
            cur = cur.next
        return cur

    def deleteNode(self, t):
        if t == self.nil:
            return
        t.prev.next = t.next
        t.next.prev = t.prev
        # del t

    def deleteFirst(self):
        self.deleteNode(self.nil.next)

    def deleteLast(self):
        self.deleteNode(self.nil.prev)

    def deleteKey(self, key):
        self.deleteNode(self.listSearch(key))

    def get_keys(self):
        results = []
        cur = self.nil.next
        while cur != self.nil:
            results.append(cur.key)
            cur = cur.next
        return results

    def print(self):
        cur = self.nil.next
        while cur != self.nil:
            print(cur.key)
            cur = cur.next


def process_instructions(dll, insts):
    # line_count = 1
    for ins in insts:
        # print('processing line: {0}'.format(line_count))
        # line_count += 1
        try:
            code, key = ins.split()
        except ValueError:
            code = ins
        if code == 'insert':
            dll.insert(int(key))
        elif code == 'delete':
            dll.deleteKey(int(key))
        elif code == 'deleteFirst':
            dll.deleteFirst()
        elif code == 'deleteLast':
            dll.deleteLast()
        else:
            raise ValueError
    return dll.get_keys()



if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    data = [input() for x in range(num)]
    #data = []
    #with open('ALDS1_3_C_in9.txt') as f:  # ???????????????????????????
    #    for line in f:
    #       data.append(line.strip())
    #data = data[1:]

    # ??????????????????
    dll = DualLinkList()
    results = process_instructions(dll, data)

    # ???????????¨???
    print('{0}'.format(' '.join(map(str, results))))

Fixed submission:
from collections import deque
n = int(input())
L = deque()

for i in range(n):
    cmdline = input().split()

    if cmdline[0] == "insert":
        L.appendleft(cmdline[1])
    elif cmdline[0] == "delete":
        try:
            L.remove(cmdline[1])
        except ValueError: pass
    elif cmdline[0] == "deleteFirst":
        L.popleft()
    elif cmdline[0] == "deleteLast":
        L.pop()

print(" ".join(L))

Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())
L = deque()

for i in range(n):
	cmdline = input().split()

	if cmdline[0] == "insert":
		L.appendleft(cmdline[1])
	elif cmdline[0] == "delete":
		L.remove(cmdline[1])
	elif cmdline[0] == "deleteFirst":
		L.popleft()
	elif cmdline[0] == "deleteLast":
		L.pop()

print(" ".join(L))

Fixed submission:
from collections import deque
n = int(input())
L = deque()

for i in range(n):
    cmdline = input().split()

    if cmdline[0] == "insert":
        L.appendleft(cmdline[1])
    elif cmdline[0] == "delete":
        try:
            L.remove(cmdline[1])
        except ValueError: pass
    elif cmdline[0] == "deleteFirst":
        L.popleft()
    elif cmdline[0] == "deleteLast":
        L.pop()

print(" ".join(L))

Buggy python submission (verdict: Time Limit Exceeded):
class Deque:
    #??????????????????
    class Node:
        def __init__(self, x, y = None, z = None):
            self.key = x
            self.next = y
            self.prev = z
    def __init__(self):
        head = Deque.Node(None)
        head.next = head
        head.prev = head
        self.size = 0
        self.head = head

    #insert x:??£??????????????????????????????x?????????????´???????????¶????
    def insert(self,x):
        h = self.head
        q = h.next
        p = Deque.Node(x,q,h)
        h.next = p
        q.prev = p
        self.size += 1

    #deleteFirst:??£????????????????????????????´???????????????????
    def deleteFirst(self):
        if self.size == 0: raise IndexError
        h = self.head
        q = h.next
        p = q.next
        p.prev = h
        h.next = p
        self.size -= 1

    #deleteLast:??£???????????????????°????????´???????????????????
    def deleteLast(self):
        if self.size == 0: raise IndexError
        h = self.head
        q = h.prev
        p = q.prev
        p.next = h
        h.prev = p
        self.size -= 1

    #???????????????????????¢?´¢
    def listSearch(self, x):
        h = self.head
        cur = h.next
        while cur.key != None and cur.key != x:
            cur = cur.next
        return cur

    #delete:x???????????????????´??????????????????°?????¢?´¢???????§?
    def delete(self, x):
        if self.size == 0: raise IndexError
        if x == None: return
        h = self.listSearch(x)
        if h.key == None: return
        q = h.next
        p = h.prev
        p.next = q
        q. prev = p
        self.size -=1

    #??????
    def printList(self):
        h = self.head
        cur = h.next
        L = []
        while 1:
            if cur.key == None: break
            L.append(cur.key)
            cur = cur.next
        print(" ".join(L))

n = int(input())
d = Deque()
for i in range(n):
    i = input().split()
    if i[0] == "insert":
        x = i[1]
        d.insert(x)
    if i[0] == "delete":
        x = i[1]
        d.delete(x)
    if i[0] == "deleteFirst":
        d.deleteFirst()
    if i[0] =="deleteLast":
        d.deleteLast()
d.printList()

Fixed submission:
from collections import deque
n = int(input())
L = deque()

for i in range(n):
    cmdline = input().split()

    if cmdline[0] == "insert":
        L.appendleft(cmdline[1])
    elif cmdline[0] == "delete":
        try:
            L.remove(cmdline[1])
        except ValueError: pass
    elif cmdline[0] == "deleteFirst":
        L.popleft()
    elif cmdline[0] == "deleteLast":
        L.pop()

print(" ".join(L))

Buggy python submission (verdict: Time Limit Exceeded):
class Deque:
    class Node:
        def __init__(self, x, y = None, z = None):
            self.key = x
            self.next = y
            self.prev = z
    def __init__(self):
        head = Deque.Node(None)
        head.next = head
        head.prev = head
        self.size = 0
        self.head = head

    def insert(self,x):
        h = self.head
        q = h.next
        p = Deque.Node(x,q,h)
        h.next = p
        q.prev = p
        self.size += 1

    def deleteFirst(self):
        if self.size == 0: raise IndexError
        h = self.head
        q = h.next
        p = q.next
        p.prev = h
        h.next = p
        self.size -= 1

    def deleteLast(self):
        if self.size == 0: raise IndexError
        h = self.head
        q = h.prev
        p = q.prev
        p.next = h
        h.prev = p
        self.size -= 1

    def listSearch(self, x):
        h = self.head
        cur = h.next
        while cur.key != None and cur.key != x:
            cur = cur.next
        return cur

    def delete(self, x):
        if self.size == 0: raise IndexError
        if x == None: return
        h = self.listSearch(x)
        if h.key == None: return
        q = h.next
        p = h.prev
        p.next = q
        q. prev = p
        self.size -=1

    def printList(self):
        h = self.head
        cur = h.next
        L = []
        while 1:
            if cur.key == None: break
            L.append(str(cur.key))
            cur = cur.next
        print(" ".join(L))

n = int(input())
d = Deque()
for i in range(n):
    i = input().split()
    if i[0] == "insert":
        x = int(i[1])
        d.insert(x)
    if i[0] == "delete":
        x = int(i[1])
        d.delete(x)
    if i[0] == "deleteFirst":
        d.deleteFirst()
    if i[0] =="deleteLast":
        d.deleteLast()
d.printList()

Fixed submission:
from collections import deque
n = int(input())
L = deque()

for i in range(n):
    cmdline = input().split()

    if cmdline[0] == "insert":
        L.appendleft(cmdline[1])
    elif cmdline[0] == "delete":
        try:
            L.remove(cmdline[1])
        except ValueError: pass
    elif cmdline[0] == "deleteFirst":
        L.popleft()
    elif cmdline[0] == "deleteLast":
        L.pop()

print(" ".join(L))

Buggy python submission (verdict: Time Limit Exceeded):
class Deque:
    class Node:  # ??????????????????
        def __init__(self, x, y=None, z=None):
            self.key = x
            self.next = y
            self.prev = z

        def search(self, x):  # listSearch??¨???????????????????????????????????????
            if(self.key == x or self.key is None):
                return self
            else:
                return self.prev.search(x)

        def delete(self):
            self.prev.next = self.next
            self.next.prev = self.prev

    def __init__(self):
        self.size = 0
        self.head = Deque.Node(None)
        self.tail = Deque.Node(None, self.head, None)
        self.head.prev = self.tail

    # insert x:??£??????????????????????????????x?????????????´???????????¶????
    def insert(self, x):
        p = Deque.Node(x, self.head, self.head.prev)
        self.head.prev.next = p
        self.head.prev = p
        self.size += 1

    # deleteFirst:??£????????????????????????????´???????????????????
    def deleteFirst(self):
        if self.size == 0:
            raise IndexError
        self.head.prev.delete()
        self.size -= 1

    # deleteLast:??£???????????????????°????????´???????????????????
    def deleteLast(self):
        if self.size == 0:
            raise IndexError
        self.tail.next.delete()
        self.size -= 1

    # ???????????????????????¢?´¢
    def listSearch(self, x):
        return self.head.prev.search(x)

    # ??¢?´¢?????\????£?
    def listSearch2(self, x):
        node = self.tail.next
        while(node.key is not None):
            if(node.key == x):
                return node
            else:
                node = node.next

    # delete:x???????????????????´??????????????????°?????¢?´¢????????¨
    def delete(self, x):
        if self.size == 0:
            raise IndexError
        node = self.listSearch(x)
        if(node.key is not None):
            node.delete()
        self.size -= 1

    # ??????
    def printList(self):
        ret = []
        node = self.head.prev
        while node.key is not None:
            ret.append(str(node.key))
            node = node.prev
        print(" ".join(ret))


n = int(input())
d = Deque()
for i in range(n):
    i = input().split()
    if i[0] == "insert":
        x = int(i[1])
        d.insert(x)
    if i[0] == "delete":
        x = int(i[1])
        d.delete(x)
    if i[0] == "deleteFirst":
        d.deleteFirst()
    if i[0] == "deleteLast":
        d.deleteLast()
d.printList()

Fixed submission:
from collections import deque
n = int(input())
L = deque()

for i in range(n):
    cmdline = input().split()

    if cmdline[0] == "insert":
        L.appendleft(cmdline[1])
    elif cmdline[0] == "delete":
        try:
            L.remove(cmdline[1])
        except ValueError: pass
    elif cmdline[0] == "deleteFirst":
        L.popleft()
    elif cmdline[0] == "deleteLast":
        L.pop()

print(" ".join(L))