Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import Control.Applicative
import Data.Char
main = do
  v <- map (map (\x->ord(x) - ord('0'))) . lines  <$> getContents
  mapM_ (putStrLn . show . solve) v

solve::[Int] -> Int
solve v = head $ aux v
  where
    aux ::[Int] -> [Int]
    aux f = if length f == 1 then
              f
            else
              aux (zipWith (\x y->(x+y) `mod` 10) f (tail f))

Fixed submission:
def shorten(f):
    #print(f) 
    if len(f) == 1:
        return(f[0])
    else:
        g = []
        v = f[0]
        for i in f[1:]:
            g.append((v + i)%10)
            v = i
        return(shorten(g))

while True:
  try:
      f = list(map(int, list(input().strip())))
      print(shorten(f))
  
  except EOFError:
      break
Buggy python submission (verdict: Runtime Error):
def cross(x, y):
    return (x.conjugate() * y).imag
 
def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
     
     
import sys
 
p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(x+y*1j))
 
print(abs(area_polygon(p)))

Fixed submission:
def op(u,v):
    return (complex.conjugate(u)*v).imag

f = []
while True:
    try:
        st = input().strip().split(',')
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

s = 0.0
fo = f[0]
for j in range(2,len(f)):
    i = j - 1
    s += op(f[i]-fo,f[j]-fo)/2.0
print("%.6f" % abs(s))

Buggy python submission (verdict: Runtime Error):
def cross(x, y):
    return (x.conjugate() * y).imag
 
def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
     
     
import sys
 
p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(x+y*j))
 
print(abs(area_polygon(p)))

Fixed submission:
def op(u,v):
    return (complex.conjugate(u)*v).imag

f = []
while True:
    try:
        st = input().strip().split(',')
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

s = 0.0
fo = f[0]
for j in range(2,len(f)):
    i = j - 1
    s += op(f[i]-fo,f[j]-fo)/2.0
print("%.6f" % abs(s))

Buggy python submission (verdict: Runtime Error):
import math
def op(u,v):
    return (conjugate(u)*v).imag

f = []
while True:
    try:
        st = input().strip().split(',')
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

s = 0.0
fo = f[0]
for j in range(2,len(f)):
    i = j - 1
    s += op(i-fo,j-fo)/2.0
print("%.6f" % abs(ss))

Fixed submission:
def op(u,v):
    return (complex.conjugate(u)*v).imag

f = []
while True:
    try:
        st = input().strip().split(',')
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

s = 0.0
fo = f[0]
for j in range(2,len(f)):
    i = j - 1
    s += op(f[i]-fo,f[j]-fo)/2.0
print("%.6f" % abs(s))
Buggy python submission (verdict: Runtime Error):
from datetime import datetime
def era(f):
    meiji_st  = datetime(1868, 9, 8)
    taisho_st = datetime(1912, 7,30)
    showa_st  = datetime(1926,12,25)
    heisei_st = datetime(1989, 1, 8)

    y,m,d = f
    dt = datetime(y,m,d)
    if dt > heisei_st:
        ret = "heisei %d %d %d" % (dt.year - heisei_st.year+1,dt.month,dt.day) 
    elif dt > showa_st:
        ret = "showa %d %d %d" % (dt.year - showa_st.year+1,dt.month,dt.day) 
    elif dt > taisho_st:
        ret = "taisho %d %d %d" % (dt.year - taisho_st.year+1,dt.month,dt.day) 
    elif dt > meiji_st:
        ret = "meiji %d %d %d" % (dt.year - meiji_st.year+1,dt.month,dt.day) 
    else:
       ret = "pre-meiji"

    return(ret)

while True:
    f = map(int, input().strip().split())
    print(era(f))

