Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

while True:
    N, M = map(int, input().split())
    if N == 0 and M == 0:
        break
    H = [int(input()) for _ in range(N)]
    W = [int(input()) for _ in range(M)]
    all_H = []
    all_W = []
    for i in range(N):
        for j in range(i + 1, N + 1):
            all_H.append(sum(H[i:j]))
    for i in range(M):
        for j in range(i + 1, M + 1):
            all_W.append(sum(W[i:j]))
    all_H = Counter(sorted(all_H))
    all_W = Counter(sorted(all_W))

    ans = 0
    for k, v in all_H.items():
        if k in all_H:
            ans += v * all_W[k]
    # print(all_H)
    # print(all_W)
    print(ans)



Fixed submission:
from collections import Counter

while True:
    N, M = map(int, input().split())
    if N == 0 and M == 0:
        break
    H = [int(input()) for _ in range(N)]
    W = [int(input()) for _ in range(M)]

    all_H = []
    for i in range(N):
        s = 0
        for j in range(i, N):
            s += H[j]
            all_H.append(s)

    all_W = []
    for i in range(M):
        s = 0
        for j in range(i, M):
            s += W[j]
            all_W.append(s)

    all_H = Counter(all_H)
    all_W = Counter(all_W)
    ans = 0
    for k, v in all_H.items():
        if k in all_H:
            ans += v * all_W[k]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

while True:
    N, M = map(int, input().split())
    if N == 0 and M == 0:
        break
    H = [int(input()) for _ in range(N)]
    W = [int(input()) for _ in range(M)]
    all_H = Counter(
        sorted([sum(H[i:j]) for i in range(N) for j in range(i + 1, N + 1)])
    )
    all_W = Counter(
        sorted([sum(W[i:j]) for i in range(M) for j in range(i + 1, M + 1)])
    )
    ans = 0
    for k, v in all_H.items():
        if k in all_H:
            ans += v * all_W[k]
    print(ans)


Fixed submission:
from collections import Counter

while True:
    N, M = map(int, input().split())
    if N == 0 and M == 0:
        break
    H = [int(input()) for _ in range(N)]
    W = [int(input()) for _ in range(M)]

    all_H = []
    for i in range(N):
        s = 0
        for j in range(i, N):
            s += H[j]
            all_H.append(s)

    all_W = []
    for i in range(M):
        s = 0
        for j in range(i, M):
            s += W[j]
            all_W.append(s)

    all_H = Counter(all_H)
    all_W = Counter(all_W)
    ans = 0
    for k, v in all_H.items():
        if k in all_H:
            ans += v * all_W[k]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
def sieve (n):
	ms_prime = [0,0,0,0,0,0]
	ms_prime += [1 for i in range(n-5)]
	ub = math.sqrt(n) + 1
	d = 6
	while d <= ub:
		if ms_prime[d] == 0:
			d += 1
			continue
		if d % 7 != 1 and d % 7 != 6:
			ms_prime[d] = 0
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			ms_prime[d*prod] = 0
			prod += 1
		d += 1
	return ms_prime
ms_prime = sieve(300000)
while 1:
	n = int(raw_input())
	if n == 1:
		break
	sys.stdout.write("%d:" % n)
	msp_factor = set()
	for i in range(6, n+1):
		tmp_factor = 0
		if ms_prime[i] == 1 and n % i == 0 and ((n / i) % 7 == 1 or (n / i) % 7 == 6): 
			sys.stdout.write(" %d" % i)
	else :
		print ""

Fixed submission:
import sys
def sieve (n):
	ms_sieve = [0,0,0,0,0,0]
	ms_sieve += [1 for i in range(n-5)]
	ms_prime = []
	d = 6
	while d <= n:
		if ms_sieve[d] == 0:
			d += 1
			continue
		if d % 7 != 1 and d % 7 != 6:
			ms_sieve[d] = 0
			d += 1
			continue
		ms_prime.append(d)
		prod = 2
		while d * prod <= n:
			ms_sieve[d*prod] = 0
			prod += 1
		d += 1
	return ms_prime
ms_prime = sieve(300000)
while 1:
	n = int(raw_input())
	if n == 1:
		break
	sys.stdout.write("%d:" % n)
	for msp in ms_prime:
		if msp > n:
			break
		quot, rem = divmod(n,msp)
		if rem != 0:
			continue 
		rem2 = quot % 7
		if rem2 == 1 or rem2 == 6: 
			sys.stdout.write(" %d" % msp)
	print ""
