Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):

def cub():
    x = raw_input("Input number >")
   return x ** 3

Fixed submission:

def cub():
   x = input()
   print x **3

cub()
Buggy python submission (verdict: Runtime Error):
a = 0
b= 0

input_numbers = raw_input()

fori in input_numbers:
   if input_numbers[0] == i:
      a = int(i)
   elif input_numbers[2] == i:
      b = int(i)

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

Fixed submission:
num = raw_input()
num = num.split()
a = int(num[0])
b = int(num[1])

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

Buggy python submission (verdict: Runtime Error):
a = 0
b= 0
 
input_numbers = raw_input()
 
fori in input_numbers:
   if input_numbers[0] == i:
      a = int(i)
   elif input_numbers[2] == i:
      b = int(i)
 
print a * b, 2 * (a + b)

Fixed submission:
num = raw_input()
num = num.split()
a = int(num[0])
b = int(num[1])

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

Buggy python submission (verdict: Runtime Error):
numbers = raw_input()
numbers = numbers.split()
a = numbers[0]
b = numbers[1]

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

Fixed submission:
num = raw_input()
num = num.split()
a = int(num[0])
b = int(num[1])

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

Buggy python submission (verdict: Runtime Error):
num = raw_input()
num = numbers.split()
a = int(num[0])
b = int(num[1])

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

Fixed submission:
num = raw_input()
num = num.split()
a = int(num[0])
b = int(num[1])

print a * b, 2 * (a + b)
Buggy python submission (verdict: Runtime Error):
nums []
num = input()
nums.append(num)

while num != 0:
	num = input()
	nums.append(num)

for i in range(len(nums)):
	print "case %d: %d" %(i + 1, nums[i])

Fixed submission:
nums = []
num = input()

while num != 0:
	nums.append(num)
	num = input()