Fixed submission:
from datetime import datetime
def era(f):
    meiji_st  = datetime(1868, 9, 8)
    taisho_st = datetime(1912, 7,30)
    showa_st  = datetime(1926,12,25)
    heisei_st = datetime(1989, 1, 8)

    y,m,d = f
    dt = datetime(y,m,d)
    if dt >= heisei_st:
        ret = "heisei %d %d %d" % (dt.year - heisei_st.year+1,dt.month,dt.day) 
    elif dt >= showa_st:
        ret = "showa %d %d %d" % (dt.year - showa_st.year+1,dt.month,dt.day) 
    elif dt >= taisho_st:
        ret = "taisho %d %d %d" % (dt.year - taisho_st.year+1,dt.month,dt.day) 
    elif dt >= meiji_st:
        ret = "meiji %d %d %d" % (dt.year - meiji_st.year+1,dt.month,dt.day) 
    else:
       ret = "pre-meiji"

    return(ret)

while True:
    try:
        f = map(int, input().strip().split())
        print(era(f))
    except EOFError:
        break
Buggy python submission (verdict: Runtime Error):
import numpy as np
def crossP(a, b, c, d):
    e = b - a
    f = c - d
    g = c - a
    A = np.matrix([[e.real,f.real],[e.imag, f.imag]])
    B = np.matrix([[g.real],[g.imag]])
    try:
        C = np.linalg.solve(A, B)
    except:
        return(-9999+(-9999)*1j)
    return(C[0,0]+C[1,0]*1j)

def rangeP(st):
    return((0.0<=st.real<=1.0) and (0.0<=st.imag<=1.0))

if __name__ == '__main__':
	n = int(input().strip())
	for i in range(n):
	    [xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys] = map(int, input().strip().split())
	    a = xp1+yp1*1j
	    b = xp2+yp2*1j
	    c = xp3+yp3*1j
	    k = xk+yk*1j
	    s = xs+ys*1j
	    shut = 0
	    if rangeP(crossP(a,b,k,s)):
	        shut += 1
	    if rangeP(crossP(b,c,k,s)):
	        shut += 1
	    if rangeP(crossP(c,a,k,s)):
	        shut += 1
	    if shut == 1:
	        print("OK")
	    else:
	        print("NG")

Fixed submission:
EPS=1e-10
def crossP(aa,bb,cc,dd):
    a = (bb-aa).real
    b = (cc-dd).real
    c = (bb-aa).imag
    d = (cc-dd).imag
    e = (cc-aa).real
    f = (cc-aa).imag
    det = a*d - b*c
    if abs(det) <EPS:
        return(-9999+(-9999)*1j)
    x = (d*e-b*f)/det
    y = (-c*e+a*f)/det
    return(x+y*1j)

def rangeP(st):
    return((0.0<=st.real<=1.0) and (0.0<=st.imag<=1.0))

if __name__ == '__main__':
	n = int(input().strip())
	for i in range(n):
	    [xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys] = map(int, input().strip().split())
	    a = xp1+yp1*1j
	    b = xp2+yp2*1j
	    c = xp3+yp3*1j
	    k = xk+yk*1j
	    s = xs+ys*1j
	    shut = 0
	    if rangeP(crossP(a,b,k,s)):
	        shut += 1
	    if rangeP(crossP(b,c,k,s)):
	        shut += 1
	    if rangeP(crossP(c,a,k,s)):
	        shut += 1
	    if shut == 1:
	        print("OK")
	    else:
	        print("NG")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*
import sys
#if False:
if True:
    fh=open('ALDS1_1_D6.txt','r')
else:
    fh=sys.stdin
input=fh.readline

def main():
    n = int(input())
    a=[]
    for _ in range(n):
        a.append(int(input()))

    pmax=a[1]-a[0]
    for k in range(0, n-1):
        p=max(a[k+1:])-a[k] 
        if p > pmax:
            pmax=p

    print(pmax)
    
if __name__ == "__main__":
    main()



Fixed submission:
# -*- coding: utf-8 -*
import sys
if False:
#if True:
    fh=open('ALDS1_1_D1.txt','r')
