Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
while True:
	n,x = map(int,raw_input().split())
	if n==x==0:
		break
	count=0
	for i in xrange(1,n):
		for j in xrange(i,n)
			for k in xrange(j,n):
				if i+j+k==x:
					count+=1
	print count

Fixed submission:
while True:
	n,x = map(int,raw_input().split())
	if n==x==0:
		break
	ans=0
	for i in xrange(1,n+1):
		for j in xrange(i+1,n+1):
			for k in xrange(j+1,n+1):
				if i+j+k==x:
					ans+=1
	print ans
Buggy python submission (verdict: Runtime Error):
while 1:
    a, b = map(int, raw_input().split())
    if not a and not b:
        break
    if a < b:
        print "%d %d" %(a, b)
    else:
        print "%d &d" %(b, a)

Fixed submission:
while True:
	a,b = map(int,raw_input().split())
	if a == b == 0:
		break
	if a < b:
		print '%d %d' % (a,b)
	else:
		print '%d %d' % (b,a)

Buggy python submission (verdict: Runtime Error):
while 1:
    a, b = map(int, raw_input().split())
    if not a and not b:
        break
    if a < b:
        print "%d %d" % (a, b)
    else:
        print "%d &d" % (b, a)

Fixed submission:
while True:
	a,b = map(int,raw_input().split())
	if a == b == 0:
		break
	if a < b:
		print '%d %d' % (a,b)
	else:
		print '%d %d' % (b,a)
Buggy python submission (verdict: Runtime Error):
a,b = map(int, raw_input.split())
print'%d %d %f,a/b, a%b, float(a/b)'

Fixed submission:
a,b = map(int,raw_input().split())
print '%d %d %f' % (a/b,a%b,float(a)/b)
Buggy python submission (verdict: Runtime Error):
n = input()                               #読み込むよ!
a = map(int,raw_input().split())
a.reverse()                               #reveres関数を使うよ!
print ' '.join(map(str,a))             #joinで結合だったよね!

Fixed submission:
n = int(raw_input())
a = map(int,raw_input().split())
a.reverse()
print ' '.join(map(str,a))
Buggy python submission (verdict: Runtime Error):
card = {}
n = int(raw_input())
for i in xrange(n):
    cards[raw_input] = True
mark = 'SHCD'
for j in mark:
    for n in range(1,14):
        if card not in cards:
            print j + ' ' + n
    

Fixed submission:
cards = {}
n = int(raw_input())
for i in xrange(n):
    cards[raw_input()] = True
for j in 'SHCD':
    for n in xrange(1,14):
        card = j + ' ' + str(n)
        if card not in cards:
            print card
Buggy python submission (verdict: Runtime Error):
# Author:      kira924age
while True:
    m, f, r = map(raw_input().split())
    if m == f == r == -1:
        break;
    if m+f < 30 or m == -1 or f == -1:
        print 'F'
    elif 80 <= m+f:
        print 'A'
    elif 65 <= m+f < 80:
        print 'B'
    elif 50 <= m+f < 65 or (30 <= m+f < 50 and 50 <= r):
        print 'C'
    else:
        print 'D'

Fixed submission:
while True:
	m,f,r = map(int,raw_input().split())
	if m==f==r==-1:
		break
	if m == -1 or f == -1 or m+f < 30:
		print 'F'
	elif m+f >= 80:
		print 'A'
	elif 80 > m+f >= 65:
		print 'B'
	elif 65 > m+f >= 50:
		print 'C'
	elif 50 > m+f >= 30:
		if r < 50:
			print 'D'
		else:
			print 'C'
Buggy python submission (verdict: Runtime Error):
s = raw_input()
l = []
while 1:
    x = raw_input()
    if x == 'END_OF_TEXT':
        break
    l += x.lower().split()
print l.count(w)

Fixed submission:
s = raw_input()
l =[]
while True:
	x = raw_input()
	if x == 'END_OF_TEXT':
		break
	l += x.lower().split()
print l.count(s)

Buggy python submission (verdict: Runtime Error):
s = raw_input()
l =[]
while True:
	x = raw_input()
	if x == 'END_OF_TEXT':
		break
	l.append(x.lower.split())
print l.count(s)