Buggy python submission (verdict: Runtime Error):
def travel(here, lb, ub, field, label):
	if field[here[1]][here[0]] == 1:
		field[here[1]][here[0]] = label
		if lb[0] < here[0] :
			travel((here[0]-1, here[1]), lb, ub, field, label)
			if lb[1] < here[1]:
				travel((here[0]-1, here[1]-1), lb, ub, field, label)

		if lb[1] < here[1] :
			travel((here[0], here[1]-1), lb, ub, field, label)
			if ub[0] > here[0] :
				travel((here[0]+1, here[1]-1), lb, ub, field, label)

		if ub[0] > here[0] :
			travel((here[0]+1, here[1]), lb, ub, field, label)
			if ub[1] > here[1]:
				travel((here[0]+1, here[1]+1), lb, ub, field, label)
				 
		if ub[1] > here[1] :
			travel((here[0], here[1]+1), lb, ub, field, label)
			if lb[0] < here[0] :
				travel((here[0]-1, here[1]+1), lb, ub, field, label)

while 1:
	w, h = map(int, raw_input().split(" "))
	if (w,h) == (0,0):
		break
	island = []
	for j in range(h):
		island.append(map(int, raw_input().split(" ")))
	label = 1
	for j in range(h):
		for i in range(w):
			if island[j][i] == 1:
				label += 1
				travel((i,j), (0,0), (w-1,h-1), island, label)
	print label - 1

Fixed submission:
def travel(here, lb, ub, field, label):
	if field[here[1]][here[0]] == 1:
		field[here[1]][here[0]] = label
		if lb[0] < here[0] :
			travel((here[0]-1, here[1]), lb, ub, field, label)
			if lb[1] < here[1]:
				travel((here[0]-1, here[1]-1), lb, ub, field, label)

		if lb[1] < here[1] :
			travel((here[0], here[1]-1), lb, ub, field, label)
			if ub[0] > here[0] :
				travel((here[0]+1, here[1]-1), lb, ub, field, label)

		if ub[0] > here[0] :
			travel((here[0]+1, here[1]), lb, ub, field, label)
			if ub[1] > here[1]:
				travel((here[0]+1, here[1]+1), lb, ub, field, label)
				 
		if ub[1] > here[1] :
			travel((here[0], here[1]+1), lb, ub, field, label)
			if lb[0] < here[0] :
				travel((here[0]-1, here[1]+1), lb, ub, field, label)

import sys
sys.setrecursionlimit(100000)
while 1:
	w, h = map(int, raw_input().split(" "))
	if (w,h) == (0,0):
		break
	island = []
	for j in range(h):
		island.append(map(int, raw_input().split(" ")))
	label = 1
	for j in range(h):
		for i in range(w):
			if island[j][i] == 1:
				label += 1
				travel((i,j), (0,0), (w-1,h-1), island, label)
	print label - 1
Buggy python submission (verdict: Runtime Error):
import math
while 1:
	n = int(raw_input())
	if n == 0:
		break
	count = 0
	for p in range(n+1,2*n+1):
		for d in range(2, int(math.sqrt(p)) + 1):
			if p != d and  p % d == 0:
				break
		else:
			count += 1
	print count

Fixed submission:
import math
MAX = 123456
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(2 * MAX)
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print sum(prime[n+1:2*n+1])

Buggy python submission (verdict: Runtime Error):
import math
while 1:
	n = int(raw_input())
	if n == 0:
		break
	count = 0
	for p in range(n+1,2*n+1):
		for d in range(2, int(math.sqrt(p)) + 1):
			if p != d and p % d == 0:
				break
		else:
			count += 1
	print count

Fixed submission:
import math
MAX = 123456
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(2 * MAX)
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print sum(prime[n+1:2*n+1])

Buggy python submission (verdict: Runtime Error):
import math
while 1:
	n = int(raw_input())
	if n == 0:
		break
	count = 0
	for p in range(n+1,2*n+1):
		d = 2
		ub = math.sqrt(p) + 1
		while d <= ub :
			if p != d and p % d == 0:
				break
			d += 1
		else:
			count += 1
	print count