for i in range(len(nums)):
	print "Case %d: %d" %(i + 1, nums[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ns = [int(input()) for _ in range(N)]

def is_prime(n):
  for m in range(2, n):
    if n % m == 0:
      return False
  return True

print(len([n for n in ns if is_prime(n)]))

Fixed submission:
N = int(input())
ns = [int(input()) for _ in range(N)]

#primes = set()
#def is_prime(n):
#  if n in primes:
#    return True
#
#  for m in range(2, n):
#    if is_prime(m) and n % m == 0:
#      return False
#
#  primes.add(n)
#  return True

# Proof:
# if n < d ^ 2 and n mod d = 0;
# n = ad (a in N)
# ad < d ^ 2
# a < d
# QED

def is_prime(n):
  if n < 2: return False
  if n == 2: return True
  if n % 2 == 0: return False

  d = 3
  while d ** 2 <= n:
    if n % d == 0:
      return False
    d += 2
  return True

print(len([n for n in ns if is_prime(n)]))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ns = [int(input()) for _ in range(N)]

primes = set()
def is_prime(n):
  if n in primes:
    return True

  for m in range(2, n):
    if is_prime(m) and n % m == 0:
      return False
  primes.add(n)
  return True

print(len([n for n in ns if is_prime(n)]))

Fixed submission:
N = int(input())
ns = [int(input()) for _ in range(N)]

#primes = set()
#def is_prime(n):
#  if n in primes:
#    return True
#
#  for m in range(2, n):
#    if is_prime(m) and n % m == 0:
#      return False
#
#  primes.add(n)
#  return True

# Proof:
# if n < d ^ 2 and n mod d = 0;
# n = ad (a in N)
# ad < d ^ 2
# a < d
# QED

def is_prime(n):
  if n < 2: return False
  if n == 2: return True
  if n % 2 == 0: return False

  d = 3
  while d ** 2 <= n:
    if n % d == 0:
      return False
    d += 2
  return True

print(len([n for n in ns if is_prime(n)]))
Buggy python submission (verdict: Runtime Error):
import math
x1, y1, x2, y2 = map(int, raw_input().split())
print math.sqrt((x2-x1)**2 + (y2-y1)**2)

Fixed submission:
x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
if num == 0:
    print 0
else:
    xi = num
    for _ in range(100):
        xi = (xi + (num / xi)) / 2.0
    print xi

Buggy python submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
xi = num
for _ in range(100):
   xi = (xi + (num / xi)) / 2.0
print xi

Fixed submission:
x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
if num == 0:
    print 0
else:
    xi = num
    for _ in range(100):
        xi = (xi + (num / xi)) / 2.0
    print xi

Buggy python submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
xi = num
for _ in range(10):
   xi = (xi + (num / xi)) / 2.0
print xi

Fixed submission:
x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
if num == 0:
    print 0
else:
    xi = num
    for _ in range(100):
        xi = (xi + (num / xi)) / 2.0
    print xi

Buggy python submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
xi = num
for _ in range(100):
   xi = (xi + (num / xi)) / 2.0
print xi

Fixed submission:
x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
if num == 0:
    print 0
else:
    xi = num
    for _ in range(100):
        xi = (xi + (num / xi)) / 2.0
    print xi

Buggy python submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
xi = num
for _ in range(100):
   xi = (xi + (num / xi)) / 2.0
print xi

Fixed submission:
x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
if num == 0:
    print 0
else:
    xi = num
    for _ in range(100):
        xi = (xi + (num / xi)) / 2.0
    print xi
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, raw_input().split())
matrix = []
array = []
for n in range(N):
    tmp = map(int, raw_input().split())
    if len(tmp) > M:
        print 'error'
    matrix.append(tmp)
matrix = np.array(matrix)

for m in range(M):
    tmp = input()
    array.append(tmp)
array = np.array(array)

multi = np.dot(matrix, array)
for i in list(multi):
    print i

Fixed submission:
N, M = map(int, raw_input().split())
matrix = [map(int, raw_input().split()) for n in range(N)]
array = [input() for m in range(M)]

for n in range(N):
    c = 0
    for m in range(M):
        c += matrix[n][m] * array[m]
    print c
Buggy python submission (verdict: Runtime Error):
docs = ''
while True:
    docs += (raw_input().lower())
    if docs[len(docs)-1] == '.':
        break
for ascii_num in range(97, 123):
    print '%s : %d' % (chr(ascii_num), docs.count(chr(ascii_num)))

Fixed submission:
docs = ''
while True:
    try:
        s = raw_input()
    except:
        break
    docs += s.lower()
for ascii_num in range(97, 123):
    print '%s : %d' % (chr(ascii_num), docs.count(chr(ascii_num)))

Buggy python submission (verdict: Runtime Error):
docs = ''
while True:
    docs += (raw_input().lower())
    if docs[len(docs)-1] == '.':
        break
for ascii_num in range(97, 123):
    print '%s : %d' % (chr(ascii_num), docs.count(chr(ascii_num)))

Fixed submission:
docs = ''
while True:
    try:
        s = raw_input()
    except:
        break
    docs += s.lower()
for ascii_num in range(97, 123):
    print '%s : %d' % (chr(ascii_num), docs.count(chr(ascii_num)))
Buggy python submission (verdict: Runtime Error):
import sys

def insertionSort(A, N):
    for n in range(N-1):
        print (A[n], end=" ")
    print(A[N-1])
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j = j - 1
        A[j + 1] = v
        
        for n in range(N-1):
            print (A[n], end=" ")
        print(A[N-1])
    return A

N = int(input())
A = input()
A = A.split(" ")
for i in range(N):
    A[i] = int(A[i])
val = insertionSort(stdin_A, stdin_N)

Fixed submission:
import sys

def insertionSort(A, N):
    for n in range(N-1):
        print (A[n], end=" ")
    print(A[N-1])
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j = j - 1
        A[j + 1] = v
        
        for n in range(N-1):
            print (A[n], end=" ")
        print(A[N-1])
    return A

N = int(input())
A = input()
A = A.split(" ")
for i in range(N):
    A[i] = int(A[i])
val = insertionSort(A, N)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
prime = 0

for _ in xrange(N):
    n = input()

    
    for i in xrange(2,n):
        if n%i == 0:
            break
    else:
        prime += 1

print prime

Fixed submission:
N = input()
sum = 0
for _ in xrange(N):
    n = input()
    for i in xrange(2,n):
        if i > n/i:
            sum += 1
            break
        if n%i == 0:
            break
    else:
        sum += 1
print sum

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
prime = 0

for _ in xrange(N):
    n = input()

    
    for i in xrange(2,n):
        if n%i == 0:
            break
    else:
        prime += 1

print prime

Fixed submission:
N = input()
sum = 0
for _ in xrange(N):
    n = input()
    for i in xrange(2,n):
        if i > n/i:
            sum += 1
            break
        if n%i == 0:
            break
    else:
        sum += 1
print sum

Buggy python submission (verdict: Runtime Error):
N = input()
prime = 0
checked = 2
primeList = [2]

def is_prime(n):
    global checked
    if n <= checked:
        if n in primeList:
            return True
        else:
            return False
    else:#?´???°????????????n?????§????´???°????????????????????????
        for i in xrange(checked+1, n+1):
            isPrime = True
            for p in primeList:
                if i%p == 0:
                    #print "{}%{} == 0".format(i,p)
                    isPrime = False
                    break
            for p in xrange(checked+1, i):
                if i%p == 0:
                    #print "{}%{} == 0".format(i,p)
                    isPrime = False
                    break
            if isPrime:
                primeList.append(i)
        checked = n
        if primeList[-1] == n:
            return True
        else:
            return False
        

for _ in xrange(N):
    n = input()
    prime += 1 if is_prime(n) else 0
print prime

Fixed submission:
N = input()
sum = 0
for _ in xrange(N):
    n = input()
    for i in xrange(2,n):
        if i > n/i:
            sum += 1
            break
        if n%i == 0:
            break
    else:
        sum += 1
print sum
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, k = map(int, input().rstrip().split())

# from random import randint
# n = 10000
# k = 100
w = [0 for _ in range(n)]
for i in range(n):
    w[i] = int(input())
    # w[i] = randint(1, 10000)
# print(w)
P = max(sum(w)//k, max(w))
count = 0
while True:
    m = 0
    ik = 1
    loss = max(w)
    for i in range(n):
        count += 1
        new = m + w[i]
        if new <= P:
            m = new
        else:
            loss = new - P if new - P < loss else loss
            m = w[i]
            ik += 1
            if ik > k:
                break
    if ik > k:
        # print("loss:", loss)
        P += loss
    else:
        break
            
        
print(P)
# print(count)

Fixed submission:
# coding: utf-8

n, k = map(int, input().rstrip().split())
w = [0 for _ in range(n)]
for i in range(n):
    w[i] = int(input())
    
# from random import randint
# n = 100000
# k = 10000
# w = [0 for _ in range(n)]
# for i in range(n):
#     w[i] = randint(1, 10000)
# print(w)
count = 0

def check(P):
    m = 0
    ik = 1
    for i in range(n):
        global count
        count += 1
        new = m + w[i]
        if new > P:
            m = w[i]
            ik += 1
            if ik > k:
                return False
        else:
            m = new
    return True

s = max(sum(w)//k, max(w))
e = sum(w)

while True:
    P = (s + e)//2
    # print("s:{}, e:{}, P:{}".format(s, e, P))
    if s == e:
        break
    if check(P):
        e = P
    else:
        s = P + 1
            
        
print(P)
# print(count)
Buggy python submission (verdict: Runtime Error):
ope = {"+": lambda a, b: b + a,
	   "-": lambda a, b: b - a,
	   "*": lambda a, b: b * abs}
stack = []

for c in input().split():
	if c in ope:
		stack.append(ope[c](stack.pop(), stack.pop()))
	else:
		stack.append(int(c))

print(stack[-1])

Fixed submission:
def push(x):
	global stack

	stack.append(x)

def pop():
	global stack

	ret = stack.pop()
	return ret

ope = {"+": lambda a, b: b + a,
	   "-": lambda a, b: b - a,
	   "*": lambda a, b: b * a}

if __name__ == '__main__':
	stack = []

	for c in input().split():
		if c in ope:
			push(ope[c](pop(), pop()))
		else:
			push(int(c))

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

Buggy python submission (verdict: Runtime Error):
ope = {"+": lambda a, b: b + a,
	   "-": lambda a, b: b - a,
	   "*": lambda a, b: b * abs}
stack = []

for c in input().split():
	if c in ope:
		stack.append(ope[c](stack.pop(), stack.pop()))
	else:
		stack.append(int(c))

print(stack[-1])

Fixed submission:
def push(x):
	global stack

	stack.append(x)

def pop():
	global stack

	ret = stack.pop()
	return ret

ope = {"+": lambda a, b: b + a,
	   "-": lambda a, b: b - a,
	   "*": lambda a, b: b * a}

if __name__ == '__main__':
	stack = []

	for c in input().split():
		if c in ope:
			push(ope[c](pop(), pop()))
		else:
			push(int(c))

	print(" ".join(map(str, stack)))
Buggy python submission (verdict: Runtime Error):
w, h = map(int, raw_input().split())
print w * h, w * 2 + h * 2

Fixed submission:
w, h = map(int, input().split())
print(w * h, w * 2 + h * 2)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m, l = map(int, input().split())

a = np.matrix(';'.join([input() for i in range(n)]))
b = np.matrix(';'.join([input() for i in range(m)]))
c = a * b

for i in range(n):
    print(' '.join(map(str, c.tolist()[i])))

Fixed submission:
n, m, l = map(int, input().split())

a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]

c = [[0 for i in range(l)] for i in range(n)]
for i in range(n):
    for j in range(l):
        c[i][j] = sum([(a[i][x] * b[x][j]) for x in range(m)])

for i in range(n):
    print(' '.join(map(str, c[i])))
Buggy python submission (verdict: Runtime Error):
text = ''
while(True):
  text += input().lower()
  if text.endswith('.'):
      break

count = [0 for i in range(26)]
for c in text:
    if c < 'a'  or c > 'z':
        continue

    count[ord(c) - ord('a')] += 1

for i, c in enumerate(count):
    print('{0} : {1}'.format(chr(i + ord('a')), c))

Fixed submission:
text = ''
while(True):
    try:
        text += input().lower()
    except:
        break

count = [0 for i in range(26)]
for c in text:
    if c < 'a'  or c > 'z':
        continue

    count[ord(c) - ord('a')] += 1

for i, c in enumerate(count):
    print('{0} : {1}'.format(chr(i + ord('a')), c))

Buggy python submission (verdict: Runtime Error):
text = ''
while(True):
  text += input().lower()
  if text[-1] in ['.', '?', '!']:
      break

count = [0 for i in range(26)]
for c in text:
    if c < 'a'  or c > 'z':
        continue

    count[ord(c) - ord('a')] += 1

for i, c in enumerate(count):
    print('{0} : {1}'.format(chr(i + ord('a')), c))

Fixed submission:
text = ''
while(True):
    try:
        text += input().lower()
    except:
        break

count = [0 for i in range(26)]
for c in text:
    if c < 'a'  or c > 'z':
        continue

    count[ord(c) - ord('a')] += 1

for i, c in enumerate(count):
    print('{0} : {1}'.format(chr(i + ord('a')), c))
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [int(x) for x in input().split()]

for i in range(n):
    a = l[i]
    j = i - 1

    while j >= 0 and l[j] > a:
        l[j+1] = l[j]
        j = j - 1

    l[j + 1] = a
    print(*1)

Fixed submission:
import string
n = int(input())
l = []
l = list(map(int, input().split()))
for i in range(n):
    key = l[i]
    j = i -1
    while j >= 0 and l[j] > key:
        l[j + 1] = l[j]
        j -= 1
    l[j + 1] = key
    print(' '.join(map(str, l)))
Buggy python submission (verdict: Runtime Error):
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())

for _ in range(n):
    (b,f,r,v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)

Fixed submission:

data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())

