Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
while 1:
        n = map(int,raw_input().split())
        if n[0] == n[1] == 0:
                break
        m, o = [1 for x in range(n[0])], 0

        for x in range(1,n[1]+1):
                a = raw_input()
                print o
                if sum(m) == 1:
                        pass
                elif x % 15 == 0:
                        if a != "FizzBuzz":
                                m[o] = 0
                elif x % 3 == 0:
                        if a != "Fizz":
                                m[o] = 0
                elif x % 5 == 0:
                        if a != "Buzz":
                                m[o] = 0
                else:
                        if a != str(x):
                                m[o] = 0
                while 1:
                        o += 1
                        if o == len(m):
                                o = -1
                        elif m[o] == 1:
                                break

        for x in range(n[0]):
                if m[x] == 1:
                        print x+1,
        print ""

Fixed submission:
while 1:
        n = map(int,raw_input().split())
        if n[0] == n[1] == 0:
                break
        m, o = [1 for x in range(n[0])], 0

        for x in range(1,n[1]+1):
                a = raw_input()
                if sum(m) == 1:
                        pass
                elif x % 15 == 0:
                        if a != "FizzBuzz":
                                m[o] = 0
                elif x % 3 == 0:
                        if a != "Fizz":
                                m[o] = 0
                elif x % 5 == 0:
                        if a != "Buzz":
                                m[o] = 0
                else:
                        if a != str(x):
                                m[o] = 0
                while 1:
                        o += 1
                        if sum(m) == 1:
                                break
                        elif o == len(m):
                                o = -1
                        elif m[o] == 1:
                                break

        OutPut = ""
        for x in range(n[0]):
                if m[x] == 1:
                        OutPut += str(x+1) + " "
        print OutPut[:-1]
Buggy python submission (verdict: Runtime Error):
while 1:
        num=map(int,raw_input().split())
        if num==[0,0,0] : break
        hrz=[0 for i in range(num[1])]
        for i in range(num[1]):
                hrz[i]=map(int,raw_input().split())
        lct=[1001,num[2]]
        while lct[0]!=1:
                pps=[0,0]
                for i in range(num[1]):
                        if pps[0]<hrz[i][0]<lct[0]:
                                if hrz[i][1]==lct[1]:
                                        pps=[hrz[i][0],hrz[i][2]]
                                elif hrz[i][2]==lct[1]:
                                        pps=[hrz[i][0],hrz[i][1]]
                lct=pps
        print lct[1]

Fixed submission:
while 1:
        num=map(int,raw_input().split())
        if num==[0,0,0] : break
        hrz=[0 for i in range(num[1])]
        for i in range(num[1]):
                hrz[i]=map(int,raw_input().split())
        pps=[1001,num[2]]
        while pps!=[0,0]:
                lct,pps=pps,[0,0]
                for i in range(num[1]):
                        if pps[0]<hrz[i][0]<lct[0]:
                                if hrz[i][1]==lct[1]:
                                        pps=[hrz[i][0],hrz[i][2]]
                                elif hrz[i][2]==lct[1]:
                                        pps=[hrz[i][0],hrz[i][1]]
        print lct[1]
Buggy python submission (verdict: Runtime Error):
import sys
a = int(sys.argv[1])
b = a ** 3
print b

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

Buggy python submission (verdict: Runtime Error):
import sys
a = int(sys.argv[0])
b = a ** 3
print b

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

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

Fixed submission:
print int(raw_input()) ** 3
Buggy python submission (verdict: Runtime Error):
import math
r = int(raw_input())
a = round(math.pi*r**2,6)
l = round(math.pi*r*2,6)
print a,
print l

