Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
while True:
    n = int(raw_input())
    if n == 0:
        break
    c = 0
    key = 0
    while c < n:
        sc = str(key+1)
        if sc.count("4") + sc.count("6") > 0:
            key += 1
        else:
            c += 1
            key += 1
    print key

Fixed submission:
ref = ["0","1","2","3","5","7","8","9"]
while True:
    n = int(raw_input())
    if n == 0: break
    ans = ""
    for i in str(oct(n))[1:]:
        ans += ref[int(i)]
    print ans

Buggy python submission (verdict: Time Limit Exceeded):
while True:
    n = int(raw_input())
    if n == 0:
        break
    c = 0
    key = 0
    while c < n:
        sc = list(set(str(key+1)))
        if sc.count("4") or sc.count("6"):
            key += 1
        else:
            c += 1
            key += 1
    print key

Fixed submission:
ref = ["0","1","2","3","5","7","8","9"]
while True:
    n = int(raw_input())
    if n == 0: break
    ans = ""
    for i in str(oct(n))[1:]:
        ans += ref[int(i)]
    print ans
Buggy python submission (verdict: Runtime Error):
while 1:
	r={}
	n=input()
	if n==0:break
	for i in [1]*n:
		p,d1,d2=map(int,raw_input().split())
		r[p]=d1+d2
	a=max(r.items(),key=lambda x:x[1])
	print a[0],a[1]

Fixed submission:
while 1:
    try:
        n=input()
        if n==0:break
        l=m=0
        for i in [1]*n:
            p,d1,d2=map(int,raw_input().split())
            d=d1+d2
            if d>m:l,m=p,d
        print l,m
    except SyntaxError:
        pass

Buggy python submission (verdict: Runtime Error):
while 1:
	try:
		r={}
		n=input()
		l=m=0
		for i in [1]*n:
			p,d1,d2=map(int,raw_input().split())
			d=d1+d2
			if d>m:l,m=p,d
		print l,m
	except syntaxError:
		pass

Fixed submission:
while 1:
    try:
        n=input()
        if n==0:break
        l=m=0
        for i in [1]*n:
            p,d1,d2=map(int,raw_input().split())
            d=d1+d2
            if d>m:l,m=p,d
        print l,m
    except SyntaxError:
        pass

Buggy python submission (verdict: Runtime Error):
while 1:
	try:
		r={}
		n=input()
		l=m=0
		for i in [1]*n:
			p,d1,d2=map(int,raw_input().split())
			d=d1+d2
			if d>m:l,m=p,d
		print l,m
	except SyntaxError:
		pass

Fixed submission:
while 1:
    try:
        n=input()
        if n==0:break
        l=m=0
        for i in [1]*n:
            p,d1,d2=map(int,raw_input().split())
            d=d1+d2
            if d>m:l,m=p,d
        print l,m
    except SyntaxError:
        pass
Buggy python submission (verdict: Runtime Error):
while 1:
	n=input()
	if n==0:break
	for i in range(n):
		m,e,j=map(int, raw_input().split())
		a=sum(m,e,j)
		if 100 in [m,e,j] or m+e>=180 or a>=240:print "A"
		elif a>=210 or (a>=150 and max(m,e)>=80):print "B"
		else:print"C"

Fixed submission:
while 1:
	n=input()
	if n==0:break
	for i in range(n):
		m,e,j=map(int, raw_input().split())
		a=m+e+j
		if 100 in [m,e,j] or m+e>179 or a>239:print"A"
		elif a>209 or (a>149 and max(m,e)>79):print"B"
		else:print"C"
Buggy python submission (verdict: Runtime Error):
while 1:
	n = input()
	if n == 0: break
	datas = [map(int,raw_input().split()) for i in range(n)]
	maxw = 0
	for d1 in datas:
		w = sum([d2[0] for d2 in datas if d2[1]<=d1[1]<d2[2]])
		maxw = max(w,mxw)
	print "OK" if maxw <= 150 else "NG"

Fixed submission:
while 1:
	n=input()
	if n==0: break
	d=[map(int,raw_input().split()) for i in range(n)]
	w=max([sum([d2[0] for d2 in d if d2[1]<=d1[1]<d2[2]]) for d1 in d])
	print "OK" if w<151 else "NG"
