Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def face(x,y,dice):
    if (x==dice[5] and y==dice[4])or(x==dice[4] and y==dice[0])or(x==dice[0] and y==dice[1])or(x==dice[1] and y==dice[5]):
        return dice[2]
    elif (x==dice[0] and y==dice[2])or(x==dice[2] and y==dice[5])or(x==dice[5] and y==dice[3])or(x==dice[3] and y==dice[0]):
        return dice[4]
    elif (y==dice[5] and x==dice[4])or(y==dice[4] and x==dice[0])or(y==dice[0] and x==dice[1])or(y==dice[1] and x==dice[5]):
        return dice[3]
    elif (y==dice[0] and x==dice[2])or(y==dice[2] and x==dice[5])or(y==dice[5] and x==dice[3])or(y==dice[3] and x==dice[0]):
        return dice[1]
    elif (x==dice[2] and y==dice[1])or(x==dice[1] and y==dice[3])or(x==dice[3] and y==dice[4])or(x==dice[4] and y==dice[2]):
        return dice[5]
    else:
        return dice[0]
         
 
for i in range(n):
    a,b=map(int,raw_input().split())
    print face(a,b,l)


Fixed submission:
class dice:

    def __init__(self, numlist):
        self._men = {"T": numlist[0],
                     "B": numlist[5],
                     "N": numlist[4],
                     "S": numlist[1],
                     "W": numlist[3],
                     "E": numlist[2]}

    def roll(self, direction):
        t = dict(self._men)

        if direction == "N":
            self._men["T"] = t["S"]
            self._men["B"] = t["N"]
            self._men["N"] = t["T"]
            self._men["S"] = t["B"]
        elif direction == "S":
            self._men["T"] = t["N"]
            self._men["B"] = t["S"]
            self._men["S"] = t["T"]
            self._men["N"] = t["B"]
        elif direction == "W":
            self._men["T"] = t["E"]
            self._men["B"] = t["W"]
            self._men["W"] = t["T"]
            self._men["E"] = t["B"]
        elif direction == "E":
            self._men["T"] = t["W"]
            self._men["B"] = t["E"]
            self._men["W"] = t["B"]
            self._men["E"] = t["T"]


    def settopsouth(self, top, south):
        if self._men["T"] == top:
            pass
        elif self._men["S"] == top:
            self.roll("N")
        elif self._men["N"] == top:
            self.roll("S")
        elif self._men["W"] == top:
            self.roll("E")
        elif self._men["E"] == top:
            self.roll("W")
        elif self._men["B"] == top:
            self.roll("N")
            self.roll("N")

        if self._men["S"] == south:
            return self._men["E"]
        elif self._men["E"] == south:
            return self._men["N"]
        elif self._men["N"] == south:
            return self._men["W"]
        elif self._men["W"] == south:
            return self._men["S"]


    def gettop(self):
        return self._men["T"]

def decode():
    numlist = [int(x) for x in input().split()]
    n = int(input())
    qs = []
    for _ in range(n):
        al = [int(x) for x in input().split()]
        qs.append(al)

    return numlist, n, qs


if __name__ == '__main__':

    numlist, n, qs = decode()
    d1 = dice(numlist)
    for q in qs:
        print(d1.settopsouth(*q))
Buggy python submission (verdict: Runtime Error):
n = int(input())
line = list(map(int, input().split()))

max = line[0]
min = line[0]
sum = line[0]

for i in range(1, n):
    if max < line[i]:
        max = line[i]
    elif min > line[i]:
        min = line[i]
    sum += line[i]

print(min, max, sum)


Fixed submission:
n = int(input())
line = list(map(int, input().split()))

max = line[0]
min = line[0]
sum = line[0]

for i in range(1, n):
    if max < line[i]:
        max = line[i]
    elif min > line[i]:
        min = line[i]
    sum += line[i]

print(min, max, sum)
Buggy python submission (verdict: Runtime Error):
print(input().swapcase())

s = input()

for c in s:
    if c.islower():
        print(c.upper(), end="")
    else:
        print(c.lower(), end="")
print()


Fixed submission:


s = input()

for c in s:
    if c.islower():
        print(c.upper(), end="")
    else:
        print(c.lower(), end="")
print()
Buggy python submission (verdict: Runtime Error):
def shellSort(A):
    global cnt
    cnt = 0
    h = 1
    g = []
    while h <= len(A):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(A,g[i])