Fixed submission:
import math
MAX = 123456
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(2 * MAX)
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print sum(prime[n+1:2*n+1])
Buggy python submission (verdict: Runtime Error):
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(1000)
while 1:
	m,a,b = map(int,raw_input().split(" "))
	if (m,a,b) == (0,0,0):
		break
	rect_max = (0,0,0)
	q = 997
	while q >= 2:
		if prime[q] == 0:
			q -= 1
			continue
		p = q
		while p * b >= q * a:
			if prime[p] == 0 or p * q > m:
				p -= 1
				continue
			if rect_max[0] <= p*q:
				rect_max = (p*q,p,q)
			p -= 1
		q -= 1
	print rect_max[1], rect_max[2]

Fixed submission:
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(50000)
while 1:
	m,a,b = map(int,raw_input().split(" "))
	if (m,a,b) == (0,0,0):
		break
	rect_max = (0,0,0)
	q = m / 2
	while q >= 2:
		if prime[q] == 0:
			q -= 1
			continue
		p = min(m / q + 1, q)
		while p * b >= q * a:
			if prime[p] == 0 or p * q > m:
				p -= 1
				continue
			if rect_max[0] <= p*q:
				rect_max = (p*q,p,q)
			p -= 1
		q -= 1
	print rect_max[1], rect_max[2]
Buggy python submission (verdict: Runtime Error):
from math import sqrt
while 1:
	n = int(raw_input())
	if n == 0:
		break
	ub = int(sqrt(n))
	square_sum = [[0 for i in range(n+1)] for j in range(4)]
	for k in range(1,ub+1):
		square_k = k**2
		square_sum[0][square_k] = 1
		for j in range(3):
			for i in range(1, n+1 - square_k):
				if square_sum[j][i] >= 1:
					square_sum[j+1][i+square_k] += square_sum[j][i]
	print sum([square_sum[j][n] for j in range(4)])
	

Fixed submission:
from math import sqrt
MAX = 2**15-1
ub = int(sqrt(MAX))
square_sum = [[0 for i in range(MAX)] for j in range(4)]
for k in range(1,ub+1):
	square_k = k**2
	square_sum[0][square_k-1] = 1 
	for j in range(3):
		for i in range(1,MAX - square_k + 1):
			if square_sum[j][i-1] >= 1:
				square_sum[j+1][i-1+square_k] += square_sum[j][i-1]
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print sum(square_sum[i][n-1] for i in range(4))

Buggy python submission (verdict: Runtime Error):
from math import sqrt
while 1:
	n = int(raw_input())
	if n == 0:
		break
	ub = int(sqrt(n))
	square = [i**2 for i in range(1,ub+1)]
	square_sum =[[0 for i in range(n)] for j in range(2)]
	count = 0
	for k in range(1,ub+1):
		for i in range(1,k+1):
			if square[k-1] + square[i-1] <= n: 
				square_sum[0][square[k-1] + square[i-1]-1] += 1
		for i in range(1, n + 1 - square[k-1]):
			if square_sum[0][i-1] >= 1:
				square_sum[1][i-1+square[k-1]] += square_sum[0][i-1]
		count += square_sum[1][n-1-square[k-1]]
	print (1 if n == ub**2 else 0) + square_sum[0][n-1] + square_sum[1][n-1] + count

Fixed submission:
from math import sqrt
MAX = 2**15-1
ub = int(sqrt(MAX))
square_sum = [[0 for i in range(MAX)] for j in range(4)]
for k in range(1,ub+1):
	square_k = k**2
	square_sum[0][square_k-1] = 1 
	for j in range(3):
		for i in range(1,MAX - square_k + 1):
			if square_sum[j][i-1] >= 1:
				square_sum[j+1][i-1+square_k] += square_sum[j][i-1]
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print sum(square_sum[i][n-1] for i in range(4))
Buggy python submission (verdict: Runtime Error):
while 1:
	n, k, s = map(int,raw_input().split())
	if (n, k, s) == (0, 0, 0):
		break
	dp = [[0 for i in range(s)] for j in range(k)]
	for x in range(1,n+1):
		for j in range(k-1):
			for i in range(s-x):
				if dp[j+1][i] >= 1:
					dp[j][i+x] += dp[j+1][i]
		dp[k-1][x-1] = 1
	print dp[0][s-1]

Fixed submission:
while 1:
	n, k, s = map(int,raw_input().split())
	if (n, k, s) == (0, 0, 0):
		break
	dp = [[0 for i in range(s)] for j in range(k)]
	ub = min(n+1,s+1)
	for x in range(1,ub):
		for j in range(k-1):
			for i in range(s-x):
				if dp[j+1][i] >= 1:
					dp[j][i+x] += dp[j+1][i]
		dp[k-1][x-1] = 1
	print dp[0][s-1]
