Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = input()
a_n = map(int,raw_input().split())
j = -1
for i in range(n):
	print(??? ???),
	sys.stdout.write(str(a_n[j])
	j -= 1

Fixed submission:
import sys
n = input()
a_n = map(int,raw_input().split())
j = -1
for i in range(n):
	if j == -1 :
			sys.stdout.write(str(a_n[j]))
			j -= 1
	else :		
		print (' '),
		sys.stdout.write(str(a_n[j]))
		j -= 1
print ''

Buggy python submission (verdict: Runtime Error):
n = input()
a_n = map(int,raw_input().split())
j = -1
for i in range(n):
	print '\b',
	sys.stdout.write(str(a_n[j])
	j -= 1

Fixed submission:
import sys
n = input()
a_n = map(int,raw_input().split())
j = -1
for i in range(n):
	if j == -1 :
			sys.stdout.write(str(a_n[j]))
			j -= 1
	else :		
		print (' '),
		sys.stdout.write(str(a_n[j]))
		j -= 1
print ''
Buggy python submission (verdict: Runtime Error):
while True :
	count = 0
	w = raw_input()
	if w=='END_OF_TEXT':
		break
	else :
		a_list = w.split()
		 for i in a_list:
			if w in i :
				count += 1
		print(count)

Fixed submission:

while True :
	count_1 = 0
	w = raw_input()
	while True :
		t = raw_input()
		if t=='END_OF_TEXT':
			break
		else :
			a_list = t.lower().split()
	 		for i in a_list:
				if (w==i):
					count_1 += 1
	print(count_1)
	if t=='END_OF_TEXT':
		break
Buggy python submission (verdict: Runtime Error):
def shuffle(l,h):
	l.extend(l[0:h])
	del l[0:h]
	
while True :
	card_list = list(raw_input())
	if card_list == ['.']:
		break
	else :
		m = input()
		h_count = [0]*m
		for i in range(m):
			h_count[i] = input()
			shuffle(card_list,h_count[i])
		print("".join(card_list))

Fixed submission:
def shuffle(l,h):
	l.extend(l[0:h])
	del l[0:h]
	
while True :
	card_list = list(raw_input())
	if card_list == ['-']:
		break
	else :
		m = input()
		h_count = [0]*m
		for i in range(m):
			h_count[i] = input()
			shuffle(card_list,h_count[i])
		print("".join(card_list))
Buggy python submission (verdict: Runtime Error):
x=input()
def f(n):
 if n==0:return 1
 return f(n-1)*n
print(f(int(n)))

Fixed submission:
# -*- coding:shift-jis -*-
x=input()
def f(n):
 if n==0:return 1
 return f(n-1)*n
print(f(int(x)))

Buggy python submission (verdict: Runtime Error):
# -*- coding:shift-jis -*-
x=input()
def f(n):
 if n==0:return 1
 return f(n-1)*n
print(f(int(n)))

Fixed submission:
# -*- coding:shift-jis -*-
x=input()
def f(n):
 if n==0:return 1
 return f(n-1)*n
print(f(int(x)))
Buggy python submission (verdict: Runtime Error):
# -*- coding:shift-jis -*-

class Dice:

	def __init__(self):
		self.top = 1
		self.south = 2
		self.north = 5
		self.east = 3
		self.west = 4
		self.bottom = 6

	def rotate(self,operation):
		if operation == "North":
			self.top,self.north,self.bottom,self.south = self.south,self.top,self.north,self.bottom
		elif operation == "East":
			self.top,self.east,self.bottom,self.west = self.west,self.top,self.east,self.bottom
		elif operation == "West":
			self.top,self.east,self.bottom,self.west = self.east,self.bottom,self.west,self.top
		elif operation == "South":
			self.top,self.north,self.bottom,self.south = self.north,self.bottom,self.south,self.top
		elif operation == "Right":
			self.north,self.east,self.south,self.west = self.west,self.north,self.east,self.south
		elif operation == "Left":
			self.north,self.east,self.south,self.west = self.east,self.south,self.west,self.north,

n = int(input()[0])

while n!=0:
	inputs = [input() for _ in range(n)]
	value = 1
	d = Dice()
	for i in inputs:
		d.rotate(i)
		value += d.top
	print(value)
	n = int(input())

Fixed submission:
# -*- coding:shift-jis -*-

class Dice:

	def __init__(self):
		self.top = 1
		self.south = 2
		self.north = 5
		self.east = 3
		self.west = 4
		self.bottom = 6

	def rotate(self,operation):
		if operation == "North":
			self.top,self.north,self.bottom,self.south = self.south,self.top,self.north,self.bottom
		elif operation == "East":
			self.top,self.east,self.bottom,self.west = self.west,self.top,self.east,self.bottom
		elif operation == "West":
			self.top,self.east,self.bottom,self.west = self.east,self.bottom,self.west,self.top
		elif operation == "South":
			self.top,self.north,self.bottom,self.south = self.north,self.bottom,self.south,self.top
		elif operation == "Right":
			self.north,self.east,self.south,self.west = self.west,self.north,self.east,self.south
		elif operation == "Left":
			self.north,self.east,self.south,self.west = self.east,self.south,self.west,self.north,

n = int(input())

while n!=0:
	inputs = [input() for _ in range(n)]
	value = 1
	d = Dice()
	for i in inputs:
		d.rotate(i)
		value += d.top
	print(value)
	n = int(input())
Buggy python submission (verdict: Runtime Error):
print(input()*input()*input())

Fixed submission:
x = int(input())
print(x*x*x)

Buggy python submission (verdict: Runtime Error):
x = input()
print(x*x*x)

Fixed submission:
x = int(input())
print(x*x*x)
Buggy python submission (verdict: Runtime Error):
x=int(input())
print(str(int(x/3600))+":"+str((x-h*3600)/60)+":"+str((x-h*3600)%60))

Fixed submission:
x = int(input())
h = int(x/3600)
m = int((x - h*3600)/60)
s = int((x - h*3600)%60)
print(str(h)+":"+str(m)+":"+str(s))
Buggy python submission (verdict: Runtime Error):
class Point():
	def __init__(self, x, y):
		self.x = x
		self.y = y
	

output_list = []


init_point = map(float, raw_input().split())

p0 = Point(init_point[0], init_point[1])
p1 = Point(init_point[2], init_point[3])


q = int(raw_input())
datalist = [map(float, raw_input().split()) for i in range(q)]


#p0--p1 : y=ax+b
#p2--t  : y=cx+d

a = (p0.y - p1.y) / (p0.x - p1.x)

if a != 0:
	c = -1/a
	b = p0.y - a*p0.x
	
	for data in datalist:
		p2 = Point(data[0], data[1])
		
		d = p2.y - c*p2.x
		
		X = (-b+d) / (a-c)
		Y = a*X + b
		
		output_list.append( (X,Y) )
		
else:
	for data in datalist:
		p2 = Point(data[0], data[1])
		output_list.append( (p2.x, p0.y) )
		
for x, y in output_list:
	print "%.10f %.10f" % (x, y)
	

Fixed submission:
class Point():
	def __init__(self, x, y):
		self.x = x
		self.y = y
	

output_list = []


init_point = map(float, raw_input().split())

p0 = Point(init_point[0], init_point[1])
p1 = Point(init_point[2], init_point[3])


q = int(raw_input())
datalist = [map(float, raw_input().split()) for i in range(q)]


#p0--p1 : y=ax+b
#p2--t  : y=cx+d

if (p0.x - p1.x) == 0:
	for data in datalist:
		p2 = Point(data[0], data[1])
		output_list.append( (p0.x, p2.y) )

elif (p0.y - p1.y) == 0:
	for data in datalist:
		p2 = Point(data[0], data[1])
		output_list.append( (p2.x, p0.y) )
		
else:
	a = (p0.y - p1.y) / (p0.x - p1.x)
	c = -1/a
	b = p0.y - a*p0.x
	
	for data in datalist:
		p2 = Point(data[0], data[1])
		
		d = p2.y - c*p2.x
		
		X = (-b+d) / (a-c)
		Y = a*X + b
		
		output_list.append( (X,Y) )
		
for x, y in output_list:
	print "%.10f %.10f" % (x, y)
Buggy python submission (verdict: Runtime Error):
print raw input()[::-1]

Fixed submission:
print raw_input()[: : -1]
Buggy python submission (verdict: Runtime Error):
while 1:
	try:
		n = input()
		x = 0
		if n < 37:
			for a in range(10):
				for b in range(10):
					for c in range(10):
						for d in range(10):
							if a + b + c + d == n:
								c += 1
			print c
		except EOFError:
			break

Fixed submission:
while 1:
	try:
		n = input()
		x = 0
		if n < 37:
			for a in range(10):
				for b in range(10):
					for c in range(10):
						for d in range(10):
							if a + b + c + d == n:
									x += 1
		print x
	except EOFError:
		break

Buggy python submission (verdict: Runtime Error):
while 1:
	try:
		n = input()
		x = 0
		if n < 37:
			for a in range(10):
				for b in range(10):
					for c in range(10):
						for d in range(10):
							if a + b + c + d == n:
								x += 1
			print x
		except EOFError:
			break

Fixed submission:
while 1:
	try:
		n = input()
		x = 0
		if n < 37:
			for a in range(10):
				for b in range(10):
					for c in range(10):
						for d in range(10):
							if a + b + c + d == n:
									x += 1
		print x
	except EOFError:
		break
Buggy python submission (verdict: Runtime Error):
w = int(raw_input())$
  2 n = int(raw_input())$
  3 a = []$
  4 for i in range(n):$
  5  a.append(map(int, raw_input().split(',')))$
  6 r = range(1,w + 1)$
  7 for i in a:$
  8  tmp = r[i[0] - 1]$
  9  r[i[0] - 1] = r[i[1] - 1]$
 10  r[i[1] - 1] = tmp$
 11 for i in r:$
 12  print i$

Fixed submission:
w = int(raw_input())
n = int(raw_input())
a = []
for i in range(n):
  a.append(map(int, raw_input().split(',')))
r = range(1,w + 1)
for i in a:
  tmp = r[i[0] - 1]
  r[i[0] - 1] = r[i[1] - 1]
  r[i[1] - 1] = tmp
for i in r:
  print i

Buggy python submission (verdict: Runtime Error):
w = int(raw_input())
n = int(raw_input())$
a = []
for i in range(n):
  a.append(map(int, raw_input().split(',')))
  r = range(1,w + 1)
for i in a:
 tmp = r[i[0] - 1]
 r[i[0] - 1] = r[i[1] - 1]
 r[i[1] - 1] = tmp
for i in r:
  print i

Fixed submission:
w = int(raw_input())
n = int(raw_input())
a = []
for i in range(n):
  a.append(map(int, raw_input().split(',')))
r = range(1,w + 1)
for i in a:
  tmp = r[i[0] - 1]
  r[i[0] - 1] = r[i[1] - 1]
  r[i[1] - 1] = tmp
for i in r:
  print i

Buggy python submission (verdict: Runtime Error):
 w = int(raw_input())
n = int(raw_input())
a = []
for i in range(n):
  a.append(map(int, raw_input().split(',')))
  r = range(1,w + 1)
  for i in a:
    tmp = r[i[0] - 1]
    r[i[0] - 1] = r[i[1] - 1]
    r[i[1] - 1] = tmp
 for i in r:
   print i

Fixed submission:
w = int(raw_input())
n = int(raw_input())
a = []
for i in range(n):
  a.append(map(int, raw_input().split(',')))
r = range(1,w + 1)
for i in a:
  tmp = r[i[0] - 1]
  r[i[0] - 1] = r[i[1] - 1]
  r[i[1] - 1] = tmp
for i in r:
  print i
Buggy python submission (verdict: Runtime Error):
while True:
    x = str(input())
    if x==0:break
    sum=0
    for i in x:
        su=su+int(i)
    print(sum)

Fixed submission:
while True:
    x = str(input())
    if x=='0':break
    sum=0
    for i in x:
        sum=sum+int(i)
    print(sum)

Buggy python submission (verdict: Runtime Error):
while True:
    x = str(input())
    if x==0:break
    sum=0
    for i in x:
        sum=sum+int(i)
    print(sum)

Fixed submission:
while True:
    x = str(input())
    if x=='0':break
    sum=0
    for i in x:
        sum=sum+int(i)
    print(sum)
Buggy python submission (verdict: Runtime Error):
(a,b) = map(int, raw_input().split())
print a/b a%b "%d" %.5e

Fixed submission:
(a,b) = map(int,raw_input().split())
print "%d %d %.5f" % (a/b , a%b, a / float(b))
Buggy python submission (verdict: Runtime Error):
n = (int,raw_input())

numlist = map(int, raw_input().split())
numlist = sorted(numlist)
for x in numlist
 print x,

Fixed submission:
n = input()
for i in sorted(map(int, raw_input().split())):
 print i ,

Buggy python submission (verdict: Runtime Error):
n = (int,raw_input())
 
numlist = map(int, raw_input().split())
numlist = sort(numlist)
for x in numlist
 print x,

Fixed submission:
n = input()
for i in sorted(map(int, raw_input().split())):
 print i ,

Buggy python submission (verdict: Runtime Error):
n = input()
for i in sorted(map(int, raw_input().split()))
 print i,

Fixed submission:
n = input()
for i in sorted(map(int, raw_input().split())):
 print i ,
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))

