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


class DoublyLinkedList():
    def __init__(self):
        head = Node()
        head.next = head
        head.prev = head
        self.size = 0
        self.head = head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node
        self.size += 1

    def delete(self, x):
        node = self.head.next
        while node is not self.head:
            if node.key == x:
                node.prev.next = node.next
                node.next.prev = node.prev
                self.size -= 1
                break
            node = node.next

    def deleteFirst(self):
        self.head.next.next.prev = self.head
        self.head.next = self.head.next.next
        self.size -= 1

    def deleteLast(self):
        self.head.prev.prev.next = self.head
        self.head.prev = self.head.prev.prev
        self.size -= 1

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(str(node.key))
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in range(n):
    inputs = input().split()
    if len(inputs) == 1:
        command = inputs[0]
    else:
        command = inputs[0]
        key = inputs[1]
    if command == "insert":
        L.insert(int(key))
    elif command == "delete":
        L.delete(int(key))
    elif command == "deleteFirst":
        L.deleteFirst()
    else:
        L.deleteLast()

print(L.getKeys())



Fixed submission:
import sys


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        node = self.search(x)
        if node is self.head:
            return None
        self._delete(node)

    def _delete(self, node):
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        L.insert(x)
    elif 'deleteFirst' in i:
        L.deleteFirst()
    elif 'deleteLast' in i:
        L.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        L.delete_key(x)
    else:
        pass
print(L.getKeys())

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


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        head = Node()
        head.next = head
        head.prev = head
        self.size = 0
        self.head = head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node
        self.size += 1

    def delete(self, x):
        node = self.head.next
        while node is not self.head:
            if node.key == x:
                node.prev.next = node.next
                node.next.prev = node.prev
                self.size -= 1
                break
            node = node.next

    def deleteFirst(self):
        self.head.next.next.prev = self.head
        self.head.next = self.head.next.next
        self.size -= 1

    def deleteLast(self):
        self.head.prev.prev.next = self.head
        self.head.prev = self.head.prev.prev
        self.size -= 1

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(str(node.key))
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in range(n):
    command = stdin.readline().strip().split()
    if command[0] == "insert":
        L.insert(int(command[1]))
    elif command[0] == "delete":
        L.delete(int(command[1]))
    elif command[0] == "deleteFirst":
        L.deleteFirst()
    else:
        L.deleteLast()

print(L.getKeys())



Fixed submission:
import sys


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        node = self.search(x)
        if node is self.head:
            return None
        self._delete(node)

    def _delete(self, node):
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        L.insert(x)
    elif 'deleteFirst' in i:
        L.deleteFirst()
    elif 'deleteLast' in i:
        L.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        L.delete_key(x)
    else:
        pass
print(L.getKeys())

Buggy python submission (verdict: Time Limit Exceeded):
# これもdeque使わないと時間切れになるのか？
from sys import stdin


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        head = Node()
        head.next = head
        head.prev = head
        self.size = 0
        self.head = head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node
        #self.size += 1

    def delete(self, x):
        node = self.head.next
        while node is not self.head:
            if node.key == x:
                node.prev.next = node.next
                node.next.prev = node.prev
        #        self.size -= 1
                break
            node = node.next

    def deleteFirst(self):
        self.head.next.next.prev = self.head
        self.head.next = self.head.next.next
        #self.size -= 1

    def deleteLast(self):
        self.head.prev.prev.next = self.head
        self.head.prev = self.head.prev.prev
        #self.size -= 1

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(str(node.key))
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in range(n):
    command = stdin.readline().strip().split()
    if command[0] == "insert":
        L.insert(int(command[1]))
    elif command[0] == "delete":
        L.delete(int(command[1]))
    elif command[0] == "deleteFirst":
        L.deleteFirst()
    else:
        L.deleteLast()

print(L.getKeys())



Fixed submission:
import sys


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        node = self.search(x)
        if node is self.head:
            return None
        self._delete(node)

    def _delete(self, node):
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        L.insert(x)
    elif 'deleteFirst' in i:
        L.deleteFirst()
    elif 'deleteLast' in i:
        L.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        L.delete_key(x)
    else:
        pass
