Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# your code goes here
#binary
n=int(input())
S=[int(i) for i in input().split()]
q=int(input())
T=[int(i) for i in input().split()]
C=0
for i in range(q):
    j=n//2
    b=n//2+1
    while T[i]!=S[j] and b>1:
        if b%2==1:
            b+=1
        b//=2
        if T[i]>S[j]:
            j+=b
        elif T[i]<S[j]:
            j-=b
    if T[i]==S[j]:
        C+=1
    else:
        if T[i]>S[j]:
            j+=b
        else:
            j-=b
        if T[i]==S[j]:
            C+=1
 #   print(j)
print(C)

Fixed submission:
# your code goes here
#binary search function
def bi(B0,bA,BI):
    bm=bA[1]+bA[2]
    bm//=2
    if BI[bA[1]]<=B0<=BI[bm]:
        bA=[0,bA[1],bm]
    else:
        bA=[0,bm,bA[2]]
   # print(bA)
    return bA
def bs(B0,BI):
    if B0<BI[0]:
        bA=[0,0,0]
    elif B0>BI[-1]:
        bA=[0,-1,-1]
    else:
        bA=[0,0,len(BI)-1]
        while bA[2]-bA[1]>1:
            bA=bi(B0,bA,BI)
        if B0==BI[bA[1]]:
            bA=[1,bA[1]]
        elif B0==BI[bA[2]]:
            bA=[1,bA[2]]
        else:
            bA=[0,bA[1],bA[2]]
   # print(bA)
    return bA
n=int(input())
S=[int(i) for i in input().split()]
q=int(input())
T=[int(i) for i in input().split()]
c=0
for i in range(q):
    bA=bs(T[i],S)
    if bA[0]==1:
        c+=1
print(c)

Buggy python submission (verdict: Runtime Error):
# your code goes here
#binary
n=int(input())
S=[int(i) for i in input().split()]
q=int(input())
T=[int(i) for i in input().split()]
C=0
for i in range(q):
    j=n//2
    b=n//2
    while T[i]!=S[j] and b>1:
        if b%2==1:
            b+=1
        b//=2
        if T[i]>S[j]:
            j+=b
        elif T[i]<S[j]:
            j-=b
    if T[i]==S[j]:
        C+=1
    else:
        if T[i]>S[j]:
            j+=b
        else:
            j-=b
        if T[i]==S[j]:
            C+=1
 #   print(j)
print(C)

Fixed submission:
# your code goes here
#binary search function
def bi(B0,bA,BI):
    bm=bA[1]+bA[2]
    bm//=2
    if BI[bA[1]]<=B0<=BI[bm]:
        bA=[0,bA[1],bm]
    else:
        bA=[0,bm,bA[2]]
   # print(bA)
    return bA
def bs(B0,BI):
    if B0<BI[0]:
        bA=[0,0,0]
    elif B0>BI[-1]:
        bA=[0,-1,-1]
    else:
        bA=[0,0,len(BI)-1]
        while bA[2]-bA[1]>1:
            bA=bi(B0,bA,BI)
        if B0==BI[bA[1]]:
            bA=[1,bA[1]]
        elif B0==BI[bA[2]]:
            bA=[1,bA[2]]
        else:
            bA=[0,bA[1],bA[2]]
   # print(bA)
    return bA
n=int(input())
S=[int(i) for i in input().split()]
q=int(input())
T=[int(i) for i in input().split()]
c=0
for i in range(q):
    bA=bs(T[i],S)
    if bA[0]==1:
        c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
#dice
D=[int(i) for i in input().split()]
Os=input()
for i in range(len(Os)):
    if Os[i]=="N":
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif Os[i]=="S":
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
elif Os[i]=="E":
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
elif Os[i]=="W":
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t        
print(D[0])

Fixed submission:
#dice
D=[int(i) for i in input().split()]
Os=input()
for i in range(len(Os)):
    if Os[i]=="N":
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif Os[i]=="S":
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
    elif Os[i]=="E":
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
    elif Os[i]=="W":
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t        
print(D[0])
Buggy python submission (verdict: Runtime Error):
our code goes here
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
        for j in range(W):
            S+="#"
        print(S)
    S=""
    for j in range(W):
        S+="#"
    print(S, end="")
    H,W=(int(i) for i in input().split())
    if H!=0 or W!=0:
        print("\n")

