Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
apart = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for joho in range(n):
    x = [int(i) for i in input().split()]
    apart[x[2]][x[1]][x[0]] += x[3]

for tou in range(4):
    for stair in range(3):
        for room in range(10):
            print(" ",apart[tou][stair][room],sep="",end="")
        print("")
    if tou != 3:
        print("####################")



Fixed submission:
n = int(input())
apart = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for joho in range(n):
    x = [int(i) for i in input().split()]
    apart[x[0]-1][x[1]-1][x[2]-1] += x[3]

for tou in range(4):
    for stair in range(3):
        for room in range(10):
            print(" ",apart[tou][stair][room],sep="",end="")
        print("")
    if tou != 3:
        print("####################")
Buggy python submission (verdict: Runtime Error):
x = input()
print(x * x * x)

Fixed submission:
x = int(input())
print(x * x * x)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 17 16:53:19 2016

@author: Yasuhiro_2
"""

def checkSorted(A):
    check = True
    a = A[0]
    for e in A:
        if a > e:
            check = False
            break
        else:
            a = e
    return check
        

def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return [cnt, A]
    
def shellSort(A, n):
    cnt = 0
    m = 0
    G = []          
    while checkSorted(A) == False:
        g = 1
        for i in range(n):
            j = i
            tmp = g
            while j < n:
                if A[i] > A[j]:
                    g = j - i
                j += tmp
        G.append(g)
        m += 1
        A = insertionSort(A, n, g, cnt)
        cnt = A[0]
        A = A[1]
    if m == 0:
        m = 1
        G = [1]
    return [m, G, cnt, A]
            
        
            

if __name__ == '__main__':   
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))
    results = shellSort(A, n)
    m = results[0]
    G = results[1]
    cnt = results[2]
    Ar = results[3]
    print(m)
    gs = ''
    for g in G:
        gs = gs + str(g) + ' '
    print(gs[:-1])
    print(cnt)
    for a in Ar:
        print(a)
    
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 17 16:53:19 2016

@author: Yasuhiro_2
"""

def checkSorted(A):
    check = True
    a = A[0]
    for e in A:
        if a > e:
            check = False
            break
        else:
            a = e
    return check
        

def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return [cnt, A]

"""
def shellSort(A, n):
    cnt = 0
    m = 0
    G = []          
    while checkSorted(A) == False:
        g = 1
        for i in range(n):
            j = i
            tmp = g
            while j < n:
                if A[i] > A[j]:
                    g = j - i
                j += tmp
        G.append(g)
        m += 1
        A = insertionSort(A, n, g, cnt)
        cnt = A[0]
        A = A[1]
    if m == 0:
        m = 1
        G = [1]
    return [m, G, cnt, A]
"""
def shellSort(A, n):
    cnt = 0
    m = 1
    G = [1]
    while G[-1] < n:
        G.append(3*G[-1] + 1)
        m += 1
    if m > 1:
        G = G[:-1]
        G.reverse()
        m -= 1
    
    for g in G:
        A = insertionSort(A, n, g, cnt)
        cnt = A[0]
        A = A[1]

    return [m, G, cnt, A]

            

if __name__ == '__main__':   
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))
    results = shellSort(A, n)
    m = results[0]
    G = results[1]
    cnt = results[2]
    Ar = results[3]
    print(m)
    gs = ''
    for g in G:
        gs = gs + str(g) + ' '
    print(gs[:-1])
    print(cnt)
    for a in Ar:
        print(a)
Buggy python submission (verdict: Time Limit Exceeded):
# AOJ 0056 Goldbach's Conjecture
# Python3 2018.6.16 bal4u

MAX = 50001
HALF = 25000

prime = [True]*MAX
def sieve(max):
	for i in range(4, max, 2):
		prime[i] = False
	sqrt = int(max**0.5)
	print('Sqrt=',sqrt)
	for i in range(3, sqrt, 2):
		if prime[i] is True:
			for j in range(i*i, max, i):
				prime[j] = False
sieve(MAX)

ans = [0]*(MAX*2)
ans[4] = 1
for i in range(3, MAX, 2):
	if prime[i]: ans[i+2] = 1

for i in range(3, HALF, 2):
	if prime[i]:
		for j in range(i, MAX, 2):
			if prime[j]: ans[i+j] += 1