Fixed submission:
s = raw_input()
l =[]
while True:
	x = raw_input()
	if x == 'END_OF_TEXT':
		break
	l += x.lower().split()
print l.count(s)
Buggy python submission (verdict: Runtime Error):
while True:
	s = raw_inut()
	if s == '-':
		break
	n = int(raw_input())
	for i in xrange(n):
		m = int(raw_input())
		s = s[m:] + s[:m]
	print s

Fixed submission:
while True:
	s = raw_input()
	if s == '-':
		break
	n = int(raw_input())
	for i in xrange(n):
		m = int(raw_input())
		s = s[m:] + s[:m]
	print s
Buggy python submission (verdict: Runtime Error):
import math
a,b,C = map(float,raw_input().split())
C = C/180 + math.pi

S = a*b*math.sin(C)/2.0;
L = a + b + sqrt(pow(b*math.sin(C),2.0) + pow(a-b*math.cos(C),2))
h = b*math.sin(C)
print "%f\n%f\n%f\n" % (S,L,h)

Fixed submission:
import math
 
a,b,C = map(float,raw_input().split())
C = C / 180.0 * math.pi

S = a * b * math.sin(C) / 2.0
L = math.sqrt(pow(b * math.sin(C), 2) + pow(a - b * math.cos(C), 2)) + a + b
h = b * math.sin(C)

print "%f\n%f\n%f\n" % (S,L,h)
Buggy python submission (verdict: Runtime Error):
import math
while Ture:
	n = int(raw_input())
	if n==0:
		break
	sum = 0
	for i in xrange(n):
		s = map(int,raw_input())
		sum += s
	ave = sum/n
	sum = 0
	for i in xnrange(n):
		sum += pow(s[i] - ave,2.0)
	print math.sqrt(sum/n)
	

Fixed submission:
import math
while True:
	n = int(raw_input())
	if n==0:
		break
	s = map(int,raw_input().split())
	ave = sum = 0.0
	for i in xrange(n):
		ave += s[i]
	ave /= n
	for i in xrange(n):
		sum += math.pow(s[i] - ave, 2.0)
	print math.sqrt(sum/n)

Buggy python submission (verdict: Runtime Error):
import math
while True:
	n = int(raw_input())
	if n==0:
		break
	sum = 0
	for i in xrange(n):
		s = map(int,raw_input())
		sum += s
	ave = sum/n
	sum = 0
	for i in xnrange(n):
		sum += pow(s[i] - ave,2.0)
	print math.sqrt(sum/n)
	

Fixed submission:
import math
while True:
	n = int(raw_input())
	if n==0:
		break
	s = map(int,raw_input().split())
	ave = sum = 0.0
	for i in xrange(n):
		ave += s[i]
	ave /= n
	for i in xrange(n):
		sum += math.pow(s[i] - ave, 2.0)
	print math.sqrt(sum/n)

Buggy python submission (verdict: Runtime Error):
import math
while True:
	n = int(raw_input())
	if n==0:
		break
	sum = 0
	for i in xrange(n):
		s = map(int,raw_input().split())
		sum += s[i]
	ave = sum/n
	sum = 0
	for i in xnrange(n):
		sum += pow(s[i] - ave,2.0)
	print math.sqrt(sum/n)
	

