Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
for word in s:
    try:
        dic[word]+=1
    except:
        dic[word]=1

m=0
l=0
for word, e in dic.items():
   if e>m:
       m=e
       w1=word
   if len(word)>l:
       l=len(word)
       w2=word

print w1, w2

Fixed submission:
s = raw_input().split()
c1 = 0
c2 = 0
for w in set(s):
    c=s.count(w)
    if c>c1: c1,w1 = c,w
    c=len(w)
    if c>c2: c2,w2 = c,w
print w1, w2
Buggy python submission (verdict: Runtime Error):
def dec2bin(n, base=10):
    s=""
    x=["0","1"]
    while n>0:
        s+=x[n%2]
        n/=2
    return (s+"0"*base)[:base]

x=[[0 for i in range(50)] for i in range(11)]
for i in range(0, 2**10):
    tmp = dec2bin(i)
    s=0
    c=0
    for j in range(10):
        if tmp[j]=="1":
            s+=j
            c+=1
    x[c][s]+=1

while True:
    n,s=map(int, raw_input().split())
    if n==0 and s==0: break
    print x[n][s]

Fixed submission:
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s,c = s+j, c+1
        j+= 1
    x[c][s]+=1

while 1:
    n, s=map(int, raw_input().split())
    if n==0 and s==0: break
    print 0 if s>=50 else x[n][s]

Buggy python submission (verdict: Runtime Error):
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s,c = s+j, c+1
        j += 1
    x[c][s]+=1

while 1:
    n, s=map(int, raw_input().split())
    if n==0 and s==0: break
    print [x[n][s],0][s>=50]

Fixed submission:
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s,c = s+j, c+1
        j+= 1
    x[c][s]+=1

while 1:
    n, s=map(int, raw_input().split())
    if n==0 and s==0: break
    print 0 if s>=50 else x[n][s]

Buggy python submission (verdict: Runtime Error):
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s+=j; c+=1
        j　+=　1
    x[c][s]　+=　1

while 1:
    n,s = map(int, raw_input().split())
    if n==0 and s==0: break
    print 0 if s>=50 else x[n][s]

Fixed submission:
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s,c = s+j, c+1
        j+= 1
    x[c][s]+=1

while 1:
    n, s=map(int, raw_input().split())
    if n==0 and s==0: break
    print 0 if s>=50 else x[n][s]
Buggy python submission (verdict: Runtime Error):
import sys
def sign(x):
    if x>0: s=1
    elif x<0: s=-1
    else s=0
    return s

def f(p1,p2,p3):
    x1,y1 = p1
    s = sign((p3[1]-y1)*(p2[0]-x1)-(p2[1]-y1)*(p3[0]-x1))
    return s

for s in sys.stdin:
    D = map(float, s.split(","))
    p1 = D[0:2]; p2 = D[2:4]; p3 = D[4:6]; p4 = D[6:8]
    x = f(p1,p3,p2) != f(p1,p3,p4) and f(p2,p4,p1) != f(p2,p4,p3)
    print ["NO","YES"][x]

Fixed submission:
import sys
def sign(x):
    if x>0: s=1
    elif x<0: s=-1
    else: s=0
    return s

def f(p1,p2,p3):
    x1,y1 = p1
    s = sign((p3[1]-y1)*(p2[0]-x1)-(p2[1]-y1)*(p3[0]-x1))
    return s

for s in sys.stdin:
    D = map(float, s.split(","))
    p1 = D[0:2]; p2 = D[2:4]; p3 = D[4:6]; p4 = D[6:8]
    x = f(p1,p3,p2) != f(p1,p3,p4) and f(p2,p4,p1) != f(p2,p4,p3)
    print ["NO","YES"][x]

Buggy python submission (verdict: Runtime Error):
import sys
def sign(x):
    if x>0: s=1
    elif x<0: s=-1
    else s=0
    return s

