Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
v, w = [0] * N, [0] * N
for i in range(N):
    v[i], w[i] = map(int, input().split())

def rec(i, weight):
    if i == N:
        return 0
    elif weight + w[i] <= W:
        return max(rec(i+1, weight), rec(i+1, weight + w[i]) + v[i])
    else:
        return rec(i+1, weight)
print(rec(0, 0))

Fixed submission:
N, maxW = map(int, input().split())
V, W = [], []
for i in range(N):
    v, w = map(int, input().split())
    V.append(v); W.append(w)
dp = [[0]*(maxW+1) for _ in range(2)]
for i in range(N):
    for j in range(maxW+1):
        if j < W[i]:
            dp[(i+1)&1][j] = dp[i&1][j]
        else:
            dp[(i+1)&1][j] = max(dp[i&1][j], dp[i&1][j-W[i]] + V[i])
print(dp[N&1][maxW])

Buggy python submission (verdict: Time Limit Exceeded):
import functools
N, W = map(int, input().split())
v, w = [0] * N, [0] * N
for i in range(N):
    v[i], w[i] = map(int, input().split())


@functools.lru_cache(maxsize=None)
def rec(i, weight):
    if i == N:
        return 0
    elif weight + w[i] <= W:
        return max(rec(i+1, weight), rec(i+1, weight + w[i]) + v[i])
    else:
        return rec(i+1, weight)
print(rec(0, 0))

Fixed submission:
N, maxW = map(int, input().split())
V, W = [], []
for i in range(N):
    v, w = map(int, input().split())
    V.append(v); W.append(w)
dp = [[0]*(maxW+1) for _ in range(2)]
for i in range(N):
    for j in range(maxW+1):
        if j < W[i]:
            dp[(i+1)&1][j] = dp[i&1][j]
        else:
            dp[(i+1)&1][j] = max(dp[i&1][j], dp[i&1][j-W[i]] + V[i])
print(dp[N&1][maxW])

Buggy python submission (verdict: Time Limit Exceeded):
import functools
N, W = map(int, input().split())
v, w = [0] * N, [0] * N
for i in range(N):
    v[i], w[i] = map(int, input().split())


@functools.lru_cache(maxsize=1 << 20)
def rec(i, weight):
    if i == N:
        return 0
    elif weight + w[i] <= W:
        return max(rec(i+1, weight), rec(i+1, weight + w[i]) + v[i])
    else:
        return rec(i+1, weight)
print(rec(0, 0))

Fixed submission:
N, maxW = map(int, input().split())
V, W = [], []
for i in range(N):
    v, w = map(int, input().split())
    V.append(v); W.append(w)
dp = [[0]*(maxW+1) for _ in range(2)]
for i in range(N):
    for j in range(maxW+1):
        if j < W[i]:
            dp[(i+1)&1][j] = dp[i&1][j]
        else:
            dp[(i+1)&1][j] = max(dp[i&1][j], dp[i&1][j-W[i]] + V[i])
print(dp[N&1][maxW])
Buggy python submission (verdict: Time Limit Exceeded):
import functools


@functools.lru_cache(maxsize=None)
def rec(state, v):
    if state == (1 << V) - 1 and v == 0:
        return 0
    ret = INF
    for c, w in edge[v]:
        if not (state >> c & 1):
            ret = min(ret, rec(state | 1 << c, c) + w)
    return ret

INF = 10**6
V, E = map(int, input().split())
edge = [[] for _ in range(V)]
for _ in range(E):
    s, t, w = map(int, input().split())
    edge[s].append((t, w))
ans = rec(0, 0)
print(ans if ans != INF else -1)

Fixed submission:
def read_list(t): return [t(x) for x in input().split()]
def read_line(t): return t(input())
def read_lines(t, N): return [t(input()) for _ in range(N)]

INF = 1<<27
V, E = read_list(int)
edge = [[] for _ in range(V)]
for _ in range(E):
    fr, to, cost = map(int, input().split())
    edge[fr].append((to, cost))