while True:
	n = int(input())
	if n == 0: break
	print(ans[n])


Fixed submission:
# AOJ 0056 Goldbach's Conjecture
# Python3 2018.6.16 bal4u

MAX = 50000
HALF = 2761			# prime[2760]=24989, prime[2761]=25013

prime = [
  3,  5,  7, 11, 13, 17, 19, 23, 29, 
 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 
 73, 79, 83, 89, 97,101,103,107,109,113, 
127,131,137,139,149,151,157,163,167,173, 
179,181,191,193,197,199,211,223 ]

sqp = [				# sqp[i] = prime[i]**2
  9,25,49,121,169,289,361,529,841,961,
1369,1681,1849,2209,2809,3481,3721,4489,5041,
5329,6241,6889,7921,9409,10201,10609,11449,11881,12769,
16129,17161,18769,19321,22201,22801,24649,26569,27889,29929,
32041,32761,36481,37249,38809,39601,44521,49729 ]

tbl = [0]*(MAX+1)	# zero if prime 
ans = [0]*(MAX+1)
ans[4] = 1

for i in range(47):
	for j in range(sqp[i], MAX, prime[i]): tbl[j] = 1;

for i in range(225, MAX+1, 2):
	if tbl[i] == 0: prime.append(i)

for i in range(HALF):
	j = i
	while True:
		k = prime[i]+prime[j]
		if k > MAX: break
		ans[k] += 1
		j += 1

while True:
	n = int(input())
	if n == 0: break
	if (n & 1) == 1: print(1-tbl[n-2])
	else: print(ans[n])
Buggy python submission (verdict: Runtime Error):
# AOJ 0069: Drawing Lots II
# Python3 2018.6.28 bal4u

while True:
	n = int(input())
	if n == 0: break
	m, p, d = [int(input()) for i in range(3)]
	a = [[0 for j in range(10)] for i in range(32)]
	for i in range(1, d+1): a[i] = [0] + list(map(int, input())) + [0]
	s = [[0 for j in range(10)] for i in range(32)]
	for i in range(1, n+1): s[d+1][i] = i
	for i in range(d, 0, -1):
		for j in range(1, n+1): s[i][j] = s[i+1][j]
		for j in range(1, n):
			if a[i][j]: s[i][j], s[i][j+1] = s[i][j+1], s[i][j]
	k = s[1][m]
	if k == p:
		print(0)
		continue
	f = False
	for i in range(1, d+1):
		for j in range(1, n):
			if ((s[i][j] == k and s[i][j+1] == p) or (s[i][j] == p and s[i][j + 1] == k)) \
				and a[i][j-1] == 0 and a[i][j] == 0 and a[i][j+1] == 0:
				print(i, j)
				f = True
				break
		if f: break
	if not f: print(1)


Fixed submission:
# AOJ 0069: Drawing Lots II
# Python3 2018.6.28 bal4u

while True:
	n = int(input())
	if n == 0: break
	m, p, d = [int(input()) for i in range(3)]
	m -= 1
	p -= 1
	a = [[] for i in range(d+1)]
	for i in range(d): a[i] = list(map(int, input()))
	s = [[0 for j in range(n)] for i in range(d+1)]
	s[d] = [i for i in range(n)]
	for i in range(d-1, -1, -1):
		for j in range(n): s[i][j] = s[i+1][j]
		for j in range(n-1):
			if a[i][j]: s[i][j], s[i][j+1] = s[i][j+1], s[i][j]
	k = s[0][m]
	if k == p:
		print(0)
		continue
	f = False
	for i in range(d):
		for j in range(n-1):
			if ((s[i][j] == k and s[i][j+1] == p) or (s[i][j] == p and s[i][j+1] == k)) \
				and (j == 0 or a[i][j-1] == 0) and a[i][j] == 0 and (j == n-2 or a[i][j+1] == 0):
				print(i+1, j+1)
				f = True
				break
		if f: break
	if not f: print(1)
Buggy python submission (verdict: Runtime Error):
# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0:  break
	min = min(d*d+w*w, d*d+h*h, w*w+h*h)
	for _ in range(int(input())):
		r = int(input())
		print('OK' if min < (2*r)**2 else 'NA')


Fixed submission:
# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0: break
	vmin = min(d*d+w*w, d*d+h*h, w*w+h*h)

	for _ in range(int(input())):
		r = int(input())
		print('OK' if (2*r)**2 > vmin else 'NA')

