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

Fixed submission:
import numpy as np
from collections import Counter

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = np.array(list(input()))

i = 0
minus = 0
for i in np.arange(K):
    arr = T[np.arange(i, N, K)]
    c = 1
    for j in np.arange(arr.shape[0] - 1):
        if arr[j] == arr[j + 1]:
            c += 1
        else:
            if c >= 2:
                if arr[j] == 'r':
                    score = P
                elif arr[j] == 's':
                    score = R
                else:
                    score = S
                minus += c // 2 * score
            c = 1
    else:
        if c >= 2:
            if arr[j] == 'r':
                score = P
            elif arr[j] == 's':
                score = R
            else:
                score = S
            minus += c // 2 * score

counter = Counter(T)


max_score = 0
for i, j in counter.items():
    if i == 'r':
        max_score += P * j
    elif i == 's':
        max_score += R * j
    else:
        max_score += S * j
print(max_score - minus)

Buggy submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = np.array(list(input()))

i = 0
minus = 0
for i in np.arange(K):
    arr = T[np.arange(i, N, K)]
    c = 1
    for j in np.arange(arr.shape[0] - 1):
        if arr[j] == arr[j + 1]:
            c += 1
        else:
            if c >= 2:
                if arr[j] == 'r':
                    score = P
                elif arr[j] == 's':
                    score = R
                else:
                    score = S
                minus += c // 2 * score
            c = 1
    else:
        if c >= 2:
            if arr[j] == 'r':
                score = P
            elif arr[j] == 's':
                score = R
            else:
                score = S
            minus += c // 2 * score

u, counts = np.unique(T, return_counts=True)

max_score = 0
for i, j in zip(u, counts):
    if i == 'r':
        max_score += P * j
    elif i == 's':
        max_score += R * j
    else:
        max_score += S * j
print(max_score - minus)
Problem p02835 (python)

Fixed submission:
a1, a2, a3 = map(int, input().split())
if a1 + a2 + a3 >= 22:
    print('bust')
else:
    print('win')

Buggy submission (verdict: Runtime Error):
A1, A2, A3 = map(int, input().split())
if A1 + A2 + A3 >= 22:
  print('bust')
else;
  print('win')
Problem p02912 (python)

Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(a)
for _ in range(m):
    tmp = (heapq.heappop(a) * (-1)) // 2
    heapq.heappush(a, -tmp)
print(sum(a) * -1)

Buggy submission (verdict: Runtime Error):
import heapq  # heapqライブラリのimoprt

N, M = map(int, input().split())
A = map(lambda x: int(x) * (-1), input().split())
heapq.heapify(A)