Fixed submission:
from math import pi
r = float(raw_input())
print "%.8f %.8f" %(r**2*pi,r*2*pi)
Buggy python submission (verdict: Runtime Error):
while 0 == 0:
        i = map(str,raw_input().split())
        i[0] = int(i[0])
        i[2] = int(i[2])
        if i[1] == "+":
                print i[0]+i[2]
        elif i[1] == "-":
                print i[0]-i[2]
        elif i[1] == "*":
                print i[0]*i[2]
        elif i[1] == "/":
                print i[0]/i[2]
        elif i[1] == "?":
                pass
        else:
                print "error"

Fixed submission:
r = 0
while r == 0:
        i = map(str,raw_input().split())
        i[0] = int(i[0])
        i[2] = int(i[2])
        if i[1] == "+":
                print i[0]+i[2]
        elif i[1] == "-":
                print i[0]-i[2]
        elif i[1] == "*":
                print i[0]*i[2]
        elif i[1] == "/":
                print i[0]/i[2]
        elif i[1] == "?":
                break
        else:
                print "error"
Buggy python submission (verdict: Runtime Error):
t=list(raw_input().lower())
c=[0 for i in range(26)]
for i in range(len(t)):
        c[ord(t[i])-ord("a")]+=1
for i in range(26):
        print chr(ord("a")+i),":",c[i]

Fixed submission:
c=[0]*26
while 1:
        try:
                t=list(raw_input().lower())
                for i in range(len(t)):
                        if 0<=ord(t[i])-ord("a")<=25:
                                c[ord(t[i])-ord("a")]+=1
        except EOFError:
                break
for i in range(26):
        print chr(ord("a")+i),":",c[i]

Buggy python submission (verdict: Runtime Error):
t=list(raw_input().lower())
c=[0 for i in range(26)]
for i in range(len(t)):
        c[ord(t[i])-ord(u"a")]+=1
for i in range(26):
        print chr(ord("a")+i),":",c[i]

Fixed submission:
c=[0]*26
while 1:
        try:
                t=list(raw_input().lower())
                for i in range(len(t)):
                        if 0<=ord(t[i])-ord("a")<=25:
                                c[ord(t[i])-ord("a")]+=1
        except EOFError:
                break
for i in range(26):
        print chr(ord("a")+i),":",c[i]
Buggy python submission (verdict: Runtime Error):
n=int(raw_input())
p=[0,0]
for i in range(n):
        c=[0 for i in range(100)]
        c=map(list,raw_input().split())
        m=0
        while 1:
                if c[0]==c[1]:
                        p[0]+=1
                        p[1]+=1
                        break
                elif c[0][m]<c[1][m]:
                        p[1]+=3
                        break
                elif c[1][m]<c[0][m]:
                        p[0]+=3
                        break
                m+=1
print p[0], p[1]

Fixed submission:
n=int(raw_input())
p=[0,0]
for i in range(n):
        c=[0 for i in range(100)]
        c=map(list,raw_input().split())
        m=0
        while 1:
                try:
                        if c[0]==c[1]:
                                p[0]+=1
                                p[1]+=1
                                break
                        elif c[0][m]<c[1][m]:
                                p[1]+=3
                                break
                        elif c[1][m]<c[0][m]:
                                p[0]+=3
                                break
                        m+=1
                except IndexError:
                        if len(c[0])<len(c[1]):
                                p[1]+=3
                                break
                        if len(c[1])<len(c[0]):
                                p[0]+=3
                                break
print p[0], p[1]
Buggy python submission (verdict: Runtime Error):
num = raw_input()

print (num * num * num)

Fixed submission:
a = input()
print a ** 3
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
print a * b

Fixed submission:
str = raw_input()
a = str.split(' ')

n1 = int(a[0])
n2 = int(a[1])

print n1 * n2, (n1 + n2) * 2
Buggy python submission (verdict: Runtime Error):
import sys
import math
import numpy as np

n, m = map(int, raw_input().split())
A = np.zeros([n, m])
b = np.zeros([m, 1])

for i in xrange(n) :
    A[i] = map(int, raw_input().split())

for i in xrange(m) :
    b[i] = input()

c = A.dot(b)