Buggy python submission (verdict: Runtime Error):
# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0: break
	min = min(d*d+w*w, d*d+h*h, w*w+h*h)

	n = int(input())
	for i in range(n):
		r = int(input())
		print('OK' if (2*r)**2 > min else 'NA')


Fixed submission:
# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0: break
	vmin = min(d*d+w*w, d*d+h*h, w*w+h*h)

	for _ in range(int(input())):
		r = int(input())
		print('OK' if (2*r)**2 > vmin else 'NA')
Buggy python submission (verdict: Runtime Error):
# AOJ 0191: Baby Tree
# Python3 2018.6.20 bal4u

while True:
	n, m = list(map(int, input().split()))
	if n == 0: break
	d =  [[0.0 for j in range(n)] for i in range(n)]
	for i in range(n): d[i] = list(map(float, input().split()))
	dp =  [[0.0 for j in range(n)] for i in range(n)]
	for i in range(n): dp[0][i] = 1
	for k in range(1, m):
		for i in range(n):
			for j in range(n):
				dp[k][j] = max(dp[k][j], dp[k-1][i]*d[i][j])
	ans = 0
	for i in range(n):
		if dp[m-1][i] > ans: ans = dp[m-1][i]
	print(format(ans, ".2f"))



Fixed submission:
# AOJ 0191: Baby Tree
# Python3 2018.6.20 bal4u

while True:
	n, m = list(map(int, input().split()))
	if n == 0: break
	d =  [[0.0 for j in range(n)] for i in range(n)]
	for i in range(n): d[i] = list(map(float, input().split()))
	dp =  [[0.0 for j in range(n)] for k in range(m)]
	for i in range(n): dp[0][i] = 1
	for k in range(1, m):
		for i in range(n):
			for j in range(n):
				dp[k][j] = max(dp[k][j], dp[k-1][i]*d[i][j])
	ans = 0
	for i in range(n):
		if dp[m-1][i] > ans: ans = dp[m-1][i]
	print(format(ans, ".2f"))
Buggy python submission (verdict: Runtime Error):
# AOJ 0220 Binary Digit A Doctor Loved
# Python3 2018.6.23 bal4u

while 1:
	a, b = map(int, input().split('.'))
	if a < 0: break
	if a > 255:
		print("NA")
		continue
	sa = format(a, '08b')
	sb, s = '', str(b)
	k = 10**len(s)
	for i in range(4):
		b *= 2
		if b >= k: sb += '1'
		else: sb += '0'
		b %= k
	if b == 0: print(sa, '.', sb, sep='')
	else: print("NA")



Fixed submission:
# AOJ 0220 Binary Digit A Doctor Loved
# Python3 2018.6.23 bal4u

while 1:
	s = input()
	if s[0] == '-': break
	if s.find('.') < 0: a, b = s, '0'
	else:
		a, b = s.split('.')
		if a == '': a = '0'
		if b == '': b = '0'
	k = 10**len(b)
	a, b = int(a), int(b)
	if a > 255:
		print("NA")
		continue
	sa = format(a, '08b')
	sb = ''
	for i in range(4):
		b *= 2
		if b >= k: sb += '1'
		else: sb += '0'
		b %= k
	if b == 0: print(sa, '.', sb, sep='')
	else: print("NA")
Buggy python submission (verdict: Time Limit Exceeded):
# AOJ 0259: All Numbers Lead to 6174
# Python3 2018.6.25 bal4u

while True:
	n = input()
	if n == "0000": break
	if len(set(n)) == 1:
		print("NA")
		continue
	ans = 0
	while n != "6174":
		ans += 1
		l = sorted(n)
		s = l[::-1]
		n = str(int(''.join(s))-int(''.join(l)))
	print(ans)



Fixed submission:
# AOJ 0259: All Numbers Lead to 6174
# Python3 2018.6.25 bal4u

while True:
	n = input()
	if int(n) == 0: break
	if len(set(n)) == 1:
		print("NA")
		continue
	ans = 0
	while n != "6174":
		ans += 1
		l = ''.join(sorted(n))
		s = l[::-1]
		n = str(int(s)-int(l)).zfill(4)
	print(ans)
Buggy python submission (verdict: Runtime Error):
# AOJ 0502: Dice
# Python3 2018.6.29 bal4u