def f(p1,p2,p3):
    x1,y1 = p1
    s = sign((p3[1]-y1)*(p2[0]-x1)-(p2[1]-y1)*(p3[0]-x1))
    return s

for s in sys.stdin:
    D = map(float, s.split(","))
    p1 = D[0:2]; p2 = D[2:4]; p3 = D[4:6]; p4 = D[6:8]
    x = f(p1,p3,p2) != f(p1,p3,p4) and f(p2,p4,p1) != f(p2,p4,p3)
    print ["NO","YES"][x]

Fixed submission:
import sys
def sign(x):
    if x>0: s=1
    elif x<0: s=-1
    else: s=0
    return s

def f(p1,p2,p3):
    x1,y1 = p1
    s = sign((p3[1]-y1)*(p2[0]-x1)-(p2[1]-y1)*(p3[0]-x1))
    return s

for s in sys.stdin:
    D = map(float, s.split(","))
    p1 = D[0:2]; p2 = D[2:4]; p3 = D[4:6]; p4 = D[6:8]
    x = f(p1,p3,p2) != f(p1,p3,p4) and f(p2,p4,p1) != f(p2,p4,p3)
    print ["NO","YES"][x]

Buggy python submission (verdict: Runtime Error):
import sys
def sign(x):
    if x>0: s=1
    elif x<0: s=-1
    else s=0
    return s

def f(p1,p2,p3):
    x1,y1 = p1
    s = sign((p3[1]-y1)*(p2[0]-x1)-(p2[1]-y1)*(p3[0]-x1))
    return s

for s in sys.stdin:
    D = map(float, s.split(","))
    p1 = D[0:2]; p2 = D[2:4]; p3 = D[4:6]; p4 = D[6:8]
    print ["NO","YES"][f(p1,p3,p2) != f(p1,p3,p4) and f(p2,p4,p1) != f(p2,p4,p3)]

Fixed submission:
import sys
def sign(x):
    if x>0: s=1
    elif x<0: s=-1
    else: s=0
    return s

def f(p1,p2,p3):
    x1,y1 = p1
    s = sign((p3[1]-y1)*(p2[0]-x1)-(p2[1]-y1)*(p3[0]-x1))
    return s

for s in sys.stdin:
    D = map(float, s.split(","))
    p1 = D[0:2]; p2 = D[2:4]; p3 = D[4:6]; p4 = D[6:8]
    x = f(p1,p3,p2) != f(p1,p3,p4) and f(p2,p4,p1) != f(p2,p4,p3)
    print ["NO","YES"][x]
Buggy python submission (verdict: Runtime Error):
def op(x,y,i):
    if i==0:
        return x+y
    elif i==1:
        return x-y
    elif i==2:
        return x*y

def check(x, n):
    a1,a2,a3,a4 = x[0],x[1],x[2],x[3]
    s='+-*'
    for i1 in range(3):
        a1 = op(x[0],x[1],i1)
        for i2 in range(3):
            a2 = op(a1,x[2],i2)
            for i3 in range(3):
                a3 = op(a2,x[3],i3)
                if a3==n:
                    b1,b2,b3 = s[i1],s[i2],s[i3]
                    s0 = '((({0} {1} {2}) {3} {4}) {5} {6})'
                    eq = s0.format(x[0],b1,x[1],b2,x[2],b3,x[3])
                    return eq
            a2 = op(x[2],x[3],i2)
            for i3 in range(3):
                a3 = op(a1,a2,i3)
                if a3==n:
                    b1,b2,b3 = s[i1],s[i3],s[i2]
                    s0 = '((({0} {1} {2}) {3} ({4} {5} {6}))'
                    eq = s0.format(x[0],b1,x[1],b2,x[2],b3,x[3])
                    return eq
    return ''

def permutations(L):
    if L == []:
        return [[]]
    else:
        return [[h]+t for i,h in enumerate(L)
                      for t   in permutations(L[:i]+L[i+1:])]