dp = [[INF] * V for _ in range(1<<V)]
dp[(1 << V) - 1][0] = 0
for state in reversed(range((1<<V)-1)):
    for v in range(V):
        for to, cost in edge[v]:
            if not (state >> to & 1):
                dp[state][v] = min(dp[state][v], dp[state | 1 << to][to] + cost)
print(dp[0][0] if dp[0][0] != INF else -1)

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


@functools.lru_cache(maxsize=None)
def rec(state, v):
    if state == (1 << V) - 1 and v == 0:
        return 0
    ret = INF
    for i, w in enumerate(A[v]):
        if not (state >> i & 1):
            ret = min(ret, rec(state | 1 << i, i) + w)
    return ret

INF = 10**6
V, E = map(int, input().split())
A = [[INF]*V for _ in range(V)]
for _ in range(E):
    s, t, w = map(int, input().split())
    A[s][t] = w
ans = rec(0, 0)
print(ans if ans != INF else -1)

Fixed submission:
def read_list(t): return [t(x) for x in input().split()]
def read_line(t): return t(input())
def read_lines(t, N): return [t(input()) for _ in range(N)]

INF = 1<<27
V, E = read_list(int)
edge = [[] for _ in range(V)]
for _ in range(E):
    fr, to, cost = map(int, input().split())
    edge[fr].append((to, cost))

dp = [[INF] * V for _ in range(1<<V)]
dp[(1 << V) - 1][0] = 0
for state in reversed(range((1<<V)-1)):
    for v in range(V):
        for to, cost in edge[v]:
            if not (state >> to & 1):
                dp[state][v] = min(dp[state][v], dp[state | 1 << to][to] + cost)
print(dp[0][0] if dp[0][0] != INF else -1)
Buggy python submission (verdict: Runtime Error):
from math import pi
r = int(input())
print("{:.010f} {:.010f}".format(2 * pi * r, r * r * pi))

Fixed submission:
from math import pi
r = float(input())
print("{:.010f} {:.010f}".format(r * r * pi, 2 * pi * r))
Buggy python submission (verdict: Runtime Error):

while true:
	a,op,b = raw_input().split
	if op == '?':
		break
	elif op == '+':
		print int(a) + int(b)
	elif op == '-':
		print int(a) - int(b)
	elif op == '*':
		print int(a) * int(b)
	else:
		print int(a) / int(b)
		

Fixed submission:

while True:
	a,op,b = raw_input().split()
	if op == '?':
		break
	elif op == '+':
		print int(a) + int(b)
	elif op == '-':
		print int(a) - int(b)
	elif op == '*':
		print int(a) * int(b)
	else:
		print int(a) / int(b)

Buggy python submission (verdict: Runtime Error):

while true:
	a,op,b = raw_input().split()
	if op == '?':
		break
	elif op == '+':
		print int(a) + int(b)
	elif op == '-':
		print int(a) - int(b)
	elif op == '*':
		print int(a) * int(b)
	else:
		print int(a) / int(b)

Fixed submission:

while True:
	a,op,b = raw_input().split()
	if op == '?':
		break
	elif op == '+':
		print int(a) + int(b)
	elif op == '-':
		print int(a) - int(b)
	elif op == '*':
		print int(a) * int(b)
	else:
		print int(a) / int(b)
Buggy python submission (verdict: Runtime Error):
for line in sys.stdin.readlines():
    a,b = map(int, line.strip().split())
    print len(str(a+b))

Fixed submission:
import sys
for line in sys.stdin.readlines():
    a,b = map(int, line.strip().split())
    print len(str(a+b))
Buggy python submission (verdict: Runtime Error):
import sys
for line in iter(sys.stdin.readline, ""):
	foo=map(str, line.strip().split())
	stack=[]
	while (foo!=[]):
		if foo[0]=='+':
			del foo[0]
			stack.append(int(stack.pop())+int(stack.pop()))
		elif foo[0]=='*':
			del foo[0]
			stack.append(int(stack.pop())*int(stack.pop()))
		elif foo[0]=='-':
			del foo[0]
			stack.append(-int(stack.pop())+int(stack.pop()))
		elif foo[0]=='/':
			del foo[0]
			stack.append(1.0/int(stack.pop())*int(stack.pop()))
		else:
			stack.append(foo.pop(0))
	print "{:.6f}".format(stack[0]+0)