for _ in range(N):
    a = heapq.heappop(A)
    a = (-a // 2) * (-1)
    heapq.heappush(A, a)
print(-sum(A))
Problem p02959 (python)

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

sum_A = sum(A)

for i in range(N):
    if B[i] > A[i]:
        B[i] -= A[i]
        A[i] = 0
        A[i + 1] = max(0, A[i + 1] - B[i])
    else:
        A[i] = max(0, A[i] - B[i])

ans = sum_A - sum(A)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
monsters = list(map(int, input().split()))
heros = list(map(int, input().split()))

def f(i, j):
  if i == j == 0:
    return min(monsters[i], heros[i])
  if i == j - 1:
    return min(monsters[i+1], heros[i] - f(i, i))
  if i == j:
    return min(monsters[i] - f(i-1, i), heros[i])

s = 0
for i in range(n):
	s += f(i, i) + f(i, i+1)
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
monsters = list(map(int, input().split()))
heros = list(map(int, input().split()))

def f(i, j):
  if i == j == 1:
    return min(monsters[i], heros[i])
  if i == j - 1:
    return min(monsters[i+1], heros[i] - f(i, i)
  if i == j:
	return min(monsters[i] - f(i-1, i), heros[i])

s = 0
for i in range(1, 1+n):
	s += f(i, i) + f(i, i+1)
Problem p03038 (python)

Fixed submission:
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: -x[1])

D = []
n = 0
for b, c in BC:
    if n + b >= N:
        while len(D) < N:
            D.append(c)
        break
    else:
        for i in range(b):
            D.append(c)
        n += b

while len(D) < N:
    D.append(0)

print(np.maximum(D, A).sum())

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()
A = A[::-1]

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
D = []
for _ in range(M):
    b, c = map(int, input().split())
    tmp = [c for _ in range(b)]
    D.extend(tmp)
D = np.array(D)
D.sort()
print(D)
print(A)
print(np.maximum(D, A))
print(np.maximum(D, A).sum())
Problem p03107 (python)

Fixed submission:
s = input()
zero = 0
one = 0
for i in s:
  if i == '0':
    zero += 1
  else:
    one += 1
print(min(zero, one) * 2)

Buggy submission (verdict: Runtime Error):
s = input()
c = 0
for i in s:
  if i == '0':
    break
  c += 1
r = list(range(len(s)))
r.reverse()
for i in r:
  if s[i] == '1':
    break
  c += 1
print(len(s) - c + d)
Problem p03250 (python)

Fixed submission:
V = list(map(int, input().split()))
V = sorted(V, reverse=True)
ans = V[0] * 10 + V[1] + V[2]
print(ans)

Buggy submission (verdict: Runtime Error):
V = list(map(int, input().split()))
V = sorted(V, reversed=True)
ans = V[0] * 10 + V[1] + V[2]
print(ans)
Problem p03265 (python)

Fixed submission:
x1, y1, x2, y2 = map(int, input().split())
x = x1 - x2
y = y1 - y2
point3 = [x2 + y, y2 - x]
point4 = [x1 + y, y1 - x]
print(*[point3[0], point3[1], point4[0], point4[1]], sep=' ')

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())
x = x1 - x2
y = y1 - y2
point3 = [x2 + y, y2 - x]
point4 = [x1 + y, y1 - x]
print(*[*point3, *point4], sep=' ')

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())
diff_x = abs(x1 - x2)
diff_y = abs(y1 - y2)

if x1 > x2 and y1 > y2:
    pass
elif x1 <= x2 and y1 > y2:
    pass
elif x1 > x2 and y1 <= y2:
    point3 = (x2 - diff_y, y2 - diff_x)
    point4 = (point3[0] + diff_x, point3[1] - diff_y)
else:  # x1 <= x2 and y1 <= y2
    point3 = (x2 - diff_y, y2 + diff_x)
    point4 = (point3[0] - diff_x, point3[1] - diff_y)

print(*[*point3, *point4], sep=' ')
Problem p03315 (python)

Fixed submission:
S = input()
S = sorted(S)
for i in range(len(S)):
    if S[i] == '-':
        ans = 2 * i - 4
        break
else:
    ans = 4
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
S = sorted(S)
for i in range(len(S)):
    if S[i] == '-':
        ans = 2 * i - 4
        break
print(ans)
Problem p03745 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
d = 0
ans = 1
for i in range(1, N):
    if A[i - 1] < A[i]:
        if d < 0:
            ans += 1
            d = 0
        elif d == 0:
            d = 1
    elif A[i - 1] > A[i]:
        if d > 0:
            ans += 1
            d = 0
        elif d == 0:
            d = -1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

v = A[1:] - A[:-1]
# print(v)

cnt = 0
i = 0
while i <= len(v) - 1:
    # print('i', i)
    if v[i] * v[i + 1] < 0:
        cnt += 1
        i += 1
    i += 1
ans = cnt + 1
print(ans)

# 単調非減少 : v[i + 1] - v[i] >= 0
# 単調非増加 : v[i + 1] - v[i] <= 0
# 折り返し点 : v[i] * v[i + 1] < 0 and v[i + 1] * v[i + 2] < 0
Problem p03804 (python)

Fixed submission:
import numpy as np
N, M = map(int, input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])
# print('AB', A, B)
for i in range(N - M + 1):
    for j in range(N - M + 1):
        # print('i j', i, j)
        A_subset = A[i:i + M, j:j + M]
        # print('A_subset', A_subset)
        if np.all(A_subset == B):
            print('Yes')
            exit()
print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])
# print('AB', A, B)
for i in range(N - M + 1):
    for j in range(N - M + 1):
        # print('i j', i, j)
        A_subset = A[i:i + N - 1, j:j + N - 1]
        # print('A_subset', A_subset)
        if np.all(A_subset == B):
            print('Yes')
            exit()
