Buggy python submission (verdict: Runtime Error):
n = input()
l = []
for i in range(int(n)):
	command = input()
	print(command)
	if command[0] == 'i':
		l.insert([(command[6:])])
	else:
		if command[7] == " ":
			if  command[6:] in l:
				l.remove(command[6:])
		else:
			if command[7] == 'L':
				l.pop()
			else:
				l.pop(0)
for i in l[:-1]:
	print(i, end=' ')
print(l[-1])

Fixed submission:
from collections import deque
n = input()
d = deque()
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft()
for _ in range(len(d)-1):
	print(d.popleft(), end=" ")
print(d.pop())

Buggy python submission (verdict: Runtime Error):
n = input()
l = []
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		l.insert([(command[6:])])
	else:
		if command[7] == " ":
			if  command[6:] in l:
				l.remove(command[6:])
		else:
			if command[7] == 'L':
				l.pop()
			else:
				l.pop(0)
for i in l[:-1]:
	print(i, end=' ')
print(l[-1])

Fixed submission:
from collections import deque
n = input()
d = deque()
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft()
for _ in range(len(d)-1):
	print(d.popleft(), end=" ")
print(d.pop())

Buggy python submission (verdict: Runtime Error):
n = input()
l = []
for i in range(int(n)):
	command = input()
	print(command)
	if command[0] == 'i':
		l.insert(command[7:])
	else:
		if command[6] == " ":
			if command[7:] in l:
				l.remove(command[7:])
		else:
			if command[7] == 'L':
				l.pop()
			else:
				l.pop(0)
for i in l[:-1]:
	print(i, end=' ')
print(l[-1])

Fixed submission:
from collections import deque
n = input()
d = deque()
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft()
for _ in range(len(d)-1):
	print(d.popleft(), end=" ")
print(d.pop())

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
l = []
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		l.insert(0, command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in l:
				l.remove(command[7:])
		else:
			if command[6] == 'L':
				l.pop()
			else:
				l.pop(0)
for i in l[:-1]:
	print(i, end=' ')
print(l[-1])

Fixed submission:
from collections import deque
n = input()
d = deque()
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft()
for _ in range(len(d)-1):
	print(d.popleft(), end=" ")
print(d.pop())

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

nil = Node(None)
nil.prev = nil
nil.next = nil

def insert(key):
	node = Node(key)
	node.next = nil.next
	nil.next.prev = node
	nil.next = node
	node.prev = nil;

def search(key):
	cur = nil.next
	while ((cur != nil) and (cur.key != key)):
		cur = cur.next
	return cur

def delete(t):
	if t!=nil:
		t.prev.next = t.next
		t.next.prev = t.prev

def deleteFirst():
	delete(nil.next)

def deleteLast():
	delete(nil.prev)

n = input()
for _ in range(int(n)):
	command = input()
	if command[0] == 'i':
		insert(command[7:])
	else:
		if command[6] == " ":
			delete(search(command[7:]))
		else:
			if command[6] == 'L':
				deleteLast()
			else:
				deleteFirst()

cur = nil.next
while(1):
	if cur.next == nil:
		break;
	print(cur.key, end=" ")
	cur = cur.next
print(cur.key)

Fixed submission:
from collections import deque
n = input()
d = deque()
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft()
for _ in range(len(d)-1):
	print(d.popleft(), end=" ")
print(d.pop())

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

nil = Node(None)
nil.prev = nil
nil.next = nil

def insert(key):
	node = Node(key)
	node.next = nil.next
	nil.next.prev = node
	nil.next = node
	node.prev = nil;

def search(key):
	cur = nil.next
	while ((cur != nil) and (cur.key != key)):
		cur = cur.next
	return cur

def delete(t):
	if t!=nil:
		t.prev.next = t.next
		t.next.prev = t.prev
		del t

def deleteFirst():
	delete(nil.next)

def deleteLast():
	delete(nil.prev)

n = input()
for _ in range(int(n)):
	command = input()
	if command[0] == 'i':
		insert(command[7:])
	else:
		if command[6] == " ":
			delete(search(command[7:]))
		else:
			if command[6] == 'L':
				deleteLast()
			else:
				deleteFirst()

cur = nil.next
while(1):
	if cur.next == nil:
		break;
	print(cur.key, end=" ")
	cur = cur.next
print(cur.key)

Fixed submission:
from collections import deque
n = input()
d = deque()
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft()
for _ in range(len(d)-1):
	print(d.popleft(), end=" ")
print(d.pop())