Buggy python submission (verdict: Runtime Error):
def pr(a):
    for i in range(len(a)):
        print(a[i],end="")
        if i == len(a)-1:
            print("")
        else :
            print(" ",end="")

n = int(input())
a = []
for i in range(n):
    x = input().split()
    if x[0] == "insert":
        a.insert(0,int(x[1]))
    elif x[0] == "delete":
        a.remove(int(x[1]))
    elif x[0] == "deleteFirst":
        a.pop(0)
    elif x[0] == "deleteLast":
        a.pop()

pr(a)



Fixed submission:
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q)

Buggy python submission (verdict: Time Limit Exceeded):

def pr(a):
    for i in range(len(a)):
        print(a[i],end="")
        if i == len(a)-1:
            print("")
        else :
            print(" ",end="")

n = int(input())
a = []
for i in range(n):
    x = input().split()
    if x[0] == "insert":
        a.insert(0,int(x[1]))
    elif x[0] == "delete":
        if int(x[1]) in a:
            a.remove(int(x[1]))
    elif x[0] == "deleteFirst":
        a.pop(0)
    elif x[0] == "deleteLast":
        a.pop()

pr(a)



Fixed submission:
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q)

Buggy python submission (verdict: Runtime Error):
def pr(data,next,head,tail):
    i = head
    while(1):
        if i == -1:
            print("")
            break
        print(data[i],end = "")
        i = next[i]
        if i != -1 :
            print(" ",end="")

def ins_f(data,next,prev,x,head,tail):
    size = len(data)
    if head != -1 :
        data.append(x)
        size += 1
        next.append(head)
        prev.append(-1)
        prev[head] = size -1
        head = size -1
    else :
        data.append(x)
        size += 1
        next.append(-1)
        prev.append(-1)
        tail = size-1
        head = size-1
    return head,tail

def dl(data,next,prev,x,head,tail):
    i = head
    while(1):
        if data[i] == x:
            if i == head:
                head = dl_f(next,prev,head)
                break
            elif i == tail:
                tail = dl_l(next,prev,tail)
                break
            else :
                prev[next[i]] = prev[i]
                next[prev[i]] = next[i]
                break
        elif i == tail:
            break
        i = next[i]
    return head,tail

def dl_f(next,prev,head,tail):
    if head == -1:
        return head
    elif next[head] == -1:
        head = -1
        tail = -1
    else:
        prev[next[head]] = -1
        head = next[head]
    return head,tail

def dl_l(next,prev,head,tail):
    if tail == -1:
        return tail
    elif prev[tail] == -1:
        head = -1
        tail = -1
    else:
        next[prev[tail]] = -1
        tail = prev[tail]
    return head,tail

n = int(input())
data = []
next = []
prev = []
head = -1
tail = -1
size = len(data)

for i in range(n):
    x = input().split()
    if x[0] == "insert":
        head,tail = ins_f(data,next,prev,x[1],head,tail)
    elif x[0] == "delete":
        head,tail = dl(data,next,prev,x[1],head,tail)
    elif x[0] == "deleteFirst":
        head,tail = dl_f(next,prev,head,tail)
    elif x[0] == "deleteLast":
        head,tail = dl_l(next,prev,head,tail)
pr(data,next,head,tail)



Fixed submission:
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q)

Buggy python submission (verdict: Runtime Error):
def pr(data,next,head,tail):
    i = head
    while(1):
        if i == -1:
            print("")
            break
        print(data[i],end = "")
        i = next[i]
        if i != -1 :
            print(" ",end="")

def ins_f(data,next,prev,x,head,tail):
    size = len(data)
    if head != -1 :
        data.append(x)
        size += 1
        next.append(head)
        prev.append(-1)
        prev[head] = size -1
        head = size -1
    else :
        data.append(x)
        size += 1
        next.append(-1)
        prev.append(-1)
        tail = size-1
        head = size-1
    return head,tail

def dl(data,next,prev,x,head,tail):
    i = head
    while(1):
        if data[i] == x:
            if i == head:
                head = dl_f(next,prev,head)
                break
            elif i == tail:
                tail = dl_l(next,prev,tail)
                break
            else :
                prev[next[i]] = prev[i]
                next[prev[i]] = next[i]
                break
        elif i == tail:
            break
        i = next[i]
    return head,tail

def dl_f(next,prev,head,tail):
    if head == -1:
        return head
    elif next[head] == -1:
        head = -1
        tail = -1
    else:
        prev[next[head]] = -1
        head = next[head]
    return head,tail

def dl_l(next,prev,head,tail):
    if tail == -1:
        return tail
    elif prev[tail] == -1:
        head = -1
        tail = -1
    else:
        next[prev[tail]] = -1
        tail = prev[tail]
    return head,tail

n = int(input())
data = []
next = []
prev = []
head = -1
tail = -1
size = len(data)

for i in range(n):
    x = input().split()
    if x[0] == "insert":
        head,tail = ins_f(data,next,prev,x[1],head,tail)
    elif x[0] == "delete":
        head,tail = dl(data,next,prev,x[1],head,tail)
    elif x[0] == "deleteFirst":
        head,tail = dl_f(next,prev,head,tail)
    elif x[0] == "deleteLast":
        head,tail = dl_l(next,prev,head,tail)
