Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys
import math

def dig(n):
  return int(math.log10(n))

num = input()
count = 0
for i in range(num):
  num1 = []
  s = input()
  t = input()
  if dig(s) > 80 or dig(t) > 80 or dig(s+t) > 80 :
    print "overflow"
  else:
    print s+t

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys

num = input()
for i in range(num):
  s = long(input())
  t = long(input())
  u = s+t
  if len(str(u)) > 80 :
    print "overflow"
  else:
    print u

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys

num = input()
for i in range(num):
  num1 = []
  s = input()
  t = input()
  u = s+u
  if len(str(u)) > 80 :
    print "overflow"
  else:
    print u

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys

num = input()
for i in range(num):
  s = long(input())
  t = long(input())
  u = s+t
  if len(str(u)) > 80 :
    print "overflow"
  else:
    print u
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

num = input()

for s in sys.stdin:
  d = map(float,s.split())
  x1,y1,x2,y2,x3,y3,x4,y4 = d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7]
  ab = [ x2-x1, y2-y1 ]
  cd = [ x4-x3, y4-y3 ]
  if ab[0] == 0 and cd[0] == 0:
    print "YES"
  elif ab[1]/ab[0] == cd[1]/cd[0]:
    print "YES"
  else:
    print "NO"

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

err = 1e-10

def cross(v1,v2):
  return v1[0]*v2[1]-v1[1]*v2[0]

num = input()

for i in range(num):
  d = map(float,sys.stdin.readline().split())
  x1,y1,x2,y2,x3,y3,x4,y4 = d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7]
  ab = [ x2-x1, y2-y1 ]
  cd = [ x4-x3, y4-y3 ]
  if abs(cross(ab,cd)) < err:
    print "YES"
  else:
    print "NO"

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

num = input()

for i in range(num):
  d = map(float,sys.stdin.readline().split())
  x1,y1,x2,y2,x3,y3,x4,y4 = d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7]
  ab = [ x2-x1, y2-y1 ]
  cd = [ x4-x3, y4-y3 ]
  if ab[0] == 0 and cd[0] == 0:
    print "YES"
  elif ab[1]/ab[0] == cd[1]/cd[0]:
    print "YES"
  else:
    print "NO"

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

err = 1e-10

def cross(v1,v2):
  return v1[0]*v2[1]-v1[1]*v2[0]

num = input()

for i in range(num):
  d = map(float,sys.stdin.readline().split())
  x1,y1,x2,y2,x3,y3,x4,y4 = d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7]
  ab = [ x2-x1, y2-y1 ]
  cd = [ x4-x3, y4-y3 ]
  if abs(cross(ab,cd)) < err:
    print "YES"
  else:
    print "NO"
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

dic = {}
for s in sys.stdin:
  d = [ e.lower() for e in map(str,s.split()) ]
  for e in d:
    if e in dic:
      dic[e] += 1
    else:
      dic[e] = 1


sdict = sorted(dic.items(),key=lambda x:-x[1])
maxnum = sdict[0][1]
for i in range(len(sdict)):
  if sdict[i][1] == maxnum:
    print sdict[i][0],
  else:
    break


maxlen = max([len(e) for e in d])
longterm = [ e for e in d if len(e) == maxlen ]
for e in longterm:
  print e,

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

a = raw_input()
b = a.split()
c = [ i.lower() for i in b ]
e = {}
h = {}
for d in c:
  if d not in e:
    h[d] = len(d)
    e[d] = 1
  else:
    e[d] += 1
f = [ (v,k) for k,v in e.items() ]
f.sort()
f.reverse()
maxnum = f[0][0]
for g in f:
  if g[0] != maxnum:
    break
  print g[1],
i = [ (v,k) for k,v in h.items() ]
i.sort()
i.reverse()
maxnum = i[0][0]
for j in i:
  if j[0] != maxnum:
    break
  print j[1],
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools
input()
lis = list(itertools.product([False,True],repeat=10))
for s in sys.stdin:
  d = map( int, s.split() )
  flag = False
  for e in lis:
    lis_r = []
    lis_l = []
    for i in range(10):
      if e[i]:
        lis_r.append(d[i])
      else:
        lis_l.append(d[i])
    f_r = sorted(lis_r)
    f_l = sorted(lis_l)
    if f_r == lis_r and f_l == lis_l:
      flag = True
      break
  if flag:
    print "YES"
  else:
    print "NO"

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = input()
for s in xrange(n):
  d = map( int, raw_input().split() )
  a = b = 0
  flag = True
  for e in d:
    if a < e: a = e
    elif b < e: b = e
    else: flag = False
  if flag: print "YES"
  else: print "NO"

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools
input()