for i in xrange(n) :
    print int(c[i])

Fixed submission:
import sys
import math

n, m = map(int, raw_input().split())
A = []
b = []

for i in xrange(n) :
    A.append(map(int, raw_input().split()))

for i in xrange(m) :
    b.append(input())

for i in xrange(n) :
    sm = 0
    for j in xrange(m) :
        sm += A[i][j] * b[j]
    print sm
Buggy python submission (verdict: Runtime Error):
from math import log10
n = int(input())
for i in range(n):
    a = int(input())
    b = int(input())
    c = a+b
    if (log10(c) > 80):
        print("overflow")
    else:
        print(c)

Fixed submission:
from sys import stdin
n = int(stdin.readline())
for i in range(n):
    c = str(int(stdin.readline().strip()) + int(stdin.readline().strip()))
    if (len(c) > 80):
        print("overflow")
    else:
        print(c)

Buggy python submission (verdict: Runtime Error):
from math import log10
n = int(input())
for i in range(n):
    a = int(input())
    b = int(input())
    c = a+b
    if (log10(c) > 80):
        print("overflow")
    else:
        print(c)

Fixed submission:
from sys import stdin
n = int(stdin.readline())
for i in range(n):
    c = str(int(stdin.readline().strip()) + int(stdin.readline().strip()))
    if (len(c) > 80):
        print("overflow")
    else:
        print(c)

Buggy python submission (verdict: Runtime Error):
from math import log10
n = int(input())
for i in range(n):
    a = int(input())
    b = int(input())
    c = a+b
    if (log10(c) > 80):
        print("overflow")
    else:
        print(c)

Fixed submission:
from sys import stdin
n = int(stdin.readline())
for i in range(n):
    c = str(int(stdin.readline().strip()) + int(stdin.readline().strip()))
    if (len(c) > 80):
        print("overflow")
    else:
        print(c)

Buggy python submission (verdict: Runtime Error):
from math import log10
n = int(input())
for i in range(n):
    a = int(input())
    b = int(input())
    c = a+b
    if (log10(c) > 80):
        print("overflow")
    else:
        print(c)

Fixed submission:
from sys import stdin
n = int(stdin.readline())
for i in range(n):
    c = str(int(stdin.readline().strip()) + int(stdin.readline().strip()))
    if (len(c) > 80):
        print("overflow")
    else:
        print(c)
Buggy python submission (verdict: Runtime Error):
import sys

while True:
    input = raw_input()
    for i in range(0, 26):
        str = ""
        for c in input:
            if c.isalpha():
                c = chr(ord(c) + i)
                if ord(c) > ord('z'):
                    c = chr(ord('a') - ord('z') + ord(c) - 1)
            str += c
        for word in ["this", "that", "the"]:
            if (str.find(word) != -1):
                print str
                break

Fixed submission:
import sys

while True:
    try:
        input = raw_input()
        for i in range(0, 26):
            str = ""
            for c in input:
                if c.isalpha():
                    c = chr(ord(c) + i)
                    if ord(c) > ord('z'):
                        c = chr(ord('a') - ord('z') + ord(c) - 1)
                str += c
            for word in ["this", "that", "the"]:
                if (str.find(word) != -1):
                    print str
                    break
    except EOFError:
        break
Buggy python submission (verdict: Time Limit Exceeded):
while True:
    n = int(input())
    if n == 0: break
    w, h = map(int, input().split())
    trees = []
    for i in range(n):
        trees.append(tuple(map(int, input().split())))
    s, t = map(int, input().split())

    max_num = 0
    # loops in upper left coordinate
    for i in range(w - s + 1):
        for j in range(h - t + 1):
            num = 0
            for k in range(s):
                for l in range(t):
                    if (i+k+1, j+l+1) in trees:
                        num += 1
                        if num > max_num:
                            max_num = num
    print(max_num)

