Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
while n != 0:
    input_list = []
    for x in range(n):
        input_list.append(map(int, raw_input().split(' ')))
    last_list_row = []
    for x in range(n):
        input_list[x].append(sum(input_list[x]))
        print ''.join(map(lambda n:"{:>5}".format(n), input_list))
        last_list.append(input_list[x][-1])

    input_len = len(input_list[0])
    column_list = []
    for x in range(input_len):
        tmp = 0
        for y in range(n):
            tmp += input_list[y][x]
        column_list.append(tmp)
    print ''.join(map(lambda n:"{:>5}".format(n), column_list))
    n = int(raw_input())

Fixed submission:
n = int(raw_input())
while n != 0:
    input_list = []
    for x in range(n):
        input_list.append(map(int, raw_input().split(' ')))
    for x in range(n):
        input_list[x].append(sum(input_list[x]))
        print ''.join(map(lambda n:"{:>5}".format(n), input_list[x]))

    input_len = len(input_list[0])
    column_list = []
    for x in range(input_len):
        tmp = 0
        for y in range(n):
            tmp += input_list[y][x]
        column_list.append(tmp)
    print ''.join(map(lambda n:"{:>5}".format(n), column_list))
    n = int(raw_input())
Buggy python submission (verdict: Runtime Error):
[print(I) for I in sorted([int(input()) for i in range(10)])[2::-1]]

Fixed submission:
a=[]
for i in range(10):
    a.append(input())
a.sort()
a=a[::-1]
a=a[:3]
print(a[0])
print(a[1])
print(a[2])

Buggy python submission (verdict: Runtime Error):
a=[print(I) for I in sorted([int(input()) for i in range(10)])[2::-1]]

Fixed submission:
a=[]
for i in range(10):
    a.append(input())
a.sort()
a=a[::-1]
a=a[:3]
print(a[0])
print(a[1])
print(a[2])

Buggy python submission (verdict: Runtime Error):
a=[print(I) for I in sorted([int(input()) for i in range(10)])[:-4:-1]]

Fixed submission:
a=[]
for i in range(10):
    a.append(input())
a.sort()
a=a[::-1]
a=a[:3]
print(a[0])
print(a[1])
print(a[2])

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

Fixed submission:
a=[]
for i in range(10):
    a.append(input())
a.sort()
a=a[::-1]
a=a[:3]
print(a[0])
print(a[1])
print(a[2])

Buggy python submission (verdict: Runtime Error):
a=[]
for i in range(10):
    a.append(input())
a.sort()
a=a[::-1]
a=a[-4]
print(a[0])
print(a[1])
print(a[2])

Fixed submission:
a=[]
for i in range(10):
    a.append(input())
a.sort()
a=a[::-1]
a=a[:3]
print(a[0])
print(a[1])
print(a[2])
Buggy python submission (verdict: Runtime Error):
import sys
a=[]
for i in sys.stdin:
    a.append(map(int,i.split()))
for i in a:
    print(str(len(str(i[0]+a[1]))))

Fixed submission:
import sys
a=[]
for i in sys.stdin:
    a.append(map(int,i.split()))
for i in a:
    print(str(len(str(i[0]+i[1]))))
Buggy python submission (verdict: Runtime Error):
print(input()[::-1])

Fixed submission:
print(raw_input()[::-1])

Buggy python submission (verdict: Runtime Error):
print(str(input())[::-1])

Fixed submission:
print(raw_input()[::-1])
Buggy python submission (verdict: Runtime Error):
a=sorted(map(int,input().split()))[::-1]
print("%d %d %d %d %d"%tuple(a))

Fixed submission:
a=sorted(map(int,raw_input().split()))[::-1]
print("%d %d %d %d %d"%tuple(a))

Buggy python submission (verdict: Runtime Error):
a=map(int,input().split())
a.sort()
a=a[::-1]
print("%d %d %d %d %d"%tuple(a))