dir = { "North":1, "East":2, "West":3, "South":4, "Right":5, "Left":6 }

rot = ((0,1,2,3,4,5,6),(0,2,6,3,4,1,5),(0,4,2,1,6,5,3),(0,3,2,6,1,5,4), \
       (0,5,1,3,4,6,2),(0,1,3,5,2,4,6),(0,1,4,2,5,3,6))

while True:
	n = int(input())
	if n == 0: break
	dice = [[i for i in range(7)] for j in range(2)]
	ans = 1
	for i in range(n):
		j = dir[input()]
		for k in range(1, 7): dice[1-(i&1)][k] = dice[i&1][rot[j][k]];
		ans += dice[1-(i&1)][1]
	print(ans)


Fixed submission:
# AOJ 0502: Dice
# Python3 2018.6.29 bal4u

d = { "North":1, "East":2, "West":3, "South":4, "Right":5, "Left":6 }

rot = ((0,1,2,3,4,5,6),(0,2,6,3,4,1,5),(0,4,2,1,6,5,3),(0,3,2,6,1,5,4), \
       (0,5,1,3,4,6,2),(0,1,3,5,2,4,6),(0,1,4,2,5,3,6))

import sys
while True:
	n = int(input())
	if n == 0: break
	dice = [[j for j in range(7)] for i in range(2)]
	ans = 1
	for i in range(n):
		j = d[input().strip()]
		for k in range(1, 7): dice[1-(i&1)][k] = dice[i&1][rot[j][k]]
		ans += dice[1-(i&1)][1]
	print(ans)

Buggy python submission (verdict: Runtime Error):
# AOJ 0502: Dice
# Python3 2018.6.29 bal4u

d = { "North":1, "East":2, "West":3, "South":4, "Right":5, "Left":6 }

rot = ((0,1,2,3,4,5,6),(0,2,6,3,4,1,5),(0,4,2,1,6,5,3),(0,3,2,6,1,5,4), \
       (0,5,1,3,4,6,2),(0,1,3,5,2,4,6),(0,1,4,2,5,3,6))

while True:
	n = int(input())
	if n == 0: break
	dice = [[i for i in range(7)] for j in range(2)]
	ans = 1
	for i in range(n):
		j = d[input()]
		for k in range(1, 7): dice[1-(i&1)][k] = dice[i&1][rot[j][k]];
		ans += dice[1-(i&1)][1]
	print(ans)


Fixed submission:
# AOJ 0502: Dice
# Python3 2018.6.29 bal4u

d = { "North":1, "East":2, "West":3, "South":4, "Right":5, "Left":6 }

rot = ((0,1,2,3,4,5,6),(0,2,6,3,4,1,5),(0,4,2,1,6,5,3),(0,3,2,6,1,5,4), \
       (0,5,1,3,4,6,2),(0,1,3,5,2,4,6),(0,1,4,2,5,3,6))

import sys
while True:
	n = int(input())
	if n == 0: break
	dice = [[j for j in range(7)] for i in range(2)]
	ans = 1
	for i in range(n):
		j = d[input().strip()]
		for k in range(1, 7): dice[1-(i&1)][k] = dice[i&1][rot[j][k]]
		ans += dice[1-(i&1)][1]
	print(ans)
Buggy python submission (verdict: Runtime Error):
# AOJ 0504: Card Game II
# Python3 2018.7.1 bal4u

def calc(b, n):
	a = 1
	for i in range(n+1):
		if a >= b:
			d[i] += a//b
			a %= b
		if a == 0: break
		a *= 10

ans = ['0']*10005
while True:
	n, k, m, r = map(int, input().split())
	if n == 0: break
	r += 6
	d = [0]*10005
	calc(n, r)
	if m == 1:
		for i in range(1, n): calc(n*i, r)
	k = 0
	for i in range(r, -1, -1):
		k += d[i]
		if k >= 10:
			ans[i] = str(k%10)
			k //= 10
		else:
			ans[i] = str(k)
			k = 0
	print(ans[0], '.', ''.join(ans[1:r-5]), sep='')


Fixed submission:
# AOJ 0504: Card Game II
# Python3 2018.7.1 bal4u

from decimal import *