print('No')
Problem p02577 (python)

Fixed submission:
a=int(input())
print("Yes"if a%9==0else"No")

Buggy submission (verdict: Runtime Error):
a = int(input())
print "Yes" if a % 9 == 0 else "No"
Problem p02679 (python)

Fixed submission:
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (a, b), (k, l) in d.items():
    now = 1
    now = (now + mod_pow(2, k, mod) - 1) % mod
    now = (now + mod_pow(2, l, mod) - 1) % mod
    ans = (ans * now) % mod
    
ans -= 1
zeros = zeros % mod
ans = (ans + zeros) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (i, j) in tuple(d.values()):
    now = 1
    now = (now + mod_pow(2, i, mod) - 1) % mod
    now = (mow + mod_pow(2, j, mod) - 1) % mod
    ans = (ans * now) % mod
    
ans -= 1
ans += zeros % mod
ans = ans % mod
print(ans)
Problem p02785 (python)

Fixed submission:
import numpy as np

N,K=map(int,input().split())
H=list(map(int,input().split()))

if K==0:
    print(sum(H))
elif N>K:
    H=sorted(H)
    del H[-K:]
    print(sum(H))
else:
    print(0)

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

for i in range(K):
    H.remove(max(H))

print(sum(H))
Problem p02570 (python)

Fixed submission:
i = list(map(int, input().split()))
print("Yes" if i[0]<=i[1]*i[2] else "No")

Buggy submission (verdict: Runtime Error):
i = list(map(int, input().split()))
print("Yes" if i[0]>i[1]*1[2] else "No")
Problem p02712 (python)