Fixed submission:
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
        for j in range(W):
            S+="#"
        print(S)
    S=""
    for j in range(W):
        S+="#"
    print(S, end="")
    H,W=(int(i) for i in input().split())
  #  if H!=0 or W!=0:
    print("\n")

Buggy python submission (verdict: Runtime Error):
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
    for j in range(W):
            S+="#"
        print(S)
for j in range(W):
            S+="#"
        print(S, end=??????)
    H,W=(int(i) for i in input().split())
    if H!=0 or W!=0:
    print("\n")

Fixed submission:
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
        for j in range(W):
            S+="#"
        print(S)
    S=""
    for j in range(W):
        S+="#"
    print(S, end="")
    H,W=(int(i) for i in input().split())
  #  if H!=0 or W!=0:
    print("\n")

Buggy python submission (verdict: Runtime Error):
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
        for j in range(W):
            S+="#"
        print(S)
    for j in range(W):
        S+="#"
    print(S, end=??????)
    H,W=(int(i) for i in input().split())
    if H!=0 or W!=0:
        print("\n")

Fixed submission:
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
        for j in range(W):
            S+="#"
        print(S)
    S=""
    for j in range(W):
        S+="#"
    print(S, end="")
    H,W=(int(i) for i in input().split())
  #  if H!=0 or W!=0:
    print("\n")

Buggy python submission (verdict: Runtime Error):
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
        for j in range(W):
            S+="#"
        print(S)
    for j in range(W):
        S+="#"
    print(S, end="")
    H,W=(int(i) for i in input().split())
    if H!=0 or W!=0:
        print("\n")

Fixed submission:
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
        for j in range(W):
            S+="#"
        print(S)
    S=""
    for j in range(W):
        S+="#"
    print(S, end="")
    H,W=(int(i) for i in input().split())
  #  if H!=0 or W!=0:
    print("\n")
Buggy python submission (verdict: Runtime Error):
#15frame  
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H):
        S=""
    for j in range(W):
            S+="#"
        print(S)
    for i in range(H-2):
        S="#"
        for i in range(W-2):
            S+="."
        S+="#"
        print(S)
    S=""
    for i in range(W):
        S+="#"
    print(S)
    H,W=(int(i) for i in input().split())
    if H!=0 or W!=0:
    print("\n")

Fixed submission:
# your code goes here
#15frame  
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    S=""
    for i in range(W):
        S+="#"
    print(S)
    for i in range(H-2):
        S="#"
        for i in range(W-2):
            S+="."
        S+="#"
        print(S)
    S=""
    for i in range(W):
        S+="#"
    print(S,end="")
    H,W=(int(i) for i in input().split())
  #  if H!=0 or W!=0:
    print("\n")
Buggy python submission (verdict: Time Limit Exceeded):
#16Bmissing
def mn(li):
    if li[0]== "S":
        c[0]=0
    elif li[0]== "H":
        li[0]=1
    elif li[0]== "C":
        li[0]=2
    elif li[0]== "D":
        li[0]=3
    li[1]=int(li[1])
    return li
def nm(nu):
    if nu==0:
        co="S"
    elif nu==1:
        co="H"
    elif nu==2:
        co="C"
    elif nu==3:
        co="D"
#    co+=??? ???+str(li[1])
    return co
N=int(input())
m=[[]]
for i in range(N-1):
    c=[j for j in input().split()]
    c=mn(c)
    for j in range(2):
        m[i].append(c[j])
    m.append([])
c=[j for j in input().split()]
c=mn(c)
for j in range(2):
    m[N-1].append(c[j])
m.sort()
i=0
j=0
l=1
#print(m)
while i < N:
    while m[i][0]!=j:
        for k in range(1,14):
            print(nm(m[i][0])+" "+str(k))
        j+=1
  #  print(i)
    while m[i][1]!=l:
        print(nm(m[i][0])+" "+str(l))
        l+=1
    l+=1
    if l>13:
        l=1
        j+=1
    i+=1

Fixed submission:
#16Bmissing
def mn(li):
    if li[0]== "S":
        c[0]=0
    elif li[0]== "H":
        li[0]=1
    elif li[0]== "C":
        li[0]=2
    elif li[0]== "D":
        li[0]=3
    li[1]=int(li[1])
    return li
def nm(nu):
    if nu==0:
        co="S"
    elif nu==1:
        co="H"
    elif nu==2:
        co="C"
    elif nu==3:
        co="D"