lis = list(itertools.product([False,True],repeat=10))
for s in sys.stdin:
  d = map( int, s.split() )
  flag = False
  for e in lis:
    lis_r = []
    lis_l = []
    for i in range(10):
      if e[i]:
        lis_r.append(d[i])
      else:
        lis_l.append(d[i])
    f_r = sorted(lis_r)
    f_l = sorted(lis_l)
    if f_r == lis_r and f_l == lis_l:
      flag = True
      break
  if flag:
    print "YES"
  else:
    print "NO"

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = input()
for s in xrange(n):
  d = map( int, raw_input().split() )
  a = b = 0
  flag = True
  for e in d:
    if a < e: a = e
    elif b < e: b = e
    else: flag = False
  if flag: print "YES"
  else: print "NO"

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools
input()
lis = list(itertools.product([False,True],repeat=10))
for s in sys.stdin:
  d = map( int, s.split() )
  flag = False
  for e in lis:
    l = [ d[i] if e[i] else -d[i] for i in xrange(10) ]
    m = [ [ e for e in l if e > 0 ],[ -e for e in l if e < 0 ]]
    n = 0
    for e in m:
      n += sum([ 1 if e[i] > e[i+1] else 0 for i in range(len(e)-1)])
    if not n:
      print "YES"
      break
  if n:
    print "NO"

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = input()
for s in xrange(n):
  d = map( int, raw_input().split() )
  a = b = 0
  flag = True
  for e in d:
    if a < e: a = e
    elif b < e: b = e
    else: flag = False
  if flag: print "YES"
  else: print "NO"
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from itertools import *
from sys import *

def solve(n,w):
  lp,lw = [],[]
  for i in xrange(n):
    s = map(int, raw_input().split(","))
    lp.append(s[0])
    lw.append(s[1])
  mp = mw = 0
  for e in product([0,1],repeat=n):
    cw = sum([ lw[i] for i in range(len(e)) if e[i] ])
    cp = sum([ lp[i] for i in range(len(e)) if e[i] ])
    
    if cp == mp and mw > cw: mw = cw
    if w >= cw and cp > mp: mp = cp; mw = cw
  print mp
  print mw

case = 0
while True:
  case += 1
  w = int(raw_input())
  if w == 0: break
  n = int(raw_input())
  print "Case %d:" % (case)
  solve(n,w)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from itertools import *
from sys import *

def solve(n,w):
  lp,lw = [],[]
  for i in xrange(n):
    s = map(int, raw_input().split(","))
    lp.append(s[0])
    lw.append(s[1])
  c = [-1]*(w+1)
  c[0] = 0
  for i in xrange(n):
    for j in reversed(xrange(w)):
      if c[j] == -1 or j+lw[i] > w : continue
      c[j+lw[i]] = max( c[j]+lp[i], c[j+lw[i]] )
  print max(c)
  print c.index(max(c))

case = 1
while True:
  w = int(raw_input())
  if w == 0: break
  n = int(raw_input())
  print "Case %d:" % (case)
  solve(n,w)
  case += 1
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math


def deg(v1,v2):
    normv1 = math.sqrt(v1[0]**2+v1[1]**2)
    normv2 = math.sqrt(v2[0]**2+v2[1]**2)
    if normv1 == 0 or normv2 == 0:
        print "ERROR"; exit()
    return (v1[0]*v2[0]+v1[1]*v2[1])/(normv1*normv2)

def calc_hull(d):
    hull = []
    point_first = d[0]
    hull.append(point_first)
    v = [ 1, 0 ]
    oldpoint=point_first
    while True:
        minipoint = 0;
        minv = [ 0,0 ]
        maxcos = -1
        for p in d:
            if p == oldpoint: continue
            o = [ p[i]-oldpoint[i] for i in xrange(2) ]
            cos = deg(o,v)
            if cos > maxcos:
                maxcos = cos
                minv = o
                minpoint = p
        if minpoint == point_first: break
        v = minv
        oldpoint = minpoint
        hull.append(minpoint)
    return hull