Fixed submission:
while True:
    n = int(input())
    if n == 0: break
    w, h = map(int, input().split())
    trees = [[0 for i in range(h+1)] for j in range(w+1)]
    dis = [[0 for i in range(h+1)] for j in range(w+1)]
    for i in range(n):
        x, y = map(int, input().split())
        trees[x][y] = 1

    for i in range(1, w+1):
        for j in range(1, h+1):
            dis[i][j] = trees[i][j] + dis[i-1][j] \
                    + dis[i][j-1] - dis[i-1][j-1]

    s, t = map(int, input().split())

    ans = 0
    for i in range(1, w - s + 2):
        for j in range(1, h - t + 2):
            num = dis[i+s-1][j+t-1] - dis[i+s-1][j-1] \
                    - dis[i-1][j+t-1] + dis[i-1][j-1]
            ans = max(ans, num)

    print(ans)
Buggy python submission (verdict: Runtime Error):
def search(x, y, m):
    if x >= len(m[0]) or y >= len(m):
        return 0
    if m[y][x] == '#':
        return 0
    m[y][x] = '#'
    return 1 + search(x+1,y, m) + search(x-1,y,m) \
            + search(x,y+1,m) + search(x,y-1,m)

while True:
    w, h = map(int, input().split())
    if w == 0: break
    room = []
    for i in range(h):
        tmp = list(input())
        room.append(tmp[:w])
        if '@' in tmp:
            y = i
            x = tmp.index('@') 
    print(search(x, y, room))

Fixed submission:
def search(x, y, m):
    if x < 0 or y < 0 \
            or x >= len(m[0]) or y >= len(m):
        return 0
    if m[y][x] == '#':
        return 0
    m[y][x] = '#'
    return 1 + search(x+1,y, m) + search(x-1,y,m) \
            + search(x,y+1,m) + search(x,y-1,m)

while True:
    w, h = map(int, input().split())
    if w == 0: break
    room = []
    for i in range(h):
        tmp = list(input())
        room.append(tmp[:w])
        if '@' in tmp:
            y = i
            x = tmp.index('@') 
    print(search(x, y, room))
Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt

primes = [x for x in range(2, 1000000) if x % 2 == 1 or x == 2]
for i in range(2, int(sqrt(1000000))):
    primes = [x for x in primes if x % i != 0 or x == i]

while True:
    a, d, n = map(int, input().split())
    if a == 0: break

    nums = [x for x in primes if (x-a) % d == 0]
    print(nums[n-1])

Fixed submission:
from math import sqrt
from array import array

size = 10000000
s = array('i', range(size+1))
s[1] = 0
sqrtn = int(round(size**0.5))
for i in range(2, sqrtn + 1):
    if s[i]:
        s[i*i: size+1 : i] = array('i', [0] * len(range(i*i, size+1, i)))
primes = list(filter(None, s))

while True:
    a, d, n = map(int, input().split())
    if a == 0: break

    ans = 0
    for p in primes:
        if p-a < 0 : continue
        if (p-a) % d == 0:
            ans = p
            n -= 1
        if n == 0:
            break
    print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3

from math import floor

while True:
    n = eval(input())
    if n != 0:
        ls = []
        for i in range(n):
            m = eval(input())
            ls.append(m)
        ls.remove(max(ls))
        ls.remove(min(ls))
        print(floor(sum(ls)/len(ls)))
    else:
        break

Fixed submission:
#!/usr/bin/python3

from math import floor

while True:
    n = eval(input())
    if n != 0:
        ls = []
        for i in range(n):
            m = eval(input())
            ls.append(m)
        ls.remove(max(ls))
        ls.remove(min(ls))
        print(floor(sum(ls)/len(ls)))
    else:
        break

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3

from math import floor

while True:
    n = eval(input())
    if n != 0:
        ls = []
        for i in range(n):
            m = eval(input())
            ls.append(m)
        ls.remove(max(ls))
        ls.remove(min(ls))
        print(floor(sum(ls)/len(ls)))
    else:
        break

