Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03035 (python)

Fixed submission:
A, B = map(int, input().split())


def f():
    if A <= 5:
        return 0
    elif 6 <= A <= 12:
        return B // 2
    else:
        return B


print(f())

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = [None] * M
for i in range(M):
    BC[i] = tuple(map(int, input().split()))
BC.sort(key=lambda tpl: tpl[1], reverse=True)  # sort by C descendant

D = [0] * N
i = 0
j = 0
while i < N and j < M:
    b, c = BC[j]
    for k in range(i, min(i + b, N)):
        D[k] = c
    i += b
    j += 1

for i in range(N):
    A[i] = max(A[i], D[i])

print(sum(A))
Problem p03061 (python)

Fixed submission:
def gcd(a, b):
    bigger = max(a, b)
    smaller = min(a, b)
    while smaller != 0:
        bigger, smaller = smaller, bigger % smaller
    return bigger


N = int(input())
A = list(map(int, input().split()))
gcd_l = [A[0]] + [0] * (N - 1)
for i in range(1, N):
    gcd_l[i] = gcd(gcd_l[i - 1], A[i])
del gcd_l[-1]

gcd_r = [0] * (N - 1) + [A[-1]]
for i in range(N - 1, 0, -1):
    gcd_r[i - 1] = gcd(gcd_r[i], A[i - 1])
del gcd_r[0]

gcds = [gcd_l.pop(), gcd_r.pop(0)]
for l, r in zip(gcd_l, gcd_r):
    gcds.append(gcd(l, r))
print(max(gcds))

Buggy submission (verdict: Runtime Error):
def gcd_seq(seq):
    from math import gcd
    size = len(seq)
    if size == 1:
        return seq[0]
    if size == 2:
        return gcd(seq[0], seq[1])
    ans = gcd(seq[0], seq[1])
    for i in range(2, size):
        ans = gcd(seq[i], ans)
    return ans


N = int(input())
A = [int(i) for i in input().split()]

ANS = gcd_seq(A)  # no change
for i in range(N):
    a = A[:]
    a.pop(i)
    ANS = max((gcd_seq(a), ANS))
print(ANS)

Buggy submission (verdict: Runtime Error):
from math import gcd


def gcd_seq(seq):
    size = len(seq)
    if size == 1:
        return seq[0]
    elif size == 2:
        return gcd(seq[0], seq[1])
    ans = gcd(seq[0], seq[1])
    for i in range(2, size):
        ans = gcd(seq[i], ans)
    return ans


N = int(input())
A = [int(i) for i in input().split()]

ANS = gcd_seq(A)  # no change
for i in range(N):
    a = A[:]
    a.pop(i)
    ans = gcd_seq(a)
    ANS = max((ans, ANS))
print(ANS)
Problem p03069 (python)

Fixed submission:
N = int(input())
S = input()

W = [0] * N
W[-1] += S[-1] == "."
for i in range(N - 2, -1, -1):
    W[i] = W[i + 1] + (S[i] == ".")

B = [0] * N
B[0] += S[0] == "#"
for i in range(1, N):
    B[i] = B[i - 1] + (S[i] == "#")