#    co+=??? ???+str(li[1])
    return co
T=[]
for i in range(4):
    T.append([])
    for j in range(14):
        T[i].append(0)
N=int(input())
for i in range(N):
    c=[j for j in input().split()]
    c=mn(c)
  #  print(c)
    T[c[0]][c[1]]=1
#print(T)
for i in range(4):
    for j in range(1,14):
        if T[i][j]==0:
            print(nm(i)+" "+str(j))
Buggy python submission (verdict: Runtime Error):
x = input()
print(x ** 3)



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

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



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

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



Fixed submission:
x = int(input())
print(x ** 3)
Buggy python submission (verdict: Runtime Error):
s = input()
ss = s.plit(" ")
a = int(ss[0])
b = int(ss[1])
print("{} {}".format(a*b, 2*(a+b))



Fixed submission:
s = input()
ss = s.split(" ")
a = int(ss[0])
b = int(ss[1])
print("{} {}".format(a*b, 2*(a+b)))
Buggy python submission (verdict: Runtime Error):
x = input()
s = x % 60
x //= 60
m = x % 60
x //= 60
print("{}:{}:{}".format(x, m, s))


Fixed submission:
x = int(input())
s = x % 60
x //= 60
m = x % 60
x //= 60
print("{}:{}:{}".format(x, m, s))
Buggy python submission (verdict: Runtime Error):
while True:
   print("Case 1: " + input())


Fixed submission:
c = 1
while True:
   i = input()
   if i == "0":
      quit()
   print("Case {}: {}".format(c, i))
   c += 1
Buggy python submission (verdict: Runtime Error):
n = input()
S = map(int,raw_input().split())
m = input()
T = map(int,raw_input().split())
print len(T & S)

Fixed submission:
n = input()
S = set([int(s) for s in raw_input().split()])
m = input()
T = set([int(s) for s in raw_input().split()])
print len(S&T)

Buggy python submission (verdict: Runtime Error):
n = input()
S = set([int(s) for s in raw_input().split()])
m = input()
T = set([int(s) for s in raw_input().split()])

r=[]
def binarySearch(a=[],p=0):
	ll=0
	ul=len(a)
	
	while(True):
		if ll>ul:
			return -1
		ms=(int(ll)+int(ul))/2

		if a[i]==p:
			r.append(p)
		elif a[i]>p:
			ul=i-1
		else:
			ll=i+1






if __name__=="__main__":
	for i in T:
		binarySearch(S,i)

	print len(r)

Fixed submission:
n = input()
S = set([int(s) for s in raw_input().split()])
m = input()
T = set([int(s) for s in raw_input().split()])
print len(S&T)

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

Fixed submission:
n = input()
S = set([int(s) for s in raw_input().split()])
m = input()
T = set([int(s) for s in raw_input().split()])
print len(S&T)

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

Fixed submission:
n = input()
S = set([int(s) for s in raw_input().split()])
m = input()
T = set([int(s) for s in raw_input().split()])
print len(S&T)
Buggy python submission (verdict: Runtime Error):
def keta_sum(n):
	a = int(n*0.001)
	b = int(n*0.01) % 10
	c = int(n*0.1) % 10
	d = n % 10
	return a+b+c+d

while 2>1:
	n_try = int(raw_input())
	count = 0
	for n in range(10000):
		if n_try == keta_sum(n):
			count += 1
	print count

Fixed submission:
def keta_sum(n):
	a = int(n*0.001)
	b = int(n*0.01) % 10
	c = int(n*0.1) % 10
	d = n % 10
	return a+b+c+d

while 2>1:
	try:
		n_try = int(raw_input())
		count = 0
		for n in range(10000):
			if n_try == keta_sum(n):
				count += 1
		print count
	except EOFError:
		break
	except ValueError:
		break
Buggy python submission (verdict: Runtime Error):
line_num = int(raw_input())
for n in range(line_num):
	a = raw_input()
	b = raw_input()
	ov = 0
	if len(a) > 80 or len(b) > 80:
		print 'overflow'
		ov = 1
	filled_a, filled_b = a.zfill(80), b.zfill(80)
	rlist_a = map(int,list(filled_a)[::-1])
	rlist_b = map(int,list(filled_b)[::-1])
	rlist_sum = []
	for n in range(80):
		rlist_sum.append(rlist_a[n]+rlist_b[n])
	for n in range(79):
		if rlist_sum[n] > 9:
			rlist_sum[n] -= 10
			rlist_sum[n+1] += 1
	if rlist_sum[79] > 9:
		if ov < 1:
			print 'overflow'
	else
		list_sum = []
		f = 0
		for n in rlist_sum[::-1]:
			if f > 0:
				list_sum.append(n)
			else:
				if n > 0:
					f = 1
					list_sum.append(n)
		print ''.join(map(str,list_sum))

Fixed submission:
line_num = int(raw_input())
for n in range(line_num):
	a = raw_input()
	b = raw_input()
	if len(a) > 80 or len(b) > 80:
		print 'overflow'
	else:
		filled_a, filled_b = a.zfill(80), b.zfill(80)
		rlist_a = map(int,list(filled_a)[::-1])
		rlist_b = map(int,list(filled_b)[::-1])
		rlist_sum = []
		for n in range(80):
			rlist_sum.append(rlist_a[n]+rlist_b[n])
		for n in range(79):
			if rlist_sum[n] > 9:
				rlist_sum[n] -= 10
				rlist_sum[n+1] += 1
		if rlist_sum[79] > 9:
			print 'overflow'
		else:
			list_sum = []
			f = 0
			for n in rlist_sum[::-1]:
				if f > 0:
					list_sum.append(n)
				else:
					if n > 0:
						f = 1
						list_sum.append(n)
			ans = ''.join(map(str,list_sum))
			if len(ans) < 1:
				print '0'
			else:
				print ans
Buggy python submission (verdict: Runtime Error):
while True:
    a = list(map(int, (input().split())))
    a = sorted(a, reverse=True)
    for i in range(4): print(a[i],end=' ')
    print(a[4])


Fixed submission:
a = list(map(int, (input().split())))
a = sorted(a, reverse=True)
for i in range(4): print(a[i],end=' ')
print(a[4])
Buggy python submission (verdict: Runtime Error):
#import math

listc = []
listd = {}
answer = []
n = 0

while True:
    s = input()
    if not s:
        break
    else:
        n += 1
        c,d = map(int,s.split(','))
    if c in listc:
        listd[c] += 1
    else:
        listc.append(c)
        listd[c] = 1

while n > 0:
    n -= 1
    c,d = map(int,input().split(','))
    if c in listc:
        if not c in answer:
            answer.append(c)
        listd[c] += 1

answer.sort()
for i in answer:
    print(i,listd[i])


Fixed submission:
#import math

listc = [0]*1001
cnt = [0]*1001
n = 0

while True:
    try:
        c, d = list(map(int, input().split(',')))
    except:
        break
    listc[c] = 1
    cnt[c] += 1

while True:
    try:
        c, d = list(map(int, input().split(',')))
    except:
        break
    if listc[c] == 1:
        listc[c] = 2
    cnt[c] += 1

for c in range(1,1001):
    if listc[c] == 2:
        print(c,cnt[c])
Buggy python submission (verdict: Runtime Error):
#import math

while True:
    w = []
    k = []
    for i in range(10):
        w.append(int(input()))
    for i in range(10):
        k.append(int(input()))
    w.sort()
    w.reverse()
    k.sort()
    k.reverse()
    print(w[0]+w[1]+w[2],k[0]+k[1]+k[2])


Fixed submission:
w = [int(input()) for i in range(10)]
k = [int(input()) for i in range(10)]
w.sort()
k.sort()
print(sum(w[-3:]),sum(k[-3:]))

Buggy python submission (verdict: Runtime Error):
#import math

while True:
    w = []
    k = []
    for i in range(10):
        w.append(int(input()))
    for i in range(10):
        k.append(int(input()))
    w.sort()
    k.sort()
    print(sum(w[-3:]),sum(k[-3:]))


Fixed submission:
w = [int(input()) for i in range(10)]
k = [int(input()) for i in range(10)]
w.sort()
k.sort()
print(sum(w[-3:]),sum(k[-3:]))

Buggy python submission (verdict: Runtime Error):
#import math

while True:
    w = []
    k = []
    for i in range(10):
        w.append(int(input()))
    for i in range(10):
        k.append(int(input()))
    w.sort()
    k.sort()
    print(sum(w[7:]),sum(k[7:]))


Fixed submission:
w = [int(input()) for i in range(10)]
k = [int(input()) for i in range(10)]
w.sort()
k.sort()
print(sum(w[-3:]),sum(k[-3:]))
Buggy python submission (verdict: Runtime Error):
s = []
while 1:
    a = raw_input()
    if a == "-":
        break
    n = input()
    for i in range(n):
        m = input()
        a = a[m:] + a[:m]
    print a
    

Fixed submission:
import math

x1, y1, x2, y2 = map(float, raw_input().split())
n = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) 
print n
Buggy python submission (verdict: Runtime Error):
n=input()
for i in range(n):
    a=input()
    b=input()
    if str(a+b)>80:
        print overflow
    else:
        print a+b