def insertionSort(A,g):
    global cnt
    
    for i in range(g,len(A)):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
            A[j+g] = v
    

n = int(input())
A = [int(input()) for i in range(n)] 


shellSort(A)
print(cnt)
for i in A:
    print(i)


Fixed submission:
def insertionSort(A,g):
    global cnt
    
    for i in range(g,len(A)):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
            
def shellSort(A):
    global cnt
    cnt = 0
    h = 1
    g = []
    while h <= len(A):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(A,g[i])

    

n = int(input())
A = [int(input()) for i in range(n)] 


shellSort(A)
print(cnt)
for i in A:
    print(i)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,g):
    global cnt
    
    for i in range(g,len(A)):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
            A[j+g] = v
            
def shellSort(A):
    global cnt
    cnt = 0
    h = 1
    g = []
    while h <= len(A):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(A,g[i])

    

n = int(input())
A = [int(input()) for i in range(n)] 


shellSort(A)
print(cnt)
for i in A:
    print(i)


Fixed submission:
def insertionSort(A,g):
    global cnt
    
    for i in range(g,len(A)):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
            
def shellSort(A):
    global cnt
    cnt = 0
    h = 1
    g = []
    while h <= len(A):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(A,g[i])

    

n = int(input())
A = [int(input()) for i in range(n)] 


shellSort(A)
print(cnt)
for i in A:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]
count=0
for i in t:
    if i in s:
        count+=1

print(count)


Fixed submission:
def search(L,e):
    """Lは昇順"""
    def bsearch(L,e,low,high):
        if high == low:
            return L[low] == e
        mid = (low + high)//2
        if L[mid] == e:
            return True
        elif L[mid] > e:
            if low==mid:
                return False
            else:
                return bsearch(L,e,low,mid-1)
        else:
            return bsearch(L,e,mid+1,high)
    if len(L) == 0:
        return False
    else:
        return bsearch(L,e,0,len(L)-1)
        
n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]
count=0
for i in t:
    if search(s,i):
        count+=1

print(count)
Buggy python submission (verdict: Runtime Error):
n = input().split()
a = int(n[0])
b = int(n[1])