n=10
op='+-*'
while True:
    x = map(int,raw_input().split())
    if x==[0,0,0,0]:break
    x = permutations(x)
    for e in x:
        s = check(e,n)
        if s!='':
            print s
            break
    else:
        print ('0')

Fixed submission:
import itertools
def op(x,y,i):
    if i=="+": return x+y
    elif i=="-": return x-y
    elif i=="*": return x*y

e0 = "((({} {} {}) {} {}) {} {})"
e1 = "(({} {} {}) {} ({} {} {}))"
def check(A, n):
    w,x,y,z = A
    S="+-*"
    for i in S:
        a = op(w,x,i)
        for j in S:
            b1,b2 = op(a,y,j),op(y,z,j)
            for k in S:
                if op(b1,z,k)==n: return e0.format(w,i,x,j,y,k,z)
                if op(a,b2,k)==n: return e1.format(w,i,x,k,y,j,z)
    return 0

n = 10
while 1:
    x = map(int,raw_input().split())
    if x==[0,0,0,0]: break
    for e in itertools.permutations(x):
        s = check(e,n)
        if s: break
    print s
Buggy python submission (verdict: Runtime Error):
import sys

c=["light fly", "fly", "bantam", "feather", "light", "light welter",
   "welter", "light middle", "middle", "light heavy", "heavy"]
w=[48,51,54,57,60,64,69,75,81,91]
for s in map(float,sys.stdin):
    i=0;
    while w[i]<s:
        i+=1
    print c[i]

Fixed submission:
import sys

c=["light fly", "fly", "bantam", "feather", "light", "light welter",
   "welter", "light middle", "middle", "light heavy", "heavy"]
w=[48,51,54,57,60,64,69,75,81,91]
for s in map(float,sys.stdin):
    i=0
    for e in w:
        if e<s: i+=1
    print c[i]

Buggy python submission (verdict: Runtime Error):
import sys

c=["light fly", "fly", "bantam", "feather", "light", "light welter",
   "welter", "light middle", "middle", "light heavy", "heavy"]
w=[48,51,54,57,60,64,69,75,81,91]
for s in map(float,sys.stdin):
    i=0
    while w[i]<s:
        i+=1
    print c[i]

Fixed submission:
import sys

c=["light fly", "fly", "bantam", "feather", "light", "light welter",
   "welter", "light middle", "middle", "light heavy", "heavy"]
w=[48,51,54,57,60,64,69,75,81,91]
for s in map(float,sys.stdin):
    i=0
    for e in w:
        if e<s: i+=1
    print c[i]
Buggy python submission (verdict: Runtime Error):
import sys

b={}
for s in sys.stdin:
    i = s[s.index(',')+1:-1]
    try: b[i]+=1
    except: b[i]=1
for e in [0,1,3,2]:
    print b[b.keys()[e]]

Fixed submission:
import sys

b=[s.split(',')[1][:-1] for s in sys.stdin]
for e in ["A","B","AB","O"]:
    print b.count(e)

Buggy python submission (verdict: Runtime Error):
import sys

b={}
for s in sys.stdin:
    i = s[s.index(',')+1:-1]
    try:
        b[i]+=1
    except:
        b[i]=1
for e in [0,1,3,2]:
    print b[b.keys()[e]]

Fixed submission:
import sys

b=[s.split(',')[1][:-1] for s in sys.stdin]
for e in ["A","B","AB","O"]:
    print b.count(e)
Buggy python submission (verdict: Runtime Error):
import sys
for n in sys.stdin:
    c=0
    for i in range(1,int(n)+1):
        while i%5==0:
            i/=5
            c+=1
    print c

Fixed submission:
while 1:
    n = input()
    if n==0: break
    c = 0
    while n:
        n /= 5
        c += n
    print c

Buggy python submission (verdict: Runtime Error):
import sys
for n in sys.stdin:
    c=0
    for i in range(1,int(n)+1):
        j=i
        while j%5==0:
            j/=5
            c+=1
    print c