Fixed submission:
n=input()
for i in range(n):
    a=input()
    b=input()
    if len(str(a+b))>80:
        print "overflow"
    else:
        print a+b
Buggy python submission (verdict: Runtime Error):
d1={
" ":"101",
"'":"000000",
",":"000011",
"-":"10010001",
".":"010001",
"?":"000001",
"A":"100101",
"B":"10011010",
"C":"0101",
"D":"0001",
"E":"110",
"F":"01001",
"G":"10011011",
"H":"010000",
"I":"0111",
"J":"10011000",
"K":"0110",
"L":"00100",
"M":"10011001",
"N":"10011110",
"O":"00101",
"P":"111",
"Q":"10011111",
"R":"1000",
"S":"00110",
"T":"00111",
"U":"10011100",
"V":"10011101",
"W":"000010",
"X":"10010010",
"Y":"10010011",
"Z":"10010000"}
d2={
"00000":"A",
"00001":"B",
"00010":"C",
"00011":"D",
"00100":"E",
"00101":"F",
"00110":"G",
"00111":"H",
"01000":"I",
"01001":"J",
"01010":"K",
"01011":"L",
"01100":"M",
"01101":"N",
"01110":"O",
"01111":"P",
"10000":"Q",
"10001":"R",
"10010":"S",
"10011":"T",
"10100":"U",
"10101":"V",
"10110":"W",
"10111":"X",
"11000":"Y",
"11001":"Z",
"11010":" ",
"11011":".",
"11100":",",
"11101":"-",
"11110":"'",
"11111":"?"}
while 1:
    s=raw_input()
    s1,ans="",""
    for w in s:
        s1+=d1[w]
    s1+="0"*(5-len(s1)%5)
    for i in range(len(s1)/5):
        ans+=d2[s1[:5]]
        s1=s1[5:]
    print ans