while True:
    n = int(raw_input())
    if n == 0: break
    d = []
    for t in xrange(n):
        d.append(map(float,raw_input().split(",")))
    h = calc_hull(sorted(d,key=lambda x:-x[1]))
    print len(d) - len(calc_hull(d))

Fixed submission:
import sys

def calc_hull(d,direction):
    maxcos0 = {"r":-1.0,"l":1.0}
    hull = [d[0]]
    p = d[0]
    while True:
        maxcos = maxcos0[direction]
        for i in xrange(1,len(d)):
            if d[i][1] < p[1]  or d[i] == p: continue
            v = [ d[i][0]-p[0] , d[i][1]-p[1] ]
            c = v[0]/(v[0]**2+v[1]**2)**0.5
            if c >= maxcos and direction == "r":
                maxcos = c
                q = d[i]
            if c <= maxcos and direction == "l":
                maxcos = c
                q = d[i]
        p = q
        hull.append(q)
        if q == d[-1]: break
    return hull

while True:
    n = int(raw_input())
    if n == 0: break
    d = []
    for t in xrange(n):
        d.append(map(float,raw_input().split(",")))
    d.sort(key = lambda x:x[1])
    print len(d) - ( len( calc_hull(d,"r") + calc_hull(d,"l") ) - 2)
Buggy python submission (verdict: Runtime Error):
import sys
def index(x,n):
    if x < 0: return 0
    if n < x: return n
    return x

las = map(int,raw_input())
for s in sys.stdin:
    now = map(int,s.split(","))
    nin,lin = len(now)-1,len(las)-1
    if nin > lin: d = -1
    if nin < lin: d = 1
    for i in xrange(nin+1):
        now[i] += max(las[index(i+d,lin)],las[index(i,lin)])
    if not nin: print now[0]
    las = now

Fixed submission:
import sys
def index(x,n):
    if x < 0: return 0
    if n < x: return n
    return x

las = [int(raw_input())]
for s in sys.stdin:
    now = map(int,s.split(","))
    nin,lin = len(now)-1,len(las)-1
    if nin > lin: d = -1
    if nin < lin: d = 1
    for i in xrange(nin+1):
        now[i] += max(las[index(i+d,lin)],las[index(i,lin)])
    if not nin: print now[0]
    las = now
Buggy python submission (verdict: Runtime Error):
print(input()**3)

Fixed submission:
print(int(input())**3)
Buggy python submission (verdict: Runtime Error):
import sys

x = y = 0.000
for i in sys.stdin():
    a, b, c, d, e, f = map(int, i.split())
    y = ((c * d) - (a * f)) / ((b * d) - (a * e))
    x = (c - (b * y)) / a
    print '{0:.3f} {1:.3f}'.format(x, y)

Fixed submission:
while 1:
    try:
        i = raw_input()
        a, b, c, d, e, f = map(float, i.split())
        y = ((c * d) - (a * f)) / ((b * d) - (a * e))
        x = (c - (b * y)) / a
        print "%.3f %.3f" % (x, y)
    except:
        break

Buggy python submission (verdict: Runtime Error):
x = y = 0.000
for i in sys.stdin():
    a, b, c, d, e, f = map(int, i.split())
    y = ((c * d) - (a * f)) / ((b * d) - (a * e))
    x = (c - (b * y)) / a
    print '{0:.3f} {1:.3f}\n'.format(x, y)

Fixed submission:
while 1:
    try:
        i = raw_input()
        a, b, c, d, e, f = map(float, i.split())
        y = ((c * d) - (a * f)) / ((b * d) - (a * e))
        x = (c - (b * y)) / a
        print "%.3f %.3f" % (x, y)
    except:
        break
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def isprime(i):
    if i == 1:
        return False
    elif i == 2 or i == 3:
        return True
    else:
        for k in range(2, (i / 2) + 1):
            if i % k == 0:
                return False
        return True

for line in sys.stdin:
    n = int(line)
    cnt = 0
    for i in range(1, n + 1):
        if isprime(i):
            cnt += 1
    print cnt

Fixed submission:
max_num = 1000000
cnt = 0
p = [1] * max_num
p[0] = p[1] = 0
for i in xrange(2, int(max_num ** 0.5) + 1):
    if p[i]:
        p[i * i::i] = [0] * len(p[i * i::i])