while True:
	n, k, m, r = map(int, input().split())
	if n == 0: break
	
	setcontext(Context(prec=r, rounding=ROUND_HALF_UP))
	one = Decimal(1)
	
	ans = one/Decimal(n)
	if m == 1:
		s = 0
		for i in range(1, n): s += one/Decimal(i)
		ans *= 1+s
	ans = str(ans)[:r+2]
	if len(ans) < r+2: ans += '0'*(r+2-len(ans))
	print(ans)
Buggy python submission (verdict: Runtime Error):
# AOJ 0517: Longest Steps
# Python3 2018.6.30 bal4u

while True:
	n, k = map(int, input().split())
	if n == 0: break
	c = [0]*(n+1)
	f = 0;
	for i in range(k):
		a = int(input())
		if a == 0: f = 1
		else: c[a] = 1
	ans = w0 = w = 0
	for i in range(1, n+1):
		if c[i]: w += 1
		elif w > 0:
			if w0 + w + f > ans: ans = w0 + w + f
			w0 = w if f and c[i+1] else 0
			w = 0
	if w0 + w + f > ans: ans = w0 + w + f
	print(ans)


Fixed submission:
# AOJ 0517: Longest Steps
# Python3 2018.6.30 bal4u

while True:
	n, k = map(int, input().split())
	if n == 0: break
	c = [0]*(n+2)
	f = 0;
	for i in range(k):
		a = int(input())
		if a == 0: f = 1
		else: c[a] = 1
	ans = w0 = w = 0
	for i in range(1, n+1):
		if c[i]: w += 1
		elif w > 0:
			if w0 + w + f > ans: ans = w0 + w + f
			w0 = w if f and c[i+1] else 0
			w = 0
	if w0 + w + f > ans: ans = w0 + w + f
	print(ans)
Buggy python submission (verdict: Runtime Error):
# AOJ 0519: Worst Reporter
# Python3 2018.6.20 bal4u

# トポロジーソート V:総ノード数, to[][]:隣接リスト
def topological_sort(V, to):
	cnt = [0]*V
	for i in range(V):
		for j in to[i]: cnt[j] += 1
	Q = []
	for i in range(V):
	   if cnt[i] == 0: Q.append(i)
	f = 0
	while len(Q) > 0:
		f |= len(Q) > 1
		i = Q[0]
		del Q[0]
		print(i+1)  # ノードの表示
		for k in to[i]:
			cnt[k] -= 1
			if cnt[k] == 0:	Q.append(k)
	return f	

import fileinput
n = int(fileinput.input())
to = [[] for i in range(n)]
m = int(fileinput.input())
for i in range(m):
	a, b = list(map(int, fileinput.input().split()))
	to[a-1].append(b-1)
print(1 if topological_sort(n, to) else 0)



Fixed submission:
# AOJ 0519: Worst Reporter
# Python3 2018.6.20 bal4u

# トポロジーソート V:総ノード数, to[][]:隣接リスト
def topological_sort(V, to):
	cnt = [0]*V
	for i in range(V):
		for j in to[i]: cnt[j] += 1
	Q = []
	for i in range(V):
	   if cnt[i] == 0: Q.append(i)
	f = 0
	while len(Q) > 0:
		f |= len(Q) > 1
		i = Q[0]
		del Q[0]
		print(i+1)  # ノードの表示
		for k in to[i]:
			cnt[k] -= 1
			if cnt[k] == 0:	Q.append(k)
	return f	

n = int(input())
to = [[] for i in range(n)]
m = int(input())
for i in range(m):
	a, b = list(map(int, input().split()))
	to[a-1].append(b-1)
print(1 if topological_sort(n, to) else 0)
Buggy python submission (verdict: Runtime Error):
# AOJ 0538: IOIOI
# Python3 2018.7.1 bal4u

while True:
	n = int(input())
	if n == 0: break
	m = int(input())
	s = input().strip()
	ans, cnt, w, i = 0, 0, len(s), -1
	while i < w:
		i += 1
		if i+1 < w and s[i:i+2] == 'IO':
			cnt += 1
			i += 1
		elif cnt > 0:
			if s[i] == 'O': cnt -= 1
			if cnt >= n: ans += cnt-n+1
			cnt = 0
	print(ans)



Fixed submission:
# AOJ 0538: IOIOI
# Python3 2018.7.1 bal4u

import sys
from sys import stdin
input = stdin.readline