Fixed submission:
d1={
" ":"101",
"'":"000000",
",":"000011",
"-":"10010001",
".":"010001",
"?":"000001",
"A":"100101",
"B":"10011010",
"C":"0101",
"D":"0001",
"E":"110",
"F":"01001",
"G":"10011011",
"H":"010000",
"I":"0111",
"J":"10011000",
"K":"0110",
"L":"00100",
"M":"10011001",
"N":"10011110",
"O":"00101",
"P":"111",
"Q":"10011111",
"R":"1000",
"S":"00110",
"T":"00111",
"U":"10011100",
"V":"10011101",
"W":"000010",
"X":"10010010",
"Y":"10010011",
"Z":"10010000"}
d2={
"00000":"A",
"00001":"B",
"00010":"C",
"00011":"D",
"00100":"E",
"00101":"F",
"00110":"G",
"00111":"H",
"01000":"I",
"01001":"J",
"01010":"K",
"01011":"L",
"01100":"M",
"01101":"N",
"01110":"O",
"01111":"P",
"10000":"Q",
"10001":"R",
"10010":"S",
"10011":"T",
"10100":"U",
"10101":"V",
"10110":"W",
"10111":"X",
"11000":"Y",
"11001":"Z",
"11010":" ",
"11011":".",
"11100":",",
"11101":"-",
"11110":"'",
"11111":"?"}
while 1:
    try:
        s=raw_input()
    except EOFError:
        break
    s1,ans="",""
    for w in s:
        s1+=d1[w]
    if len(s1)%5!=0:
        s1+="0"*(5-len(s1)%5)
    for i in range(len(s1)/5):
        ans+=d2[s1[:5]]
        s1=s1[5:]
    print ans
Buggy python submission (verdict: Runtime Error):
import math

def is_prime(n):
    sqrtn = math.ceil(math.sqrt(n))
    for i in range(2, sqrtn + 1):
        if n % i == 0:
            return False
    return n != 1