#    print(data,head,tail)
pr(data,next,head,tail)



Fixed submission:
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q)

Buggy python submission (verdict: Time Limit Exceeded):
def pr(data,next,head,tail):
    i = head
    while(1):
        if i == -1:
            print("")
            break
        print(data[i],end = "")
        i = next[i]
        if i != -1 :
            print(" ",end = "")

def ins_f(data,next,prev,x,head,tail):
    size = len(data)
    if head != -1 :
        data.append(x)
        size += 1
        next.append(head)
        prev.append(-1)
        prev[head] = size -1
        head = size -1
    else :
        data.append(x)
        size += 1
        next.append(-1)
        prev.append(-1)
        tail = size-1
        head = size-1
    return head,tail

def dl(data,next,prev,x,head,tail):
    i = head
    while(1):
        if data[i] == x:
            if i == head:
                head,tail = dl_f(next,prev,head,tail)
                break
            elif i == tail:
                head,tail = dl_l(next,prev,head,tail)
                break
            else :
                prev[next[i]] = prev[i]
                next[prev[i]] = next[i]
                break
        elif i == tail:
            break
        i = next[i]
    return head,tail

def dl_f(next,prev,head,tail):
    if head == -1:
        return head
    elif next[head] == -1:
        head = -1
        tail = -1
    else:
        prev[next[head]] = -1
        head = next[head]
    return head,tail

def dl_l(next,prev,head,tail):
    if tail == -1:
        pass
    elif prev[tail] == -1:
        head = -1
        tail = -1
    else:
        next[prev[tail]] = -1
        tail = prev[tail]
    return head,tail

n = int(input())
data = []
next = []
prev = []
head = -1
tail = -1
size = len(data)

for i in range(n):
    x = input().split()
    if x[0] == "insert":
        head,tail = ins_f(data,next,prev,x[1],head,tail)
    elif x[0] == "delete":
        head,tail = dl(data,next,prev,x[1],head,tail)
    elif x[0] == "deleteFirst":
        head,tail = dl_f(next,prev,head,tail)
    elif x[0] == "deleteLast":
        head,tail = dl_l(next,prev,head,tail)
pr(data,next,head,tail)



Fixed submission:
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q)

Buggy python submission (verdict: Time Limit Exceeded):
def pr(data,next,head,tail):
    i = head
    while(1):
        if i == -1:
            print("")
            break
        print(data[i],end = "")
        i = next[i]
        if i != -1 :
            print(" ",end = "")

def ins_f(data,next,prev,x,head,tail):
    size = len(data)
    if head != -1 :
        data.append(x)
        size += 1
        next.append(head)
        prev.append(-1)
        prev[head] = size -1
        head = size -1
    else :
        data.append(x)
        size += 1
        next.append(-1)
        prev.append(-1)
        tail = size-1
        head = size-1
    return head,tail

def dl(data,next,prev,x,head,tail):
    i = head
    while(1):
        if data[i] == x:
            if i == head:
                head,tail = dl_f(next,prev,head,tail)
                break
            elif i == tail:
                head,tail = dl_l(next,prev,head,tail)
                break
            else :
                prev[next[i]] = prev[i]
                next[prev[i]] = next[i]
                break
        elif i == tail:
            break
        i = next[i]
    return head,tail

def dl_f(next,prev,head,tail):
    if head == -1:
        return head
    elif next[head] == -1:
        head = -1
        tail = -1
    else:
        prev[next[head]] = -1
        head = next[head]
    return head,tail

def dl_l(next,prev,head,tail):
    if tail == -1:
        pass
    elif prev[tail] == -1:
        head = -1
        tail = -1
    else:
        next[prev[tail]] = -1
        tail = prev[tail]
    return head,tail

n = int(input())
data = []
next = []
prev = []
head = -1
tail = -1
size = len(data)

for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        head,tail = ins_f(data,next,prev,x[7:],head,tail)
    elif x[6] == " ":
        head,tail = dl(data,next,prev,x[7:],head,tail)
    elif l > 10:
        head,tail = dl_f(next,prev,head,tail)
    elif l > 6:
        head,tail = dl_l(next,prev,head,tail)
pr(data,next,head,tail)



Fixed submission:
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q)

Buggy python submission (verdict: Time Limit Exceeded):
def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
a = []
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        a.insert(0,x[7:])
    elif x[6] == " ":
        try:
            a.remove(x[7:])
        except:
            pass
    elif l > 10:
        a.pop(0)
    elif l > 6:
        a.pop()

pr(a)



Fixed submission:
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

pr(q)


Fixed submission:
from collections import deque

def pr(a):
    for i in range(len(a)):
        if i == len(a)-1:
            print(a[i])
        else:
            print(a[i],end = " ")

n = int(input())
q = deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[6] == " ":
        try:
            q.remove(x[7:])
        except:
            pass
    elif l > 10:
        q.popleft()
    elif l > 6:
        q.pop()

print(*q)