Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = input()
list = []
for i in xrange(n):
    command, key = raw_input().split()
    if command == "insert":
        list.insert(0, key)
    elif command == "delete":
        list.remove(key)
    elif command == "deleteFirst":
        list.pop(0)
    elif command == "deleteLast":
        list.pop()
        
print " ".join(list)

Fixed submission:
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = input()
list = []
for i in xrange(n):
    command = raw_input().split()
    if command[0] == "insert":
        list.insert(0, command[1])
    elif command[0] == "delete":
        list.remove(command[1])
    elif command[0] == "deleteFirst":
        list.pop(0)
    elif command[0] == "deleteLast":
        list.pop()
        
print " ".join(list)

Fixed submission:
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = input()
list = []
for i in xrange(n):
    command = raw_input().split()
    if command[0] == "insert":
        list.insert(0, command[1])
    elif command[0] == "delete":
        if command[1] in list:
            list.remove(command[1])
    elif command[0] == "deleteFirst":
        list.pop(0)
    elif command[0] == "deleteLast":
        list.pop()
        
print " ".join(list)

Fixed submission:
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

n = input()
list = np.array([], dtype=long)

for i in xrange(n):
    command = raw_input().split()
    if command[0] == "insert":
        list = np.append(int(command[1]), list)
    elif command[0] == "delete":
        key = int(command[1])
        for i in xrange(len(list)):
            if list[i] == key:
                list = np.delete(list, i)
    elif command[0] == "deleteFirst":
        list = np.delete(list, 0)
    elif command[0] == "deleteLast":
        list = np.delete(list, len(list)-1)
        
print " ".join(map(str,list))

Fixed submission:
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = input()
class DoubleLinkedList(object):
    def __init__(self):
        self.next = None
        self.prev = None
        self.value = None
        
    def insert(self, value):
        new = DoubleLinkedList()
        new.next = self.next
        new.prev = self
        self.next.prev = new
        self.next = new
        new.value = value
        
    def delete(self):
        next = self.next
        prev = self.prev
        self.next.prev = prev
        self.prev.next = next

head = DoubleLinkedList()
tail = DoubleLinkedList()
head.next = tail
tail.prev = head

for i in xrange(n):
    command = raw_input().split()
    if command[0] == "insert":
        head.insert(int(command[1]))
    elif command[0] == "delete":
        key = int(command[1])
        e = head.next
        while True:
            if e is tail:
                break
            if e.value == key:
                e.delete()
                break
            e = e.next
    elif command[0] == "deleteFirst":
        if not head.next is tail:
            head.next.delete()
    elif command[0] == "deleteLast":  
        if not tail.prev is head:
            tail.prev.delete()
    
e = head.next
while True:
    if e is tail:
        break
    print e.value,
    e = e.next

Fixed submission:
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = input()
class DoubleLinkedList(object):
    def __init__(self):
        pass
        
    def insert(self, value):
        new = DoubleLinkedList()
        new.next = self.next
        new.prev = self
        self.next.prev = new
        self.next = new
        new.value = value
        
    def delete(self):
        next = self.next
        prev = self.prev
        self.next.prev = prev
        self.prev.next = next

head = DoubleLinkedList()
tail = DoubleLinkedList()
head.next = tail
tail.prev = head

for i in xrange(n):
    command = raw_input().split()
    if command[0] == "insert":
        head.insert(int(command[1]))
    elif command[0] == "delete":
        key = int(command[1])
        e = head.next
        while True:
            if e is tail:
                break
            if e.value == key:
                e.delete()
                break
            e = e.next
    elif command[0] == "deleteFirst":
        if not head.next is tail:
            head.next.delete()
    elif command[0] == "deleteLast":  
        if not tail.prev is head:
            tail.prev.delete()
    
e = head.next
while True:
    if e is tail:
        break
    print e.value,
    e = e.next

Fixed submission:
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = input()
class DoubleLinkedList(object):
    def __init__(self):
        pass
        
    def insert(self, value):
        new = DoubleLinkedList()
        new.next = self.next
        new.prev = self
        self.next.prev = new
        self.next = new
        new.value = value
        
    def delete(self):
        next = self.next
        prev = self.prev
        self.next.prev = prev
        self.prev.next = next
        self = None

head = DoubleLinkedList()
tail = DoubleLinkedList()
head.next = tail
tail.prev = head

for i in xrange(n):
    command = raw_input().split()
    if command[0] == "insert":
        head.insert(int(command[1]))
    elif command[0] == "delete":
        key = int(command[1])
        e = head.next
        while True:
            if e is tail:
                break
            if e.value == key:
                e.delete()
                break
            e = e.next
    elif command[0] == "deleteFirst":
        if not head.next is tail:
            head.next.delete()
    elif command[0] == "deleteLast":  
        if not tail.prev is head:
            tail.prev.delete()
    
e = head.next
while True:
    if e is tail:
        break
    print e.value,
    e = e.next

Fixed submission:
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        l.pop(l.lindex(cmd[1]))
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Fixed submission:
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        l.pop(len(l) - l[::-1].index(cmd[1]) -1)
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])

Fixed submission:
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])