T = [w + b - 1 for w, b in zip(W, B)]
T = min(T)
print(min(T, W[0], B[-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

W = [0] * N
W[-1] += S[-1] == "."
for i in range(N - 2, -1, -1):
    W[i] = W[i + 1] + (S[i] == ".")

B = [0] * N
B[0] += S[0] == "#"
for i in range(1, N):
    B[i] = B[i - 1] + (S[i] == "#")

T = [w + b for w, b in zip(W, B)]
print(min(*T, W[0], B[-1]))
Problem p03076 (python)

Fixed submission:
from sys import stdin

num_dishes = 5
dishes = []
for i in range(5):
    dishes.append(int(stdin.readline()))
for i in range(0, num_dishes - 1):
    for j in range(i + 1, num_dishes):
        if (dishes[i] % 10 > dishes[j] % 10):
            dishes[i], dishes[j] = dishes[j], dishes[i]
dishes.sort(key=lambda d: d % 10)
got = False
ans = 0
for dish in dishes:
    if dish % 10 == 0:
        ans += dish
        continue
    else:
        if got:
            ans += dish + (10 - dish % 10)
        else:
            got = True
            ans += dish
print(ans)

Buggy submission (verdict: Runtime Error):
A = [int(input()) for _ in range(5)]
ans = 0
I = [i for i, a in enumerate(A) if a % 10 == 0]
for i in reversed(I):
    ans += A.pop(i)
A.sort(key=lambda a: a % 10)
ans += A.pop(0)
for i in range(len(A)):
    A[i] += 10 - (A[i] % 10)
ans += sum(A)
print(ans)
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())

i = 0
while i < len(S) and S[i] == '1':
    i += 1
if K <= i or i == len(S):
    print(1)
else:
    print(S[i])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

i = 0
while S[i] == '1' and i < len(S):
    i += 1
if K < i:
    print(1)
else:
    print(S[i])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

i = 0
while S[i] == '1':
    i += 1
if K < i:
    print(1)
else:
    print(S[i])
Problem p03288 (python)

Fixed submission:
r = int(input())

if r < 1200:
    print("ABC")
elif r < 2800:
    print("ARC")
else:
    print("AGC")

Buggy submission (verdict: Runtime Error):
r = input()

if r < 1200:
    print("ABC")
elif r < 2800:
    print("ARC")
else:
    print("AGC")
Problem p03386 (python)

Fixed submission:
A, B, K = map(int, input().split())
R = range(A, min(B + 1, A + K))
S = range(max(A, B - K + 1), B + 1)
L = list(set(R) | set(S))
L.sort()
print(*L, sep="\n")

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
print(
    *sorted(
        list(set(range(A, min(B + 1, A + K))) | set(range(max(A, B - K) + 1, B + 1)))
    ),
    sep="\n",
)
Problem p02843 (python)

Fixed submission:
x = int(input())
if x < 100:
    print(0)
    exit()
else:
    y = int(str(x)[:-2])
    z = int(str(x)[-2:])
    if (y*5) < z:
        print(0)
        exit()
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
x = int(input())
y = int(str(x)[:-2])
z = int(str(x)[-2:])
if x < 100:
    print(0)
    exit()
elif (y*5) < z:
    print(0)
    exit()
else:
    print(1)
Problem p02913 (python)

Fixed submission:
n = int(input())
s = input()

ans = 0
i = j= 0

while j <= n-1:
    if s[i:j] in s[j:]:
        ans = max(ans, j-i)
        j += 1
    else:
        i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(intput())
s = int(intput())

ans = 0
i = j= 0

while j <= n-1:
    if s[i:j] in s[j:]:
        ans = max(ans, j-i)
        j += 1
    else:
        i += 1
print(ans)
Problem p02924 (python)

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(int(n(n-1)/2))

Buggy submission (verdict: Runtime Error):
n = int(input())
print(sum(list(range(1,n))))

Buggy submission (verdict: Runtime Error):
n = int(input())
print(sum(list(range(1,n))))

Buggy submission (verdict: Runtime Error):
n = int(input())
ns = list(range(1, n+1))
ns_ = ns[1:] + [ns[0]]

total = 0
for i in range(n):
    total += ns[i] % ns_[i]
print(total)
Problem p02934 (python)

Fixed submission:
import numpy as np
n = int(input())
alist = list(map(int, input().split()))
alist = np.array(alist)
gyakulist = 1 / alist
print(1/sum(gyakulist))

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int, input().split()))
alist = np.array(alist)
gyakulist = 1 / alist
print(1/sum(gyakulist))
Problem p03037 (python)

Fixed submission:
import numpy as np
def main():
    N, M = map(int, input().split())
    maxl = -float('inf')
    minr = float('inf')
    for _ in range(M):
        l, r = map(int, input().split())
        if l >= maxl:
            maxl = l
        if r <= minr:
            minr = r
    val = minr - maxl + 1
    if val >= 0:
        print(val)
    else:
        print(0)