Buggy python submission (verdict: Runtime Error):
import math 
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = e
	while math.pow(z,3) <= e:
		y = 0
		while y ** 2 <= e - math.pow(z,3):
			m = min(e + y + z - y**2 - math.pow(z,3), m)
			y += 1
		z += 1
	print int(m)

Fixed submission:
from math import sqrt
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = float("inf")
	while z ** 3 <= e:
		y = int(sqrt(e - z**3))
		m = min(m, e  - y**2 - z**3 + y + z)
		z += 1
	print int(m)

Buggy python submission (verdict: Runtime Error):
import math 
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = e
	while math.pow(z,3) <= e:
		y = 0
		while y ** 2 <= e - math.pow(z,3):
			m = min(e + y + z - y**2 - math.pow(z,3), m)
			y += 1
		z += 1
	print y, z
	print int(m)
quit()

Fixed submission:
from math import sqrt
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = float("inf")
	while z ** 3 <= e:
		y = int(sqrt(e - z**3))
		m = min(m, e  - y**2 - z**3 + y + z)
		z += 1
	print int(m)

Buggy python submission (verdict: Runtime Error):
import math 
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = e
	while math.pow(z,3) <= e:
		y = 0
		while y ** 2 <= e - math.pow(z,3):
			m = min(e + y + z - y**2 - math.pow(z,3), m)
			y += 1
		z += 1
	print int(m)
quit()

Fixed submission:
from math import sqrt
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = float("inf")
	while z ** 3 <= e:
		y = int(sqrt(e - z**3))
		m = min(m, e  - y**2 - z**3 + y + z)
		z += 1
	print int(m)
Buggy python submission (verdict: Runtime Error):
from math import log
class SegmentTree :
	def __init__ (self, N):
		self.N = N
		self.tree = [0 for i in range(2 * N - 1)]

	def update(self,i,x):
		node = i + self.N - 1
		self.tree[node] += x
		while node > 0:
			node = (node-1) / 2
			self.tree[node] += x

	def sum(self,here,l,r,hl,hr): #init : hl = 0, hr = N = 2 ** x - 1
		if here >= self.N - 1 or l == hl and r == hr:
			return self.tree[here]
		midle = (hl + hr + 1) / 2 # belong to rchild
		result = 0
		if l < midle :
			result += self.sum(2 * here + 1, l, min(r,midle - 1), hl, midle - 1) 
		if r >= midle :
			result += self.sum(2 * here + 2, max(l,midle), r, midle, hr) 
		return result
while 1 :
	n, m = map(int,raw_input().split(" "))
	if (n, m) == (0,0):
		break
	Lon_idx = log(n,2)
	Lat_idx = log(m,2)
	LonN = 2 ** (int(Lon_idx) if Lon_idx.is_integer() else (int(Lon_idx)+1))
	LatN = 2 ** (int(Lat_idx) if Lat_idx.is_integer() else (int(Lat_idx)+1))
	LonST = SegmentTree(LonN)
	LatST = SegmentTree(LatN)
	for i in range(0,n):
		LonST.update(i,int(raw_input()))
	for i in range(0,m):
		LatST.update(i,int(raw_input()))
	Lon = [0 for i in range(n*1000+1)]
	Lat = [0 for i in range(m*1000+1)]
	for i in range(1,n+1):
		for j in range(n+1-i):
			Lon[LonST.sum(0,j,j+i-1,0,LonN-1)]+=1
	for i in range(1,m+1):
		for j in range(m+1-i):
			Lat[LatST.sum(0,j,j+i-1,0,LatN-1)]+=1
	max_width = min(LonST.tree[0],LatST.tree[0])
	print sum([Lon[i]*Lat[i] for i in range(1,max_width+1)])

Fixed submission:
while 1 :
	n, m = map(int,raw_input().split(" "))
	if (n, m) == (0,0):
		break
	Lon = [0 for _ in range(1000 * n + 1)]
	Lat = [0 for _ in range(1000 * m + 1)]
	Lon_sum = []
	Lat_sum = []
	for _ in range(0,n):
		h = int(raw_input())
		Lon_sum = [h + j for j in Lon_sum] + [h]
		for j in Lon_sum:
			Lon[j] += 1
	for _ in range(0,m):
		w = int(raw_input())
		Lat_sum = [w + j for j in Lat_sum] + [w]
		for j in Lat_sum:
			Lat[j] += 1
	max_width = min(Lon_sum[0],Lat_sum[0])
	print sum([Lon[i]*Lat[i] for i in range(1,max_width+1)])