else:
    fh=sys.stdin
input=fh.readline

def main():
    n = int(input())
    a=[]
    for _ in range(n):
        a.append(int(input()))

    pmax=a[1]-a[0]
    pmin=a[0]
    for j in range(1, n):
        pmax = max(a[j]-pmin,pmax)
        pmin = min(pmin,a[j])

    print(pmax)
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*
import sys
if False:
#if True:
    fh=open('ALDS1_1_D1.txt','r')
else:
    fh=sys.stdin
input=fh.readline

def main():
    n = int(input())
    a=[]
    for _ in range(n):
        a.append(int(input()))
    #print('a=',a)
    pmax=a[1]-a[0]
    for k in range(0, n-1):
        p=max(a[k+1:])-a[k] 
        if p > pmax:
            pmax=p

    print(pmax)
    
if __name__ == "__main__":
    main()



Fixed submission:
# -*- coding: utf-8 -*
import sys
if False:
#if True:
    fh=open('ALDS1_1_D1.txt','r')
else:
    fh=sys.stdin
input=fh.readline

def main():
    n = int(input())
    a=[]
    for _ in range(n):
        a.append(int(input()))

    pmax=a[1]-a[0]
    pmin=a[0]
    for j in range(1, n):
        pmax = max(a[j]-pmin,pmax)
        pmin = min(pmin,a[j])

    print(pmax)
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
w = input().lower()
lines = sys.stdin.read()
line=lines[0:lines.find('END_OF_TEXT')].lower().split()
print(line.count(w))

Fixed submission:
import sys
w = input().lower()
lines = sys.stdin.read()
line=lines[0:lines.find('END_OF_TEXT')].lower().split()
print(line.count(w))
Buggy python submission (verdict: Time Limit Exceeded):
intMax = -100000000

inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    inputList.append(int(input()))
    count = count + 1

inputDataMax = intMax
inputDataMin = inputList[0]
count2 = 1
while count2 < inputData:
    inputDataMax = max(inputDataMax,  inputList[count2] - inputDataMin)
    inputMin = min(inputDataMin, inputList[count2])

print(inputDataMax)


Fixed submission:
intMax = -10000000000
inputData = int(input())
inputList = list()
for i in range(inputData):
    inputList.append(int(input()))

inputDataMax = intMax
inputDataMin = inputList[0]
for i in range(inputData - 1):
    inputDataMax = max(inputDataMax,  inputList[i + 1] - inputDataMin)
    inputDataMin = min(inputDataMin, inputList[i + 1])

print(inputDataMax)

Buggy python submission (verdict: Time Limit Exceeded):
intMax = -100000000

inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    inputList.append(int(input()))
    count = count + 1

inputDataMax = intMax
inputDataMin = inputList[0]
count2 = 1
while count2 < inputData:
    inputDataMax = max(inputDataMax,  inputList[count2] - inputDataMin)
    inputMin = min(inputDataMin, inputList[count2])

print(inputDataMax)


Fixed submission:
intMax = -10000000000
inputData = int(input())
inputList = list()
for i in range(inputData):
    inputList.append(int(input()))

inputDataMax = intMax
inputDataMin = inputList[0]
for i in range(inputData - 1):
    inputDataMax = max(inputDataMax,  inputList[i + 1] - inputDataMin)
    inputDataMin = min(inputDataMin, inputList[i + 1])

print(inputDataMax)

Buggy python submission (verdict: Time Limit Exceeded):
intMax = -100000000

inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    inputList.append(int(input()))
    count = count + 1

inputDataMax = intMax
inputDataMin = inputList[0]
count2 = 1
while count2 < inputData:
    inputDataMax = max(inputDataMax,  inputList[count2] - inputDataMin)
    inputMin = min(inputDataMin, inputList[count2])

print(inputDataMax)


Fixed submission:
intMax = -10000000000
inputData = int(input())
inputList = list()
for i in range(inputData):
    inputList.append(int(input()))