for i in xrange(max_num):
    cnt += p[i]
    p[i] = cnt

while True:
    try: print(p[int(raw_input())])
    except: break

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def isprime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True

for line in sys.stdin:
    n = int(line)
    cnt = 0
    for i in range(1, n + 1):
        if isprime(i):
            cnt += 1
    print cnt

Fixed submission:
max_num = 1000000
cnt = 0
p = [1] * max_num
p[0] = p[1] = 0
for i in xrange(2, int(max_num ** 0.5) + 1):
    if p[i]:
        p[i * i::i] = [0] * len(p[i * i::i])

for i in xrange(max_num):
    cnt += p[i]
    p[i] = cnt

while True:
    try: print(p[int(raw_input())])
    except: break
Buggy python submission (verdict: Runtime Error):
import math

n = input()
for i in xrange(n):
    result = long(raw_input()) + long(raw_input())
    if int(math.log10(result)) + 1 >80: print "overflow"
    else: print result

Fixed submission:
n = input()
limit = 10 ** 80
for i in xrange(n):
    result = input() + input()
    if result >= limit: print "overflow"
    else: print result

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

n = input()
for i in xrange(n):
    result = long(raw_input()) + long(raw_input())
    if math.log10(result) + 1 >80: print "overflow"
    else: print result

Fixed submission:
n = input()
limit = 10 ** 80
for i in xrange(n):
    result = input() + input()
    if result >= limit: print "overflow"
    else: print result
Buggy python submission (verdict: Runtime Error):
while 1:
    n = input()
    if n == 0: break
    sums = []
    a, b, c = 0, 0, input()
    for i in xrange(n - 1):
        sums.append(a + b + c)
        a, b, c = b, c, input()
    print max(sums)

Fixed submission:
while 1:
    n = input()
    if n == 0: break
    sums = [-100000]
    for i in xrange(n):
        num = input()
        sums.append(max(sums[-1] + num, num))
    print max(sums)
Buggy python submission (verdict: Runtime Error):
import itertools

while 1:
    n, s = map(int, raw_input().split())
    d = [i for i in xrange(s)]
    if n == 0: break
    x = map(sum, list(itertools.combinations(d, n)))
    print x.count(s)

Fixed submission:
import itertools

d = xrange(10)
while 1:
    n, s = map(int, raw_input().split())
    if n == 0: break
    x = map(sum, list(itertools.combinations(d, n)))
    print x.count(s)

Buggy python submission (verdict: Runtime Error):
import itertools

d = [i for i in xrange(101)]
while 1:
    n, s = map(int, raw_input().split())
    if n == 0: break
    x = map(sum, list(itertools.combinations(d[0:s + 1], n)))
    print x.count(s)

Fixed submission:
import itertools

d = xrange(10)
while 1:
    n, s = map(int, raw_input().split())
    if n == 0: break
    x = map(sum, list(itertools.combinations(d, n)))
    print x.count(s)
Buggy python submission (verdict: Runtime Error):
N = input()
for i in xrange(N):
    b, c = 0, 0
    for j in map(int, raw_input().split()):
        if b[-1] < j: b = j
        elif c[-1] < j: c = j
        else: break
    else:
        print 'YES'
        continue
    print 'NO'

Fixed submission:
for i in xrange(input()):
    b, c = 0, 0
    for j in map(int, raw_input().split()):
        if b < j: b = j
        elif c < j: c = j
        else: break
    else:
        print 'YES'
        continue
    print 'NO'
Buggy python submission (verdict: Runtime Error):
while True:
    num = input()
    for i in range(num): print raw_input().replace("Hoshino", "Hoshina")

Fixed submission:
for i in range(input()): print raw_input().replace("Hoshino", "Hoshina")
Buggy python submission (verdict: Runtime Error):
while True:
    num = input()
    if num == 0: break

    sht = []
    for i in range(num):
        sht.append(map(int, raw_input().split()))
        sht[i].append(sum(sht[i]))
        print " ".join(map(str, sht[i]))

    row = []
    for i in range(num + 1):
        sum = 0
        for j in range(num):
            sum += sht[j][i]
        row.append(sum)
    print " ".join(map(str, row))