n = int(input())
answer = 0
for _ in range(0, n+1):
    m = int(input())
    if is_prime(m):
        print(m)
        answer = answer + 1
print(answer)


Fixed submission:
def witness(a, n, t, u):
    x = pow(a, u, n)  # x0 = a^u mod nを計算

    for _ in range(0, t):
        y = (x * x) % n

        # 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る
        if y == 1 and x != 1 and x != (n - 1):
            return True
        x = y
    return y != 1

def is_probably_prime(n, witnesses):
    t = 1
    u = n >> 1
    while u & 1 == 0:
        t = t + 1
        u >>= 1
    assert(2**t * u == n - 1)

    for a in witnesses:
        if a < n and witness(a, n, t, u):
            return False
    return True

def is_definitely_prime(n):
    if ((not (n & 1)) and n != 2) or (n < 2) or ((n % 3 == 0) and (n != 3)):
        return False
    elif n <= 3:
        return True
    else:
        return is_probably_prime(n, [2, 7, 61])


n = int(input())
answer = 0
for _ in range(0, n):
    m = int(input())
    if is_definitely_prime(m):
        answer = answer + 1
print(answer)

Buggy python submission (verdict: Runtime Error):
def witness(a, n, t, u):
    x = pow(a, u, n)  # x0 = a^u mod nを計算
    y = x

    for _ in range(0, t):
        y = (x * x) % n

        # 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る
        if y == 1 and x != 1 and x != (n - 1):
            return True
        x = y
    return y != 1

def is_probably_prime(n, witnesses):
    t = 1
    u = n >> 1
    while u & 1 == 0:
        t = t + 1
        u >>= 1
    assert(2**t * u == n - 1)

    for a in witnesses:
        if a < n and witness(a, n, t, u):
            return False
    return True

def is_definitely_prime(n):
    '''
    if ((not (n & 1)) and n != 2) or (n < 2) or ((n % 3 == 0) and (n != 3)):
        return False
    elif n <= 3:
        return True
    else:
    '''
    return is_probably_prime(n, [2, 7, 61])

n = int(input())
answer = 0
for _ in range(0, n):
    m = int(input())
    if is_definitely_prime(m):
        answer = answer + 1
print(answer)


Fixed submission:
def witness(a, n, t, u):
    x = pow(a, u, n)  # x0 = a^u mod nを計算

    for _ in range(0, t):
        y = (x * x) % n

        # 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る
        if y == 1 and x != 1 and x != (n - 1):
            return True
        x = y
    return y != 1

def is_probably_prime(n, witnesses):
    t = 1
    u = n >> 1
    while u & 1 == 0:
        t = t + 1
        u >>= 1
    assert(2**t * u == n - 1)

    for a in witnesses:
        if a < n and witness(a, n, t, u):
            return False
    return True

def is_definitely_prime(n):
    if ((not (n & 1)) and n != 2) or (n < 2) or ((n % 3 == 0) and (n != 3)):
        return False
    elif n <= 3:
        return True
    else:
        return is_probably_prime(n, [2, 7, 61])


n = int(input())
answer = 0
for _ in range(0, n):
    m = int(input())
    if is_definitely_prime(m):
        answer = answer + 1
print(answer)
Buggy python submission (verdict: Runtime Error):
while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [map(int,input().split()) for i in range(n)]:
    a=str(a)
    if a in L:
      d=b*c
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a] >= 1e6:
      print(a)
      f=0
  if f:print('NA')

Fixed submission:
while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [input().split() for i in range(n)]:
    d=int(b)*int(c)
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a]>=1e6:print(a);f=0
  if f:print('NA')

Buggy python submission (verdict: Runtime Error):
while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [input().split() for i in range(n)]:
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a]>=1e6:
      print(a)
      f=0
  if f:print('NA')

Fixed submission:
while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [input().split() for i in range(n)]:
    d=int(b)*int(c)
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a]>=1e6:print(a);f=0
  if f:print('NA')
Buggy python submission (verdict: Runtime Error):
while(1):print(oct(n)[2:].translate(str.maketrans('4567', '5789')))

Fixed submission:
while(1):
  n = int(input())
  if n == 0:
    break
  print(oct(n)[2:].translate(str.maketrans('4567', '5789')))
Buggy python submission (verdict: Runtime Error):
import sys
print(sys.stdin.read().split().count(input()))

Fixed submission:
import sys
w=input().upper()
print(sys.stdin.read().upper().split().count(w))