main()

Buggy submission (verdict: Runtime Error):
import numpy as np
def main():
    N, M = map(int, input().split())
    f = np.zeros((M,N))
    for i in range(M):
        l, r = map(int, input().split())
        f[i, l-1:r] += 1
    ans = sum(np.all(f, axis=0))
    print(ans)
main()
Problem p03109 (python)

Fixed submission:
lst = list(map(int, input().split('/')))
if lst[1] >= 5:
    print('TBD')
else:
    print('Heisei')

Buggy submission (verdict: Runtime Error):
lst = list(map(int, input().split('/'))
if lst[1] >= 5:
    print('TBD')
else:
    print('Heisei')
Problem p03110 (python)

Fixed submission:
def main():
    N = int(input())
    rate = 380000
    jpy = 0
    bit = 0
    for _ in range(N):
        x, u = input().split()
        if u=='JPY':
            jpy += float(x)
        else:
            bit += float(x)
    print(jpy + bit*rate)
main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    rate = 380000
    jpy = 0
    bit = 0
    for _ in range(N):
        x, u = input().split()
        if u=='JPY':
            jpy += x
        else:
            bit += x
    print(jpy + bit*rate)
main()
Problem p03128 (python)

Fixed submission:
def main():
    N, M = map(int, input().split())
    lst = list(map(int, input().split()))
    mapk = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
    
    dp = [0 for _ in range(N+1)] # ちょうどi本使ったときの最大桁数
    for i in range(1, N+1):
        tmp = []
        for k in lst:
            if (i-mapk[k])>=0:
                tmp.append(dp[i-mapk[k]] + 1)
            else:
                tmp.append(-float('inf'))
        dp[i] = max(tmp)
    #print(dp)
    
    ans = ''
    X = N
    lst = sorted(lst, reverse=True)
    for _ in range(dp[N]):
        for k in lst:
            if (X-mapk[k]>=0) and (dp[X - mapk[k]] == dp[X] - 1):
                ans += str(k)
                X -= mapk[k]
                break
    print(ans)
main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    lst = list(map(int, input().split()))
    mapk = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
    
    dp = [0 for _ in range(N+1)] # ちょうどi本使ったときの最大桁数
    for i in range(1, N+1):
        tmp = []
        for k in lst:
            if (i-mapk[k])>=0:
                tmp.append(dp[i-mapk[k]] + 1)
            else:
                tmp.append(-float('inf'))
        dp[i] = max(tmp)
    #print(dp)
    
    ans = ''
    X = N
    lst = sorted(lst, reverse=True)
    for _ in range(dp[N]):
        for k in lst:
            if dp[X - mapk[k]] == dp[X] - 1:
                ans += str(k)
                X -= mapk[k]
                break
    print(ans)
main()
Problem p03240 (python)

Fixed submission:
def main():
    N = int(input())
    points = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        points.append((x, y, h))
        if h >= 1:
            hint = (x, y, h)

    for px in range(101):
        for py in range(101):
            H = hint[2] + abs(px-hint[0]) + abs(py-hint[1])
            clearflag = True
            for point in points:
                x, y, h = point
                val = max([H - abs(px-x) - abs(py-y), 0])
                if val != h:
                    clearflag = False

            if clearflag:
                print(px, py, H)
                return
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
{ % if prediction_success % }
{ % endif % }
{ % if mod or yes_str or no_str % }

{ % endif % }
{ % if mod % }
MOD = None  # type: int
{ % endif % }
{ % if yes_str % }
YES = "None"  # type: str
{ % endif % }
{ % if no_str % }
NO = "None"  # type: str
{ % endif % }
{ % if prediction_success % }


def main():
    N = int(input())
    points = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        points.append((x, y, h))
        if h >= 1:
            hint = (x, y, h)

    for px in range(1, 101):
        for py in range(1, 101):
            H = hint[2] + abs(px-hint[0]) + abs(py-hint[1])
            clearflag = True
            for point in points:
                x, y, h = point
                val = max([H - abs(px-x) - abs(py-y), 0])
                if val != h:
                    clearflag = False

            if clearflag:
                print(px, py, H)
                return
if __name__ == '__main__':
    main()
Problem p03262 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

def gcd_list(numbers):
    return reduce(gcd, numbers)

n, x = map(int, input().split())
city = list(map(int, input().split()))
city.append(x)
city = sorted(city)
diff = [city[i+1] - city[i] for i in range(len(city)-1)]

if len(diff)==1:
    print(diff[0])
else:
    print(gcd_list(diff))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n, x = map(int, input().split())
city = list(map(int, input().split()))
city.append(x)
city = sorted(city)
diff = [city[i+1] - city[i] for i in range(len(city)-1)]

if len(diff)==1:
    print(diff[0])
else:
    print(gcd_list(diff))
Problem p03282 (python)

Fixed submission:
s = input()
n = len(s)
k = int(input())
ans = None
for i in range(k):
    if i == n:
        break

    if s[i] != '1':
        ans = int(s[i])
        break
    else:
        continue
if ans:
    print(ans)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
k = int(input())
for i in range(k):
    if i == n:
        break

    if s[i] != '1':
        ans = int(s[i])
        break
    else:
        continue
if ans:
    print(ans)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
for i in range(k):
    if s[i] != '1':
        ans = int(s[i])
        break
    else:
        continue
if ans:
    print(ans)
else:
    print(1)
Problem p03415 (python)

Fixed submission:
tmp = [input()[i] for i in range(3)]
print(''.join(tmp))

Buggy submission (verdict: Runtime Error):
tmp = [row[i] for i, row in enumerate(input())]
print(''.join(tmp))
Problem p03424 (python)

Fixed submission:
# B
n = int(input())
sli = list(input().split())
for s in sli:
    if s == 'Y':
        print('Four')
        exit()

print('Three')

Buggy submission (verdict: Runtime Error):
# B
n = int(input())
sli = list(map(int, input().spllit()))
for s in sli:
    if s == 'Y':
        print('Four')
        exit()

print('Three')
Problem p03455 (python)

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

if (a*b) % 2 == 0:
	print('Even')
else:
	print('Odd')

Buggy submission (verdict: Runtime Error):
print(sum(list(map(int, list(input())))))
Problem p03457 (python)

Fixed submission:
N = int(input())

plist = [(0,0,0)]
for _ in range(N):
	plist.append(tuple(map(int, input().split())))

judge = 'Yes'
for i in range(N):
	mae = plist[i]
	usi = plist[i+1]

	time_diff = usi[0] - mae[0]
	road = abs(usi[1] - mae[1]) + abs(usi[2] - mae[2])

	if time_diff < road:
		judge = 'No'
	elif time_diff >= road:
		yozyo = time_diff - road
		if yozyo % 2 != 0:
			judge = 'No'

print(judge)

Buggy submission (verdict: Runtime Error):
N = int(input())

plist = [(0,0,0)]
for _ in range(N):
	plist.append(tuple(map(int, input().split())))

judge = True
for i in range(N):
	mae = plist[i]
	usi = plist[i+1]

	time_diff = usi[0] - mae[0]
	road = abs(usi[1] - mae[1]) + abs(usi[2] - mae[2])

	amari = time_diff % road

	if amari % 2 != 0:
		judge =False

print(judge)

Buggy submission (verdict: Runtime Error):
N = int(input())

plist = [(0,0,0)]
for _ in range(N):
	plist.append(tuple(map(int, input().suplit())))

judge = True
for i in range(N):
	mae = plist[i]
	usi = plist[i+1]

	time_diff = usi[0] - mae[0]
	road = abs(usi[1] - mae[1]) + abs(usi[2] - mae[2])

	amari = time_diff % road

	if amari % 2 != 0:
		judge =False

print(judge)
Problem p03470 (python)

Fixed submission:
N = int(input())
mochis = []
for _ in range(N):
	mochis.append(int(input()))

dan = len(list(set(mochis)))
print(dan)

Buggy submission (verdict: Runtime Error):
N = int(input())
mochis = []
for _ in range(N):
	mochis.append(int(input()))

mochis = sorted(mochis, reverse=True)
dan = 0
for i in range(N):
	dan += 1
	if mochis[i] == mochis[i+1]:
		break

print(dan)

Buggy submission (verdict: Runtime Error):
N = int(input())
mochis = []
for _ in range(N):
	mochis.append(int(input())

mochis = sorted(mochis, reverse=True)
dan = 0
for i in range(N):
	dan += 1
	if mochis[i] == mochis[i+1]:
		break

print(dan)
Problem p03474 (python)

Fixed submission:
a, b = map(int, input().split())
s = input()

if (s[a]=='-' and s.count('-')==1):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# B
a, b = map(int, input().split())
s = input()
n = len(s)
nums = list(range(10))
point = 0
flag = 'Yes'

if n != a+b+1:
    flag = 'No'
    print(flag)
    exit()

while point<=n-1:
    if point == a:
        if s[point] != '-':
            flag = 'No'
    else:
        if int(s[point]) not in nums:
            flag = 'No'
    point += 1
print(flag)

Buggy submission (verdict: Runtime Error):
# B
a, b = map(int, input().split())
s = input()
n = len(s)
nums = list(range(10))
point = 0
flag = 'Yes'

while (0<=point<=n-1):
    if point == a:
        if s[point] != '-':
            flag = 'No'
    else:
        if int(s[point]) not in nums:
            flag = 'No'
    point += 1
print(flag)
Problem p03476 (python)

Fixed submission:
# D submit
from math import sqrt
def sieve(n):
    if n<2:
        return [False]*(n+1)
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(sqrt(n))+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return is_prime

n = int(1e5)
is_prime = sieve(n)

cnt = [0]*(n+1)
for i in range(1, n+1):
    cnt[i] += cnt[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        cnt[i] += 1
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(cnt[r] - cnt[l-1])

Buggy submission (verdict: Runtime Error):
# D submit
from math import sqrt
def sieve(n):
    if n<2:
        return [False]*(n+1)
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(sqrt(n))+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return is_prime

n = int(1e5)
is_prime = sieve(n)

cnt = [0]*(n+1)
for i in range(1, N+1):
    cnt[i] += cnt[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        cnt[i] += 1
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(cnt[r] - cnt[l-1])
Problem p03494 (python)

Fixed submission:
N = int(input())
Alist = list(map(int, input().split()))

flag = True
count = 0
while flag:
	for i in range(N):
		if Alist[i] % 2 != 0:
			flag = False
			break

	if flag:
		for i in range(N):
			Alist[i] = Alist[i] / 2
		count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
AList = list(map(int, input().split()))

count = 0
roop = 0
while reduce(lambda x,y:x*y, AList) % 2 == 0:
	for i in range(N):
		AList[i] = AList[i] / 2
		if AList[i] % 2 == 0:
			break
		count += 1

roop = count // N
print(roop)
Problem p03680 (python)

Fixed submission:
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(count)
        break
    elif count >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(count)
        break
    elif c >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(coount)
        break
    elif c >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(c)
        break
    elif c >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

visitedlist = [0]
from = 0
for _ in range(n):
    to = alist[from]
    if to in visitedlist:
        print(-1)
        break
    elif to == 1:
        print(len(visitedlist))
        break
    else:
        visitedlist.append(to)
        from = to
Problem p03694 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = [int(input()) for _ in range(n)]
dis = max(alist) - min(alist)
print(dis)
Problem p03696 (python)

Fixed submission:
n = int(input())
s = input()

left = 0
leftplus = 0
for i in range(len(s)):
    if s[i] == '(':
        left += 1
    else:
        if left == 0:
            leftplus += 1
        else:
            left -= 1

right = 0
rightplus = 0
r = s[::-1]
for i in range(len(r)):
    if r[i] == ')':
        right += 1
    else:
        if right == 0:
            rightplus += 1
        else:
            right -= 1
print('('*leftplus + s + ')'*rightplus)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

left = 0
leftplus = 0
for i in range(len(s)):
    if s[i] == '(':
        left += 1
    else:
        if left == 0:
            leftplus += 1
        else:
            left -= 1

right = 0
rightplus = 0
r = s[::-1]
for i in range(len(reverse)):
    if r[i] == ')':
        right += 1
    else:
        if right == 0:
            rightplus += 1
        else:
            right -= 1
print('('*leftplus + s + ')'*rightplus)
Problem p03699 (python)

Fixed submission:
n = int(input())
slist = [int(input()) for _ in range(n)]
total = sum(slist)

if total % 10 != 0:
    print(total)
    exit()
else:
    nonten = []
    for i in range(n):
        if slist[i] % 10 != 0:
            nonten.append(slist[i])
    if len(nonten) == 0:
        print(0)
    else:
        nonten = sorted(nonten)
        total -= nonten[0]
        print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
slist = [int(input()) for _ in range(n)]
slist = sorted(slist)

max_ = 0
for i in range(n+1):
    if i == 0:
        val = sum(slist)
        if val%10 != 0:
            max_ = val
            break
    else:
        for j in range(n-i):
            tmp = slist.copy()
            for k in range(j, j+i):
                tmp.pop(k)
            if (val > max_) and (val%10 != 0):
                max_ = val
            
print(max_)
Problem p03713 (python)

Fixed submission:
H, W = map(int, input().split())

ans = float('inf')
for _ in range(2):
    for i in range(1, H):
        a = i*W

        b = ((H - i) // 2) * W
        c = ((H - i + 1)// 2) * W
        ans = min(ans, abs(max(a, b, c) - min(a, b, c)))

        b = (W // 2) * (H -i)
        c = ((W + 1) // 2) * (H - i)
        ans = min(ans, abs(max(a, b, c) - min(a, b, c)))
    H, W = W, H
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

ans = float('inf')
for _ in range(2):
    for i in range(1, H):
        a = i*W

        b = ((H - i) // 2) * W
        c = ((H - i + 1)// 2) * W
        ans = min(ans, abs(max(a, b, c) - min(a, b, c)))

        b = (W // 2) * (H -i)
        c = ((W + 1) // 2) * (H - i)
        ans = min(ans, abs(max(a, b, c) - min(a, b, c)))
    H, W = W, H
return ans
Problem p02960 (python)

Fixed submission:
S=input()
# S="".join(["?" for _ in range(10**5)])
# S = "??2??5"
# S= "?44"

MOD = 10**9+7
dp = [[0 for i in range(13)] for j in range(len(S)+1)]
dp[0][0] = 1
for t,ss in enumerate(S[::-1]):
    if t==0:
        tt = 1
    else:
        tt = (10*tt)%13
    if ss=="?":
        for i in range(13):
            for j in range(10):
                k = (j*tt+i)%13
                dp[t+1][k] += dp[t][i]%MOD
    else:
        s = int(ss)
        for i in range(13):
            k = (s*tt+i)%13
            dp[t+1][k] += dp[t][i]%MOD

print(dp[t+1][5]%MOD)

Buggy submission (verdict: Runtime Error):
S=input()
# S = "??2??5"
# S= "?44"

MOD = 10**9+7
dp = {}
for i in range(13):
    dp[(-1,i)] = 0
dp[(-1,0)] = 1
for t,ss in enumerate(S[::-1]):
    for i in range(13):
        dp[(t,i)] = 0
    if ss=="?":
        for i in range(13):
            for j in range(10):
                dp[(t,(j*10**t+i)%13)] += dp[(t-1,i)]
                dp[(t,(j*10**t+i)%13)] %= MOD
    else:
        s = int(ss)
        for i in range(13):
            dp[(t,(s*10**t+i)%13)] += dp[(t-1,i)]
            dp[(t,(j*10**t+i)%13)] %= MOD


print(dp[(t,5)])