print(L.getKeys())

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


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        head = Node()
        tail = Node()
        head.next = tail
        head.prev = tail
        tail.next = head
        tail.prev = head
        #self.size = 0
        self.head = head
        self.tail = tail

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node
        #self.size += 1

    def delete(self, x):
        node = self.head.next
        while node is not self.tail:
            if node.key == x:
                node.prev.next = node.next
                node.next.prev = node.prev
                #self.size -= 1
                break
            node = node.next

    def deleteFirst(self):
        self.head.next.next.prev = self.head
        self.head.next = self.head.next.next
        #self.size -= 1

    def deleteLast(self):
        self.tail.prev.prev.next = self.tail
        self.tail.prev = self.tail.prev.prev
        #self.size -= 1

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.tail:
            keys.append(str(node.key))
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in range(n):
    command = stdin.readline().strip().split()
    if command[0] == "insert":
        L.insert(int(command[1]))
    elif command[0] == "delete":
        L.delete(int(command[1]))
    elif command[0] == "deleteFirst":
        L.deleteFirst()
    else:
        L.deleteLast()

print(L.getKeys())



Fixed submission:
import sys


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        node = self.search(x)
        if node is self.head:
            return None
        self._delete(node)

    def _delete(self, node):
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        L.insert(x)
    elif 'deleteFirst' in i:
        L.deleteFirst()
    elif 'deleteLast' in i:
        L.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        L.delete_key(x)
    else:
        pass
print(L.getKeys())

Buggy python submission (verdict: Time Limit Exceeded):
# これもdeque使わないと時間切れになるのか？
from sys import stdin


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def delete(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        if node != self.head:
            node.prev.next = node.next
            node.next.prev = node.prev

    def deleteFirst(self):
        self.head.next.next.prev = self.head
        self.head.next = self.head.next.next

    def deleteLast(self):
        self.head.prev.prev.next = self.head
        self.head.prev = self.head.prev.prev

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(str(node.key))
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in range(n):
    command = stdin.readline().strip().split()
    if command[0] == "insert":
        L.insert(int(command[1]))
    elif command[0] == "delete":
        L.delete(int(command[1]))
    elif command[0] == "deleteFirst":
        L.deleteFirst()
    else:
        L.deleteLast()

print(L.getKeys())



Fixed submission:
import sys


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        node = self.search(x)
        if node is self.head:
            return None
        self._delete(node)

    def _delete(self, node):
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        L.insert(x)
    elif 'deleteFirst' in i:
        L.deleteFirst()
    elif 'deleteLast' in i:
        L.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        L.delete_key(x)
    else:
        pass
print(L.getKeys())

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


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        node = self.search(x)
        if node is self.head:
            return None
        self._delete(node)

    def _delete(self, node):
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in range(n):
    command = stdin.readline().strip().split()
    if command[0] == "insert":
        L.insert(command[1])
    elif command[0] == "delete":
        L.delete_key(command[1])
    elif command[0] == "deleteFirst":
        L.deleteFirst()
    else:
        L.deleteLast()
    # print(L.getKeys())

print(L.getKeys())



Fixed submission:
import sys


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        node = self.search(x)
        if node is self.head:
            return None
        self._delete(node)

    def _delete(self, node):
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        L.insert(x)
    elif 'deleteFirst' in i:
        L.deleteFirst()
    elif 'deleteLast' in i:
        L.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        L.delete_key(x)
    else:
        pass
print(L.getKeys())

Buggy python submission (verdict: Runtime Error):
import sys


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        if node is self.head:
            return None
        node = self.search(x)
        self._delete(node)

    def _delete(self, node):
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        L.insert(x)
    elif 'deleteFirst' in i:
        L.deleteFirst()
    elif 'deleteLast' in i:
        L.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        L.delete_key(x)
    else:
        pass
print(L.getKeys())



Fixed submission:
import sys


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        node = self.search(x)
        if node is self.head:
            return None
        self._delete(node)

    def _delete(self, node):
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        L.insert(x)
    elif 'deleteFirst' in i:
        L.deleteFirst()
    elif 'deleteLast' in i:
        L.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        L.delete_key(x)
    else:
        pass
print(L.getKeys())