print('{} {}'.format(a*b,2*a+2*b)

Fixed submission:
a,b = map(int,input().split())
s = a * b
l = 2*a + 2*b

print(s,l)

Buggy python submission (verdict: Runtime Error):
n = input().split()
a = int(n[0])
b = int(n[1])
s = a*b
l = 2*a+2*b

print('{} {}'.format(s,l)

Fixed submission:
a,b = map(int,input().split())
s = a * b
l = 2*a + 2*b

print(s,l)

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())

s = a*b
l = 2*a + 2*b
print(s,l)




Fixed submission:
a,b = map(int,input().split())
s = a * b
l = 2*a + 2*b

print(s,l)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
import math 

def is_loadable(load, num_truck, w_list):

    excess = load*num_truck - sum(w_list)
    #print('Minimum Load:', load, num_truck, 'excess:', excess)
    cur_load = 0
    #truck_load = list()
    for w in w_list:
        #print(cur_load, w)
        if cur_load + w < load:
            cur_load += w
        elif cur_load + w == load:
            #truck_load.append(cur_load + w)
            cur_load = 0
            num_truck -= 1
            if num_truck < 0:
                return False
        else:
            num_truck -= 1
            if num_truck < 0:
                return False
            excess += load - cur_load
            if excess < 0:
                return False
            #print(cur_load, 'is added')
            #truck_load.append(cur_load)
            cur_load = w

    #truck_load.append(cur_load)
    if (cur_load and num_truck == 0):
        return False
    #print(truck_load)
    return True

n, num_truck = map(int, sys.stdin.readline().split())

weight = list()
for i in range(n):
    weight.append(int(sys.stdin.readline()))

ave_w = sum(weight) / num_truck
max_w = max(weight)
load = max(max_w, math.ceil(ave_w))

while True:
    if is_loadable(load, num_truck, weight):
        break
    load += 1

print(load)



Fixed submission:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
import math 

def is_loadable(load, num_truck, w_list):

    excess = load*num_truck - sum(w_list)
    # print('Minimum Load:', load, num_truck, 'excess:', excess)
    cur_load = 0
    #truck_load = list()
    for w in w_list:
        #print(cur_load, w)
        if cur_load + w < load:
            cur_load += w
        elif cur_load + w == load:
            #truck_load.append(cur_load + w)
            cur_load = 0
            num_truck -= 1
            if num_truck < 0:
                return False
        else:
            num_truck -= 1
            if num_truck < 0:
                return False
            excess += load - cur_load
            if excess < 0:
                return False
            #print(cur_load, 'is added')
            #truck_load.append(cur_load)
            cur_load = w

    #truck_load.append(cur_load)
    if (cur_load and num_truck == 0):
        return False
    #print(truck_load)
    return True

n, num_truck = map(int, sys.stdin.readline().split())

weight = list()
for i in range(n):
    weight.append(int(sys.stdin.readline()))

ave_w = sum(weight) / num_truck
max_w = max(weight)
load = max(max_w, math.ceil(ave_w))
max_ng = load - 1

while True:
    if is_loadable(load, num_truck, weight):
        break
    min_ng = load
    load += 1024

min_ok = load
while True:
    if min_ok == max_ng + 1:
        break
    load = (max_ng + min_ok) // 2
    if is_loadable(load, num_truck, weight):
        min_ok = load
    else:
        max_ng = load

print(min_ok)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding: utf-8 -*-

def solve(p, t, A):
    if A[p] == t:
        return True
    if len(A)-1 == p:
        return False
    if solve(p+1, t-A[p], A):
        return True
    if solve(p+1, t, A):
        return True
    return False

import sys

n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
num_q = int(sys.stdin.readline())
query = list(map(int, sys.stdin.readline().split()))

for m in query:
    if solve(0, m, A):
        print('yes')
    else:
        print('no')



Fixed submission:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

def solve(p, t, A, result):
    if A[p] == t:
        result[(p,t)] = True
        return True
    if p == len(A) - 1:
        return False
    if (p,t) in result:
        # print('Cache Hit')
        return result[(p,t)]
    if solve(p+1, t-A[p], A, result):
        result[(p,t)] = True
        return True
    if solve(p+1, t, A, result):
        result[(p,t)] = True
        return True
    result[(p,t)] = False 
    return False

import sys

n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
num_q = int(sys.stdin.readline())
query = list(map(int, sys.stdin.readline().split()))
result = dict()

for m in query:
    if solve(0, m, A, result):
        print('yes')
    else:
        print('no')
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print(a*b)
print(2a + 2b)


Fixed submission:
a,b = map(int,input().split())
print(a * b,(a + b) * 2)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print(a*b)
print(2*a + 2*b)


Fixed submission:
a,b = map(int,input().split())
print(a * b,(a + b) * 2)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print(a*b)
print(2*a+2*b)


Fixed submission:
a,b = map(int,input().split())
print(a * b,(a + b) * 2)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print(a*b 2*(a+b))


Fixed submission:
a,b = map(int,input().split())
print(a * b,(a + b) * 2)
Buggy python submission (verdict: Runtime Error):
s = int(input())

print(s/60/60 + ":" + s/60%60 + ":" + s%60)


Fixed submission:
s = int(input())
print(s//3600, s//60%60, s%60, sep=":")
Buggy python submission (verdict: Runtime Error):
a,b = (int(x) for x in input().split())

if a > b:
  print("a > b")
elif a < b:
  print("a < b")
else
  print("a == b")


Fixed submission:
a,b = (int(x) for x in input().split())
 
if a > b:
  print("a > b")
elif a < b:
  print("a < b")
else:
  print("a == b")
Buggy python submission (verdict: Runtime Error):
w,h,x,y,r = [int(x) for x in input().split()]

if (x+r) =< w and (y+r) =< h:
	print("yes")
else:
	print("No")


Fixed submission:
w,h,x,y,r = [int(x) for x in input().split()]

if x >= r and y >= r and (x+r) <= w and (y+r) <= h:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
while True:
	x = list(int(i) for i in input().split())
	x.sort()
	print(x[0],x[1],sep=" ")


Fixed submission:
while True:
	x = list(int(i) for i in input().split())
	if x[0] == 0 and x[1] == 0:
		break;
	x.sort()
	print(x[0],x[1],sep=" ")
Buggy python submission (verdict: Runtime Error):
import math
r = int(input())

print("%f %f" % (r*r*math.pi, 2*r*math.pi))


Fixed submission:
import math
r = float(input())

print("%f %f" % (r*r*math.pi, 2*r*math.pi))

Buggy python submission (verdict: Runtime Error):
import math
r = input()

print("%f %f" % (r*r*math.pi, 2*r*math.pi))



Fixed submission:
import math
r = float(input())

print("%f %f" % (r*r*math.pi, 2*r*math.pi))
Buggy python submission (verdict: Runtime Error):
while True:
	a,op,b = input().split()
	if op = '+':
		print(a+b)
	if op = '-':
		print(a-b)
	if op = '*':
		print(a*b)
	if op = '/':
		print(a/b)
	if op = '?':
		break


Fixed submission:
while 1:
    s=input()
    if '?' in s:break
    print(int(eval(s)))
Buggy python submission (verdict: Runtime Error):
while 1:
	if h==0 and w==0:
		break
	h,w = [int(x) for x in input().split()]
	for i in range(h):
		print("#"*w)
	print("")



Fixed submission:
while 1:
	h,w = [int(x) for x in input().split()]
	if h==0 and w==0:
		break
	for i in range(h):
		print("#"*w)
	print("")
Buggy python submission (verdict: Runtime Error):
import numpy as np
x = list(map(float, input().split(' ')))
ans = np.sqrt(pow(x[0]-x[2], 2) + pow(x[1]-x[3], 2))
print("{0:.8f}".format(ans))


Fixed submission:
x = list(map(float, input().split(' ')))
ans = pow((pow(x[0]-x[2], 2) + pow(x[1]-x[3], 2)), 0.5)
print("{0:.8f}".format(ans))
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int,input().split(' ')))
A = int(a*b)
S=int(2*(a+b))
print(str(A) + ' '+ str(S))