Fixed submission:
import sys
for line in sys.stdin.readlines():
	stack=[]
	for foo in line.strip().split():
		if foo=="+":
			foo=stack.pop()+stack.pop()
		elif foo=="*":
			foo=stack.pop()*stack.pop()
		elif foo=="-":
			foo=-stack.pop()+stack.pop()
		elif foo=="/":
			foo=1.0/stack.pop()*stack.pop()
		stack.append(float(foo))
	print "{:.6f}".format(stack[0]+0)

Buggy python submission (verdict: Runtime Error):
import sys
for line in sys.stdin.readlines():
	foo=map(str, line.strip().split())
	stack=[]
	while (foo!=[]):
		if foo[0]=='+':
			del foo[0]
			stack.append(int(stack.pop())+int(stack.pop()))
		elif foo[0]=='*':
			del foo[0]
			stack.append(int(stack.pop())*int(stack.pop()))
		elif foo[0]=='-':
			del foo[0]
			stack.append(-int(stack.pop())+int(stack.pop()))
		elif foo[0]=='/':
			del foo[0]
			stack.append(1.0/int(stack.pop())*int(stack.pop()))
		else:
			stack.append(foo.pop(0))
	print "{:.6f}".format(stack[0]+0)

Fixed submission:
import sys
for line in sys.stdin.readlines():
	stack=[]
	for foo in line.strip().split():
		if foo=="+":
			foo=stack.pop()+stack.pop()
		elif foo=="*":
			foo=stack.pop()*stack.pop()
		elif foo=="-":
			foo=-stack.pop()+stack.pop()
		elif foo=="/":
			foo=1.0/stack.pop()*stack.pop()
		stack.append(float(foo))
	print "{:.6f}".format(stack[0]+0)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python

array = []

for i in range(10):
  array[i] = raw_input()

for j in range(3):
  print max(array) + "\n"
  array.remove(max(array))

Fixed submission:
import sys

array = [0 for i in range(10)]

for i in range(10):
  array[i] = int(raw_input())

array.sort()
array.reverse()

for j in range(3):
  print str(array[j])

sys.exit()

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

array = []

for i in range(10):
  array[i] = raw_input()

for j in range(3):
  print max(array) + "\n"
  array.remove(max(array))

Fixed submission:
import sys

array = [0 for i in range(10)]

for i in range(10):
  array[i] = int(raw_input())

array.sort()
array.reverse()

for j in range(3):
  print str(array[j])

sys.exit()

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

import sys

array = []

for i in range(10):
  array[i] = raw_input()

for j in range(3):
  print max(array) + "\n"
  array.remove(max(array))

sys.exit()

Fixed submission:
import sys

array = [0 for i in range(10)]

for i in range(10):
  array[i] = int(raw_input())

array.sort()
array.reverse()

for j in range(3):
  print str(array[j])

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

while True:
	num = int(raw_input())
	tmp = [i+1 for i in range(1, num)]
	x = math.sqrt(num)
	for i in tmp:
		if i > x: break
		for j in range(2,num):
			if i*j > num: break
			if i*j in tmp: tmp.remove(i*j)
	print len(tmp)

Fixed submission:
from bisect import bisect

def sieve(n):
    num = [True]*n
    num[0] = num[1] = False
    for i in xrange(2,int(n**0.5)+1):
        if num[i]:
            for j in xrange(i**2, n, i):
                num[j] = False
    return [i for i in xrange(2,n) if num[i]]

prime =  sieve(999999)

while True:
	try:
		print bisect(prime, input())
	except:
		break

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

val = []
max_prime = 0