Fixed submission:
while 1:
    n = input()
    if n==0: break
    c = 0
    while n:
        n /= 5
        c += n
    print c
Buggy python submission (verdict: Runtime Error):
s in sys.stdin:
    a,b,n=map(int,s.split())
    a=a%b
    s=0
    for i in range(n):
        a*=10
        s+=a/b
        a%=b
    print s

Fixed submission:
import sys
for s in sys.stdin:
    a,b,n=map(int,s.split())
    s=0
    while n:
        a=a%b*10
        s+=a/b
        n-=1
    print s
Buggy python submission (verdict: Runtime Error):
import sys
for s in sys.stdin:
    x=map(int,list(str(s))[:-1])
    while True:
        a=len(x)
        x=[(x[i]+x[i+1])%10 for i in range(a-1)]
        if a==1: break
    print x[0]

Fixed submission:
import sys
for s in sys.stdin:
    x=["0123456789".index(c) for c in s[:-1]]
    while True:
        a=len(x)-1
        x=[(x[i]+x[i+1])%10 for i in range(a)]
        if a==1: break
    print x[0]
Buggy python submission (verdict: Runtime Error):
s="".join([s for s in sys.stdin])
p=re.compile('\d+')
x=p.findall(s)
print sum(map(int,x))

Fixed submission:
import sys,re
s="".join([s for s in sys.stdin])
p=re.compile('\d+')
x=p.findall(s)
print sum(map(int,x))

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <string>
int main(){
	std::string s,x="";
	while(std::cin>>s)x+=s;
	s="";
	int a=0,i=0;
	for (;i<(int)x.size();i++)
		if (isdigit(x[i])) s+=x[i];
		else
			if (!s.empty()){
				a+=atoi(s.c_str());
				s="";
			}
	std::cout<<a<<"\n";
}

Fixed submission:
import sys,re
s="".join([s for s in sys.stdin])
p=re.compile('\d+')
x=p.findall(s)
print sum(map(int,x))
Buggy python submission (verdict: Runtime Error):
import sys
C=range(1000)
f=0
d=[[0 for i in C] for j in range(2)]
for s in sys.stdin.readlines():
    if s=="\n":f+=1
    else:
        a,b=map(int,s.split(','))
        d[f][a]+=1
for i in C:
    a=d[0][i]
    b=d[1][i]
    if a!=0 and b!=0: print i, a+b

Fixed submission:
import sys
C=range(1001)
m=0
d=[[0 for i in C] for j in range(2)]
for s in sys.stdin.readlines():
    if s=="\n":m+=1
    else:
        a,b=map(int,s.split(','))
        d[m][a]+=1
for i in C:
    a=d[0][i]
    b=d[1][i]
    if a and b:print i,a+b

Buggy python submission (verdict: Runtime Error):
import sys
C=range(1000)
m=0
d=[[0 for i in C] for j in range(2)]
for s in sys.stdin.readlines():
    if s=="\n":m+=1
    else:
        a,b=map(int,s.split(','))
        d[m][a]+=1
for i in C:
    a=d[0][i]
    b=d[1][i]
    if a!=0 and b!=0:print i,a+b

Fixed submission:
import sys
C=range(1001)
m=0
d=[[0 for i in C] for j in range(2)]
for s in sys.stdin.readlines():
    if s=="\n":m+=1
    else:
        a,b=map(int,s.split(','))
        d[m][a]+=1
for i in C:
    a=d[0][i]
    b=d[1][i]
    if a and b:print i,a+b
Buggy python submission (verdict: Runtime Error):
import sys
def f(y,x):
    f=0
    if m[y][x]==1:
        m[y][x]=c
        f=1
    return f
def LR(y,x,dx):
    P=[]
    x+=dx
    while 0<=x<12 and m[y][x]!=0:
        if f(y,x):P+=[(y,x)]
        x+=dx
    return P
