Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
ls = []
for i in range(n):
    cmd = map(str, raw_input().split())
    if cmd[0] == "insert":
        ls.insert(0, cmd[0])
    elif cmd[0] == "delete":
        ls.remove(ls.index(cmd[1]))
    elif cmd[0] == "deleteFirst":
        ls.remove(0)
    elif cmd[0] == "deleteLast":
        ls.remove(len(ls)-1)
print " ".join(map(str, ls))

Fixed submission:
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
ls = []
for i in range(n):
    cmd = map(str, raw_input().split())
    if cmd[0] == "insert":
        ls.insert(0, cmd[1])
    elif cmd[0] == "delete":
        ls.remove(cmd[1])
    elif cmd[0] == "deleteFirst":
        ls.remove(0)
    elif cmd[0] == "deleteLast":
        ls.remove(len(ls)-1)
    print ls
print " ".join(map(str, ls))

Fixed submission:
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
ls = []
for i in range(n):
    cmd = map(str, raw_input().split())
    if cmd[0] == "insert":
        ls.insert(0, cmd[1])
    elif cmd[0] == "delete":
        ls.remove(cmd[1])
    elif cmd[0] == "deleteFirst":
        del ls[:1]
    elif cmd[0] == "deleteLast":
        del ls[len(ls)-1:]
print " ".join(map(str, ls))

Fixed submission:
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
ls = []
for i in range(n):
    cmd = map(str, raw_input().split())
    if cmd[0] == "insert":
        ls.insert(0, cmd[1])
    elif cmd[0] == "delete":
        if ls.count(cmd[1]) > 0:
            ls.remove(cmd[1])
    elif cmd[0] == "deleteFirst":
        del ls[:1]
    elif cmd[0] == "deleteLast":
        del ls[len(ls)-1:]
print " ".join(map(str, ls))

Fixed submission:
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
ls = []
l = 0
for i in range(n):
    cmd = map(str, raw_input().split())
    if cmd[0] == "insert":
        ls.insert(0, cmd[1])
        l += 1
    elif cmd[0] == "deleteFirst":
        del ls[:1]
        l -= 1
    elif cmd[0] == "deleteLast":
        del ls[l-1:]
        l -= 1
    elif cmd[0] == "delete":
        if ls.count(cmd[1]) > 0:
            ls.remove(cmd[1])
            l -= 1
print " ".join(map(str, ls))

Fixed submission:
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
ls = []
for i in range(n):
    cmd = map(str, raw_input().split())
    if cmd[0] == "insert":
        ls.append(cmd[1])
    elif cmd[0] == "deleteFirst":
        del ls[len(ls)-1:]
    elif cmd[0] == "deleteLast":
        del ls[1:]
    else:
        for i in range(len(ls)-1,0,-1):
            if ls[i] == cmd[1]:
            a = ls.pop(i)
print " ".join(map(str, ls[::-1]))

Fixed submission:
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
ls = []
for i in range(n):
    cmd = raw_input()
    if cmd[0] == "i":
        ls.append(int(cmd[6:]))
    elif cmd[6] == "F":
        del ls[len(ls)-1:]
    elif cmd[6] == "L":
        del ls[:1]
    else:
        try:
            p = ls[::-1].index(int(cmd[7:]))
            if p != -1:
                del ls[-p-1]
        except:
            pass
print " ".join(map(str, ls[::-1]))

Fixed submission:
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
ls = []
for i in range(n):
    cmd = raw_input()
    if cmd[0] == "i":
        ls.insert(0,cmd[7])
    elif cmd[6] == " ":
        ls.remove(cmd[7])
    elif cmd[6] == "F":
        ls.pop(0)
    else:
        ls.pop(-1)

print " ".join(map(str, ls))

Fixed submission:
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
ls = []
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.insert(0,cmd[7:])
	elif cmd[6] == " ":
		try:
			ls.remove(cmd[7:])
		except:
			pass
	elif cmd[6] == "F":
		ls.pop(0)
	else:
		ls.pop(-1)

print " ".join(map(str, ls))

Fixed submission:
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))