inputDataMax = intMax
inputDataMin = inputList[0]
for i in range(inputData - 1):
    inputDataMax = max(inputDataMax,  inputList[i + 1] - inputDataMin)
    inputDataMin = min(inputDataMin, inputList[i + 1])

print(inputDataMax)
Buggy python submission (verdict: Runtime Error):
mountain=[]
for i in range(10):
 mountain[i]=int(input())
mountain.sort()
fori in range(3):
 print(mountain[i])

Fixed submission:
mountain=[]
for i in range(10):
 mountain.append(int(input()))
mountain.sort()
mountain.reverse()
for i in range(3):
 print(mountain[i])

Buggy python submission (verdict: Runtime Error):
mountain=[]
for i in range(10):
 mountain[i]=int(input())
mountain.sort()
for i in range(3):
 print(mountain[i])
 

Fixed submission:
mountain=[]
for i in range(10):
 mountain.append(int(input()))
mountain.sort()
mountain.reverse()
for i in range(3):
 print(mountain[i])

Buggy python submission (verdict: Runtime Error):
mountain=[]
for i in range(10):
 mountain[i]=int(input())
mountain.sort(::-1)
for i in range(3):
 print(mountain[i])
 

Fixed submission:
mountain=[]
for i in range(10):
 mountain.append(int(input()))
mountain.sort()
mountain.reverse()
for i in range(3):
 print(mountain[i])

Buggy python submission (verdict: Runtime Error):
mountain=[]
for i in range(10):
 mountain[i]=int(input())
mountain.sort()
mountain.reverse()
for i in range(3):
 print(mountain[i])
 

Fixed submission:
mountain=[]
for i in range(10):
 mountain.append(int(input()))
mountain.sort()
mountain.reverse()
for i in range(3):
 print(mountain[i])
Buggy python submission (verdict: Runtime Error):
import math
deta=[float(i) for i in input().split()]
h1=math.sqrt((deta[2]-deta[0])**2+(deta[3]-deta[1])**2)
h2=math.sqrt((deta[4]-deta[2])**2+(deta[5]-deta[3])**2)
h3=math.sqrt((deta[0]-deta[4])**2+(deta[1]-deta[5])**2)
sub=(h1+h2+h3)/2
s=math.sqrt(sub*(sub-h1)*(sub-h2)*(sub-h3))
sum=((h1*h2*h3)/s)/4

a=2*deta[2]-2*deta[0]
b=2*deta[3]-2*deta[1]
c=-(deta[0]**2+deta[1]**2-(deta[2]**2)-(deta[3]**2))
d=2*deta[4]-2*deta[2]
e=2*deta[5]-2*deta[3]
f=-(deta[2]**2+deta[3]**2-(deta[4]**2)-(deta[5]**2))

x=(e*c-b*f)/(a*e-b*d)
y=(a*f-c*d)/(a*e-b*d)
print("{0:.3f} {1:.3f} {2:.3f}".format(x,y,sum))

Fixed submission:
import math

n=int(input())
for i in range(n):
    deta=[float(i) for i in input().split()]
    h1=math.sqrt((deta[2]-deta[0])**2+(deta[3]-deta[1])**2)
    h2=math.sqrt((deta[4]-deta[2])**2+(deta[5]-deta[3])**2)
    h3=math.sqrt((deta[0]-deta[4])**2+(deta[1]-deta[5])**2)
    sub=(h1+h2+h3)/2
    s=math.sqrt(sub*(sub-h1)*(sub-h2)*(sub-h3))
    sum=((h1*h2*h3)/s)/4
    a=2*deta[2]-2*deta[0]
    b=2*deta[3]-2*deta[1]
    c=-(deta[0]**2+deta[1]**2-(deta[2]**2)-(deta[3]**2))
    d=2*deta[4]-2*deta[2]
    e=2*deta[5]-2*deta[3]
    f=-(deta[2]**2+deta[3]**2-(deta[4]**2)-(deta[5]**2))
    
    x=(e*c-b*f)/(a*e-b*d)
    y=(a*f-c*d)/(a*e-b*d)
    print("{0:.3f} {1:.3f} {2:.3f}".format(x,y,sum))