def UD(y,x,dy):
    P=[]
    y+=dy
    while 0<=y<12 and m[y][x]!=0:
        if f(y,x):P+=[(y,x)]
        y+=dy
    return P
def v1(buf):
    f=0
    while len(buf)>0:
        f=1
        y,x=buf.pop()
        m[y][x]=c
buf=list(set(buf+LR(y,x,-1)+LR(y,x,1)+UD(y,x,-1)+UD(y,x,1)))
    return f
def solve():
    global c
    buf=[]
    c=2
    for i in A:
        x=m[i]
        while x.count(1)>0:
            buf+=[(i,x.index(1))]
            if v1(buf):c+=1
    return c-2
A=range(12)
m=[[0 for x in A] for y in A]
y=0
for s in sys.stdin:
    if y<12:
        x=0
        for e in map(int,list(s[:-1])):
            m[y][x]=e
            x+=1
        y+=1
    else:
        print solve()
        y=0
print solve()

Fixed submission:
import sys
A=range(14)
m=[[0 for i in A]for j in A]
def f(y,x):
    if m[y][x]==1:
        m[y][x]=0
        f(y,x+1)
        f(y,x-1)
        f(y+1,x)
        f(y-1,x)
    return 1
def solve():
    c=0
    for i in A:
        while m[i].count(1)>0:c+=f(i,m[i].index(1))
    print c
    return 0
y=0
for s in sys.stdin:
    if y<12:
        y+=1
        m[y]=[0]+map(int,list(s[:-1]))+[0]
    else:y=solve()
solve()
Buggy python submission (verdict: Runtime Error):
import sys
def side(p1,p2):
  global D
  y1,x1=p1
  y2,x2=p2
  dy=y2-y1
  dx=x2-x1
  for p3 in D[::-1]:
    if p1==p3 or p2==p3:pass
    y3,x3=p3
    elif (x3-x1)*dy-dx*(y3-y1)<0:return 0
  else:return 1

while 1:
  n=input()
  if n==0:break
  D=sorted([list(input()) for i in range(n)])
  p=p1=D[0]
  D1=D[:]
  while True:
    for p2 in D1:
      if p1!=p2 and side(p1,p2):break
    p1=p2
    D1.remove(p2)
    if p2==p:break
  print len(D1)

Fixed submission:
import sys
def side(p1,p2):
  global D
  y1,x1=p1
  y2,x2=p2
  dy=y2-y1
  dx=x2-x1
  for p3 in D:
    if p1==p3 or p2==p3:continue
    if (p3[1]-x1)*dy-dx*(p3[0]-y1)<0:return 0
  else:return 1
 
while 1:
  n=input()
  if n==0:break
  D=sorted([list(input()) for i in range(n)])
  p=p1=D[0]
  while 1:
    for p2 in D:
      if p1!=p2 and side(p1,p2):break
    p1=p2
    D.remove(p2)
    if p2==p:break
  print len(D)
Buggy python submission (verdict: Runtime Error):
import sys
n=input()
N=range(n)
m=input()
A=[sys.maxint]*n
B=[A[:] for i in N]
A=[0]*n
C=[A[:] for i in N]
while 1:
    s=raw_input()
    if s=="0": break
    a,b,w=map(int,s.split(","))
    B[a][b],B[b][a]=w,w

s=0
for i in N:
    x=min(B[i])
    y=B[i].index(x)
    if C[i][y]==0:
        C[i][y],C[y][i]=1,1
        s+=x/100-1
print s

Fixed submission:
while 1:
    n=input()
    if n==0:break
    N=range(n)
    T=N[:]
    M=range(input())
    S=[map(int,raw_input().split(","))for i in M]
    S=sorted(S,key=lambda x:x[2])        
    a=0
    while S:
        x,y,w=S.pop(0)
        b,c=T[x],T[y]
        if b==c:continue
        for i in N:
            if T[i]==b:T[i]=c
        a+=w/100-1
    print a