while True:
	num = int(raw_input())
	tmp = [i+1 for i in range(1, num)]
	x = math.sqrt(num)
	if len(val) != 0: 
		max_prime = val[-1]
		tmp = tmp[max_prime-1:]
	print tmp
	for i in tmp:
		if i > x: break
		for j in range(2,num):
			if i*j > num: break
			if i*j in tmp: tmp.remove(i*j)
	val += tmp[len(val):]
	print val
	print max_prime
	print len(tmp)

Fixed submission:
from bisect import bisect

def sieve(n):
    num = [True]*n
    num[0] = num[1] = False
    for i in xrange(2,int(n**0.5)+1):
        if num[i]:
            for j in xrange(i**2, n, i):
                num[j] = False
    return [i for i in xrange(2,n) if num[i]]

prime =  sieve(999999)

while True:
	try:
		print bisect(prime, input())
	except:
		break

Buggy python submission (verdict: Time Limit Exceeded):
def sieve(n):
	nums = [i+1 for i in range(2, n, 2)]
	ans = [2]
	while len(nums) != 0:
		for i in range(nums[0]*2, nums[-1]+1, nums[0]):
			if i in nums: nums.remove(i)
		ans.append(nums.pop(0))
	return len(ans)

while True:
	try:
		print sieve(input())
	except:
		break

Fixed submission:
from bisect import bisect

def sieve(n):
    num = [True]*n
    num[0] = num[1] = False
    for i in xrange(2,int(n**0.5)+1):
        if num[i]:
            for j in xrange(i**2, n, i):
                num[j] = False
    return [i for i in xrange(2,n) if num[i]]

prime =  sieve(999999)

while True:
	try:
		print bisect(prime, input())
	except:
		break

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python

def judge_prime(n):
    if n == 2: return True
    if n < 2: return False
    return pow(2, n-1, n) == 1

while True:
	try:
		ans = 0
		for i in range(input()):
			if judge_prime(i+1):
				ans += 1
		print ans
	except:
		break

Fixed submission:
from bisect import bisect

def sieve(n):
    num = [True]*n
    num[0] = num[1] = False
    for i in xrange(2,int(n**0.5)+1):
        if num[i]:
            for j in xrange(i**2, n, i):
                num[j] = False
    return [i for i in xrange(2,n) if num[i]]

prime =  sieve(999999)

while True:
	try:
		print bisect(prime, input())
	except:
		break
Buggy python submission (verdict: Runtime Error):
nums = []
val = []

while True:
	try:
		nums.append(int(raw_input()))
	except EOFError:
		num_list = sorted(list(set(nums)))
		for n in num_list:
			val.append(nums.count(n))
		ans.append(num_list[val.index(max(val))])
		tmp = max(val)
		val.remove(max(val))
		while max(val) == tmp:
			ans.append(num_list[val.index(max(val))])
			val.remove(max(val))
		for s in ans:
			print s
		break

Fixed submission:
nums = []
val = []
ans = []

while True:
	try:
		nums.append(int(raw_input()))
	except EOFError:
		num_list = sorted(list(set(nums)))
		for n in num_list:
			val.append(nums.count(n))
		ans.append(num_list[val.index(max(val))])
		tmp = max(val)
		val.remove(max(val))
		num_list.pop(val.index(tmp))
		while max(val) == tmp:
			ans.append(num_list[val.index(max(val))])
			num_list.pop(val.index(tmp))
			val.remove(max(val))
		for s in ans:
			print s
		break

Buggy python submission (verdict: Runtime Error):
nums = []
val = []
ans = []

while True:
	try:
		nums.append(int(raw_input()))
	break:
		num_list = sorted(list(set(nums)))
		for n in num_list:
			val.append(nums.count(n))
		ans.append(num_list[val.index(max(val))])
		tmp = max(val)
		val.remove(max(val))
		num_list.pop(val.index(tmp))
		while max(val) == tmp:
			ans.append(num_list[val.index(max(val))])
			num_list.pop(val.index(tmp))
			val.remove(max(val))
		for s in ans:
			print s

Fixed submission:
nums = []
val = []
ans = []