while True:
	n = int(input())
	if n == 0: break
	m = int(input())
	s = input().strip()
	ans = cnt = i = 0
	while i < m:
		if i+1 < m and s[i:i+2] == 'IO':
			cnt += 1
			i += 1
		elif cnt > 0:
			if s[i] == 'O': cnt -= 1
			if cnt >= n: ans += cnt-n+1
			cnt = 0
		i += 1
	print(ans)
Buggy python submission (verdict: Runtime Error):
# AOJ 0588: Simple Calculator
# Python3 2018.6.30 bal4u

a = int(input())
while True:
	op = input().strip()
	if op == '=': break
	b = int(input()) 
	if      op == '+': a += b
	elif s == '-': a -= b
	elif s == '*': a *= b
	else:          a //= b
print(a)


Fixed submission:
# AOJ 0588: Simple Calculator
# Python3 2018.6.30 bal4u

a = int(input())
while True:
	op = input().strip()
	if op == '=': break
	b = int(input()) 
	if   op == '+': a += b
	elif op == '-': a -= b
	elif op == '*': a *= b
	else:          a //= b
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
# AOJ 1030 Cubes Without Holes
# Python3 2018.7.6 bal4u

import sys
from sys import stdin
input = stdin.readline

while True:
	n, h = map(int, input().split())
	if n == 0: break
	f = [[[0 for k in range(3)] for c in range(500)] for r in range(500)]
	ans = n**3
	for i in range(h):
		c, a, b = input().split()
		a, b = int(a)-1, int(b)-1
		ans -= n
		if c == "xy":
			f[a][b][0] = 1
			ans += sum([(f[a][j][1] | f[a][j][2]) for j in range(n)])
		elif c == "xz":
			f[a][b][1] = 1
			ans += sum([(f[a][j][0] | f[i][b][2]) for j in range(n)])
		else:
			f[a][b][2] = 1
			ans += sum([(f[j][a][0] | f[j][b][1]) for j in range(n)])
	print(ans)


Fixed submission:
# AOJ 1030 Cubes Without Holes
# Python3 2018.7.6 bal4u

import sys
from sys import stdin
input = stdin.readline

# n <= 500,  2^9 = 512
while True:
	n, h = map(int, input().split())
	if n == 0: break
	ans = []
	for i in range(h):
		s = input()
		c = s[:2]
		a, b = s[3:].split()
		a, b = int(a)-1, int(b)-1
		if c == "xy":
			k = a+(b<<9)
			ans += [k+(z<<18) for z in range(n)]
		elif c == "xz":
			k = a+(b<<18)
			ans += [k+(y<<9) for y in range(n)]
		else:
			k = (a<<9)+(b<<18)
			ans += [k+x for x in range(n)]
	print(n**3-len(set(ans)))
Buggy python submission (verdict: Runtime Error):
# AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u

while True:
	n, a, b = map(int, input().split())
	if n == 0: break
	f = [0]*(n+1)
	for x in range(0, n, a):
		for y in range(0, n+1, b): f[x+y] = 1
	print(n-sum(f))



Fixed submission:
# AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u

while True:
	n, a, b = map(int, input().split())
	if n == 0: break
	f = [0]*(n+max(a,b)+1)
	f[0], f[a], f[b] = 1, 1, 1
	s = min(a, b)
	for k in range(s, n+1):
		if f[k]: f[a+k] = 1; f[b+k] = 1
	print(n-sum(f[s:n+1]))

Buggy python submission (verdict: Runtime Error):
# AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u

while True:
	n, a, b = map(int, input().split())
	if n == 0: break
	f = [0]*(n>>1)
	for x in range(0, n, a):
		for y in range(0, n+1, b): f[x+y] = 1
	print(n-sum(f[1:n+1]))


Fixed submission:
# AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u

while True:
	n, a, b = map(int, input().split())
	if n == 0: break
	f = [0]*(n+max(a,b)+1)
	f[0], f[a], f[b] = 1, 1, 1
	s = min(a, b)
	for k in range(s, n+1):
		if f[k]: f[a+k] = 1; f[b+k] = 1
	print(n-sum(f[s:n+1]))

Buggy python submission (verdict: Time Limit Exceeded):
# AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u