Buggy python submission (verdict: Runtime Error):
import sys
s=[input()]
while(True):
    n=input()
    if n=="0":
        print(s.pop())
    elif n=="":
        sys.exit()
    else:
        s.append(n)

Fixed submission:
import sys
s=[]
while True:
    try:
        n=int(input())
    except:
        sys.exit()
    if n==0:
        print(s.pop())
    else:
        s.append(n)

Buggy python submission (verdict: Runtime Error):
import sys
s=[int(input())]
while(True):
    n=input()
    if n=="0":
        print(s.pop())
    elif n=="":
        sys.exit()
    else:
        s.append(int(n))

Fixed submission:
import sys
s=[]
while True:
    try:
        n=int(input())
    except:
        sys.exit()
    if n==0:
        print(s.pop())
    else:
        s.append(n)
Buggy python submission (verdict: Runtime Error):
def dfs(index,n,m,c,dp):
    if dp[index][m] != 30:
        return dp[index][m]

    if index==n:
        return n+1

    if m==c[index]:
        return 1

    if m<c[index]:
        return dfs(index+1,n,m,c,dp)

    ret=min(dfs(index+1,n,m,c,dp),
            dfs(index+1,n,m-c[index],c,dp)+1,
            dfs(index,n,m-c[index],c,dp)+1)
    dp[index][m]=ret
    return ret
m,n=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
dp=[[30 for i in range(m+1)] for j in range(n+1)]
print(dfs(0,n,m,c,dp))

Fixed submission:
m,n=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
dp=[[int(1e4) for i in range(m+1)] for j in range(n+1)]
i=n-1
while i>=0:
    for j in range(m+1):
        if j==c[i]:
            dp[i][j]=1
        elif j<c[i]:
            dp[i][j]=dp[i+1][j]
        else:
            dp[i][j]=min(dp[i+1][j],dp[i+1][j-c[i]]+1,dp[i][j-c[i]]+1)
    i-=1
print(dp[0][m])
Buggy python submission (verdict: Runtime Error):
class Vector2:
    """
    A simple 2D vector class.
    @Author:whitestone0811(Vir_MeL0)
    """
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __add__(self,other):
        return Vector2(self.x+other.x,self.y+other.y)
    def __sub__(self,other):
        return Vector2(self.x-other.x,self.y-other.y)
    def __mul__(self,other):
        if isinstance(other, Vector2):
            return self.x*other.x+self.y*other.y
        else:
            return Vector2(self.x*other,self.y*other)
    def __rmul__(self,other):
        if not isinstance(other,Vector2):
            return Vector2(self.x*other,self.y*other)
    def abs(self):
        return (self.x**2+self.y**2)**0.5
    def cos(self,other):
        return (self*other)/(self.abs()*other.abs())
    def __str__(self):
        return "[{0},{1}]".format(self.x,self.y)
    def __neg__(self):
        return Vector2(-self.x,-self.y)
#    
_in=input()
while _in!='':
    cors=[float(cor)for cor in _in.split(',')]
    vAB=Vector2(cors[2]-cors[0],cors[3]-cors[1])
    vBC=Vector2(cors[4]-cors[2],cors[5]-cors[3])
    vCD=Vector2(cors[6]-cors[4],cors[7]-cors[5])
    vDA=Vector2(cors[0]-cors[6],cors[1]-cors[7])
    cnv_a=True if(vAB-vDA)*(vAB+vBC)>0 else False
    cnv_b=True if(vBC-vAB)*(vBC+vCD)>0 else False
    cnv_c=True if(vCD-vBC)*(vCD+vDA)>0 else False
    cnv_d=True if(vDA-vCD)*(vDA+vAB)>0 else False
    print("YES" if cnv_a and cnv_b and cnv_c and cnv_d else "NO")
    _in=input()