for _ in range(n):
    (b,f,r,v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)
Buggy python submission (verdict: Runtime Error):
sentence = ''
while True:
    try:
        sentence += input().lower()
        except:
            break

for i in range(ord('a'), ord('z') + 1):
    print('{} : {}'.format(chr(i),sentence.count(chr(i))))

Fixed submission:
sentence = ''
while True:
    try:
        sentence += input().lower()
    except:
            break

for i in range(ord('a'), ord('z') + 1):
    print('{} : {}'.format(chr(i),sentence.count(chr(i))))
Buggy python submission (verdict: Runtime Error):
def isPrime(num):
    if num == 2: return 1
    if num < 2 or num&1 == 0: return 0
    if pow(2, num-1, num) == 1: return 1

n = input()
s = 0
for i in xrange(n):
    s += isPrime(input())

print s

Fixed submission:
def isPrime(num):
    if num == 2: return 1
    if num < 2 or num&1 == 0: return 0
    if pow(2, num-1, num) == 1: return 1
    return 0

n = input()
s = 0
for i in xrange(n):
    s += isPrime(input())

print s
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
R = [input()] 
Rmin = 0
maxdif = -999999999
for i in xrange(n-1):
    Rt = input()
    for j in xrange(Rmin, len(R)):
        if (Rt - R[j]) > maxdif:
            maxdif = Rt - R[j]
    if Rt < Rmin:
        Rmin = i + 1
    R.append(Rt)