Buggy python submission (verdict: Runtime Error):
while 1:
	n = input()
	if n == 0: break
	a = map(int,raw_input().split())
	da = [a[i+1] - a[i] for i in range(n)]
	d = sorted(list(set(da)), key = lambda x:da.count(x)[1]
	for i in range(n):
		if i == 0 and a[i] + d != a[i+1]:
			if a[i] + 2*d == a[i+2]:
				print a[i+1]
			else:
				print a[i]
			break
		elif a[i] + d != a[i+1]:
			print a[i+1]
			break

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	a = map(int,raw_input().split())
	da = [a[i+1] - a[i] for i in range(n)]
	d = sorted(list(set(da)), key = lambda x:da.count(x))[-1]
	for i in range(n):
		if i == 0 and a[i] + d != a[i+1]:
			if a[i+1] + d != a[i+2]:
				print a[i+1]
			else:
				print a[i]
			break
		elif a[i] + d != a[i+1]:
			print a[i+1]
			break
Buggy python submission (verdict: Runtime Error):
while 1:
	n=list(raw_input())
	if n[0]==n[1]==n[2]==n[3]=="0": break
	elif n[0]==n[1]==n[2]==n[3]:
		print "NA"
		continue
	count=0
	while 1:
		if n==["6","1","7","4"]:
			print count
			break
		m=sorted(n)[::-1]
		l=sorted(n)[n.count("0"):]
		n=list(str(int("".join(map(str,m)))-int("".join(map(str,l)))))
		count+=1

Fixed submission:
while 1:
    n=raw_input()
    if n=="0000": break
    if int(n)%1111==0:
        print "NA"
        continue
    ans = 0
    while n!="6174":
        n="".join(sorted(n))
        n=str(int(n[::-1])-int(n)).zfill(4)
        ans+=1
    print ans
Buggy python submission (verdict: Runtime Error):
for i in range(input()):
	hex=raw_input()
	bit=""
	for j in b:
		bit+=format(int(j,16),"b").zfill(4)
	ans=0.0
	for i in range(1,32):
		ans+=int(bit[i])*2.0**(24-i)
	print (-1)**int(bit[0])*ans

Fixed submission:
for i in range(input()):    
	b=int(raw_input(),16)
	s=1<<31
	p=""
	if b&s!=0:
		b^=s
		p="-"
	a=int(b*1.0/(1<<7))
	print p+str(a)+str(abs(b*1.0/(1<<7)-a))[1:]

Buggy python submission (verdict: Runtime Error):
gets
$<.map{|l|n=0.0;b=l.hex;31.times{|i|n+=(2**(24-i))*b[i]};p n*(-1)**b[31]}

Fixed submission:
for i in range(input()):    
	b=int(raw_input(),16)
	s=1<<31
	p=""
	if b&s!=0:
		b^=s
		p="-"
	a=int(b*1.0/(1<<7))
	print p+str(a)+str(abs(b*1.0/(1<<7)-a))[1:]
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,raw_input().split())
c=map(int,raw_input().split())
for i in range(q):
	m=int(raw_input())
	print max([c[i]%m for i in range(n)])

Fixed submission:
N,Q=map(int,raw_input().split())
c=map(int,raw_input().split())

mxc=max(c)
p=[0]*(mxc+1)
for i in c:
    p[i]=1
    
l=[0]*(mxc+1)
num=0
for i in range(mxc+1):
    l[i]=num
    if p[i]:
        num=i
        
for i in range(Q):
    q=int(raw_input())
    sp=mxc
    ans=0
    while 1:
        r=sp%q
        ans=max(ans,r)
        if sp-r<=0:break
        sp=l[sp-r]
    print ans

Buggy python submission (verdict: Runtime Error):
n,q=map(int,raw_input().split())
c=map(int,raw_input().split())
p=[0]*(max(c)+1)
for i in c:
	p[i]=1

for k in range(q):
	m=int(raw_input())n,q=map(int,raw_input().split())
c=map(int,raw_input().split())
p=[0]*(max(c)+1)
for i in c:
	p[i]=1