Fixed submission:
class Vector2:
    """
    A simple 2D vector class.
    @Author:whitestone0811(Vir_MeL0)
    """
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __add__(self,other):
        return Vector2(self.x+other.x,self.y+other.y)
    def __sub__(self,other):
        return Vector2(self.x-other.x,self.y-other.y)
    def __mul__(self,other):
        if isinstance(other, Vector2):
            return self.x*other.x+self.y*other.y
        else:
            return Vector2(self.x*other,self.y*other)
    def __rmul__(self,other):
        if not isinstance(other,Vector2):
            return Vector2(self.x*other,self.y*other)
    def abs(self):
        return (self.x**2+self.y**2)**0.5
    def cos(self,other):
        return (self*other)/(self.abs()*other.abs())
    def __str__(self):
        return "[{0},{1}]".format(self.x,self.y)
    def __neg__(self):
        return Vector2(-self.x,-self.y)
#  
import sys  
lines=sys.stdin
for _in in lines:
    cors=[float(cor)for cor in _in.split(',')]
    vAB=Vector2(cors[2]-cors[0],cors[3]-cors[1])
    vBC=Vector2(cors[4]-cors[2],cors[5]-cors[3])
    vCD=Vector2(cors[6]-cors[4],cors[7]-cors[5])
    vDA=Vector2(cors[0]-cors[6],cors[1]-cors[7])
    cnv_a=True if(vAB-vDA)*(vAB+vBC)>0 else False
    cnv_b=True if(vBC-vAB)*(vBC+vCD)>0 else False
    cnv_c=True if(vCD-vBC)*(vCD+vDA)>0 else False
    cnv_d=True if(vDA-vCD)*(vDA+vAB)>0 else False
    print("YES" if cnv_a and cnv_b and cnv_c and cnv_d else "NO")
Buggy python submission (verdict: Runtime Error):
while True:
    n=int(input())
    if n==0:break
    res={}
    li=[]
    for i in range(n):
        d=[int(num) for num in input().split(' ')]
        res[d[0]-1]+=d[1]*d[2]
        if d[0]-1 not in li:li.append(d[0]-1)
    flag=False
    for i in li:
        if res[i]>=1000000:
            print(i+1)
            flag=True
    if flag==False:print("NA")

Fixed submission:
while True:
    n=int(input())
    if n==0:break
    res={}
    li=[]
    for i in range(n):
        d=[int(num) for num in input().split(' ')]
        if d[0]-1 in res:
            res[d[0]-1]+=d[1]*d[2]
        else:
            res[d[0]-1]=d[1]*d[2]
            li.append(d[0]-1)
    flag=False
    for i in li:
        if res[i]>=1000000:
            print(i+1)
            flag=True
    if flag==False:print("NA")
Buggy python submission (verdict: Runtime Error):
while True:
    n=int(input())
    if n==0:break
    m=int(input())
    rel=sorted([[int(s)for s in input().split(" ")]for i in range(m)],key=lambda x:x[0])
    isf=[False for i in range(n)]
    inv=[False for i in range(n)]
    isf[0]=True
    for r in rel:
        if r[0]==1:
            isf[r[1]]=True
            inv[r[1]]=True
        elif isf[r[0]]==True:inv[r[1]]=True
    print(inv.count(True))

Fixed submission:
while True:
    n=int(input())
    if n==0:break
    m=int(input())
    rel=sorted([[int(s)for s in input().split(" ")]for i in range(m)],key=lambda x:x[0])
    isf=[False for i in range(n)]
    inv=[False for i in range(n)]
    isf[0]=True
    for r in rel:
        if r[0]==1:isf[r[1]-1]=True
    for r in rel:
        if isf[r[0]-1]==True:inv[r[1]-1]=True
        elif isf[r[1]-1]==True:inv[r[0]-1]=True
    print(inv.count(True))
