Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
while True:
    things = {}
    count = input()
    if count == 0: break
    for i in range(count):
        fuga = raw_input().split()
        things[fuga[0]] = int(fuga[1])
    for i in range(input()):
        fuga = raw_input().split()
        money =0
        for j in range(int(fuga[1])):
            money+= things[fuga[j+2]]
        things[fuga[0]] = things[fuga[0]] if money > things[fuga[0]] else money
    ans = raw_input()
    fin = things[ans] if ans in things else 0
    print fin

Fixed submission:
q,w,e=range,input,raw_input
while True:
  n=w()
  if n==0:break
  d={}
  for i in q(n):
    o=e().split()
    d[o[0]]=int(o[1])
  for j in q(w()):
    t=e().split()
    a=sum([d[i] if i in d else 0 for i in t[2:]])
    d[t[0]]=a if a<d[t[0]] else d[t[0]]
  print d[e()]

Buggy python submission (verdict: Runtime Error):
while True:
&#160;&#160;&#160;&#160;ts={}
&#160;&#160;&#160;&#160;c=input()
&#160;&#160;&#160;&#160;if c==0: break
&#160;&#160;&#160;&#160;for i in range(c):
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;f=raw_input().split()
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ts[f[0]]=int(f[1])
&#160;&#160;&#160;&#160;for i in range(input()):
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;f=raw_input().split()
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;m=0
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for j in range(int(f[1])):
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;h=ts[f[j+2]] if f[j+2] in ts else 0
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;m+=h
	q=ts[f[0]]
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ts[f[0]]=q if m > q else m
&#160;&#160;&#160;&#160;print ts[raw_input()]

Fixed submission:
q,w,e=range,input,raw_input
while True:
  n=w()
  if n==0:break
  d={}
  for i in q(n):
    o=e().split()
    d[o[0]]=int(o[1])
  for j in q(w()):
    t=e().split()
    a=sum([d[i] if i in d else 0 for i in t[2:]])
    d[t[0]]=a if a<d[t[0]] else d[t[0]]
  print d[e()]

Buggy python submission (verdict: Runtime Error):
q,w,e=range,input,raw_input
while True:
  n=w()
  if n==0:break
  d={}
  for i in q(n):
    o=e().split()
    d[o[0]]=int(o[1])
  for j in q(w()):
    t=e().split()
    a=sum([d[i] for i in t[2:]])
    d[t[0]]=a if a<d[t[0]] else d[t[0]]
  print d[e()]

Fixed submission:
q,w,e=range,input,raw_input
while True:
  n=w()
  if n==0:break
  d={}
  for i in q(n):
    o=e().split()
    d[o[0]]=int(o[1])
  for j in q(w()):
    t=e().split()
    a=sum([d[i] if i in d else 0 for i in t[2:]])
    d[t[0]]=a if a<d[t[0]] else d[t[0]]
  print d[e()]
Buggy python submission (verdict: Runtime Error):
while True:
    q={}
    a=input()
    if a==0:break
    for i in range(10): q[i]=0
    for i in range(a): q[input()]+=1
    for i in range(10):  print "*"*q[i] if q[i] != 0 else "-"

Fixed submission:
while True:
    try:
        q={}
        a=input()
        if a==0:break
        for i in range(10): q[i]=0
        for i in range(a): q[input()]+=1
        for i in range(10):  print "*"*q[i] if q[i] != 0 else "-"
    except SyntaxError: pass
Buggy python submission (verdict: Runtime Error):
while 1:
 print sum(map(int,raw_input().split()))
except: break

Fixed submission:
while True:
 try:
  a = map(int,raw_input().split())
  a,b = a[0],a[1]
  print a+b
 except EOFError:
  break
Buggy python submission (verdict: Runtime Error):
input = input()
a,b = input.split()
print(a * b, a*2 + b*2)