for k in range(q):
	m=int(raw_input())
	flag=0
	for i in range(m-1,0,-1):
		for pi in p[i::m]:
			if pi:
				print i
				flag=1
				break
		if flag: break
	else:
		print 0
	flag=0
	for i in range(m-1,0,-1):
		for pi in p[i::m]:
			if pi:
				print i
				flag=1
				break
		if flag: break

Fixed submission:
N,Q=map(int,raw_input().split())
c=map(int,raw_input().split())

mxc=max(c)
p=[0]*(mxc+1)
for i in c:
    p[i]=1
    
l=[0]*(mxc+1)
num=0
for i in range(mxc+1):
    l[i]=num
    if p[i]:
        num=i
        
for i in range(Q):
    q=int(raw_input())
    sp=mxc
    ans=0
    while 1:
        r=sp%q
        ans=max(ans,r)
        if sp-r<=0:break
        sp=l[sp-r]
    print ans

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,raw_input().split())
c=map(int,raw_input().split())
p=[0]*(max(c)+1)
for i in c:
	p[i]=1

for k in range(q):
	m=int(raw_input())
	flag=0
	ans=0
	for i in range(m-1,0,-1):
		for pi in p[i::m]:
			if pi:
				ans=i
				break
		if ans>0:
			break
	print ans

Fixed submission:
N,Q=map(int,raw_input().split())
c=map(int,raw_input().split())

mxc=max(c)
p=[0]*(mxc+1)
for i in c:
    p[i]=1
    
l=[0]*(mxc+1)
num=0
for i in range(mxc+1):
    l[i]=num
    if p[i]:
        num=i
        
for i in range(Q):
    q=int(raw_input())
    sp=mxc
    ans=0
    while 1:
        r=sp%q
        ans=max(ans,r)
        if sp-r<=0:break
        sp=l[sp-r]
    print ans
Buggy python submission (verdict: Runtime Error):
while True:
    try:
        a,b=map(int,raw_input().split())
        print a-b

Fixed submission:
while True:
    try:
        a,b=map(int,raw_input().split())
        print a-b
    except:
        break
Buggy python submission (verdict: Time Limit Exceeded):
n,r,l=map(int,raw_input().split())
id_t=[0]*n
id_x=[0]*n
log=[map(int,raw_input().split()) for i in range(r)]
log.insert(0,[1,0,0])
log.append([1,l,0])
for i in range(1,r+2):
	id_t[id_x.index(max(id_x))]+=log[i][1]-log[i-1][1]
	id_x[log[i][0]-1]+=log[i][2]
print id_t.index(max(id_t))+1

Fixed submission:
def findMaxId(id_x):
	max_x=0
	max_id=0
	for i in range(n):
		if id_x[i]>max_x:
			max_x=id_x[i]
			max_id=i
	return max_id
	
n,r,l=map(int,raw_input().split())
log=[map(int,raw_input().split()) for i in range(r)]
log.insert(0,[1,0,0])
log.append([1,l,0])
id_t=[0]*n
id_x=[0]*n
max_id=0
for i in range(1,r+2):
	cur_id=log[i][0]-1
	id_t[max_id]+=log[i][1]-log[i-1][1]
	id_x[cur_id]+=log[i][2]
	if cur_id==max_id and log[i][2]<0:
		max_id=findMaxId(id_x)
	elif id_x[max_id]<id_x[cur_id] or (id_x[max_id]==id_x[cur_id] and max_id>cur_id):
		max_id=cur_id
print id_t.index(max(id_t))+1

Buggy python submission (verdict: Time Limit Exceeded):
n,r,l=map(int,raw_input().split())
log=[map(int,raw_input().split()) for i in range(r)]
log.insert(0,[1,0,0])
log.append([1,l,0])
id_t=[0]*n
id_x=[0]*n
max_id=0
for i in range(1,r+2):
	cur_id=log[i][0]-1
	id_t[max_id]+=log[i][1]-log[i-1][1]
	id_x[cur_id]+=log[i][2]
	if log[i][2]<0:
		max_id=id_x.index(max(id_x))
	elif id_x[max_id]<id_x[cur_id] or (id_x[max_id]==id_x[cur_id] and max_id>cur_id):
		max_id=cur_id
print id_t.index(max(id_t))+1