Fixed submission:
#!/usr/bin/python3

from math import floor

while True:
    n = eval(input())
    if n != 0:
        ls = []
        for i in range(n):
            m = eval(input())
            ls.append(m)
        ls.remove(max(ls))
        ls.remove(min(ls))
        print(floor(sum(ls)/len(ls)))
    else:
        break
Buggy python submission (verdict: Runtime Error):
m = []

def walk(i,j):
    if i < 0 or j < 0 \
            or i >= len(m) or j >= len(m[i]):
                return
    if m[i][j] == 0:
        return
    m[i][j] = 0
    for k in range(-1,2):
        for l in range(-1,2):
            walk(i+k,j+l)

while True:
    w, h = map(int, input().split())
    if w == 0: break
    for i in range(h):
        m.append(list(map(int, input().split())))
    ans = 0
    for i in range(len(m)):
        for j in range(len(m[i])):
            if m[i][j] == 1:
                walk(i,j)
                ans += 1
    print(ans)
    m = []

Fixed submission:
m = []

def walk(i,j):
    stack = []
    stack.append((i,j))
    while stack:
        p = stack.pop()
        pi = p[0]
        pj = p[1]
        m[pi][pj] = 0
        for k in range(-1,2):
            for l in range(-1,2):
                a = pi+k
                b = pj+l
                if a < 0 or b < 0 \
                        or a >= len(m) or b >= len(m[a]):
                            pass
                elif m[a][b] == 0:
                    pass
                else:
                    stack.append((a,b))

while True:
    w, h = map(int, input().split())
    if w == 0: break
    for i in range(h):
        m.append(list(map(int, input().split())))
    ans = 0
    for i in range(len(m)):
        for j in range(len(m[i])):
            if m[i][j] == 1:
                walk(i,j)
                ans += 1
    print(ans)
    m = []
Buggy python submission (verdict: Runtime Error):
from math import sqrt

while True:
    n = int(input())
    if n == 0: break
    nums = [ x for x in range(n, 2*n+1) if x % 2 == 1 or x == 2]
    #print(nums)
    for i in range(2,int(sqrt(2*n))):
        nums = [x for x in nums if x % i != 0 or x == i]
        #print(i, nums)
    print(len(nums))

#    ans = 0
#    for i in range(n, 2*n+1):
#        for j in [x for x in range(2,i) if x * x <= i]:
#            if i % j == 0:
#                break
#        else:
#            ans += 1
#    print(ans)

Fixed submission:
from math import sqrt

size = 123456
primes = [x for x in range(2, 2*size+1) if x == 2 or x % 2 == 1]
for i in range(2, int(sqrt(2*size))):
    primes = [x for x in primes if x % i != 0 or x == i]

while True:
    n = int(input())
    if n == 0: break
    nums = [x for x in primes if x > n and x <= 2*n]
    print(len(nums))

Buggy python submission (verdict: Runtime Error):
from math import sqrt

while True:
    n = int(input())
    if n == 0: break
    nums = [ x for x in range(n, 2*n+1) if x % 2 == 1 or x == 2]
    for i in range(2,int(sqrt(2*n))):
        nums = [x for x in nums if x % i != 0 or x == i]
    print(len(nums))

Fixed submission:
from math import sqrt

size = 123456
primes = [x for x in range(2, 2*size+1) if x == 2 or x % 2 == 1]
for i in range(2, int(sqrt(2*size))):
    primes = [x for x in primes if x % i != 0 or x == i]

while True:
    n = int(input())
    if n == 0: break
    nums = [x for x in primes if x > n and x <= 2*n]
    print(len(nums))
Buggy python submission (verdict: Runtime Error):
while True:
    n, m, a = map(int, input().split())
    if n == 0: break
    ls = [[0 for i in range(n+1)] for i in range(m)]
    print(ls)
    for i in range(m):
        h, p, q = map(int, input().split())
        ls[h][p] = 1
    ls.reverse()
    print(ls)
    for t in ls:
        if t[a] == 1:
            a += 1
        elif t[a-1] == 1:
            a -= 1
    print(a)