Fixed submission:
input = input()
a,b = map(int, input.split())
print(a * b, a*2 + b*2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    print('YES' if abs((x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1)) < 1e-10 else 'NO')

Fixed submission:
n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    print('YES' if abs((x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1)) < 1e-10 else 'NO')
Buggy python submission (verdict: Runtime Error):
h={15:2244,12:1870,10:1520,5:850,3:550,2:380}
m={0:0}

for i in range(50):
  if i in m:
    for k,v in h.items():
      m[i+k] = min(m.get(i+k,1e9),m[i]+v)

while True:
  n = input()
  if n == 0 : break
  print(m[n/100])

Fixed submission:
h={15:2244,12:1870,10:1520,5:850,3:550,2:380}
m={0:0}

for i in range(50):
  if i in m:
    for k,v in h.items():
      m[i+k] = min(m.get(i+k,1e9),m[i]+v)

while True:
  n = input()
  if n == 0 : break
  print(m[n/100])
Buggy python submission (verdict: Runtime Error):
s=[]
for i in raw_input().split():
    if i<"0":
        t=s.pop()
        s.append("("+s.pop()+i+t+")")
    else:
        s.append(i)
print eval(s[0])

Fixed submission:
s=[]
for i in raw_input().split():
    if i<"0":
        t=s.pop()
        s.append(str(eval(s.pop()+i+t)))
    else:
        s.append(i)
print s[0]
Buggy python submission (verdict: Runtime Error):
def f(n,d):
    t=[f(i,d+1)+1 for i in l[n][1]]
    h=0 if t==[] else max(t)
    c[n][3:3]=[len(l[n][1]),d,h,"root" if d<1 else "leaf" if h<1 else "internal node"]
    return h
m=input()
c=[0]*m
l=sorted([map(int,raw_input().split()) for _ in range(m)])
for i in l:
    n,a,b=i
    if a>0:c[a]=[a,n,b]
    if b>0:c[b]=[b,n,a]
    i[1:]=[[j for j in i[1:] if j>=0]]
n=c.index(0)
c[n]=[n,-1,-1]
f(n,0)
for i in c:print "node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}".format(*i)

Fixed submission:
def f(n,d):
    t=[f(i,d+1)+1 for i in l[n][1]]
    h=0 if t==[] else max(t)
    c[n][3:3]=[len(l[n][1]),d,h,"root" if d<1 else "leaf" if h<1 else "internal node"]
    return h
m=input()
c=[0]*m
l=sorted([map(int,raw_input().split()) for _ in range(m)])
for i in l:
    n,a,b=i
    if a>=0:c[a]=[a,n,b]
    if b>=0:c[b]=[b,n,a]
    i[1:]=[[j for j in i[1:] if j>=0]]
n=c.index(0)
c[n]=[n,-1,-1]
f(n,0)
for i in c:print "node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}".format(*i)
Buggy python submission (verdict: Runtime Error):
#coding utf-8
a,b = map(int,input().split())
if(a == b):
	print('a == b')
elif(a < b):
	print('a < b')
else:
	print(


Fixed submission:
a,b = map(int,input().split())
if(a == b):
	print("a == b")
elif(a < b):
	print("a < b")
else:
	print("a > b")

Buggy python submission (verdict: Runtime Error):
#coding utf-8
a,b = map(int,input().split())
if(a == b):
	print('a == b')
elif(a < b):
	print('a < b')
else:
	print(


Fixed submission:
a,b = map(int,input().split())
if(a == b):
	print("a == b")
elif(a < b):
	print("a < b")
else:
	print("a > b")

Buggy python submission (verdict: Runtime Error):
#coding utf-8
a,b = map(int,input().split())
if(a == b):
	print('a == b',sep="")
elif(a < b):
	print('a < b',sep="")
else:
	print('a > 


Fixed submission:
a,b = map(int,input().split())
if(a == b):
	print("a == b")
elif(a < b):
	print("a < b")
else:
	print("a > b")
Buggy python submission (verdict: Runtime Error):
while True:
    try:
        input_line = input()
        if input_line == '':
            break
        else:
            nums = list(map(int, input_line.split()))
            max_num = max(nums)
            nums.remove(max_num)
            if max_num**2 == nums[0]**2 + nums[1]**2:
                print("YES")
            else:
                print("NO")
    except EOFError:
        break


Fixed submission:
n = int(input())
for i in range(0, n):
    nums = list(map(int, input().split()))
    max_num = max(nums)
    nums.remove(max_num)
    if max_num**2 == nums[0]**2 + nums[1]**2:
        print("YES")
    else:
        print("NO")
Buggy python submission (verdict: Runtime Error):
a = sorted(list(map(int, input().split())))

for i in range(len(a)):
    if i == 0:
        print(a[i], end="")
    else:
        print(' '+ '{}'.format(a[i]), end="")

Fixed submission:
a = sorted(list(map(int, input().split())))

for i in range(len(a)):
    if i == len(a)-1:
        print(a[i])
    else:
        print(a[i], end=" ")
Buggy python submission (verdict: Runtime Error):
import math

r = int(input())
pi = math.pi

area = ('%03.6f' % (r * r * pi))
length = ('%03.6f' % (2 * r * pi))

print(area, length, sep=" ")

Fixed submission:
import math
r = float(input())

area = math.pi * r**2
length = 2 * r * math.pi

print("{:.6f} {:.6f}".format(area, length))
Buggy python submission (verdict: Runtime Error):
n = input()

for i in range(n):
    a = input(),
    b = input()
    print a + b

Fixed submission:
n = input()

for i in range(n):
    a = input()
    b = input()
    c = int(a) + int(b)
    if len(str(c)) > 80:
        print 'overflow'
    else:
        print a + b

Buggy python submission (verdict: Runtime Error):
n = input()

for i in range(n):
    a = input(),
    b = input()
    c = a + b
    if len(a) > 80 or len(b) > 80 or len(c) > 80 :
        print 'overflow'
    else:
        print a + b

Fixed submission:
n = input()

for i in range(n):
    a = input()
    b = input()
    c = int(a) + int(b)
    if len(str(c)) > 80:
        print 'overflow'
    else:
        print a + b
Buggy python submission (verdict: Runtime Error):
from math import pi
r = int(input())
print("{} {}".format(pi*(r**2), 2*pi*r))

Fixed submission:
from math import pi

r = float(input())
print("{:.10f} {:.10f}".format(pi*(r**2), 2*pi*r))

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

r = input()
print("{:.10f} {:.10f}".format(pi*(r**2), 2*pi*r))

Fixed submission:
from math import pi

r = float(input())
print("{:.10f} {:.10f}".format(pi*(r**2), 2*pi*r))

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

r = input()
print("{:.10f} {:.10f}".format(pi*(r**2), 2*pi*r))

Fixed submission:
from math import pi

r = float(input())
print("{:.10f} {:.10f}".format(pi*(r**2), 2*pi*r))

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

r = int(input())
print("{:.10f} {:.10f}".format(pi*(r**2), 2*pi*r))

Fixed submission:
from math import pi

r = float(input())
print("{:.10f} {:.10f}".format(pi*(r**2), 2*pi*r))
Buggy python submission (verdict: Runtime Error):
a = input()
print(a**3)

Fixed submission:
a = int(input())
print(a**3)
Buggy python submission (verdict: Runtime Error):
import sys
  
for s in sys.stdin:
    g,r=m,n = map(int,s.split())
    while r!=0:
      g,r = r,g%r
    print(g,m//g*n)

Fixed submission:
import sys
  
for s in sys.stdin:
    m,n = map(int,s.split())
    g,r = m,n
    while r!=0:
      g,r = r,g%r
    print(g,m//g*n)
Buggy python submission (verdict: Runtime Error):
import math
import itertools
x = 100
for _ in itertools.repeat(None,int(input())):
    x = math.ceil(x*1.05)
print(x*1000)

Fixed submission:
print(input()[::-1])
Buggy python submission (verdict: Runtime Error):
import sys
import math
import array from array

M = 1000000
B = int(math.sqrt(M)+1)//6+1
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = array('I',[1]) * N1
m = array('I',[1]) * N2
i = 5
ini = 4
for p in range(B):
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])
    i += 6
    ini += 5
 
for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

Fixed submission:
import sys
from array import array

N = 1000000
primes = array('I',[1]) * (N//2)
primes[0] = 0

for i in range(3,int(N**0.5),2):
    if primes[i//2]:
        primes[(i*i)//2::i] = array('I',[0]) * len(primes[(i*i)//2::i])

for i in sys.stdin:
    n = int(i)
    if n < 4:
        print(n-1)
    else:
        print(sum(primes[:(n+1)//2])+1)

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

M = 1000000
B = int(math.sqrt(M)+1)//6+1
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = array('I',[1]) * N1
m = array('I',[1]) * N2
i = 5
ini = 4
for p in range(B):
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])
    i += 6
    ini += 5
 
for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

Fixed submission:
import sys
from array import array

N = 1000000
primes = array('I',[1]) * (N//2)
primes[0] = 0

for i in range(3,int(N**0.5),2):
    if primes[i//2]:
        primes[(i*i)//2::i] = array('I',[0]) * len(primes[(i*i)//2::i])

for i in sys.stdin:
    n = int(i)
    if n < 4:
        print(n-1)
    else:
        print(sum(primes[:(n+1)//2])+1)
Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())
minv = int(input())
maxv = -1000000000

for r in map(int,sys.stdin.readlines()):
  if maxv < r-minv < 0:
    maxv = r-minv
    minv = r
  elif maxv < r-minv:
    maxv = r-minv
  elif m < 0:
    minv = r

print(maxv)

Fixed submission:
import sys
 
l = sys.stdin.readlines()
minv = int(l[1])
maxv = -1000000000

for r in map(int,l[2:]):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
 
print(maxv)

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

n = int(input())
minv = int(input())
maxv = -1000000000

for r in map(int,sys.stdin.readlines()):
  if maxv < r-minv < 0:
    maxv = r-minv
    minv = r
  elif maxv < r-minv:
    maxv = r-minv
  elif m < 0:
    minv = r

print(maxv)

Fixed submission:
import sys
 
l = sys.stdin.readlines()
minv = int(l[1])
maxv = -1000000000

for r in map(int,l[2:]):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
 
print(maxv)

Buggy python submission (verdict: Runtime Error):
import sys
 
n = int(input())
minv = int(input())
maxv = -1000000000
 
for r in map(int,sys.stdin.readlines()):
  m = r-minv
  if maxv < m: maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
 
print(maxv)

Fixed submission:
import sys
 
l = sys.stdin.readlines()
minv = int(l[1])
maxv = -1000000000

for r in map(int,l[2:]):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
 
print(maxv)
Buggy python submission (verdict: Runtime Error):
import sys
import math

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

n = int(input())
a = list(map(int, sys.stdin.readlines()))
b = 701
g = [x for x in [1,4,10,23,57,132,301,701] if x <= n]
while True:
    b = math.floor(2.25*b)
    if b > n:
        break
    g.append(b)
g = g[::-1]

for i in g:
    insertion_sort(a, n, i)

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

Fixed submission:
import sys
import math

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

n = int(input())
a = list(map(int, sys.stdin.readlines()))

b = math.floor(2.25*701)
g = [x for x in [1,4,10,23,57,132,301,701] if x <= n]

while b<=n:
    g.append(b)
    b = math.floor(2.25*b)
g = g[::-1]

for i in g:
    insertion_sort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(ct)
print(*a, sep="\n")
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
c = list(map(int,input().split()))

minimum = [50000] * (n+1)
minimum[0] = 0

for i in range(1,n+1):
    if c[j] <= 2:
        continue
    for j in range(m):
        if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1

print(minimum[n])

Fixed submission:
n = int(input().split()[0])
c = list(map(int,input().split()))
dp = list(range(n+1))

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

print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
l = list(map(int, input().split()))
d = [0] * (n+1)

for i in range(1,n+1):
    if i in l:
        d[i] = 1
    else:
        min = 50000
        for j in range(i+1):
            if d[i-j]+d[j] < min and d[i-j]+d[j]>0:
                min = d[i-j] + d[j]
        d[i] = min

print(d[n])

Fixed submission:
n = int(input().split()[0])
c = list(map(int,input().split()))
dp = list(range(n+1))

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

print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int, input().split())
v = [0] * N
w = [0] * N
dp = [[0]*(W+1)]*(N+1)

for i in range(N):
    v[i], w[i] = map(int, input().split())

def rec(i,j,dp):
    res = 0
    if dp[i][j] > 0:
        return dp[i][j]
    if i<0:
        return 0
    elif j < w[i]:
        res = rec(i-1, j, dp)
    else:
        res = max(rec(i-1,j,dp),rec(i-1, j-w[i],dp)+v[i])

    return res
print(rec(N-1,W,dp))

Fixed submission:
N,W = map(int, input().split())
dp = [0]*(W+1)

for i in range(1,N+1):
    v,w = map(int,input().split())
    for j in range(W, w-1, -1):
        x = v+dp[j-w]
        if x > dp[j]: dp[j] = x

print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):

N,W = map(int, input().split())
v = [0] * N
w = [0] * N
dp = [[-1]*(W+1)]*(N+1)

for i in range(N):
    v[i], w[i] = map(int, input().split())

def rec(i,j,dp):
    res = 0
    if dp[i][j] != -1:
        return dp[i][j]
    if i<0:
        return 0
    elif j < w[i]:
        res = rec(i-1, j, dp)
    else:
        res = max(rec(i-1,j,dp),rec(i-1, j-w[i],dp)+v[i])

    return res
print(rec(N-1,W,dp))

Fixed submission:
N,W = map(int, input().split())
dp = [0]*(W+1)

for i in range(1,N+1):
    v,w = map(int,input().split())
    for j in range(W, w-1, -1):
        x = v+dp[j-w]
        if x > dp[j]: dp[j] = x

print(dp[W])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())                                                                
  2 print("{0} {1} {2:0f}".format(a//b,a%b,a/b))

Fixed submission:
a,b = map(int,input().split())                                                                
print("{0} {1} {2:0f}".format(a//b,a%b,a/b))
Buggy python submission (verdict: Runtime Error):
input()
n = map(int,input().split())
print(min(n),max(x),sum(s))

Fixed submission:
input()
n = list(map(int,input().split()))
print(min(n),max(n),sum(n))

Buggy python submission (verdict: Runtime Error):
input()
n = map(int,input().split())
print(min(n),max(n),sum(n))

Fixed submission:
input()
n = list(map(int,input().split()))
print(min(n),max(n),sum(n))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

strs = []

for i in range(n):
    s = input().split()
    if(s[0] == 'insert'):
        if(s[1] not in strs):
            strs.append(s[1])
    else:
        if(s[1] in strs):
            print('yes')
        else:
            print('no')


Fixed submission:
n = int(input())

strs = {}

for i in range(n):
    s = input().split()
    if(s[0] == 'insert'):
        if(s[1] not in strs):
            strs[s[1]] = ''
    else:
        if(s[1] in strs):
            print('yes')
        else:
            print('no')
Buggy python submission (verdict: Runtime Error):
import math
a = int(input())
print(str("{0:.6f}".format((a * a) * math.pi)) + " " + str("{0:.5f}".format((a + a) * math.pi)))


Fixed submission:
import math
a = float(input())
print(str("{0:.6f}".format((a * a) * math.pi)) + " " + str("{0:.5f}".format((a + a) * math.pi)))

Buggy python submission (verdict: Runtime Error):
import math
a = int(input())
print(str("{0:.6f}".format((a * a) * math.pi)) + " " + str("{0:.5f}".format((a + a) * math.pi)))


Fixed submission:
import math
a = float(input())
print(str("{0:.6f}".format((a * a) * math.pi)) + " " + str("{0:.5f}".format((a + a) * math.pi)))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
from fractions import Fraction
import sys
if sys.version_info[0]>=3: raw_input=input

def gauss(a):
	if not a or len(a)==0: return None
	n=len(a)
	for i in range(n):
		if a[i][i]==0:
			for j in range(i+1,n):
				if a[j][i]!=0:
					for k in range(i,n+1): a[i][k]+=a[j][k]
					break
		for j in range(n):
			if i!=j:
				r = Fraction(a[j][i],a[i][i])
				for k in range(i,n+1): a[j][k] = a[j][k] - a[i][k]*r
	for i in range(n):
		x=Fraction(a[i][i],1)
		for j in range(len(a[i])):
			a[i][j] /= x
	return a

uaz=list(map(int,raw_input().split()))
enemy=[0]+[-x+y for x,y in zip(map(int,raw_input().split()),uaz)]
b0=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b1=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b2=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
sol=gauss(list(map(list,zip(b0,b1,b2,enemy,[1,0,0,0]))))
print('MISS' if sol and all(0<=e[-1]<=1 for e in sol) else 'HIT')

Fixed submission:
#!/usr/bin/python
from fractions import Fraction
import sys
if sys.version_info[0]>=3: raw_input=input

def gauss(a):
	if not a or len(a)==0: return None
	n=len(a)
	for i in range(n):
		if a[i][i]==0:
			for j in range(i+1,n):
				if a[j][i]!=0:
					for k in range(i,n+1): a[i][k]+=a[j][k]
					break
			else:
				return None
		for j in range(n):
			if i!=j:
				r = Fraction(a[j][i],a[i][i])
				for k in range(i,n+1): a[j][k] = a[j][k] - a[i][k]*r
	for i in range(n):
		x=Fraction(a[i][i],1)
		for j in range(len(a[i])):
			a[i][j] /= x
	return a

uaz=list(map(int,raw_input().split()))
enemy=[0]+[-x+y for x,y in zip(map(int,raw_input().split()),uaz)]
b0=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b1=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b2=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
sol=gauss(list(map(list,zip(b0,b1,b2,enemy,[1,0,0,0]))))
print('MISS' if sol and all(0<=e[-1]<=1 for e in sol) else 'HIT')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	y,m,d=[int(e) for e in raw_input().split()]
	y-=1;m-=1
	print(196471-y*195-y//3*5-m*20+(m//2 if y%3!=2 else 0)-a[2])

Fixed submission:
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=[int(e) for e in raw_input().split()]
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2])

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

n=int(sys.stdin.readline())
for i in range(0,n):
	a=map(int,sys.stdin.readline().split())
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])

Fixed submission:
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=[int(e) for e in raw_input().split()]
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2])

Buggy python submission (verdict: Runtime Error):
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=map(int,raw_input())
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])

Fixed submission:
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=[int(e) for e in raw_input().split()]
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2])

Buggy python submission (verdict: Runtime Error):
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=map(int,raw_input().split())
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])

Fixed submission:
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=[int(e) for e in raw_input().split()]
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2])