Fixed submission:
a = list(map(int,input().split(' ')))
A = int(a[0] * a[1])
S=int(2*(a[0] + a[1]))
print(str(A) + ' '+ str(S))

Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split(' ')))
A = int(a[0] * a[1])
S=int(2*(a[0] + a[1]))
print(str(A) + ' '+ str(S))


Fixed submission:
a = list(map(int,input().split(' ')))
A = int(a[0] * a[1])
S=int(2*(a[0] + a[1]))
print(str(A) + ' '+ str(S))
Buggy python submission (verdict: Runtime Error):
r = int(input())
pi = 3.141592653589793
A = float(pow(r, 2) * pi)
S = float(2 * pi * r)
print("{0:.8f}".format(A) + ' ' + "{0:.8f}".format(S))


Fixed submission:
r = float(input())
pi = 3.141592653589793
A = float(pow(r, 2) * pi)
S = float(2 * pi * r)
print("{0:.8f}".format(A) + ' ' + "{0:.8f}".format(S))
Buggy python submission (verdict: Runtime Error):
a, b = int(input()), int(input())
print(a * b, 2 * (a + b))



Fixed submission:
a, b = list(map(int, input().split()))
print(a * b, 2 * (a + b))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
print(a * b, 2 * (a + b))



Fixed submission:
a, b = list(map(int, input().split()))
print(a * b, 2 * (a + b))

Buggy python submission (verdict: Runtime Error):
x = map(int, raw_input().split())
a, b = x[0], x[1]
print(a * b, 2 * (a + b))



Fixed submission:
a, b = list(map(int, input().split()))
print(a * b, 2 * (a + b))
Buggy python submission (verdict: Runtime Error):
def insertionSort(A,N):
  for i in range(1,len(A)):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
    
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)


Fixed submission:
def insertionSort(A,N):
  for i in range(N):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
  
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,N):
  for i in range(1,len(A)):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)


Fixed submission:
def insertionSort(A,N):
  for i in range(N):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
  
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,N):
  for i in range(N):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
  
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)


Fixed submission:
def insertionSort(A,N):
  for i in range(N):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
  
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x_y):
    tmp = list(map(int, x_y.split()))
    x = tmp[0]
    y = tmp[1]

    xcd = set([ n for n in range(1, x+1) if  x % n == 0])  # xの約数
    ycd = set([ n for n in range(1, y+1) if  y % n == 0])  # yの約数
    cd = list(xcd & ycd)  # ｘとyの公約数
    return max(cd)  # ｘとyの最大公約数

x_y = input()
print(gcd(x_y))


Fixed submission:
def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while y > 0:
        r = x % y
        x = y
        y = r

    return print(x)