Fixed submission:
a=sorted(map(int,raw_input().split()))[::-1]
print("%d %d %d %d %d"%tuple(a))
Buggy python submission (verdict: Runtime Error):
a=map(int,raw_input().split())
a.sort()
while a[1]%a[0]!=0:
 a,b=b%a,a
return a

Fixed submission:
a=map(int,raw_input().split())
a.sort()
while a[1]%a[0]!=0:
 a[0],a[1]=a[1]%a[0],a[0]
print(a[0])

Buggy python submission (verdict: Runtime Error):
a=map(int,raw_input().split())
a.sort()
while a[1]%a[0]!=0:
 a[0],a[1]=a[1]%a[0],a[0]
return a[0]

Fixed submission:
a=map(int,raw_input().split())
a.sort()
while a[1]%a[0]!=0:
 a[0],a[1]=a[1]%a[0],a[0]
print(a[0])
Buggy python submission (verdict: Runtime Error):
print(input()**3)

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

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

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

Buggy python submission (verdict: Runtime Error):
raw_int(input())**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):
a=input()
print(str(a//3600)+":"+str(a%3600//60)+":"+str(a%60)

Fixed submission:
a=input()
print(str(a//3600)+":"+str(a%3600//60)+":"+str(a%60))

Buggy python submission (verdict: Runtime Error):
a=int(raw_input())
print(str(a//3600)+":"+str(a%3600//60)+":"+str(a%60)

Fixed submission:
a=input()
print(str(a//3600)+":"+str(a%3600//60)+":"+str(a%60))
Buggy python submission (verdict: Runtime Error):
i=0
while True:
 i+=1
 a=input()
 if a==0:
  break
 else:
  print("Case "+str(i)": "+str(a))

Fixed submission:
i=0
while True:
 i+=1
 a=input()
 if a==0:
  break
 else:
  print("Case "+str(i)+": "+str(a))
Buggy python submission (verdict: Runtime Error):
While True:
 a=map(int,input().split())
 if a==[0,0]:
  break
 if a[0]>a[1]:print(str(a[1])+" "+str(a[0]))
 else: print(str(a[0])+" "+str(a[1]))

Fixed submission:
while True:
 a=map(int,raw_input().split())
 if a==[0,0]:
  break
 if a[0]>a[1]:print(str(a[1])+" "+str(a[0]))
 else: print(str(a[0])+" "+str(a[1]))

Buggy python submission (verdict: Runtime Error):
While True:
 a=map(int,raw_input().split())
 if a==[0,0]:
  break
 if a[0]>a[1]:print(str(a[1])+" "+str(a[0]))
 else: print(str(a[0])+" "+str(a[1]))

Fixed submission:
while True:
 a=map(int,raw_input().split())
 if a==[0,0]:
  break
 if a[0]>a[1]:print(str(a[1])+" "+str(a[0]))
 else: print(str(a[0])+" "+str(a[1]))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
d=0
for i in range(a,b+1):
    if c%i==0:
        d+=1

Fixed submission:
a,b,c=map(int,raw_input().split())
d=0
for i in range(a,b+1):
    if c%i==0:
        d+=1
print(str(d))

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
d=0
for i in range(a,b+1):
    if c%i==0:
        d+=1
print(str(d))

Fixed submission:
a,b,c=map(int,raw_input().split())
d=0
for i in range(a,b+1):
    if c%i==0:
        d+=1
print(str(d))
Buggy python submission (verdict: Runtime Error):
while True:
    a,b,c=map(str,raw_input().split())
    a,c=int(a),int(c)
    if b=="?":
        break
    if   b=="+":
        print(a+b)
    elif b=="-":
        print(a-b)
    elif b=="*"
        print(a*b)
    else:
        print(a//b)
    

Fixed submission:
while True:
    a,b,c=map(str,raw_input().split())
    a,c=int(a),int(c)
    if b=="?":
        break
    if   b=="+":
        print(a+c)
    elif b=="-":
        print(a-c)
    elif b=="*":
        print(a*c)
    else:
        print(a//c)

Buggy python submission (verdict: Runtime Error):
while True:
    a,b,c=map(str,raw_input().split())
    a,c=int(a),int(c)
    if b=="?":
        break
    if   b=="+":
        print(a+b)
    elif b=="-":
        print(a-b)
    elif b=="*"
        print(a*b)
    else:
        print(a//b)
    

Fixed submission:
while True:
    a,b,c=map(str,raw_input().split())
    a,c=int(a),int(c)
    if b=="?":
        break
    if   b=="+":
        print(a+c)
    elif b=="-":
        print(a-c)
    elif b=="*":
        print(a*c)
    else:
        print(a//c)

Buggy python submission (verdict: Runtime Error):
while True:
    a,b,c=map(str,raw_input().split())
    a,c=int(a),int(c)
    if b=="?":
        break
    if   b=="+":
        print(a+c)
    elif b=="-":
        print(a-c)
    elif b=="*"
        print(a*c)
    else:
        print(a//c)
    

Fixed submission:
while True:
    a,b,c=map(str,raw_input().split())
    a,c=int(a),int(c)
    if b=="?":
        break
    if   b=="+":
        print(a+c)
    elif b=="-":
        print(a-c)
    elif b=="*":
        print(a*c)
    else:
        print(a//c)
Buggy python submission (verdict: Runtime Error):
a=input()
a=map(int,raw_input().split())
print(str(min(a))+" "+max(a)+" "+sum(a))

Fixed submission:
a=input()
a=map(int,raw_input().split())
print(str(min(a))+" "+str(max(a))+" "+str(sum(a)))
Buggy python submission (verdict: Runtime Error):
while True:
    a=input()
    if a==0: break
    sum([int(i) for i in a])

Fixed submission:
while True:
    a=str(raw_input())
    if a=="0": break
    print(sum([int(i) for i in a]))

Buggy python submission (verdict: Runtime Error):
while True:
    a=raw_input()
    if a==0: break
    sum([int(i) for i in a])

Fixed submission:
while True:
    a=str(raw_input())
    if a=="0": break
    print(sum([int(i) for i in a]))
Buggy python submission (verdict: Runtime Error):
import math
a=int(input())
b=int(input())
print(math.ceil(math.log10(a*b)))

Fixed submission:
import sys,math

inputs = list()

for n in sys.stdin:
	inputs.append(list(map(int,n.split())))

for n in inputs:
	print(math.floor(math.log10(n[0]+n[1]))+1)

Buggy python submission (verdict: Runtime Error):
import math
nums = input().split()
print(math.ceil(math.log10(int(nums[0])*int(nums[1]))))

Fixed submission:
import sys,math

inputs = list()

for n in sys.stdin:
	inputs.append(list(map(int,n.split())))

for n in inputs:
	print(math.floor(math.log10(n[0]+n[1]))+1)

Buggy python submission (verdict: Runtime Error):
import math
nums = input().split()
print(math.ceil(math.log10(int(nums[0])*int(nums[1]))))

Fixed submission:
import sys,math

inputs = list()

for n in sys.stdin:
	inputs.append(list(map(int,n.split())))

for n in inputs:
	print(math.floor(math.log10(n[0]+n[1]))+1)

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

inputs = sys.stdin.readlines()
inputs = list(map(lambda x:list(map(int,x.split())),inputs))

for n in inputs:
	print(math.floor(math.log10(n[0]*n[1]))+1)

Fixed submission:
import sys,math

inputs = list()

for n in sys.stdin:
	inputs.append(list(map(int,n.split())))

for n in inputs:
	print(math.floor(math.log10(n[0]+n[1]))+1)

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

inputs = sys.stdin.readlines()
inputs = list(map(lambda x:list(map(int,x.split())),inputs))

for n in inputs:
	print(math.floor(math.log10(n[0]*n[1]))+1)

Fixed submission:
import sys,math

inputs = list()

for n in sys.stdin:
	inputs.append(list(map(int,n.split())))

for n in inputs:
	print(math.floor(math.log10(n[0]+n[1]))+1)

Buggy python submission (verdict: Runtime Error):
import sys,math
inputs = list()
for n in sys.stdin:
	inputs.append(list(map(int,n.split())))
for n in inputs:
	print(math.floor(math.log10(n[0]*n[1]))+1)

Fixed submission:
import sys,math

inputs = list()

for n in sys.stdin:
	inputs.append(list(map(int,n.split())))

for n in inputs:
	print(math.floor(math.log10(n[0]+n[1]))+1)

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

inputs = list()

for n in sys.stdin:
	inputs.append(list(map(int,n.split())))

for n in inputs:
	print(math.floor(math.log10(n[0]*n[1]))+1)

Fixed submission:
import sys,math

inputs = list()

for n in sys.stdin:
	inputs.append(list(map(int,n.split())))

for n in inputs:
	print(math.floor(math.log10(n[0]+n[1]))+1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
for n in range(N):
	sides = list(map(int,input().split()))
	sides.sort()
	if sides[-1] < sides[-2]+sides[-3]:
		print("YES")
	else:
		print("NO")

Fixed submission:
N=int(input())
for n in range(N):
	sides = list(map(int,input().split()))
	sides.sort()
	if sides[-1]**2 == sides[-2]**2 + sides[-3]**2:
		print("YES")
	else:
		print("NO")
Buggy python submission (verdict: Runtime Error):
againstN = [0]*50

for a in range(0,10):
  for b in range(0,10):
    for c in range(0,10):
      for d in range(0,10):
        againstN[a+b+c+d] += 1

inputs=[]
while True:
  try:
    inputs.append(int(input()))
  except EOFError:
    break

for i in inputs:
  print(againstN[i])

Fixed submission:
answermap=[0]*51
answermap[0] = 1
answermap[1] = 4
answermap[2] = 10
answermap[3] = 20
answermap[4] = 35
answermap[5] = 56
answermap[6] = 84
answermap[7] = 120
answermap[8] = 165
answermap[9] = 220
answermap[10] = 282
answermap[11] = 348
answermap[12] = 415
answermap[13] = 480
answermap[14] = 540
answermap[15] = 592
answermap[16] = 633
answermap[17] = 660
answermap[18] = 670
answermap[19] = 660
answermap[20] = 633
answermap[21] = 592
answermap[22] = 540
answermap[23] = 480
answermap[24] = 415
answermap[25] = 348
answermap[26] = 282
answermap[27] = 220
answermap[28] = 165
answermap[29] = 120
answermap[30] = 84
answermap[31] = 56
answermap[32] = 35
answermap[33] = 20
answermap[34] = 10
answermap[35] = 4
answermap[36] = 1
answermap[37] = 0
answermap[38] = 0
answermap[39] = 0
answermap[40] = 0
answermap[41] = 0
answermap[42] = 0
answermap[43] = 0
answermap[44] = 0
answermap[45] = 0
answermap[46] = 0
answermap[47] = 0
answermap[48] = 0
answermap[49] = 0
answermap[50] = 0

inputs = []

while True:
  try:
    inputs.append(int(input()))
  except EOFError:
    break

for i in inputs:
  print(answermap[i])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
import math

for line in sys.stdin:
    a, b = map(int, raw_input().split())
    print math.log10(a+b)+1

Fixed submission:
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    print len(str(a+b))

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

import sys

for line in sys.stdin:
    a, b = map(int, raw_input().split())
    print len(str(a+b))

Fixed submission:
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    print len(str(a+b))

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

import sys

for line in sys.stdin.readLines():
    a, b = map(int, raw_input().split())
    print len(str(a+b))

Fixed submission:
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    print len(str(a+b))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

for i in sys.stdin:
    a, b, c, d, e, f = map(int, line.split())
    print "%f %f" %((d*c-a*f)/(b*d-a*e), (b*f-c*e)/(b*d-a*e))

Fixed submission:
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    a, b, c, d, e, f = map(float, line.split())
    print "%.3f %.3f" %(round(b*f-c*e)/(b*d-a*e)+0, (c*d-a*f)/(b*d-a*e)+0)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

def gcd(a, b):
    global gcd
    if b == 0:
        gcd = a:
    else:
        gcd = gcd(b, a%b)

for line in sys.stdin:
    gcd = 1
    lcm = 1
    a, b = map(int, line.split())
    gcd(a, b)
    lcm = a*b/gcd/gcd
    print "%d %d" %(gcd, lcm)

Fixed submission:
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    t1, t2 = a, b
    while True:
        if a%b:
            a, b = b, a%b
        else:
            break
    gcd = b
    lcm = t1/gcd*t2
    print "%d %d" %(gcd, lcm)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

sum = [0]*37
for a in range(10):
    for b in range(10):
        for c in range(10):
            for d in range(10):
                sum[a+b+c+d] += 1
for line in sys.stdin:
    print sum[int(line)]

Fixed submission:
# -*- coding: utf-8 -*-

import sys

sum = [0]*37
for a in range(10):
    for b in range(10):
        for c in range(10):
            for d in range(10):
                sum[a+b+c+d] += 1
for line in sys.stdin:
    n = int(line)
    if n >= 0 and n <= 36:
        print sum[n]
    else:
        print "0"
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

def isPrime(p):
    if p == 2:
        return True
    elif p < 2 or p%2 == 0:
        return False
    elif pow(2, p-1, p) == 1:
        return True
    else:
        return False

for line in sys.stdin:
    n = int(line)
    count = 0
    for i in range(n):
        if isPrime(int(raw_input())):
            count += 1
    print count

Fixed submission:
# -*- coding: utf-8 -*-

import sys
import math

def countPrimes(n):
    m = int(math.sqrt(n))
    keys = [n/i for i in range(1, m+1)]
    keys += range(keys[-1]-1, 0, -1)
    h = {i:i-1 for i in keys}
    for i in range(2, m+1):
        if h[i] > h[i-1]:
            hp = h[i-1]
            i2 = i*i
            for j in keys:
                if j < i2:
                    break
                h[j] -= h[j/i]-hp
    return h[n]

for line in sys.stdin:
    print countPrimes(int(line))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import sys

DATA_NUM = 1000000
primes = [2]
for i in range(3, DATA_NUM):
    flag = True
    for p in primes:
         if i % p == 0:
             flag = False
             break
    if flag:
        primes.append(i)
for line in sys.stdin:
    count = 0
    while primes[count] <= int(line):
        count += 1
    print count

Fixed submission:
# -*- coding: utf-8 -*-

import sys
import math

def countPrimes(n):
    m = int(math.sqrt(n))
    keys = [n/i for i in range(1, m+1)]
    keys += range(keys[-1]-1, 0, -1)
    h = {i:i-1 for i in keys}
    for i in range(2, m+1):
        if h[i] > h[i-1]:
            hp = h[i-1]
            i2 = i*i
            for j in keys:
                if j < i2:
                    break
                h[j] -= h[j/i]-hp
    return h[n]

for line in sys.stdin:
    print countPrimes(int(line))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def slope(p1, p2):
    return (p2.y-p1.y)/(p2.x-p1.x)

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    p4 = Point_Class(x4, y4)
    print "YES" if slope(p1, p2) == slope(p3, p4) else "NO"

Fixed submission:
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
    print "YES" if abs(((y2-y1)*(x4-x3) - (x2-x1)*(y4-y3))) < 1e-10 else "NO"

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

import sys

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def slope(p1, p2):
    return (p2.y-p1.y)/(p2.x-p1.x) if p2.x != p1.x else sys.intmax

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    p4 = Point_Class(x4, y4)
    print "YES" if slope(p1, p2) == slope(p3, p4) else "NO"

Fixed submission:
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
    print "YES" if abs(((y2-y1)*(x4-x3) - (x2-x1)*(y4-y3))) < 1e-10 else "NO"
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

primes = [2]
for i in range(3, 50010):
    flag = True
    for p in primes:
        if i % p == 0:
            flag = False
            break
    if flag:
        primes.append(i)

for line in sys.stdin:
    n = int(line)
    i = 0
    while primes[i] < n and i < len(primes):
        i += 1
    if primes[i] == n:
        s = primes[i-1]
    else:
        s = primes[i]
    m = primes[i+1]
    print s, m

Fixed submission:
# -*- coding: utf-8 -*-

import sys

primes = [2]
for i in range(3, 50022):
    flag = True
    for p in primes:
        if i % p == 0:
            flag = False
            break
    if flag:
        primes.append(i)

for line in sys.stdin:
    n = int(line)
    i = 0
    while primes[i] < n and i < len(primes):
        i += 1
    if primes[i] == n:
        s = primes[i-1]
        m = primes[i+1]
    else:
        s = primes[i-1]
        m = primes[i]
    print s, m
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

dic = {'A':0, 'B':0, 'AB':0, 'O':0}
for line in sys.stdin:
    id, type = map(int, line.split(','))
    dic[type] += 1
for key in dic:
    print dic[key]

Fixed submission:
# -*- coding: utf-8 -*-

import sys

dic = {'A':0, 'B':0, 'AB':0, 'O':0}
for line in sys.stdin:
    id, type = map(str, line.split(','))
    type = type[:len(type)-1]
    dic[type] += 1
print dic['A']
print dic['B']
print dic['AB']
print dic['O']
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

primes = [2]
n = 3
while n < 10000:
    flag = True
    for p in primes:
        if n % p == 0:
            flag = False
            break
    if flag:
        primes.append(n)
    n += 1

while True:
    n = int(raw_input())
    if n == 0:
        break
    sum = 0
    for i in range(n):
        sum += primes[i]
    print sum

Fixed submission:
# -*- coding: utf-8 -*-

primes = [2]
i = 3
count = 1
while count < 10000:
    flag = True
    for p in primes:
        if i % p == 0:
            flag = False
            break
    if flag:
        primes.append(i)
        count += 1
    i += 1

while True:
    n = int(raw_input())
    if n == 0:
        break
    sum = 0
    for i in range(n):
        sum += primes[i]
    print sum
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(raw_input())
R_List = []
Max = 0
for i in range(n):
    R_List.append(int(raw_input()))
    if i == 0:
        continue
    elif i == 1:
        Max = R_List[1]-R_List[0]
    else:
        for j in range(i):
            Max = max(Max, R_List[i]-R_List[j])
print Max

Fixed submission:
# -*- coding: utf-8 -*-

n = int(raw_input())
R_List = []
Max = 0
R_min = 0
for i in range(n):
    R_List.append(int(raw_input()))
    if i == 0:
        R_min = R_List[0]
    elif i == 1:
        Max = R_List[1]-R_min
        R_min = min(R_min, R_List[1])
    else:
        Max = max(Max, R_List[i]-R_min)
        R_min = min(R_min, R_List[i])
print Max
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(raw_input())
S = map(int, raw_input().split())
q = int(raw_input())
T = map(int, raw_input().split())
count = 0
for i in range(q):
    for j in range(n):
        if T[i] == S[j]:
            count += 1
            break
print count

Fixed submission:
# -*- coding: utf-8 -*-

def sort(a, left, right):
    if left < right:
        mid = (left+right)/2
        pivot = a[mid]
        a[mid] = a[left]
        p = left
        for i in range(left+1, right+1):
            if a[i] < pivot:
                p = p+1
                p, i = i, p
        a[left] = a[p]
        a[p] = pivot
        sort(a, left, p-1)
        sort(a, p+1, right)

def search(a, target):
    lo = 0
    hi = n-1
    while lo <= hi:
        mid = (lo+hi)/2
        if target <= a[mid]:
            hi = mid-1
        if target >= a[mid]:
            lo = mid+1
    if lo == hi+2:
        return True
    else:
        return False

n = int(raw_input())
S = map(int, raw_input().split())
q = int(raw_input())
T = map(int, raw_input().split())
count = 0
sort(S, 0, n-1)
for i in range(q):
    if search(S, T[i]):
        count += 1
print count