Buggy python submission (verdict: Runtime Error):
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(2*10**5)

while 1:
	N,P = map(int,raw_input().split())
	if (N,P) == (0,0):
		break
	prime_ub = P
	prime_list = []
	prime_num = 0
	inc = N + 1
	while prime_num < prime_ub :
		if prime[inc] == 1:
			prime_num += 1
			prime_list.append(inc)
		inc += 1
	sum_list = []
	for i in range(prime_num):
		sum_list += [prime_list[i] + p for p in prime_list[i:]]
	sum_list.sort()
	print sum_list[P-1]

Fixed submission:
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(2*10**5)

while 1:
	N,P = map(int,raw_input().split())
	if (N,P) == (-1,-1):
		break
	prime_ub = P
	prime_list = []
	prime_num = 0
	inc = N + 1
	while prime_num < prime_ub :
		if prime[inc] == 1:
			prime_num += 1
			prime_list.append(inc)
		inc += 1
	sum_list = []
	for i in range(prime_num):
		sum_list += [prime_list[i] + p for p in prime_list[i:]]
	sum_list.sort()
	print sum_list[P-1]
Buggy python submission (verdict: Time Limit Exceeded):
amount = int(input())

numbers = [int(input()) for i in range(amount)]

max_profit = -1 * (numbers[0] - numbers[1])

for i in range(amount - 1):
    for j in range(i + 1, amount):
        if (-1 * (numbers[i] - numbers[j])) >= max_profit:
            max_profit = -1 * (numbers[i] - numbers[j])

print(max_profit)

Fixed submission:
maxv = -2 * 10 ** 9
minv = 2 * 10 ** 9

n = int(input())
for i in range(n):
    x = int(input())
    maxv = max(x - minv, maxv)
    minv = min(x, minv)

print(maxv)
Buggy python submission (verdict: Runtime Error):
def bubble_sort(A):
    cnt = 0
    for i in range(len(A) - 1):
        for j in reversed(range(i+1, len(A))):
            if A[j] < A[j - 1]:
                cnt += 1
                tmp = A[j]
                A[j] = A[j - 1]
                A[j - 1] = tmp
    return cnt

cnt = 0
amount = int(input())
nl = list(int(input()) for i in range(amount))

cnt = bubble_sort(nl)

for i in range(amount - 1):
    print(nl[i], end=" ")
print(nl[amount - 1])
print(cnt)

Fixed submission:
def bubble_sort(A):
    cnt = 0
    for i in range(len(A) - 1):
        for j in reversed(range(i+1, len(A))):
            if A[j] < A[j - 1]:
                cnt += 1
                tmp = A[j]
                A[j] = A[j - 1]
                A[j - 1] = tmp
    return cnt

cnt = 0
amount = int(input())
nl = list(map(int, input().split()))

cnt = bubble_sort(nl)

for i in range(amount - 1):
    print(nl[i], end=" ")
print(nl[amount - 1])
print(cnt)
Buggy python submission (verdict: Runtime Error):

while True:
	n, r = map(int, input().split())
	if (n, r) == (0, 0):
		break
	cards = list(range(1, n+1))[::-1]
	print(cards)

	for i in range(r):
		p, c = map(int, input().split())
		cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]
	print(cards[0])

Fixed submission:

while True:
	n, r = map(int, input().split())
	if (n, r) == (0, 0):
		break
	cards = list(range(1, n+1))[::-1]

	for i in range(r):
		p, c = map(int, input().split())
		cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]
	print(cards[0])
Buggy python submission (verdict: Runtime Error):

def tax(p, x):
	return p * (100 + x) // 100

while True:
	x, y, s = map(int, input().split())
	if (x, y, s) == (0, 0, 0):
		break
	r = 0
	for i in range(1, s):
		for j in range(1, s):
			if (tax(i, x) + tax(j, x)) == s:
				r = max((tax(i, y) + tax(j, y)), r)
	print(r)

Fixed submission:

def tax(p, x):
	return p * (100 + x) // 100

while True:
	x, y, s = map(int, input().split())
	if (x, y, s) == (0, 0, 0):
		break
	r = 0
	for i in range(1, s):
		for j in range(1, s):
			t = tax(i, x) + tax(j, x)
			if t > s:
				break
			if (t) == s:
				r = max((tax(i, y) + tax(j, y)), r)
	print(r)
Buggy python submission (verdict: Time Limit Exceeded):
import math