Fixed submission:
def findMaxId(id_x):
	max_x=0
	max_id=0
	for i in range(n):
		if id_x[i]>max_x:
			max_x=id_x[i]
			max_id=i
	return max_id
	
n,r,l=map(int,raw_input().split())
log=[map(int,raw_input().split()) for i in range(r)]
log.insert(0,[1,0,0])
log.append([1,l,0])
id_t=[0]*n
id_x=[0]*n
max_id=0
for i in range(1,r+2):
	cur_id=log[i][0]-1
	id_t[max_id]+=log[i][1]-log[i-1][1]
	id_x[cur_id]+=log[i][2]
	if cur_id==max_id and log[i][2]<0:
		max_id=findMaxId(id_x)
	elif id_x[max_id]<id_x[cur_id] or (id_x[max_id]==id_x[cur_id] and max_id>cur_id):
		max_id=cur_id
print id_t.index(max(id_t))+1
Buggy python submission (verdict: Runtime Error):
s = sum(map(int, raw_input().split())
t = sum(map(int, raw_input().split())
print max(s,t)

Fixed submission:
s = map(int, raw_input().split())
t = map(int, raw_input().split())
print max(sum(s),sum(t))
Buggy python submission (verdict: Runtime Error):
ref = set[i for i in range(1,31)]
for i in range(28):
    ls.append(i)
print "".join(map(str, sorted(list(ref-set(ls)))))

Fixed submission:
ref = [i for i in range(1,31)]
for i in range(28):
    ref.remove(int(raw_input()))
for i in ref:
    print i

Buggy python submission (verdict: Runtime Error):
ref = [i for i in range(1,31)]
for i in range(28):
    ref.pop(int(raw_input())-1)
for i in ref:
    print i

Fixed submission:
ref = [i for i in range(1,31)]
for i in range(28):
    ref.remove(int(raw_input()))
for i in ref:
    print i
Buggy python submission (verdict: Runtime Error):
dic="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
code=raw_input()
ans=""
for w in code:
	ans+=dic[(dic.index(w)+24)%27]
print ans
		

Fixed submission:
print "".join([chr((ord(w)-42)%26+65) for w in raw_input()])
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
deck = [i for i in range(1,2*n+1)]
m = int(raw_input())
for i in range(m):
    k = int(raw_input())
    if k == 0:
        deck1 = []
        for j in range(n):
            deck1 += deck[i]+deck[n+i]
        deck = deck1
    elif:
       deck = deck[k+1:]+deck[:k+1]
for i in deck:
    print deck

Fixed submission:
n = int(raw_input())
d = [i for i in range(1,2*n+1)]
m = int(raw_input())
for i in range(m):
    k = int(raw_input())
    if k == 0:
        for j in range(n):
            d += [d[j]]+[d[n+j]]
        d = d[2*n:]
    else:
        d = d[k:]+d[:k]
for i in d:
    print i
Buggy python submission (verdict: Time Limit Exceeded):
def solve(x,y):
	if x == a and y == b: return 1
	if x > a or y > b or [x,y] in block: return 0
	return solve(x+1,y) + solve(x,y+1)
	
while 1:
	a,b = map(int,raw_input().split())
	if a == 0: break
	block = [map(int,raw_input().split()) for i in range(input())]
	print solve(1,1)

Fixed submission:
while 1:
	a,b = map(int,raw_input().split())
	if a == 0: break
	block = [map(int,raw_input().split()) for i in range(input())]
	road = [[0]*(a+1) for i in range(b+1)]
	road[1][1] = 1
	for bi in range(1,b+1):
		for ai in range(1,a+1):
			if [ai,bi] not in block:
				road[bi][ai] += road[bi-1][ai] + road[bi][ai-1]
	print road[b][a]
Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	n,k=map(int,raw_input().split())
	if n==0:break
	a=[int(raw_input()) for i in range(n)]
	ans=-999999999
	for i in range(n-k):
		ans=max(ans,sum(a[i:i+k]))
	print ans

Fixed submission:
while 1:
	n,k=map(int,raw_input().split())
	if n==0:break
	a=[int(raw_input()) for i in range(n)]
	cur=mx=sum(a[:k])
	for i in range(n-k):
		cur=cur-a[i]+a[i+k]
		mx=max(mx,cur)
	print mx

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	n,k=map(int,raw_input().split())
	if n==0:break
	a=[int(raw_input()) for i in range(n)]
	b=[0]*(n-k)
	for ki in range(k):
		for i in range(n-k):
			b[i]+=a[i+ki]
	print max(b)

Fixed submission:
while 1:
	n,k=map(int,raw_input().split())
	if n==0:break
	a=[int(raw_input()) for i in range(n)]
	cur=mx=sum(a[:k])
	for i in range(n-k):
		cur=cur-a[i]+a[i+k]
		mx=max(mx,cur)
	print mx
Buggy python submission (verdict: Runtime Error):
while 1:
	n,k = map(int,raw_input().split())
	if n == 0: break
	s = [0]*(n+1)
	c = sorted([int(raw_input()) for i in range(k)])
	p = min(0,C[0])
	pre = 0
	for i in c[p:]:
		s[i] = s[i-1] + 1
		if p and s[i-1] == 0:
			if s[i-2]:
				s[i] += s[i-2] + 1 - pre
				pre = s[i-2] + 1
			if s[i-2] == 0:
				pre = 0
	print max(s)

Fixed submission:
while 1:
	n,k = map(int,raw_input().split())
	if n == 0: break
	s = [0]*(n+1)
	c = sorted([int(raw_input()) for i in range(k)])
	p = 1 if c[0] == 0 else 0
	pre = 0
	for i in c[p:]:
		s[i] = s[i-1] + 1
		if p and s[i-1] == 0:
			if s[i-2] > 0:
				s[i] += s[i-2] + 1 - pre
				pre = s[i-2] + 1
			if s[i-2] == 0:
				pre = 0
	print max(s)
Buggy python submission (verdict: Runtime Error):
c = [500,100,50,10,5,1]
while True:
    e = int(raw_input())
    if e == 0: break
    i,m = 0,0
    while e > 0:
        if e >= c[i]:
            e -= c[i]
            count += 1
        else:
            i += 1
    print count

Fixed submission:
c = [500,100,50,10,5,1]
while True:
    e = int(raw_input())
    if e == 0: break
    e = 1000-e
    i,m = 0,0
    while e > 0:
        if e >= c[i]:
            e -= c[i]
            m += 1
        else:
            i += 1
    print m

Buggy python submission (verdict: Runtime Error):
c = [500,100,50,10,5,1]
while True:
    e = 1000 - int(raw_input())
    if e == 0: break
    i,m = 0,0
    while e > 0:
        if e >= c[i]:
            e -= c[i]
            m += 1
        else:
            i += 1
    print m

Fixed submission:
c = [500,100,50,10,5,1]
while True:
    e = int(raw_input())
    if e == 0: break
    e = 1000-e
    i,m = 0,0
    while e > 0:
        if e >= c[i]:
            e -= c[i]
            m += 1
        else:
            i += 1
    print m
Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		ans = 0
		for sp in range(len(t)):
			for L in range(len(t)-sp):
				if t[sp:sp+L] in s:
					ans = max(ans,L)
		print ans
	except:
		break

Fixed submission:
while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		MAXL = sum(min(s.count(i),t.count(i)) for i in set(list(s))&set(list(t)))
		ans = 0
		for sp in range(len(t)):
			if len(t) - sp <= ans:
				break
			for L in range(ans+1,min(MAXL+1,len(t)-sp+1)):
				if t[sp:sp+L] in s:
					ans = L
				else:
					break
		print ans
	except:
		break

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		ans = 0
		for L in range(len(t),0,-1):
			for sp in range(len(t)-L):
				if t[sp:sp+L] in s:
					ans = L
					break
			if ans > 0:
				break
		print ans
	except:
		break

Fixed submission:
while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		MAXL = sum(min(s.count(i),t.count(i)) for i in set(list(s))&set(list(t)))
		ans = 0
		for sp in range(len(t)):
			if len(t) - sp <= ans:
				break
			for L in range(ans+1,min(MAXL+1,len(t)-sp+1)):
				if t[sp:sp+L] in s:
					ans = L
				else:
					break
		print ans
	except:
		break

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	try:
		s,t = raw_input(),raw_input()
		Ls,Lt = len(s),len(t)
		if Ls < Lt:
			s,t,Ls,Lt = t,s,Lt,Ls
		ans = 0
		for d in range(Lt+1):
			L = 0
			for i in range(d):
				if s[i] == t[-d+i]:
					L += 1
				elif L > 0:
					ans = max(ans,L)
					L = 0
			ans = max(ans,L)
		for d in range(Ls):
			L = 0
			for i in range(min(Lt,Ls-d)):
				if s[i+d] == t[i]:
					L += 1
				elif L > 0:
					ans = max(ans,L)
					L = 0
			ans = max(ans,L)
		print ans
	except:
		break

Fixed submission:
while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		MAXL = sum(min(s.count(i),t.count(i)) for i in set(list(s))&set(list(t)))
		ans = 0
		for sp in range(len(t)):
			if len(t) - sp <= ans:
				break
			for L in range(ans+1,min(MAXL+1,len(t)-sp+1)):
				if t[sp:sp+L] in s:
					ans = L
				else:
					break
		print ans
	except:
		break

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		ans = 0
		for sp in range(len(t)):
			for L in range(len(t)-sp):
				if t[sp:sp+L] in s:
					ans = max(ans,L)
				else:
					break
		print ans
	except:
		break

Fixed submission:
while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		MAXL = sum(min(s.count(i),t.count(i)) for i in set(list(s))&set(list(t)))
		ans = 0
		for sp in range(len(t)):
			if len(t) - sp <= ans:
				break
			for L in range(ans+1,min(MAXL+1,len(t)-sp+1)):
				if t[sp:sp+L] in s:
					ans = L
				else:
					break
		print ans
	except:
		break
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
while 1:
	N,M = map(int,raw_input().split())
	if N == 0: break
	P = set([int(raw_input()) for i in range(N)])
	ans = 0
	for i in range(2,5):
		for p in itertools.combinations_with_replacement(P,i):
			if ans < sum(p) <= M:
				ans = sum(p)
	print ans

Fixed submission:
from bisect import *
while 1:
	N,M = map(int,raw_input().split())
	if N == 0: break
	P = [int(raw_input()) for i in range(N)] + [0]
	P = sorted(set(i+j for i in P for j in P))
	s = bisect(P,M) - 1
	print max(i + P[bisect(P,M-i) - 1] for i in P[:s])

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import *
while 1:
	N,M = map(int,raw_input().split())
	if N == 0: break
	P = [int(raw_input()) for i in range(N)] + [0]
	P = sorted([i+j for i in P for j in P])
	s = bisect(P,M) - 1
	print max(i + P[bisect(P,M-i) - 1] for i in P[:s])

Fixed submission:
from bisect import *
while 1:
	N,M = map(int,raw_input().split())
	if N == 0: break
	P = [int(raw_input()) for i in range(N)] + [0]
	P = sorted(set(i+j for i in P for j in P))
	s = bisect(P,M) - 1
	print max(i + P[bisect(P,M-i) - 1] for i in P[:s])
Buggy python submission (verdict: Runtime Error):
w, k = [],[]
for i in range(10):
    w.append(int(raw_input())
for i in range(10):
    k.append(int(raw_input())
print sum(sorted(w)[-3:]),sum(sorted(k)[-3:])

Fixed submission:
a = []
for i in range(20):
    a.append(int(raw_input()))
print sum(sorted(a[:11])[-3:]),sum(sorted(a[11:])[-3:])
Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	n=input()
	if n==0:break
	m=input()
	a=raw_input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		if all([a[i+k]==P[k] for k in range(l)]):c+=1
	print c
	

Fixed submission:
while 1:
	n=int(raw_input())
	if n==0:break
	m=int(raw_input())
	a=raw_input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		if a[i:i+l]==P:c+=1
	print c

Buggy python submission (verdict: Runtime Error):
while 1:
	n=input()
	if n==0:break
	m=input()
	a=raw_input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		for k in range(l):
			if a[i+k]!=P[k]
				break
		else:c+=1
	print c
	

Fixed submission:
while 1:
	n=int(raw_input())
	if n==0:break
	m=int(raw_input())
	a=raw_input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		if a[i:i+l]==P:c+=1
	print c

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	n=input()
	if n==0:break
	m=input()
	a=raw_input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		for k in range(l):
			if a[i+k]!=P[k]:
				break
		else:c+=1
	print c
	

Fixed submission:
while 1:
	n=int(raw_input())
	if n==0:break
	m=int(raw_input())
	a=raw_input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		if a[i:i+l]==P:c+=1
	print c

Buggy python submission (verdict: Runtime Error):
while 1:
	n=int(raw_input())
	if n==0:break
	m=int(raw_input())
	a=raw_input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		if a[i:i+l]=P:
	print c
	

Fixed submission:
while 1:
	n=int(raw_input())
	if n==0:break
	m=int(raw_input())
	a=raw_input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		if a[i:i+l]==P:c+=1
	print c
Buggy python submission (verdict: Runtime Error):
print min([input() for i in [1,1,1])+min([input() for i in [1,1]]) -50

Fixed submission:
a=[input() for i in [1]*5]
print min(a[:3])+min(a[3:])-50
Buggy python submission (verdict: Runtime Error):
a=raw_input()
for k in range(len(a)//3,0,-1):
	joi="J"*k+"O"*k+"I"*k
	if joi in a:
		print k
		break
else:
	print 0

Fixed submission:
a=raw_input()
l=len(a)
i=ans=0
while i<l:
	lenj=leno=leni=0
	while i<l and a[i]=="J":
		lenj+=1
		i+=1
	while i<l and a[i]=="O":
		leno+=1
		i+=1
	while i<l and a[i]=="I":
		leni+=1
		i+=1
	if lenj>=leno and leni>=leno:
		ans=max(ans,leno)
print ans

Buggy python submission (verdict: Runtime Error):
a=raw_input()
sp=min(a.count("J"),a.count("I"),a.count("O"))
for k in range(sp,0,-1):
	joi="J"*k+"O"*k+"I"*k
	if joi in a:
		print k
		break
else:
	print 0

Fixed submission:
a=raw_input()
l=len(a)
i=ans=0
while i<l:
	lenj=leno=leni=0
	while i<l and a[i]=="J":
		lenj+=1
		i+=1
	while i<l and a[i]=="O":
		leno+=1
		i+=1
	while i<l and a[i]=="I":
		leni+=1
		i+=1
	if lenj>=leno and leni>=leno:
		ans=max(ans,leno)
print ans
Buggy python submission (verdict: Runtime Error):
import sys
for i, j in sys.stdin:
    print i + j

Fixed submission:
import sys
for inp in sys.stdin:
    i, j = map(int, inp.split())
    print i + j
Buggy python submission (verdict: Runtime Error):
ref = ["","',.!?","abcABC","defDEF","ghiGHI","jklJKL","mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ"]
def inp(s[0],l):
    n = int(s[0])
    p = (l-1)%len(ref[n])
    return ref[n][p]

while 1:
    try:
        ans = ""
        s = ""
        for push in raw_input():
            l = len(s)
            if push == "0":
                if l > 0:
                    ans += inp(s[0],l)
                    s = ""
                else:
                    ans += " "
            elif l == 0 or s[-1] == push:
                s += push
            else:
                ans += inp(s[0],l)
                s = push
        if l > 0:
            ans += " "*l if s[0] == 0 else ans += inp(s[0],l):
        print ans
    except:
        break

Fixed submission:
ref = ["",
       "',.!?",
       "abcABC",
       "defDEF",
       "ghiGHI",
       "jklJKL",
       "mnoMNO",
       "pqrsPQRS",
       "tuvTUV",
       "wxyzWXYZ"]

def inp(s):
    n = int(s[0])
    p = (len(s)-1)%len(ref[n])
    return ref[n][p]

while 1:
    try:
        pushes = raw_input()
    except:
        break
    ans = ""
    s = ""
    for push in pushes:
        l = len(s)
        if push == "0":
            if l > 0: ans += inp(s)
            else: ans += " "
            s = ""
        elif l == 0 or s[-1] == push:
            s += push
        else:
            ans += inp(s)
            s = push
    if l > 0:
        ans += " "*l if s[0] == "0" else inp(s)
    print ans