print maxdif

Fixed submission:
n = input()
R = [input() for i in xrange(n)]

Rmin = n
maxdif = R[1] - R[0]

while Rmin > 0:
    tRmin = R.index(min(R[0:Rmin]))
    Rmax = R.index(max(R[tRmin:Rmin]))
    if tRmin == Rmax:
        if tRmin == n-1:
            tRmin-=1
        elif tRmin < n-1:
            Rmax = tRmin + 1
    Rmin = tRmin
    if (R[Rmax] - R[Rmin]) > maxdif:
        maxdif = R[Rmax] - R[Rmin]

print maxdif

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
R = [input()] 
Rmin = 0
maxdif = -999999999
for i in xrange(n-1):
    Rt = input()
    for j in xrange(Rmin, len(R)):
        if (Rt - R[j]) > maxdif:
            maxdif = Rt - R[j]
    if Rt < R[Rmin]:
        Rmin = i + 1
    R.append(Rt)

print maxdif

Fixed submission:
n = input()
R = [input() for i in xrange(n)]

Rmin = n
maxdif = R[1] - R[0]

while Rmin > 0:
    tRmin = R.index(min(R[0:Rmin]))
    Rmax = R.index(max(R[tRmin:Rmin]))
    if tRmin == Rmax:
        if tRmin == n-1:
            tRmin-=1
        elif tRmin < n-1:
            Rmax = tRmin + 1
    Rmin = tRmin
    if (R[Rmax] - R[Rmin]) > maxdif:
        maxdif = R[Rmax] - R[Rmin]