while True:
	try:
		nums.append(int(raw_input()))
	except EOFError:
		num_list = sorted(list(set(nums)))
		for n in num_list:
			val.append(nums.count(n))
		ans.append(num_list[val.index(max(val))])
		tmp = max(val)
		val.remove(max(val))
		num_list.pop(val.index(tmp))
		while max(val) == tmp:
			ans.append(num_list[val.index(max(val))])
			num_list.pop(val.index(tmp))
			val.remove(max(val))
		for s in ans:
			print s
		break
Buggy python submission (verdict: Time Limit Exceeded):
def sieve(n):
    num = [True] * n
    num[0] = num[1] = False
    for i in range(2,int(n**0.5)+1):
        if num[i]:
            for j in range(i**2, n, i):
                num[j] = False
    return [i for i in range(2, n) if num[i]]


while True:
	n = int(input())
	if n == 0: break
	print(sum(sieve(n * 100)[:n]))

Fixed submission:
def sieve(n):
    num = [True] * n
    num[0] = num[1] = False
    for i in range(2,int(n**0.5)+1):
        if num[i]:
            for j in range(i**2, n, i):
                num[j] = False
    return [i for i in range(2, n) if num[i]]

prime = sieve(110000)

while True:
	n = int(input())
	if n == 0: break
	print(sum(prime[:n]))
Buggy python submission (verdict: Runtime Error):
def slant(xa, ya, xb, yb):
    if ya - yb == 0:
        return 'y'
    elif xa - xb == 0:
        return 'x'
    else:
        return (ya - yb) / (xa - xb)

while True:
    try:
        xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
    except:
        break
    AB = slant(xa, ya, xb, yb)
    CD = slant(xc, yc, xd, yd)
    is_digit = ('x' and 'y') not in [AB, CD]

    if [AB, CD] == (['x', 'y'] or ['y', 'x']):
        print('YES')
        continue

    if is_digit:
        print('YES' if AB * CD == -1 else 'NO')
    else:
        print('NO')

Fixed submission:
while True:
    try:
        xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
    except:
        break
    if abs((ya - yb) * (yc - yd) + (xa - xb) * (xc - xd)) < 1.e-10:
        print('YES')
    else:
        print('NO')
Buggy python submission (verdict: Runtime Error):
old = []
new = []
ans = []
t = True

while True:
    n = input().split(',')[0]
    if n == '':
        if t:
            t = False
        else:
            break
    if t:
        old.append(n)
    else:
        new.append(n)


for o in set(old):
    if o in new:
        s = old.count(o) + new.count(o)
        ans.append([int(o), int(s)])
ans.sort()
for a in ans:
    print('%d %d' % (a[0], a[1]))

Fixed submission:
old = []
new = []
ans = []
t = True

while True:
    try:
        n = input()
    except:
        break

    n = n.split(',')[0]
    if not n:
        t = False
    if t:
        old.append(n)
    else:
        new.append(n)

for o in set(old):
    if o in new:
        s = old.count(o) + new.count(o)
        ans.append([int(o), int(s)])