Fixed submission:
while True:
    num = input()
    if num == 0: break

    mrx = []
    row = [0] * (num + 1)
    for i in range(num):
        mrx.append(map(int, raw_input().split()))
        mrx[i].append(sum(mrx[i]))
        for j in range(num + 1): row[j] += mrx[i][j]
    mrx.append(row)
    for i in mrx: print "".join([str(s).rjust(5) for s in i])
Buggy python submission (verdict: Runtime Error):
def check(item):
    price = 0
    for i in recipe[item[-1]]:
        if recipe.has_key(i) == False:
            price += pricelist[i]
        else:
            item.append(i)
            price += min(check(item), pricelist[item[-1]])
            item.pop()
    return price

while True:
    pricelist = {}
    recipe = {}

    n = input()
    if n == 0: break

    for i in range(n):
        item, price = raw_input().split()
        pricelist[item] = int(price)

    m = input()
    for i in range(m):
        data = raw_input().split()
        recipe[data[0]] = []
        for j in range(int(data[1])):
            recipe[data[0]].append(data[j + 2])

    price = check([raw_input()])
    print price

Fixed submission:
def work(item):
    if recipe.has_key(item):
        price = 0
        for i in recipe[item]: price += work(i)
        p_list[item] = min(price, p_list[item])
        del recipe[item]
    return p_list[item]

while True:
    p_list = {}
    recipe = {}

    n = input()
    if n == 0: break

    for i in range(n):
        item, price = raw_input().split()
        p_list[item] = int(price)

    m = input()
    for i in range(m):
        data = raw_input().split()
        recipe[data[0]] = []
        for j in range(int(data[1])):
            recipe[data[0]].append(data[j + 2])

    if m == 0:
        print p_list[raw_input()]
    else:
        price = work(raw_input())
        print price
Buggy python submission (verdict: Runtime Error):
c = 0
n = input()
a = map(int, input_raw().split())

for i in range(n):
	for j in range(n -1, i + 1, -1):
		if a[j] < a[j - 1]:
			a[j], a[j - 1] = a[j], a[j - 1]
			c += 1

print(" ".join(map(str, a)))
print(c)

Fixed submission:
n = input()
a = map(int, raw_input().split())

c = 0
for i in range(n):
    for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            c += 1

print(" ".join(map(str, a)))
print(c)

Buggy python submission (verdict: Runtime Error):
def main():
	c = 0
	n = input()
	a = map(int, input_raw().split())

	for i in range(n):
		for j in range(n -1, i + 1, -1):
			if a[j] < a[j - 1]:
				a[j], a[j - 1] = a[j], a[j - 1]
				c += 1

	print(" ".join(map(str, a)))
	print(c)

main()

Fixed submission:
n = input()
a = map(int, raw_input().split())

c = 0
for i in range(n):
    for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            c += 1

print(" ".join(map(str, a)))
print(c)
Buggy python submission (verdict: Runtime Error):
max = 9
for x in xrange(max):
	for y in xrange(max):
		print %dx%d=%d % (x, y, x * y)

Fixed submission:
max = 10
for x in xrange(1, max):
	for y in xrange(1, max):
		print "%dx%d=%d" % (x, y, x * y)
Buggy python submission (verdict: Runtime Error):
import sys

data_length = int(sys.stdin.readline())
lines[]
for x in xrange(data_length):
	input_line = sys.stdin.readline()
	lines = map(int, input_line.strip().split())
	lines.sort(reverse = True)
	if lines[0]**2 == (lines[1]**2 + lines[2]**2):
		print "YES"
	else:
		print "NO"

Fixed submission:
import sys

data_list = sys.stdin.readlines()
data_length = int(data_list.pop(0))

for x in xrange(data_length):
	lines = map(int, data_list[x].strip().split())
	lines.sort(reverse = True)
	if lines[0]**2 == (lines[1]**2 + lines[2]**2):
		print "YES"
	else:
		print "NO"
Buggy python submission (verdict: Runtime Error):
num = int(sys.stdin.readlines())
ans = num　** 3
print ans

Fixed submission:
import sys
num = int(sys.stdin.readline())
ans = num ** 3
print ans

Buggy python submission (verdict: Runtime Error):
num = int(sys.stdin.readline())
ans = num ** 3
print ans