def is_prime(num):
    for i in range(2, max(num, math.floor(math.sqrt(num)))):
        if num % i == 0:
            return False
    return True


N = int(input())
nums = [int(input()) for _ in range(N)]
ans = len([num for num in nums if is_prime(num)])
print(ans)

Fixed submission:
import math


def is_prime(num):
    if num == 2:
        return True
    elif not num & 1:
        return False

    for i in range(3, math.ceil(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False
    return True


N = int(input())
nums = [int(input()) for _ in range(N)]
ans = len([num for num in nums if is_prime(num)])
print(ans)
Buggy python submission (verdict: Runtime Error):
# l = open('input.txt').readline()
l = input()

k = 0
S1, S2 = [], []
for i in range(len(l)):
    if l[i] == '\\':
        S1.append(i)
    elif l[i] == '/':
        j = S1.pop()
        a = i - j
        k += i - j

        while S2 and S2[-1][0] > j:
            a += S2.pop()[1]
        S2.append((j, a))
print(k)
print(len(S2), *(a for j, a in S2))

Fixed submission:
# l = open('input.txt').readline()
l = input()

k = 0
S1, S2 = [], []
for i in range(len(l)):
    if l[i] == '\\':
        S1.append(i)
    elif l[i] == '/' and S1:
        j = S1.pop()
        a = i - j
        k += i - j

        while S2 and S2[-1][0] > j:
            a += S2.pop()[1]
        S2.append((j, a))
print(k)
print(len(S2), *(a for j, a in S2))
Buggy python submission (verdict: Time Limit Exceeded):


G = [301,91,58,31,7,4,1]

def insertion_sort(array,g):
    for i in range(g,len(array)-1):
        v = array[i]
        j = i-g
        while j>=0 and array[j] > v:
            array[j+g] = array[j]
            j = j-g
            array[-1] += 1
        array[j+g] = v

def shell_sort(array,G):
    for i in G:
        insertion_sort(array,i)


n = int(input())
arr = [int(input()) for i in range(n)] + [0]
Gn = [i for i in G if i <= n]


shell_sort(arr,Gn)
print(len(Gn))
print(' '.join([str(i) for i in Gn]))
print(arr[-1])
[print(i) for i in arr[:-1]]

Fixed submission:


G = [120001,60001,30001,15001,3001,901,601,301,91,58,31,7,4,1]

def insertion_sort(array,g):
    for i in range(g,len(array)-1):
        v = array[i]
        j = i-g
        while j>=0 and array[j] > v:
            array[j+g] = array[j]
            j = j-g
            array[-1] += 1
        array[j+g] = v

def shell_sort(array,G):
    for i in G:
        insertion_sort(array,i)


n = int(input())
arr = [int(input()) for i in range(n)] + [0]
Gn = [i for i in G if i <= n]


shell_sort(arr,Gn)
print(len(Gn))
print(' '.join([str(i) for i in Gn]))
print(arr[-1])
[print(i) for i in arr[:-1]]

Buggy python submission (verdict: Time Limit Exceeded):


G = [901,601,301,91,58,31,7,4,1]

def insertion_sort(array,g):
    for i in range(g,len(array)-1):
        v = array[i]
        j = i-g
        while j>=0 and array[j] > v:
            array[j+g] = array[j]
            j = j-g
            array[-1] += 1
        array[j+g] = v

def shell_sort(array,G):
    for i in G:
        insertion_sort(array,i)


n = int(input())
arr = [int(input()) for i in range(n)] + [0]
Gn = [i for i in G if i <= n]


shell_sort(arr,Gn)
print(len(Gn))
print(' '.join([str(i) for i in Gn]))
print(arr[-1])
[print(i) for i in arr[:-1]]

Fixed submission:


G = [120001,60001,30001,15001,3001,901,601,301,91,58,31,7,4,1]

def insertion_sort(array,g):
    for i in range(g,len(array)-1):
        v = array[i]
        j = i-g
        while j>=0 and array[j] > v:
            array[j+g] = array[j]
            j = j-g
            array[-1] += 1
        array[j+g] = v

def shell_sort(array,G):
    for i in G:
        insertion_sort(array,i)


n = int(input())
arr = [int(input()) for i in range(n)] + [0]
Gn = [i for i in G if i <= n]


shell_sort(arr,Gn)
print(len(Gn))
print(' '.join([str(i) for i in Gn]))
print(arr[-1])
[print(i) for i in arr[:-1]]