print maxdif

Buggy python submission (verdict: Runtime Error):
n = input()
R = [input() for i in xrange(n)]

Rmin = n
maxdif = R[1] - R[0]

while Rmin > 0:
    tRmin = R.index(min(R[0:Rmin]))
    Rmax = R.index(max(R[tRmin:Rmin]))
    if tRmin == Rmax:
        if tRmin == n:
            tRmin-=1
        elif tRmin < n:
            Rmax = tRmin + 1
    Rmin = tRmin
    if (R[Rmax] - R[Rmin]) > maxdif:
        maxdif = R[Rmax] - R[Rmin]

print maxdif

Fixed submission:
n = input()
R = [input() for i in xrange(n)]

Rmin = n
maxdif = R[1] - R[0]

while Rmin > 0:
    tRmin = R.index(min(R[0:Rmin]))
    Rmax = R.index(max(R[tRmin:Rmin]))
    if tRmin == Rmax:
        if tRmin == n-1:
            tRmin-=1
        elif tRmin < n-1:
            Rmax = tRmin + 1
    Rmin = tRmin
    if (R[Rmax] - R[Rmin]) > maxdif:
        maxdif = R[Rmax] - R[Rmin]

print maxdif
Buggy python submission (verdict: Time Limit Exceeded):
# input
n, q = map(int, raw_input().split())
procs = [raw_input().split() for i in xrange(n)]

# procsessing
cnt, lack = 0, 1
while lack > 0:
    lack = 0
    for i in xrange(n):
        t = int(procs[i][1])
        if t == 0:
            continue
        if t <= q:
            cnt += t
            t = 0
            print procs[i][0], cnt
        else: # t >= q
            cnt += q
            t = t - q
            lack += t
        procs[i][1] = str(t)

Fixed submission:
# input
n, q = map(int, raw_input().split())
procs = [raw_input().split() for i in xrange(n)]
procs = list(reversed(procs))

# procsessing
cnt, lack = 0, 1
while lack > 0:
    lack = 0
    tprocs = []
    for i in xrange(n):
        proc = procs.pop()
        t = int(proc[1])
        if t <= q:
            cnt += t
            print proc[0], cnt
            n -= 1
        else: # t > q
            cnt += q
            t = t - q
            lack += t
            proc[1] = str(t)
            tprocs.append(proc)
    procs = list(reversed(tprocs))
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
lis = []
for i in xrange(n):
    com = raw_input()
    try:
        com, x = com.split()
        if   com == 'insert':
            lis.append(x)
        elif com == 'delete':
            l = len(lis) - 1
            while (lis[l] != x) and l >= 0:
                l -= 1
            if lis[l] == x:
                lis.pop(l)
    except:
        if com == 'deleteFirst':
            lis.pop()
        if com == 'deleteLast':
            lis.pop(0)

print " ".join( map(str, reversed(lis)) )

Fixed submission:
n = input()
lis = []
bot = 0
for i in xrange(n):
    com = raw_input()
    if   com[0] == 'i':
        lis.append(com[7:])
    elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
    elif com[6] == 'F':
        lis.pop()
    else:
        bot += 1

print ' '.join( map(str, reversed(lis[bot:])) )
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
dic = []
for i in xrange(n):
    order = raw_input().split()
    if order[0][0] == 'i':
        dic.append(order[1])
    else:
        print "yes" if order[1] in dic else "no"

Fixed submission:
n = input()
dic = set([])
for i in xrange(n):
    order = raw_input().split()
    if order[0][0] == 'i':
        dic.add(order[1])
    else:
        print "yes" if order[1] in dic else "no"