ans.sort()
for a in ans:
    print('%d %d' % (a[0], a[1]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
input()

for i in range(n):
	board = [list(input()) for i in range(8)]
	sx = int(input()) - 1
	sy = int(input()) - 1
	input()
	
	board[sy][sx] == 2
	bomb = []
	n_bomb = [[sy, sx]]
	points = []
	for j in range(len(board)):
		while '1' in board[j]:
			px = board[j].index('1')
			py = j
			points.append([py, px])
			board[j][px] = '2'
	
	while len(n_bomb) != 0:
		bomb += n_bomb
		n_bomb = []
		for b in bomb:
			for p in points:
				if (p[0] == b[0] and b[1]-3 <= p[1] <= b[1]+3) or (p[1] == b[1] and b[0]-3 <= p[0] <= b[0]+3):
					points.remove(p)
					n_bomb.append(p)
	
	ans = [['0'] * 8 for j in range(8)]
	for p in points:
		ans[p[0]][p[1]] = '1'

	print("Data %s:" % str(i+1))
	for p in ans:
		print("".join(p))

Fixed submission:
n = int(input())

for i in range(n):
	input()
	board = [list(input()) for i in range(8)]
	sx = int(input()) - 1
	sy = int(input()) - 1

	board[sy][sx] == 2
	bomb = []
	n_bomb = [[sy, sx]]
	points = []
	for j in range(len(board)):
		while '1' in board[j]:
			px = board[j].index('1')
			py = j
			points.append([py, px])
			board[j][px] = '2'
	
	while len(n_bomb) != 0:
		bomb += n_bomb
		n_bomb = []
		for b in bomb:
			for p in points:
				if (p[0] == b[0] and b[1]-3 <= p[1] <= b[1]+3) or (p[1] == b[1] and b[0]-3 <= p[0] <= b[0]+3):
					points.remove(p)
					n_bomb.append(p)
	
	ans = [['0'] * 8 for j in range(8)]
	for p in points:
		ans[p[0]][p[1]] = '1'

	print("Data %s:" % str(i+1))
	for p in ans:
		print("".join(p))
Buggy python submission (verdict: Runtime Error):
while True:
	calc = raw_input().split()
	ans = []
	while len(calc) != 0:
		if calc[0].isdigit():
			ans.append(calc.pop(0))
		else:
			mark = calc[0]
			if mark == "+":
				tmp = float(ans.pop()) + float(ans.pop())
			elif mark == "-":
				tmp = -float(ans.pop()) + float(ans.pop())
			elif mark == "*":
				tmp = float(ans.pop()) * float(ans.pop())
			elif mark == "/":
				tmp = float(ans.pop()) / float(ans.pop())
				tmp = 1 / tmp
			ans.append(tmp)
			calc.pop(0)
	print '%.6f' % ans[0]

Fixed submission:
while True:
	try:
		stack = []
		for s in raw_input().split():
			if s in ('+', '-', '*', '/'):
				stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
			else:
				stack.append(float(s))
		print '%.6f' % stack.pop()
	except EOFError:
		break

Buggy python submission (verdict: Runtime Error):
while True:
	stack = []
	for s in raw_input().split():
		if s in ('+', '-', '*', '/'):
			stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
		else:
			stack.append(float(s))
	print '%.6f' % stack.pop()

Fixed submission:
while True:
	try:
		stack = []
		for s in raw_input().split():
			if s in ('+', '-', '*', '/'):
				stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
			else:
				stack.append(float(s))
		print '%.6f' % stack.pop()
	except EOFError:
		break

Buggy python submission (verdict: Runtime Error):
while True:
  stack = []
  for s in raw_input().split():
    if s in ('+', '-', '*', '/'):
      stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
    else:
      stack.append(float(s))
    print '%.6f' % stack.pop()

Fixed submission:
while True:
	try:
		stack = []
		for s in raw_input().split():
			if s in ('+', '-', '*', '/'):
				stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
			else:
				stack.append(float(s))
		print '%.6f' % stack.pop()
	except EOFError:
		break
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, raw_input().split())
fish = [0] * n
for i in range(q):
	a, v = map(int, raw_input().split())
	fish[a-1] = fish[a-1] + v
	ans1 = fish.index(max(fish)) + 1
	ans2 = max(fish)
	print "{} {}".format(ans1, ans2)

Fixed submission:
n, q = map(int, raw_input().split())
fish = [0] * n
ans1 = 0
ans2 = 0
for i in range(q):
	a, v = map(int, raw_input().split())
	fish[a-1] = fish[a-1] + v
	if ans1 == a and v < 0:
		ans1 = fish.index(max(fish)) + 1
		ans2 = max(fish)
	elif ans2 < fish[a-1]:
		ans1 = a
		ans2 = fish[a-1]
	elif ans2 == fish[a-1] and a < ans1:
		ans1 = a
	print "{} {}".format(ans1, ans2)
Buggy python submission (verdict: Runtime Error):
while True:
    n = input()
    ans = []
    if n == 0: break
    tmp = [0] * (n+1)
    for i in range(n):
        ans.append(map(int, raw_input().split()))
        ans[i].append(sum(ans[i]))
        for j in range(len(ans[i])):
            tmp[j] += ans[i][j]
    ans.append(tmp)
    for a in ans:
        print " ".join(map(lamda x: str(x).rjust(5), a))

Fixed submission:
while True:
    n = input()
    ans = []
    if n == 0: break
    tmp = [0] * (n+1)
    for i in range(n):
        ans.append(map(int, raw_input().split()))
        ans[i].append(sum(ans[i]))
        for j in range(len(ans[i])):
            tmp[j] += ans[i][j]
    ans.append(tmp)
    for a in ans:
        print "".join(map(lambda x: str(x).rjust(5), a))
Buggy python submission (verdict: Runtime Error):
while True:
	h, w = map(int, raw_input().split())
	if h + w == 0: break
	b = [list(raw_input()) for i in range(h)]
	direction = {'>':[1,0],'v':[0,1],'<':[-1,0],'^':[0,-1]}
	f = False
	for i in range(h):
		for j in range(w):
			if b[j][i] != ".":
				p = [i,j]
				f = True
				break
		if f: break
	c = 0
	while True:
		tmp = direction[b[p[1]][p[0]]]
		p[0] += tmp[0]
		p[1] += tmp[1]
		c += 1
		if c == h * w:
			print "LOOP"
			break
		elif b[p[1]][p[0]] == ".":
			print "{} {}".format(p[0],p[1])
			break

Fixed submission:
while True:
	h, w = map(int, raw_input().split())
	if h + w == 0: break
	b = [list(raw_input()) for i in range(h)]
	x = y = 0
	while True:
		a = b[y][x]
		b[y][x] = 0
		if a == ">": x += 1
		elif a == "<": x -= 1
		elif a == "v": y += 1
		elif a == "^": y -= 1
		elif a == ".": print x,y; break
		else: print "LOOP"; break

Buggy python submission (verdict: Runtime Error):
while True:
	h, w = map(int, raw_input().split())
	if h + w == 0: break
	b = [list(raw_input()) for i in range(h)]
	direction = {'>':[1,0],'v':[0,1],'<':[-1,0],'^':[0,-1]}
	f = False
	for i in range(h):
		for j in range(w):
			if b[j][i] != ".":
				p = [i,j]
				f = True
				break
		if f: break
	c = 0
	while True:
		tmp = direction[b[p[1]][p[0]]]
		p[0] += tmp[0]
		p[1] += tmp[1]
		c += 1
		if c == h * w:
			print "LOOP"
			break
		elif b[p[1]][p[0]] == ".":
			print "{} {}".format(p[0],p[1])
			break

Fixed submission:
while True:
	h, w = map(int, raw_input().split())
	if h + w == 0: break
	b = [list(raw_input()) for i in range(h)]
	x = y = 0
	while True:
		a = b[y][x]
		b[y][x] = 0
		if a == ">": x += 1
		elif a == "<": x -= 1
		elif a == "v": y += 1
		elif a == "^": y -= 1
		elif a == ".": print x,y; break
		else: print "LOOP"; break
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int, input().split(' ')))

for i in range(len(nums)):
    key = nums[i]
    j = i - 1
    while j >= 0 and nums[j] > key:
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = key
    print(' '.join(map(str, nums)))

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))

for i in range(len(nums)):
    key = nums[i]
    j = i - 1
    while j >= 0 and nums[j] > key:
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = key
    print(' '.join(map(str, nums)))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python

import sys

num = str(raw_input()).split(" ")

a = int(num[0])
b = int(num[1])

d = a / b - a % b
r = a % b
float f = a / b

print str(d + " " + r + " " + f)

sys.exit()

Fixed submission:
a, b = map(int, raw_input().split())
d = a / b
r = a % b
f = '%.6f' % (float(a) / float(b))
print " ".join(map(str, [d,r,f]))