Buggy python submission (verdict: Runtime Error):
def f(t):
    c,t=t%N,t/N
    print "%02d:%02d:%02d"%(t/N,t%N,c)
    return

while 1:
    h,m,s=map(int,raw_input().split())
    if [h,m,s]==[-1,-1,-1]: break
    t=7200-(h*N+m)*N-s
    f(t)
    f(t*3)

Fixed submission:
N=60
def f(t):
    c,t=t%N,t/N
    print "%02d:%02d:%02d"%(t/N,t%N,c)
    return

while 1:
    h,m,s=map(int,raw_input().split())
    if [h,m,s]==[-1,-1,-1]: break
    t=7200-(h*N+m)*N-s
    f(t)
    f(t*3)
Buggy python submission (verdict: Runtime Error):
import sys
for s in sys.stdin:
    s1=s.split(",")
    n=int(s1[0])
    h,w=map(float(s[1:]))
    bmi=w/h^2
    if bmi>=25: print n

Fixed submission:
import sys
for s in sys.stdin:
    n,w,h = map(float, s.split(","))
    if w / h**2 >= 25: print int(n)
Buggy python submission (verdict: Runtime Error):
A=[]
x=1.0
y=0.0
for i in range(101):
    A.append([x,y])
    tmp=(x**2+y**2)**.5
    dx,dy=-y/tmp,x/tmp
    x+=dx
    y+=dy

while 1:
    n=input()
    if n==-1:break
    a,b=A[n-1]
    print "%.2f\n%.2f"%(a,b)

Fixed submission:
N=1001
A=[[]]*N
x=1.0
y=0.0
for i in range(1,N):
    A[i]=[x,y]
    tmp=i**.5
    x,y=x-y/tmp,y+x/tmp
 
while 1:
    n = input()
    if n==-1:break
    a,b=A[n]
    print a,b
Buggy python submission (verdict: Runtime Error):
import sys
for s in sys.stdin:
    while 1:
        p　=　s.find("@")
        if p==-1:　break
        s　=　s.replace(s[p:p+3],　s[p+2]　*　int(s[p+1]))
    print s[:-1]

Fixed submission:
import sys
for s in sys.stdin:
    while 1:
        p = s.find("@")
        if p==-1: break
        s = s.replace(s[p:p+3], s[p+2] * int(s[p+1]))
    print s[:-1]
Buggy python submission (verdict: Runtime Error):
s=raw_input().replace(","," ").replace("."," ").split()
s=" ".join(map(lambda 2<len(w)<7 s))
print s

Fixed submission:
s=" "
x=raw_input().replace(",",s).replace(".",s).split()
x=s.join([w for w in x if 2<len(w)<7])
print x
Buggy python submission (verdict: Runtime Error):
import sys
A=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ"
B="101 000000 000011 10010001 010001 000001 100101 10011010 "\
  "0101 0001 110 01001 10011011 010000 0111 10011000 "\
  "0110 00100 10011001 10011110 00101 111 10011111 1000 "\
  "00110 00111 10011100 10011101 000010 10010010 10010011 10010000".split()
C="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"
d1={}
for i in range(26):d1[A[i]]=B[i]
for s in sys.stdin:
  x=""
  for c in s[:-1]:x+=d1[c]
  x+="0"*(-len(x)%5)
  s=""
  for i in range(0,len(x),5):s+=C[int(x[i:i+5],2)]
  print s

Fixed submission:
import sys
L="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
A=" ',-.?"+L
B="101 000000 000011 10010001 010001 000001 100101 10011010 "\
  "0101 0001 110 01001 10011011 010000 0111 10011000 "\
  "0110 00100 10011001 10011110 00101 111 10011111 1000 "\
  "00110 00111 10011100 10011101 000010 10010010 10010011 10010000".split()