Fixed submission:
import math
while True:
	n = int(raw_input())
	if n==0:
		break
	s = map(int,raw_input().split())
	ave = sum = 0.0
	for i in xrange(n):
		ave += s[i]
	ave /= n
	for i in xrange(n):
		sum += math.pow(s[i] - ave, 2.0)
	print math.sqrt(sum/n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
ans = 0
for i in T:
	if i in S:
		ans += 1
print ans

Fixed submission:
n = int(raw_input())
S = set(raw_input().split())
q = int(raw_input())
T = set(raw_input().split())
print len(S&T)

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
S = set(int,raw_input().split())
q = int(raw_input())
T = set(int,raw_input().split())
print len(S&T)

Fixed submission:
n = int(raw_input())
S = set(raw_input().split())
q = int(raw_input())
T = set(raw_input().split())
print len(S&T)
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
ans = 0
for i in q:
	if i in n:
		ans += 1
print ans

Fixed submission:
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
ans = 0
for i in T:
	if i in S:
		ans += 1
print ans

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
ans = 0
for i in q:
	if int(i) in n:
		ans += 1
print ans

Fixed submission:
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
ans = 0
for i in T:
	if i in S:
		ans += 1
print ans

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
ans = 0
for i in T:
	if i in n:
		ans += 1
print ans

Fixed submission:
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
ans = 0
for i in T:
	if i in S:
		ans += 1
print ans
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
taro=hana=0
for i in xrange(n):
	x,y=map(str,raw_input().split())
	if x == y:
		taro += 1
		hana += 1
	elif x < y:
		hana += 3
	else
		taro += 3
print "%d %d\n" % (taro,hana)

Fixed submission:
n = int(raw_input())
taro=hana=0
for i in xrange(n):
	x,y=map(str,raw_input().split())
	if x == y:
		taro += 1
		hana += 1
	elif x < y:
		hana += 3
	else:
		taro += 3
print "%d %d" % (taro,hana)
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
a=int(input())
b=int(input())
print(a+b)

Fixed submission:
n = int(input())

for i in range(n):
    a = int(input())
    b = int(input())

    if (a + b) < (10 ** 80):
        print(a + b)
    else:
        print("overflow")
Buggy python submission (verdict: Runtime Error):
input a;
print a * a * a;

Fixed submission:
print(int(input())**3)

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

Fixed submission:
print(int(input())**3)

Buggy python submission (verdict: Runtime Error):
input a
print "%d", (a * a * a)

Fixed submission:
print(int(input())**3)

Buggy python submission (verdict: Runtime Error):
input a
print "%d" % (a * a * a)

Fixed submission:
print(int(input())**3)

Buggy python submission (verdict: Runtime Error):
a = raw_input()
print "%d"% (a * a * a)

Fixed submission:
print(int(input())**3)

Buggy python submission (verdict: Runtime Error):
a = raw_input()
print (a * a * a)

Fixed submission:
print(int(input())**3)

Buggy python submission (verdict: Runtime Error):
a = int(raw_input())
print(a * a * a)

Fixed submission:
print(int(input())**3)

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

Fixed submission:
print(int(input())**3)
Buggy python submission (verdict: Runtime Error):
r = int(input())
pi = 3.141592653589793238
print(pi * r * r, 2 * pi * r)


Fixed submission:
r = float(input())
pi = 3.1415926535897932384626
print(pi * r * r, 2 * pi * r)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

import math

cnt = 0
m = 0
G = []
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
            A[j+g] = v
    return A
            
def shellSort(A, n):
    global m, G
    m = 1 if int(math.log(n, 2)) == 0 else int(math.log(n, 2)) 
    G = [2**x for x in range(m - 1, -1, -1)]
    for i in range(m):
        A = insertionSort(A, n, G[i])
    return A
    
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
    
A = shellSort(A, n)


print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in range(n):
    print(A[i])

Fixed submission:
# coding: utf-8

import math
import sys

def insertionSort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            ct += 1
            a[j+g] = v
    return ct

n = int(input())
a = list(map(int, sys.stdin.readlines()))
cnt = 0
m = 0
h = 0
g = []

while True:
    h = 3*h + 1
    if h > n:
        break
    g.insert(0, math.ceil(h))

for i in g:
    cnt += insertionSort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(cnt)
print(*a, sep="\n")

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import math
import sys

def insertionSort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and A[j] > v:
            a[j+g] = A[j]
            j = j - g
            ct += 1
            a[j+g] = v
    return ct

n = int(input())
a = list(map(int, sys.stdin.readlines()))
cnt = 0
m = 0
h = 0
g = []

while True:
    h = 3*h + 1
    if h > n:
        break
    g.insert(0, h)

for i in g:
    cnt += insertionSort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(cnt)
print(*a, sep="/n")

Fixed submission:
# coding: utf-8

import math
import sys

def insertionSort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            ct += 1
            a[j+g] = v
    return ct

n = int(input())
a = list(map(int, sys.stdin.readlines()))
cnt = 0
m = 0
h = 0
g = []

while True:
    h = 3*h + 1
    if h > n:
        break
    g.insert(0, math.ceil(h))

for i in g:
    cnt += insertionSort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(cnt)
print(*a, sep="\n")
Buggy python submission (verdict: Runtime Error):
height =[]
inp = ""
while True:
    inp = input()
    if inp == "":break
    else: height.append(int(inp))

height.sort(reverse=True)
for j in range(0,3):
    print(str(height[j]))

Fixed submission:
height =[]
inp = ""
for i in range(0,10):
    inp = input()
    height.append(int(inp))
height.sort(reverse=True)
for i in range(0,3):
    print(str(height[i]))
Buggy python submission (verdict: Runtime Error):
x = map(int, raw_input().split())
print(x[0]*x[1]+' '+(x[0]+x[1])*2)


Fixed submission:
a,b = map(int, input().split())
print(str(a*b)+" "+str(2*(a+b)))

Buggy python submission (verdict: Runtime Error):
x = map(int, raw_input().split())
print(x[0]*x[1]+' '+(x[0]+x[1])*2)


Fixed submission:
a,b = map(int, input().split())
print(str(a*b)+" "+str(2*(a+b)))

Buggy python submission (verdict: Runtime Error):
a,b = map(int, raw_input().split())
print x[0]*x[1],(x[0]+x[1])*2


Fixed submission:
a,b = map(int, input().split())
print(str(a*b)+" "+str(2*(a+b)))

Buggy python submission (verdict: Runtime Error):
a,b = map(int, raw_input().split())
print(a*b,(a+b)*2)


Fixed submission:
a,b = map(int, input().split())
print(str(a*b)+" "+str(2*(a+b)))
Buggy python submission (verdict: Runtime Error):
i = 0
while True:
    i += 1
    n = input()
    if (n == 0): break
    print("Case " + str(i) + ": " + str(n))


Fixed submission:
i = 0
while True:
    i += 1
    n = input()
    if (n == "0"): break
    print("Case " + str(i) + ": " + n)
Buggy python submission (verdict: Runtime Error):
for _ in range(int(input())):
    ax, ay, bx, by, cx, cy, dx, dy = map(float, input().split())
    print(['NO','YES'][(by-ay)/(bx-ax)==(dy-cy)/(dx-cx)])

Fixed submission:
for _ in range(int(input())):
    ax, ay, bx, by, cx, cy, dx, dy = map(float, input().split())
    print(['NO','YES'][abs((ay-by)*(dx-cx)-(ax-bx)*(dy-cy))<1e-10])
Buggy python submission (verdict: Runtime Error):
n=1000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
p=[i for i in range(n+1) if p[i]==1]
while 1:
    try:n=int(input())
    except:break
    i=p.index(n)
    print(p[i-1],p[i+1])

Fixed submission:
n=1000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
p=[i for i in range(n+1) if p[i]==1]
while 1:
    try:n=int(input())
    except:break
    for i in range(len(p)):
        if p[i]==n:
            print(p[i-1],p[i+1])
            break 
        elif p[i]>n:
            print(p[i-1],p[i])
            break
Buggy python submission (verdict: Runtime Error):
while 1:
    n,i=int(input()),0
    if n==0:break
    n=str(math.factorial(n))[::-1]
    while n[i]=='0':i+=1
    print(i)

Fixed submission:
import math
while 1:
    n,i=int(input()),0
    if n==0:break
    n=str(math.factorial(n))[::-1]
    while n[i]=='0':i+=1
    print(i)
Buggy python submission (verdict: Runtime Error):
while 1:
    a=[i+1 for i in range(10)]
    try:b=list(map(int,input().split()))
    except:break
    for i in b:a.remove(b)
    print('YES' if sum([1 for i in a if i<=20-sum(b[:2])])/7>=0.5 else 'NO')

Fixed submission:
while 1:
    a=[i+1 for i in range(10)]
    try:b=list(map(int,input().split()))
    except:break
    for i in b:a.remove(i)
    c=sum(b[:2])
    print(['NO','YES'][sum([1 for i in a if c+i<=20])/7>=0.5])
Buggy python submission (verdict: Time Limit Exceeded):
from math import sin,cos,pi
x=[0]*100;y=[0]*100
h=1000
while 1:
    n=int(input())
    if n==0:break
    a=0
    for i in range(n):x[i],y[i]=map(float,input().split(','))
    for i in range(n):
        for j in range(h):
            cx=x[i]+cos(2*pi*j/h)
            cy=y[i]+sin(2*pi*j/h)
            c=0
            for k in range(n):
                if (cx-x[k])*(cx-x[k])+(cy-y[k])*(cy-y[k])<1.0+1e-7:c+=1
            a=max(a,c)
    print(a)

Fixed submission:
import itertools
x=[0.]*100;y=[0.]*100
while 1:
    n=int(input())
    if n==0:break
    a=0
    for i in range(n):x[i],y[i]=map(float,input().split(','))
    for i,j in itertools.product(range(100),range(100)):
            c=0
            for k in range(n):
                if pow(x[k]-(i/10),2)+pow(y[k]-(j/10),2)<=1.01:c+=1
            if c>a:a=c
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
b=[0]*2001
for i in range(1001):
    for j in range(1001):
        b[i+j]+=1
while 1:
    try:n=int(input())
    except:break
    c=0;a=[1000,n][n<1000]
    for i in range(2*a+1):
        for j in range(2*a+1):
            if i+j==n:c+=b[i]*b[j]
    print(c)

Fixed submission:
s=[0]*4001
for i in range(2001):
    a=a+2*(i-999)*(i-1000) if i>1000 else 0
    s[i]=(i+3)*(i+2)*-~i//6-a
    s[4000-i]=s[i]
while 1:
    try:print(s[int(input())])
    except:break
Buggy python submission (verdict: Time Limit Exceeded):
a={}
_,q=map(int,input().split())
for i in range(q):
    b,c=map(int,input().split())
    if b in a:a[b]+=c
    else:a[b]=c
    d=max(a.items(),key=lambda x:x[1])
    if list(a.values()).count(d[1])>1:
        e={}
        for i in a:
            if a[i]==d[1]:e[i]=d[1]
        print(*min(e.items(),key=lambda x:x[0]))
    else:print(*d)

Fixed submission:
n,q=list(map(int, input().split()))
c=[0 for _ in range(n + 1)]
b=[0,0]
for _ in range(q):
    a,v=map(int, input().split())
    c[a]+=v
    if b[0]==a and v>0:b[1]+=v
    elif b[0]==a:mx=max(c[0:]);b[0],b[1]=min([i for i, value in enumerate(c) if value == mx]),mx
    elif b[1]<c[a]:b[0],b[1]=a,c[a]
    elif b[1]==c[a] and b[0] > a:b[0],b[1]=a,c[a]
    print(*b)
Buggy python submission (verdict: Runtime Error):
for _ in [0]*int(input()):
    s=input()
    if s[1]=='\'':
        a=s[2:-1].split('#')
        print(['NA','A'][set(a[0])==set(a[1])=={'='} and len(set(a))==1])
    else:
        s=s[2:-2]
        print(['NA','B'][len(s)==2*s.count('Q=')])

Fixed submission:
for _ in [0]*int(input()):
    s=input()
    a='NA'
    if s[:2]==">'" and s[-1]=='~' and '#' in s:
        s=s[2:-1].split('#')
        a=[a,'A'][set(s[0])==set(s[1])=={'='} and len(set(s))==1]
    elif s[:2]=='>^' and s[-2:]=='~~':
        s=s[2:-2]
        a=['NA','B'][len(s)==2*s.count('Q=') and len(s)>0]
    print(a)

Buggy python submission (verdict: Runtime Error):
for _ in [0]*int(input()):
    s=input()
    if s[:2]=='>\'' and s[-1]=='~':
        a=s[2:-1].split('#')
        print(['NA','A'][set(a[0])==set(a[1])=={'='} and len(set(a))==1])
    elif s[:2]=='>^' and s[-2:]=='~~':
        s=s[2:-2]
        print(['NA','B'][len(s)==2*s.count('Q=')])

Fixed submission:
for _ in [0]*int(input()):
    s=input()
    a='NA'
    if s[:2]==">'" and s[-1]=='~' and '#' in s:
        s=s[2:-1].split('#')
        a=[a,'A'][set(s[0])==set(s[1])=={'='} and len(set(s))==1]
    elif s[:2]=='>^' and s[-2:]=='~~':
        s=s[2:-2]
        a=['NA','B'][len(s)==2*s.count('Q=') and len(s)>0]
    print(a)
Buggy python submission (verdict: Runtime Error):
def score(x):
    s=0;t=1
    for _ in[0]*10:
        a=2;b=3
        if x[t]==10:a=1
        elif x[t]+x[t+1]!=10:b=2
        s+=sum(x[t:t+b]);t+=a
    return x[0],s

while 1:
    n=int(input())
    if n==0:break
    A=sorted([score(map(int,input().split())) for _ in [0]*n])
    for a,b in sorted(A,key=lambda x:-x[1]):print(a,b)

Fixed submission:
def score(x):
    s=0;t=1
    for _ in[0]*10:
        a=2;b=3
        if x[t]==10:a=1
        elif x[t]+x[t+1]!=10:b=2
        s+=sum(x[t:t+b]);t+=a
    return x[0],s

while 1:
    n=int(input())
    if n==0:break
    A=sorted([score(list(map(int,input().split()))) for _ in [0]*n])
    for a,b in sorted(A,key=lambda x:-x[1]):print(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
n=1000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:
        for j in range(i*i,n,i):
            p[j]=0
while 1:
    l=int(input())
    if l==0:break
    ans=-l
    while l:
        l-=1
        a,m=map(int,input().split())
        ans+=sum(p[max(1,a-m)-1:min(n,a+m)])
    print(ans)

Fixed submission:
import bisect
n=1000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(input())
    ans=-n
    if n==0:break
    while n:
        n-=1
        a,m=map(int,input().split())
        ans+=bisect.bisect_left(p,a+m+1)-bisect.bisect_left(p,a-m)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=1000000
p=[1]*(n+1)
pr=[]
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n,i):
            p[j]=0
for i in range(2,n):
    if p[i]:
        pr.append(int(i))
while 1:
    l=int(input())
    if l==0:break
    ans=-l
    while l:
        l-=1
        a,m=map(int,input().split())
        j=0
        while j<len(pr) and pr[j]<=a+m:
            if(pr[j]>=a-m):ans+=1
            j+=1
    print(ans)

Fixed submission:
import bisect
n=1000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(input())
    ans=-n
    if n==0:break
    while n:
        n-=1
        a,m=map(int,input().split())
        ans+=bisect.bisect_left(p,a+m+1)-bisect.bisect_left(p,a-m)
    print(ans)
Buggy python submission (verdict: Runtime Error):
while 1:
    l,r=0,int(input())
    a=[int(input()) for _ in range(r)]
    r-=1;c=0
    k=int(input())
    while l<=r:
        c+=1
        m=(l+r)//2
        if a[m]==k:break
        if a[m]<k:l=m+1
        else:r=m-1
    print(c)

Fixed submission:
while 1:
    l,r=0,int(input())
    if r==0:break
    a=[int(input()) for _ in range(r)]
    r-=1;c=0
    k=int(input())
    while l<=r:
        c+=1
        m=(l+r)//2
        if a[m]==k:break
        if a[m]<k:l=m+1
        else:r=m-1
    print(c)
Buggy python submission (verdict: Runtime Error):
while 1:
    n=int(input())
    if n=='0': break
    for _ in range(n):
        a=list(map(int,input().split()))
        c=sum(a)
        if sum(a[:2])/2>=90 or c/3>=80 or 100 in a: b='A'
        elif c/3>=70 or (c/3>=50 and (a[0]>=80 or a[1]>=80)): b='B'
        else: b='C'
        print(b)

Fixed submission:
while 1:
    n=int(input())
    if n==0: break
    for _ in range(n):
        a=list(map(int,input().split()))
        c=sum(a)
        if sum(a[:2])>179 or c>239 or 100 in a: b='A'
        elif c>209 or (c>149 and max(a[:2])>79): b='B'
        else: b='C'
        print(b)
Buggy python submission (verdict: Time Limit Exceeded):
n=10000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
#p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(input())
    if n==0: break
    for i in range(n,2,-1):
        if (p[i],p[i-2],p[i-6],p[i-8])==(1,1,1,1):
            print(i)
            break

Fixed submission:
n=10000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
#p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(input())
    if n==0: break
    if n<19:print(13)
    else:
        for i in range((n+1)//10*10-1,2,-10):
            if (p[i],p[i-2],p[i-6],p[i-8])==(1,1,1,1):
                print(i)
                break