Fixed submission:
import sys
num = int(sys.stdin.readline())
ans = num ** 3
print ans
Buggy python submission (verdict: Runtime Error):
for i in range(9):
    for j in range(9):))
        print('%sx%s=%s' % ((i+1), (j+1), (i+1)*(j+1)

Fixed submission:
# coding: utf-8
# Here your code !
for i in range(9):
    for j in range(9):
        print('%sx%s=%s' % ((i+1), (j+1), (i+1)*(j+1)))
Buggy python submission (verdict: Time Limit Exceeded):
import math as m
while True:
	try:
		n=int(input())
		a=[0]*(n+1)
		a[0],a[1]=1,1
		for i in range(2,int(m.sqrt(n))+1):
			for j in range(2,int(n/i)+1):
				a[i*j]=1
		print(a.count(0))
	except:
		break

Fixed submission:
while True:
	try:
		n=int(input())
		a=[True]*(n+1)
		a[0]=a[1]=False
		for i in range(2,int(n**0.5)+1):
			if a[i]:
				for j in range(i**2,n+1,i):
					a[j]=False
		print(a.count(True))
	except:
		break
Buggy python submission (verdict: Runtime Error):
while True:
	n=int(input())
	if n:
		a=[list(map(int,input().split())) for _ in range(n)]
		b={}
		for i in range(n):
			if a[i][0] in b:
				b[a[i][0]]+=a[i][1]*a[i][2]
			else:
				b[a[i][0]]=a[i][1]*a[i][2]
		for k in b.keys():
			if b[k]>=1000000:
				print(k)
		if max(k.values())<1000000:
			print("NA")
	else:
		break

Fixed submission:
while True:
	n=int(input())
	if n==0: break
	l=[]
	d={}
	for _ in range(n):
		a,b,c=list(map(int,input().split()))
		if a in d:
			d[a]+=b*c
		else:
			d[a]=b*c
			l.append(a)
	if max(d.values())<1000000:
		print("NA")
	else:
		for k in l:
			if d[k]>=1000000:
				print(k)

Buggy python submission (verdict: Runtime Error):
while True:
	n=int(input())
	if n==0: break
	l=[]
	d={}
	for i in range(n):
		i,p,q=list(map(int,input().split()))
		if a in d:
			d[a]+=b*c
		else:
			d[a]=b*c
			l.append(a)
	if max(d.values())<1000000:
		print("NA")
	else:
		for k in l:
			if d[k]>=1000000:
				print(k)

Fixed submission:
while True:
	n=int(input())
	if n==0: break
	l=[]
	d={}
	for _ in range(n):
		a,b,c=list(map(int,input().split()))
		if a in d:
			d[a]+=b*c
		else:
			d[a]=b*c
			l.append(a)
	if max(d.values())<1000000:
		print("NA")
	else:
		for k in l:
			if d[k]>=1000000:
				print(k)
Buggy python submission (verdict: Time Limit Exceeded):
c = 0
n = int(input())
for _ in range(n):
	t = int(input())
	for i in range(2,t):
		if t%i==0:
			break
	else:
		c+=1
print(c)

Fixed submission:
import math
c = 0
n = int(input())
for _ in range(n):
	t = int(input())
	for i in range(2,int(math.sqrt(t)+1)):
		if t%i==0:
			break
	else:
		c+=1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
c = 0
n = int(input())
for _ in range(n):
	t = int(input())
	for i in range(2,t):
		if t%i==0:
			break
	else:
		c+=1
print(c)

Fixed submission:
import math
c = 0
n = int(input())
for _ in range(n):
	t = int(input())
	for i in range(2,int(math.sqrt(t)+1)):
		if t%i==0:
			break
	else:
		c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
count = 0
a,b,c = map(int,input().split())
for i in range(a,b+1)
	if c%i==0:
		count+=1
print(count)

Fixed submission:
count = 0
a,b,c = map(int,input().split())
for i in range(a,b+1):
	if c%i==0:
		count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
line = sys.stdin.readlines()
a,b = map(int, line.strip().split(','))

Fixed submission:
for i in range(1, 10):
	for j in range(1, 10):
		print "%sx%s=%s"%(i,j,i*j)
Buggy python submission (verdict: Runtime Error):
while True:
	a,b = map(int,raw_input().split())
   	print len(str(a+b))

Fixed submission:
while True:
    try:
        a,b = map(int,raw_input().split())
        print len(str(a+b))
    except EOFError:
        break