C=L+" .,-'?"
for s in sys.stdin:
  x=""
  for c in s[:-1]:x+=B[A.index(c)]
  x+="0"*(-len(x)%5)
  s=""
  for i in range(0,len(x),5):s+=C[int(x[i:i+5],2)]
  print s
Buggy python submission (verdict: Time Limit Exceeded):
import sys

while 1:
  n=input()
  if n==0:break
  A=[raw_input() for i in range(n)]
  B=[]
  c=0
  for i in range(n):
    if c==0 and '1' in A[i]: c=1
    B.append(int(A[i].replace('.','1').replace('*','0'),2))
  C=B[:]
  for i in range(1,n):
    for j in range(n-i):
      B[j]&=B[j+1]
      if '1'*(i+1) in format(B[j],'b'): c=i+1
  print c

Fixed submission:
import sys

while 1:
  n = input() + 1
  if n==1: break
  N = range(n)
  M = [0] * n
  y = [0] * n
  for i in N[1:]:
    x = [0] * n
    A = ' ' + raw_input()
    for j in N[1:]:
      if A[j] == '.': x[j] = min(y[j-1],y[j],x[j-1]) + 1
    M[i]=max(x)
    y = x
  print max(M)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

while 1:
  n=input()
  if n==0:break
  A=[raw_input() for i in range(n)]
  B=[]
  c=0
  for i in range(n):
    if c==0 and '1' in A[i]: c=1
    B.append(int(A[i].replace('.','1').replace('*','0'),2))
  C=B[:]
  for i in range(1,n):
    for j in range(n-i):
      B[j]&=B[j+1]
      if '1'*(i+1) in format(B[j],'b'): c=i+1
    if c!=i+1: break
  print c

Fixed submission:
import sys

while 1:
  n = input() + 1
  if n==1: break
  N = range(n)
  M = [0] * n
  y = [0] * n
  for i in N[1:]:
    x = [0] * n
    A = ' ' + raw_input()
    for j in N[1:]:
      if A[j] == '.': x[j] = min(y[j-1],y[j],x[j-1]) + 1
    M[i]=max(x)
    y = x
  print max(M)

Buggy python submission (verdict: Runtime Error):
import sys

while 1:
  n=input()+1
  if n==1:break
  A=[''*n]+[' '+raw_input() for i in range(1,n)]
  M=[[0]*n for i in range(n)]
  for i in range(1,n):
    for j in range(1,n):
      if A[i][j]=='.':
        M[i][j]=min(M[i-1][j-1],M[i-1][j],M[i][j-1])+1
  print max(map(max,M))
        a=min(M[i-1][j-1],M[i-1][j],a)+1
        M[i][j]=a
  print max(map(max,M))

Fixed submission:
import sys

while 1:
  n = input() + 1
  if n==1: break
  N = range(n)
  M = [0] * n
  y = [0] * n
  for i in N[1:]:
    x = [0] * n
    A = ' ' + raw_input()
    for j in N[1:]:
      if A[j] == '.': x[j] = min(y[j-1],y[j],x[j-1]) + 1
    M[i]=max(x)
    y = x
  print max(M)

Buggy python submission (verdict: Runtime Error):
import sys
while 1:
  n = input() + 1
  if n==1: break
  N = range(n)
  M = [[0] * n for i in N]
  y = M[0]
  for i in N[1:]:
    x = [0] * n
    A = ' ' + raw_input()
    for j in N[1:]:
      if A[j] == '.': x[j] = min(y[j-1],　y[j],　x[j-1]) + 1
    M[i] = x
    y = x
  print max(map(max,　M))

Fixed submission:
import sys

while 1:
  n = input() + 1
  if n==1: break
  N = range(n)
  M = [0] * n
  y = [0] * n
  for i in N[1:]:
    x = [0] * n
    A = ' ' + raw_input()
    for j in N[1:]:
      if A[j] == '.': x[j] = min(y[j-1],y[j],x[j-1]) + 1
    M[i]=max(x)
    y = x
  print max(M)