Buggy python submission (verdict: Runtime Error):
while True:
    n=int(input())
    if n==0:
        break;
    li=[input() for i in range(n)]
    index=0
    def pls(depth):
        k=0
        global index
        while len(li[index])>depth and li[index][depth-1]=='.':
            if (not li[index][depth]=='+') and (not li[index][depth]=='*'):
                k+=int(li[index][depth])
                if not index==n-1:
                    index+=1
                else:
                    return k
            elif li[index][depth]=='+':
                index+=1
                k+=pls(depth+1)
            elif li[index][depth]=='*':
                index+=1
                k+=prd(depth+1)
        else:
            return k
    def prd(depth):
        k=1
        global index
        while len(li[index])>depth and li[index][depth-1]=='.':
            if (not li[index][depth]=='+') and (not li[index][depth]=='*'):
                k*=int(li[index][depth])
                if not index==n-1:
                    index+=1
                else:
                    return k
            elif li[index][depth]=='+':
                index+=1
                k*=pls(depth+1)
            elif li[index][depth]=='*':
                index+=1
                k*=prd(depth+1)
        else:
            return k
    if li[0]=='+':
        index+=1
        print(pls(1))
    elif li[0]=='*':
        index+=1
        print(prd(1))

Fixed submission:
while True:
    n=int(input())
    if n==0:
        break;
    elif n==1:
        print(input())
        continue;
    li=[input() for i in range(n)]
    index=0
    def pls(depth):
        k=0
        global index
        while len(li[index])>depth and li[index][depth-1]=='.':
            if (not li[index][depth]=='+') and (not li[index][depth]=='*'):
                k+=int(li[index][depth])
                index+=1
            elif li[index][depth]=='+':
                index+=1
                k+=pls(depth+1)
            elif li[index][depth]=='*':
                index+=1
                k+=prd(depth+1)
            if index==n:
                return k    
        else:
            return k
    def prd(depth):
        k=1
        global index
        while len(li[index])>depth and li[index][depth-1]=='.':
            if (not li[index][depth]=='+') and (not li[index][depth]=='*'):
                k*=int(li[index][depth])
                index+=1
            elif li[index][depth]=='+':
                index+=1
                k*=pls(depth+1)
            elif li[index][depth]=='*':
                index+=1
                k*=prd(depth+1)
            if index==n:
                return k
        else:
            return k
    if li[0]=='+':
        index+=1
        print(pls(1))
    elif li[0]=='*':
        index+=1
        print(prd(1))
Buggy python submission (verdict: Runtime Error):
def isRTri(a, b, c):
    return a * a + b * b == c * c

a = [0, 0, 0]
n = input()
for k in range(n):
    a = map(int, raw_input().split())
    r = isRTri(a[0], a[1], a[2])
    print "YES" if r else "NO"

Fixed submission:
def isRTri(a, b, c):
    return a * a + b * b == c * c

a = [0, 0, 0]
n = input()
for k in range(n):
    a = map(int, raw_input().split())
    a.sort()
    r = isRTri(a[0], a[1], a[2])
    print "YES" if r else "NO"

Buggy python submission (verdict: Runtime Error):
def isRTri(a, b, c):
    if a * a + b * b == c * c: return 1
    else return 0

a = [0, 0, 0]
n = input()
for k in range(n):
    a = map(int, raw_input().split())
    r = isRTri(a[0], a[1], a[2])
    if r: print "YES"
    else: print "NO"

Fixed submission:
def isRTri(a, b, c):
    return a * a + b * b == c * c

a = [0, 0, 0]
n = input()
for k in range(n):
    a = map(int, raw_input().split())
    a.sort()
    r = isRTri(a[0], a[1], a[2])
    print "YES" if r else "NO"