while True:
	n, a, b = map(int, input().split())
	if n == 0: break
	f = [0]*(n<<1)
	for x in range(0, n, a):
		for y in range(0, n+1, b): f[x+y] = 1
	print(n-sum(f[1:n+1]))


Fixed submission:
# AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u

while True:
	n, a, b = map(int, input().split())
	if n == 0: break
	f = [0]*(n+max(a,b)+1)
	f[0], f[a], f[b] = 1, 1, 1
	s = min(a, b)
	for k in range(s, n+1):
		if f[k]: f[a+k] = 1; f[b+k] = 1
	print(n-sum(f[s:n+1]))
Buggy python submission (verdict: Runtime Error):
# AOJ 1518: Last One
# Python3 2018.7.13 bal4u

ans = 0;
n = int(input())
for i in range(n):
	p, ms = input().split();
	ms = list(ms)
	s = 0
	for m in ms:
		if m.isdigit(): s += int(m)
		elif m.isupper(): s += ord(m)-ord('A')+10
		else: s += ord(m)-ord('a')+36
	ans ^= s
print("win" if ans else "lose")


Fixed submission:
# AOJ 1518: Last One
# Python3 2018.7.13 bal4u

ans = 0;
for i in range(int(input())):
	p = input().split();
	if len(p) == 1: ms = []
	else: ms = list(p[1])
	s = 0
	for m in ms:
		if m.isdigit(): s += int(m)
		elif m.isupper(): s += ord(m)-ord('A')+10
		else: s += ord(m)-ord('a')+36
	ans ^= s
print("win" if ans else "lose")
Buggy python submission (verdict: Runtime Error):
# AOJ 1566 Movie
# Python3 2018.7.13 bal4u

n = int(input())
tbl = []
for i in range(n):
	a, b = map(int, input().split())
	tbl.append([b, a])
tbl.sort()
ans = saw = 0
seen = [0]*32
for i in range(1, 32):
	for j in range(n):
		if i < tbl[j][1] or tbl[j][0] < i: continue
		if seen[j]: continue
		ans += 100; seen[j] = 1; saw += 1
		break;
print(ans+(31-saw)*50)


Fixed submission:
# AOJ 1566 Movie
# Python3 2018.7.13 bal4u

n = int(input())
tbl = []
for i in range(n):
	a, b = map(int, input().split())
	tbl.append([b, a])
tbl.sort()
ans = saw = 0
seen = [0]*101
for i in range(1, 32):
	for j in range(n):
		if i < tbl[j][1] or tbl[j][0] < i: continue
		if seen[j]: continue
		ans += 100; seen[j] = 1; saw += 1
		break;
print(ans+(31-saw)*50)
Buggy python submission (verdict: Runtime Error):
# AOJ 2805: Tournament
# Python3 2018.7.11 bal4u

def calc(l, n):
	if n == 2:
		if a[l] and a[l+1]: return [0, True]
		if a[l] or a[l+1]: return [0, False]
		return [1, False]
	m = n >> 1
	c1, f1 = calc(l, m)
	c2, f2 = calc(l+m, m)
	if f1 and f2: return [c1+c2, True]
	if f1 or f2: return [c1+c2, False]
	return [c1+c2+1, False]

while True:
	N, M = map(int, input().split())
	if M == 0: print(N-1)
	else:
		a = [False]*256
		for i in range(M): a[int(input())] = True
		print(calc(0, N)[0])


Fixed submission:
# AOJ 2805: Tournament
# Python3 2018.7.11 bal4u

N, M = map(int, input().split())
print(N-1-M)
Buggy python submission (verdict: Runtime Error):
# AOJ ITP1_4_D: Min, Max and Sum
# 2018.6.7 bal4u
#

n = input()
data = list(map(int, input().split()))   # 1行にある複数の値を整数にして、リストにしまう
#
vmin = min(data)  # 最小値
vmax = max(data)  # 最大値
vsum = sum(data)  # 合計
#
print(vmin, vmax, vsum)  # 結果表示


Fixed submission:
# AOJ ITP1_4_D: Min, Max and Sum
# Python3 2018.6.7 bal4u

n = int(input())
data = list(map(int, input().split()))   # 1行にある複数の値を整数にして、リストにしまう
#
vmin = min(data)  # 最小値
vmax = max(data)  # 最大値
vsum = sum(data)  # 合計
#
print(vmin, vmax, vsum)  # 結果表示