Buggy python submission (verdict: Runtime Error):
f=0
while 1:
  a,　b = map(int, raw_input().split())
  if a==b==0: break
  x = [i for i in range(a, b+1) if (i%4　==　0 and (i%100　!= 0 or i%400 == 0))]
  if x==[]: x=["NA"]

  if f: print
  for e in x: print e
  f=1

Fixed submission:
f=0
while 1:
  a, b = map(int, raw_input().split())
  if a==b==0: break
  x=[i for i in range(a,b+1) if (i%4==0 and (i%100!=0 or i%400==0))]
  if x==[]: x=["NA"]

  if f: print
  for e in x: print e
  f=1
Buggy python submission (verdict: Runtime Error):
n=input()
a0,v0=inf,0
for i in range(n):
  a,v=map(int,raw_input().split())
  if v>v0: a0,v0=a,v
  elif v=v0: a0=min(a0,a)
print a,v

Fixed submission:
n=input()
x=[0]*n
for i in range(n):
  a,v=map(int,raw_input().split())
  x[a-1]=v
m=max(x)
print x.index(m)+1,m

Buggy python submission (verdict: Runtime Error):
n=input()
a0,v0=n,0
for i in range(n):
  a,v=map(int,raw_input().split())
  if v>v0: a0,v0=a,v
  elif v=v0: a0=min(a0,a)
print a,v

Fixed submission:
n=input()
x=[0]*n
for i in range(n):
  a,v=map(int,raw_input().split())
  x[a-1]=v
m=max(x)
print x.index(m)+1,m
Buggy python submission (verdict: Runtime Error):
import sys

n=1001
a=range(1,n)
a+=[n]+a[::-1]

for n in map(int,sys.stdin):
  x=0
  for i in range(max(0,n-2000),n+1):
    x+=a[i]*a[n-i]
  print x

Fixed submission:
import sys
n=1001
a=range(1,n)
a+=[n]+a[::-1]
for n in map(int,sys.stdin):
  print sum([a[i]*a[n-i] for i in range(max(0,n-2000),min(n,2000)+1)])

Buggy python submission (verdict: Runtime Error):
import sys

n=1001
a=range(1,n)
a+=[n]+a[::-1]

for n in map(int,sys.stdin):
  x=0
  for i in range(max(0,n-2000),n+1):
    x+=a[i]*a[n-i]
  print x

Fixed submission:
import sys
n=1001
a=range(1,n)
a+=[n]+a[::-1]
for n in map(int,sys.stdin):
  print sum([a[i]*a[n-i] for i in range(max(0,n-2000),min(n,2000)+1)])

Buggy python submission (verdict: Runtime Error):
n=1001
a=range(1,n)
a+=[n]+a[::-1]
for n in map(int,sys.stdin):
  x=0
  for i in range(max(0,n-2000),min(n,2000)+1):
    x+=a[i]*a[n-i]
  print x

Fixed submission:
import sys
n=1001
a=range(1,n)
a+=[n]+a[::-1]
for n in map(int,sys.stdin):
  print sum([a[i]*a[n-i] for i in range(max(0,n-2000),min(n,2000)+1)])
Buggy python submission (verdict: Time Limit Exceeded):
m=1001
while 1:
  n,s=map(int,raw_input().split())
  if n==s==0: break
  A=range(n)
  d=[[0]*m for i in A]
  for i in range(101):
    for j in A[::-1]:
      if j==0: d[j][i]=1
      else:
        for k in range(m):
          if k+i<m: d[j][k+i]+=d[j-1][k]
  print d[n-1][s]

Fixed submission:
m=1001
A=range(9)
d=[[0]*m for i in A]
for i in range(101):
  for j in A[1:][::-1]:
    for k in range(m-i): d[j][k+i]+=d[j-1][k]
  d[0][i]=1
while 1:
  n,s=map(int,raw_input().split())
  if n==s==0: break
  print d[n-1][s]