x_y = input()
tmp = list(map(int, x_y.split()))
x = tmp[0]
y = tmp[1]
gcd(x, y)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x_y):
    tmp = list(map(int, x_y.split()))
    x = tmp[0]
    y = tmp[1]

    xcd = set([ n for n in range(1, x+1) if  x % n == 0])  # xの約数
    ycd = set([ n for n in range(1, y+1) if  y % n == 0])  # yの約数
    cd = list(xcd & ycd)  # ｘとyの公約数
    print(max(cd))  # ｘとyの最大公約数

x_y = input()
gcd(x_y)


Fixed submission:
def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while y > 0:
        r = x % y
        x = y
        y = r

    return print(x)

x_y = input()
tmp = list(map(int, x_y.split()))
x = tmp[0]
y = tmp[1]
gcd(x, y)
Buggy python submission (verdict: Runtime Error):
ef is_prime(n):
  t = 2
  while n > t:
    if n % t == 0: return 0
    t += 1
  return 1

c = 0
for _ in range(int(input())):
  c += is_prime(int(input()))
print(c)


Fixed submission:
def is_prime(x):
  if x == 2: return 1
  if x % 2 == 0: return 0
  for i in range(3, int(x ** 0.5) + 1, 2):
    if x % i == 0: return 0
  return 1

c = 0
for _ in range(int(input())):
  c += is_prime(int(input()))
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
def is_prime(n):
  t = 2
  while n > t:
    if n % t == 0: return 0
    t += 1
  return 1

c = 0
for _ in range(int(input())):
  c += is_prime(int(input()))
print(c)


Fixed submission:
def is_prime(x):
  if x == 2: return 1
  if x % 2 == 0: return 0
  for i in range(3, int(x ** 0.5) + 1, 2):
    if x % i == 0: return 0
  return 1

c = 0
for _ in range(int(input())):
  c += is_prime(int(input()))
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
def is_prime(n):
  ps = [2, 3, 5, 7, 11, 13, 17]
  for p in ps:
    if n == p: return 1
    if n % p == 0: return 0
  t = 19
  while n > t:
    if n % t == 0: return 0
    t += 2
  return 1

c = 0
for _ in range(int(input())):
  c += is_prime(int(input()))
print(c)


Fixed submission:
def is_prime(x):
  if x == 2: return 1
  if x % 2 == 0: return 0
  for i in range(3, int(x ** 0.5) + 1, 2):
    if x % i == 0: return 0
  return 1

c = 0
for _ in range(int(input())):
  c += is_prime(int(input()))
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
l = []
for _ in range(int(input())):
  a = input().split()
  if "insert" in a: l.insert(0, int(a[1]))
  elif "deleteFirst" in a: l.pop(0)
  elif "deleteLast" in a: l.pop()
  else:
    if int(a[1]) in l: l.remove(int(a[1]))
print(*l)


Fixed submission:
from collections import deque
d = deque()
for _ in range(int(input())):
  a = input()
  if "i" == a[0]: d.appendleft(int(a[7:]))
  elif "F" == a[6]: d.popleft()
  elif "L" == a[6]: d.pop()
  else:
    try: d.remove(int(a[7:]))
    except: pass
print(*d)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
d = deque()
for _ in range(int(input())):
  a = input().split()
  if "insert" in a: d.appendleft(int(a[1]))
  elif "deleteFirst" in a: d.popleft()
  elif "deleteLast" in a: d.pop()
  else:
    try: d.remove(int(a[1]))
    except: pass
print(*d)


Fixed submission:
from collections import deque
d = deque()
for _ in range(int(input())):
  a = input()
  if "i" == a[0]: d.appendleft(int(a[7:]))
  elif "F" == a[6]: d.popleft()
  elif "L" == a[6]: d.pop()
  else:
    try: d.remove(int(a[7:]))
    except: pass
print(*d)

Buggy python submission (verdict: Runtime Error):
from collections import deque
d = deque()
for _ in range(int(input())):
  a = input()
  if "i" == a[0]: d.appendleft(int(a[1]))
  elif "F" == a[6]: d.popleft()
  elif "L" == a[6]: d.pop()
  else:
    try: d.remove(int(a[1]))
    except: pass
print(*d)


Fixed submission:
from collections import deque
d = deque()
for _ in range(int(input())):
  a = input()
  if "i" == a[0]: d.appendleft(int(a[7:]))
  elif "F" == a[6]: d.popleft()
  elif "L" == a[6]: d.pop()
  else:
    try: d.remove(int(a[7:]))
    except: pass
print(*d)