if __name__ = "__main__":
    while True:
        a, b = raw_input().split()
        print "%d\n" % dn(a, b),

Fixed submission:
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))
get = lambda: [int(x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        try:
            print "%d" % dn(*get())
        except EOFError:
            break

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))

if __name__ = "__main__":
        a, b = raw_input().split()
        print "%d\n" % dn(a, b),

Fixed submission:
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))
get = lambda: [int(x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        try:
            print "%d" % dn(*get())
        except EOFError:
            break

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))

if __name__ == "__main__":
    while True:
        a, b = raw_input().split()
        print "%d\n" % dn(a, b),

Fixed submission:
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))
get = lambda: [int(x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        try:
            print "%d" % dn(*get())
        except EOFError:
            break

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))
get = lambda : [int (x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        print "%d\n" % dn(*get()),

Fixed submission:
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))
get = lambda: [int(x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        try:
            print "%d" % dn(*get())
        except EOFError:
            break

Buggy python submission (verdict: Runtime Error):
dn = lambda a, b: len(str(a+b))
get = lambda : [int (x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        print "%d\n" % dn(*get()),

Fixed submission:
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))
get = lambda: [int(x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        try:
            print "%d" % dn(*get())
        except EOFError:
            break

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))
get = lambda : [int(x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        print "%d" % dn(*get())

Fixed submission:
#!/usr/bin/env python

dn = lambda a, b: len(str(a+b))
get = lambda: [int(x) for x in raw_input().split()]

if __name__ == "__main__":
    while True:
        try:
            print "%d" % dn(*get())
        except EOFError:
            break
Buggy python submission (verdict: Time Limit Exceeded):
#coding: UTF-8

N = int(input())

a = [int(input()) for i in range(N)]

ans = []

for i in range(N-1):
    Rj = int(a.pop(0));
    tmp = max(a);
    ans.append(tmp - Rj);

print(max(ans))

Fixed submission:
#coding: UTF-8

N = int(input())

a = [int(input()) for i in range(N)]

ans = set()

maxv = -9999999999
minv = a[0]
for i in range(1,N):
    if (a[i] - minv) > maxv:
        maxv = a[i] - minv
    if a[i] < minv:
        minv = a[i]

print(maxv)

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

N = int(input())

a = [int(input()) for i in range(N)]

ans = set()

for i in range(N-1):
    Rj = int(a.pop(0));
    tmp = max(a);
    ans.add(tmp - Rj);

print(max(ans))

Fixed submission:
#coding: UTF-8

N = int(input())

a = [int(input()) for i in range(N)]

ans = set()

maxv = -9999999999
minv = a[0]
for i in range(1,N):
    if (a[i] - minv) > maxv:
        maxv = a[i] - minv
    if a[i] < minv:
        minv = a[i]

print(maxv)
Buggy python submission (verdict: Runtime Error):
inputlist=[]
while 1:
	inputnum=int(raw_input())
	if(inputnum==0):break
	inputlist.append(inputnum)
def octnpower(num):
	flag=0
	maxi=0
	maxj=0
	if(num<8):
		temp[0]=num
		return
	for i in range(1,11):
		for j in range(1,8):
			if(num>=(8**i)*j):
				flag=(8**i)*j
				maxi=i
				maxj=j
			else:
				temp[maxi]=maxj
				return octnpower(num-flag)

octdictionary={0:0,1:1,2:2,3:3,4:5,5:7,6:8,7:9}
for i in range(len(inputlist)-1):
	temp=[0]*10
	octnpower(inputlist[i])
	for i in range(len(temp)):
		temp[i]=octdictionary[temp[i]]
	temp.reverse()
	for j in range(len(temp)):
		index=j
		if(temp[j]!=0):break
	temp=temp[index:]
	ansstr=""
	for j in range(len(temp)):
		ansstr+=str(temp[i])
	print ansstr

Fixed submission:
inputlist=[]
while 1:
	inputnum=int(raw_input())
	if(inputnum==0):break
	inputlist.append(inputnum)
def octnpower(num):
	flag=0
	maxi=0
	maxj=0
	if(num<8):
		temp[-1]=num
		return
	for i in range(1,11):
		for j in range(1,8):
			if(num>=(8**i)*j):
				flag=(8**i)*j
				maxi=i
				maxj=j
			else:
				temp[-maxi-1]=maxj
				return octnpower(num-flag)

octdictionary={0:0,1:1,2:2,3:3,4:5,5:7,6:8,7:9}
for i in range(len(inputlist)):
	temp=[0]*10
	octnpower(inputlist[i])
	for j in range(len(temp)):
		index=j
		if(temp[j]!=0):break
	temp=temp[index:]
	for j in range(len(temp)):
		temp[j]=octdictionary[temp[j]]
	ansstr=""
	for j in range(len(temp)):
		ansstr+=str(temp[j])
	print ansstr
Buggy python submission (verdict: Runtime Error):
import math

def prime(num):
  for i in range(math.sqrt(num)+1):
    if num%i==0:
      return False
  else:
    return True

n=int(input())
ans=0
for i in range(n):
  if prime(int(input())):
    ans+=1
print(ans)


Fixed submission:
import math
 
def prime(num):
  if num==1 or num==2 or num==3:
    return True
  for i in range(2,int(math.sqrt(num))+1):
    if num%i==0:
      return False
  else:
    return True
 
n=int(input())
ans=0
for i in range(n):
  tmp=int(input())
  if prime(tmp):
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache
import sys
from collections import deque
sys.setrecursionlimit(1000000)
	
sorted_a = ""
m = dict({})

def dist_a(a):
	res = 0
	for i, x in enumerate(a):
		res += abs(i - int(x))
	return res

N = int(input())
A = ''.join(list(map(lambda x: str(int(x)-1), input().split())))
sorted_a = ''.join(list(sorted(A)))
#i = 1
#j = 4
#x = "03214"
#print(A[:i:])
#print(A[::-1][len(A)-j:len(A)-i:])
#print(A[j::])
#print(x[:i:] + x[::-1][len(x)-j:len(x)-i:] + x[j::])
q = deque()
q.append((A, 0))
m[A] = 0
while True:
	a, x = q.popleft()
	if a in m and m[a] < x:
		continue
	#if x == 4:
	#	break;
	#print(len(m))
	if a == sorted_a:
		print(x)
		break
	d_a = dist_a(a)
	for i in range(len(a)):
		for j in range(i+2, len(a)+1):
			next_a = a[:i:] + a[::-1][len(a)-j:len(a)-i:] + a[j::]
			if next_a in m:
				continue
			if d_a < dist_a(next_a):
				continue
			q.append((next_a, x+1))
			m[next_a] = x+1
			
	
#print(reverse_a(A, 0))




Fixed submission:
from functools import lru_cache
import sys
from collections import deque
sys.setrecursionlimit(1000000)
	
sorted_a = ""
m = dict({})

N = int(input())
A = ''.join(list(map(lambda x: str(int(x)-1), input().split())))
sorted_a = ''.join(list(sorted(A)))

q = deque()
q.append((A, 0))
m[A] = 0
while True:
	a, x = q.popleft()
	if a in m and m[a] < x:
		continue
	if x == (len(a)-1) // 2:
		break;

	for i in range(len(a)):
		for j in range(i+2, len(a)+1):
			next_a = a[:i:] + a[::-1][len(a)-j:len(a)-i:] + a[j::]
			if next_a in m:
				continue

			q.append((next_a, x+1))
			m[next_a] = x+1
			
m2 = dict({})
q = deque()
q.append((sorted_a, 0))
m2[sorted_a] = 0
while True:
	a, x = q.popleft()
	if a in m2 and m2[a] < x:
		continue
	if x == (len(a)-1) // 2:
		break;

	for i in range(len(a)):
		for j in range(i+2, len(a)+1):
			next_a = a[:i:] + a[::-1][len(a)-j:len(a)-i:] + a[j::]
			if next_a in m2:
				continue
			q.append((next_a, x+1))
			m2[next_a] = x+1

ret = sys.maxsize
for a, x in m.items():
	if a in m2:
		ret = min(ret, x + m2[a])
	
if ret == sys.maxsize:
	print(len(A) - 1)
else:
	print(ret)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for _ in range(n):
    a = sum([int(input()) for _ in range(n)])
    print(a if a < 10**80 else 'overflow')

Fixed submission:
for _ in range(int(input())):
    a=int(input())+int(input())
    print(a if a < 10**80 else 'overflow')

Buggy python submission (verdict: Runtime Error):
for _ in range(int(input()):
    a=int(input())+int(input())
    print(a if a < 10**80 else 'overflow')

Fixed submission:
for _ in range(int(input())):
    a=int(input())+int(input())
    print(a if a < 10**80 else 'overflow')

Buggy python submission (verdict: Runtime Error):
for _ in range(int(input())):
    a=int(input())+int(input())
    print(a if a<10**80else'overflow')

Fixed submission:
for _ in range(int(input())):
    a=int(input())+int(input())
    print(a if a < 10**80 else 'overflow')
Buggy python submission (verdict: Runtime Error):
    upper_hull = get_bounds(ps)
    ps.reverse()
    lower_hull = get_bounds(ps)
    del upper_hull[-1]
    del lower_hull[-1]
    upper_hull.extend(lower_hull)
    return upper_hull

def get_bounds(ps):
    qs = []
    for p in ps:
        while len(qs) > 1 and (qs[-1] - qs[-2]).det(p - qs[-1]) <= 0:
            del qs[-1]
        qs.append(p)
    return qs
    
while True:
    n = int(input())
    if n == 0: break
    points = []
    for i in range(n):
        x, y = map(float, input().split(','))
        points.append(Point(x, y))
    print(len(points) - len(convex_hull(points)))
    

Fixed submission:
eps = 1e-10

def add(a, b):
    return 0 if abs(a + b) < eps * (abs(a) + abs(b)) else a + b

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, p):
        return Point(add(self.x, p.x), add(self.y, p.y))

    def __sub__(self, p):
        return Point(add(self.x, -p.x), add(self.y, -p.y))

    def __mul__(self, d):
        return Point(self.x * d, self.y * d)

    def dot(self, p):
        return add(self.x * p.x, self.y * p.y)

    def det(self, p):
        return add(self.x * p.y, -self.y * p.x)

    def __str__(self):
        return "({}, {})".format(self.x, self.y)

def convex_hull(ps):
    ps = [Point(x, y) for x, y in sorted([(p.x, p.y) for p in ps])]
    lower_hull = get_bounds(ps)
    ps.reverse()
    upper_hull = get_bounds(ps)
    del upper_hull[-1]
    del lower_hull[-1]
    lower_hull.extend(upper_hull)
    return lower_hull

def get_bounds(ps):
    qs = [ps[0], ps[1]]
    for p in ps[2:]:
        while len(qs) > 1 and (qs[-1] - qs[-2]).det(p - qs[-1]) <= 0:
            del qs[-1]
        qs.append(p)
    return qs
    
while True:
    n = int(input())
    if n == 0: break
    points = []
    for i in range(n):
        x, y = map(float, input().split(','))
        points.append(Point(x, y))
    print(len(points) - len(convex_hull(points)))
Buggy python submission (verdict: Time Limit Exceeded):
import functools


#@functools.lru_cache(maxsize=None)
def rec(i):
    if i <= 0:
        return i == 0
    return rec(i-1) + rec(i-2) + rec(i-3)

while True:
    N = int(input())
    if not N:
        break
    print(((rec(N)-1)//10)//365+1)

Fixed submission:
import functools, math


@functools.lru_cache(maxsize=None)
def rec(i):
    if i <= 0:
        return i == 0
    return rec(i-1) + rec(i-2) + rec(i-3)

while True:
    N = int(input())
    if not N:
        break
    print(int(math.ceil(rec(N)/3650)))
Buggy python submission (verdict: Runtime Error):
from math import sqrt
prime = [1 for _ in xrange(10**6+1)]
prime[1] = 1
prime[0] = 0
for i in xrange(2, int(sqrt(10**6+1))+1):
    if prime[i] == 1:
        for j in xrange(i+i, 10**6+1, i):
            prime[j] = 0
while True:
    N, X = map(int, raw_input().split())
    if (N, X) == (0, 0): break
    price = [input() for _ in xrange(N)]
    dp = [0] * (X+1)
    dp[0] = 1
    for i in xrange(X+1):
        if dp[i] == 0: continue
        for p in price:
            if i + p <= X:
                dp[i+p] = 1
    for i in xrange(X, -1, -1):
        if i > 0 and dp[i] == 1 and prime[i] == 1:
            print(i)
            break
    else:
        print("NA")

Fixed submission:
while True:
    N, M = map(int, raw_input().split())
    if (N, M) == (0, 0): break
    fert = [map(float, raw_input().split()) for _ in range(N)]
    dp = [[0]*N for _ in range(M)]
    for i in range(N): dp[0][i] = 1.0
    for i in range(M-1):
        for j in range(N):
            dp[i+1][j] = max([dp[i][k]*fert[k][j] for k in range(N)])
    print('{:.2f}'.format(max(dp[M-1])))