Fixed submission:
n=int(input())
print((n+n**2-3*(n//3)*(1+(n//3))-5*(n//5)*(1+(n//5))+15*(n//15)*(1+(n//15)))//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
print((n+n**2-3-3(n//3)-3((n//3)**2)-5(n//5)-5((n//5)**2)+15(n//15)+15((n//15)**2))/2)
Problem p02552 (python)

Fixed submission:
n = int(input())
print(1 if not n else 0)

Buggy submission (verdict: Runtime Error):
 tmp = 10 ** 9 + 7
def div(n,T):
    _ = 1
    for t in range(T):
        _ *= n
        _ %= tmp
    return _
    
N = int(input())
a = div(10,N)
b = div(9,N)
c = div(8,N)

print((a + c - 2 * b) % tmp)
Problem p02571 (python)

Fixed submission:
S = input()
T = input()
LS = len(S)
LT = len(T)
L = []

if T in S:
  print(0)
else:
    for ls in range(LS - LT + 1):
        d = 0
        for lt in range(LT):
            if S[ls + lt] != T[lt]:
                d += 1
        L.append(d)
    print(min(L))

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
LS = len(S)
LT = len(T)
L = []

if T in S:
  print(0)
else:
    for ls in range(LS - LT):
        d = 0
        for lt in range(LT):
            if S[ls + lt] != T[lt]:
                d += 1
        L.append(d)
    print(min(L))

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
LS = len(S)
LT = len(T)
L = []

if T in S:
  print(0)
else:
    for ls in range(LS - LT):
        d = 0
        for lt in range(LT):
            if S[ls + lt:ls + LT] != T[lt]:
                d += 1
        L.append(d)
    print(min(L))
Problem p02629 (python)

Fixed submission:
alpha = [chr(i + 97) for i in range(26)] 
N = int(input())
name = ''
while N >= 1:
  N -= 1
  _ = N % 26
  name += alpha[_]
  N //= 26
  
print(name[-1::-1])

Buggy submission (verdict: Runtime Error):
alphabet = 'abcdefghijklmnopqrstuvwxyz'
num_2_alpha = {i:alphabet[i - 1] for i in range(1,27)}

def named(N):
  _ = ''
  while N > 0:
    a = N % 26
    N //= 26
    _ += num_2_alpha[a]
  
  return _[-1::-1]

N = int(input())
print(named(N))

Buggy submission (verdict: Runtime Error):
alphabet = 'abcdefghijklmnopqrstuvwxyz'
num_2_alpha = {i:alphabet[i - 1] for i in range(1,27)}

def named(N):
  _ = ''
  while N > 0:
    a = N % 26
    N = N // 26
    _ = num_2_alpha[a] + _
  
  return _

N = int(input())
print(named(N))
Problem p02880 (python)

Fixed submission:
kuku = [i * j for i in range(1,10) for j in range(1,10)]
N = int(input())
 
print('Yes' if N in kuku else 'No')

Buggy submission (verdict: Runtime Error):
kuku = [i * j for i　in range(1,10) for j in range(1,10)]
N = int(input())

print('Yes' if N in kuku else 'No')
Problem p03775 (python)

Fixed submission:
N = int(input())
r_N = int(N ** (1 / 2))
 
li = []
for n in range(1,r_N + 1):
  if N % n == 0:
    a = N // n
    l = max(len(str(a)),len(str(n)))
    li.append(l)
    
print(min(li))

Buggy submission (verdict: Runtime Error):
N = int(input())
r_N = int(N ** (1 / 2))
 
li = []
for n in range(1,r_N + 1):
  if N % n == 0:
    a = N // n
    l = max(len(str(a)),len(str(n)))
  	li.append(l)
    
print(min(li))

Buggy submission (verdict: Runtime Error):
N = int(input())
r_N = int(N ** (1 / 2))

li = []
for n in range(1,r_N + 1):
  if N % n == 0:
    a = N // n
    l = max(len(str(a)),len(str(n))))
  	li.append(l)
    
print(min(li))
Problem p02580 (python)

Fixed submission:
def solve():
    H,W,M = map(int,input().split())
    h_counter = [0] * H
    w_counter = [0] * W

    opponents = []
    for _ in range(M):
        h, w = map(lambda x:int(x)-1, input().split())
        h_counter[h] += 1
        w_counter[w] += 1
        opponents.append((h,w))
    
    h_max = max(h_counter)
    w_max = max(w_counter)

    h_max_area_cnt = 0
    h_max_area_nums = set()
    for h in range(H):
        if h_counter[h] == h_max:
            h_max_area_nums.add(h)
            h_max_area_cnt += 1

    w_max_area_cnt = 0
    w_max_area_nums = set()
    for w in range(W):
        if w_counter[w] == w_max:
            w_max_area_nums.add(w)
            w_max_area_cnt += 1

    max_area_cnt = h_max_area_cnt * w_max_area_cnt

    opponent_in_max_area = 0
    for h,w in opponents:
        if h in h_max_area_nums and w in w_max_area_nums:
            opponent_in_max_area += 1

    if max_area_cnt > opponent_in_max_area:
        print(h_max + w_max)
    else:
        print(h_max + w_max - 1)

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    H,W,M = map(int,input().split())
    h_counter = [0] * H
    w_counter = [0] * W

    opponents = []
    for _ in range(M):
        h, w = map(lambda x:int(x)-1, input().split())
        h_counter[h] += 1
        w_counter[w] += 1
        opponents.append((h,w))
    
    h_max = max(h_counter)
    w_max = max(w_counter)

    h_max_area_cnt = 0
    h_max_area_nums = set()
    for h in range(H):
        if h_counter[h] == h_max:
            h_max_area_nums.add(h)
            h_max_area_cnt += 1

    w_max_area_cnt = 0
    w_max_area_nums = set()
    for w in range(H):
        if w_counter[w] == w_max:
            w_max_area_nums.add(w)
            w_max_area_cnt += 1

    max_area_cnt = h_max_area_cnt * w_max_area_cnt

    opponent_in_max_area = 0
    for h,w in opponents:
        if h in h_max_area_nums and w in w_max_area_nums:
            opponent_in_max_area += 1

    if max_area_cnt > opponent_in_max_area:
        print(h_max + w_max)
    else:
        print(h_max + w_max - 1)

if __name__ == '__main__':
    solve()
Problem p02685 (python)

Fixed submission:
def solve():
    N,M,K = map(int,input().split())
    MOD = 998244353

    fac, finv, inv = COMinit(N+1,MOD)

    ans = 0
    for i in range(K+1):
        ans += M % MOD * pow(M-1,N-1-i,MOD) % MOD * COM(N-1,i,MOD,fac,finv,inv) % MOD
    
    print(ans%MOD)

# COMの前処理
# テーブルを作る
# O(n)
def COMinit(N, mod):
    fac = [0] * N
    finv = [0] * N
    inv = [0] * N

    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1

    for i in range(2, N):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
    
    return fac, finv, inv

# nCrを計算 前処理としてCOMinitの実行が必要
# O(1)
def COM(n, r, mod, fac, finv, inv):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N,M,K = map(int,input().split())
    MOD = 998244353

    fac, finv, inv = COMinit(N,MOD)

    ans = 0
    for i in range(K+1):
        ans += M % MOD * pow(M-1,N-1-i,MOD) % MOD * COM(N-1,i,MOD,fac,finv,inv) % MOD
    
    print(ans%MOD)

# COMの前処理
# テーブルを作る
# O(n)
def COMinit(N, mod):
    fac = [0] * N
    finv = [0] * N
    inv = [0] * N

    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1

    for i in range(2, N):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
    
    return fac, finv, inv

# nCrを計算 前処理としてCOMinitの実行が必要
# O(1)
def COM(n, r, mod, fac, finv, inv):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
if __name__ == '__main__':
    solve()
Problem p02754 (python)

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

    n_times = N // (A+B)
    amari = N % (A+B)

    cnt = 0
    if A <= amari:
        cnt = A
    else:
        cnt = amari
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N, A, B = map(int, input().split())

    n_times = N // (A+B)
    amari = N % (A+B)
    cnt = 0
    if amari != 0:
        S = 'b' * A + 'r' * B
        S = S[0:amari]

        for ball in S:
            if ball == 'b':
                cnt += 1
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N, A, B = map(int, input().split())
    if A + B == 0:
        print(0)
        exit(0)

    n_times = N // (A+B)
    amari = N % (A+B)
    cnt = 0
    if amari != 0:
        S = 'b' * A + 'r' * B
        S = S[:min(amari, len(S))]

        for ball in S:
            if ball == 'b':
                cnt += 1
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N, A, B = map(int, input().split())
    n_times = N // (A+B)
    amari = N % (A+B)
    cnt = 0
    if amari != 0:
        S = 'b' * A + 'r' * B
        S = S[:min(amari, len(S)-1)]

        for ball in S:
            if ball == 'b':
                cnt += 1
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N, A, B = map(int, input().split())
    n_times = N // (A+B)
    amari = N % (A+B)
    cnt = 0
    if amari != 0:
        S = 'b' * A + 'r' * B
        S = S[:amari]

        for ball in S:
            if ball == 'b':
                cnt += 1
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()
Problem p02773 (python)

Fixed submission:
def solve():
    N = int(input())
    dict = {}

    for _ in range(N):
        S = input()
        if S in dict:
            dict[S] += 1
        else:
            dict[S] = 1
    sorted_dict = list(sorted(dict.items(), key=lambda x:x[1], reverse=True))
    mx = sorted_dict[0][1]
    cand = []
    for d in sorted_dict:
        if d[1] == mx:
            cand.append(d[0])
        else:
            break
    print(*sorted(cand), sep='\n')
    
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def solve():
    N = int(input())
    d = defaultdict(int)

    for _ in range(N):
        S = input()
        d[S] += 1

    items = list(d.items())
    items.sort(key=lambda x:x[1], reverse=True)
    mx = items[0][1]
    cand = []
    for item in items:
        if item[1] == mx:
            cand.append(item[0])
        else:
            break
    
    print(*ans, sep='\n')
    
if __name__ == '__main__':
    solve()
Problem p02847 (python)

Fixed submission:
def solve():
    S = input()
    day = ["MON","TUE","WED","THU","FRI","SAT","SUN"]
    for i in range(len(day)):
        if S == "SUN":
            print(7)
            break
        elif S == day[i]:
            print(6-i)
            break
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import math
def solve():
    A, B, X = map(int, input().split())
    
    ans = 0
    for d in range(1, 18):
        N = (X - B*d)/A
        N = int(math.ceil(N))
        if N <= 0:
            continue
        if d == len(str(N)):
            if d >= 10:
                ans = 10**9
            else:
                ans = N
    
    print(ans)
 
if __name__ == '__main__':
    solve()