Fixed submission:
while True:
    n, m, a = map(int, input().split())
    if n == 0: break
    ls = [[0 for i in range(n+1)] for i in range(1001)]
    for i in range(m):
        h, p, q = map(int, input().split())
        ls[h][p] = 1
    ls.reverse()
    for t in ls:
        if t[a] == 1:
            a += 1
        elif t[a-1] == 1:
            a -= 1
    print(a)
Buggy python submission (verdict: Runtime Error):
cubics = [ x * x * x for x in range(101)]
squares = [ x * x for x in range(1000)]
while True:
    x, y, z = -1, -1, -1
    m = 1000000
    e = int(input())
    if e == 0: break
#    for i in range(len(cubics)):
#        if e - cubics[i] < 0:
#            e -= cubics[i - 1]
#            z = i - 1
#            break
#    for i in range(len(squares)):
#        if e - squares[i] < 0:
#            e -= squares[i -1]
#            y = i - 1
#            break
#    x = e
    for cubic in cubics:
        if e < cubic: break
        else: z += 1
        tmp = e - cubic
        #print("tmp:",tmp)
        y = -1
        for squ in squares:
            if tmp < squ: break
            else: 
                x = tmp - squ
                y += 1
                #print(x,y,z)
                m = min(m, x + y + z)
    print(m)

Fixed submission:
from math import floor, sqrt

cubics = [ x * x * x for x in range(101)]
squares = [ x * x for x in range(1000)]
while True:
    m = 1000000
    e = int(input())
    if e == 0: break
    for z in range(len(cubics)):
        if e < cubics[z]: break
        tmp = e - cubics[z]
        y = floor(sqrt(tmp))
        x = tmp - y ** 2
        m = min(m, x + y + z)
    print(m)
Buggy python submission (verdict: Runtime Error):
while True:
    n, m = map(int, input().split())
    ls = []
    if n == 0: break
    for i in range(n):
        d, p = map(int, input().split())
        ls.append([d,p])
    ls.sort(key=lambda x:x[1], reverse=True)
    j = 0
    for i in range(m):
        ls[j][0] -= 1
        if ls[j][0] == 0:
            j += 1
    print(sum(x[0] * x[1] for x in ls))

Fixed submission:
while True:
    n, m = map(int, input().split())
    ex = [0] * 11
    if n == 0: break
    for i in range(n):
        d, p = map(int, input().split())
        ex[p] += d
    ex.reverse()
    for i in range(len(ex)):
        m -= ex[i]
        if m <= 0:
            ex[i] = abs(m)
            break
        else:
            ex[i] = 0
    ex.reverse()
    ans = 0
    for i in range(len(ex)):
        ans += ex[i] * i
    print(ans)

Buggy python submission (verdict: Runtime Error):
while True:
    n, m = map(int, input().split())
    ls = []
    if n == 0: break
    for i in range(n):
        d, p = map(int, input().split())
        ls.append([d,p])
    ls.sort(key=lambda x:x[1], reverse=True)
    j = 0
    for i in range(m):
        ls[j][0] -= 1
        if ls[j][0] == 0:
            j += 1
            if j == (len(ls)):
                break
    print(sum(x[0] * x[1] for x in ls))

Fixed submission:
while True:
    n, m = map(int, input().split())
    ex = [0] * 11
    if n == 0: break
    for i in range(n):
        d, p = map(int, input().split())
        ex[p] += d
    ex.reverse()
    for i in range(len(ex)):
        m -= ex[i]
        if m <= 0:
            ex[i] = abs(m)
            break
        else:
            ex[i] = 0
    ex.reverse()
    ans = 0
    for i in range(len(ex)):
        ans += ex[i] * i
    print(ans)