Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
prices = [int(n) for n in input().split()]
money = 1000
stock = 0
p_today = prices[0]
for n in range(N-1):
    p_tomm = prices[n+1]
    if p_tomm >= p_today:
        while money >= p_today:
            stock += 1
            money -= p_today
    else:
        money += p_today * stock
        stock = 0
    p_today = p_tomm

if stock > 0:
    money += prices[-1] * stock

print(money)

Fixed submission:
N = int(input())
prices = [int(n) for n in input().split()]
money = 1000
stock = 0
p_today = prices[0]
for n in range(N-1):
    p_tomm = prices[n+1]
    if p_tomm >= p_today:
        n_stock = money // p_today
        stock += n_stock
        money = money - p_today * n_stock
        # while money >= p_today:
        #     stock += 1
        #     money -= p_today
    else:
        money += p_today * stock
        stock = 0
    p_today = p_tomm

if stock > 0:
    money += prices[-1] * stock

print(money)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
prices = [int(n) for n in input().split()]
money = 1000
stock = 0
for n in range(N-1):
    p_today = prices[n]
    p_tomm = prices[n+1]
    if p_tomm >= p_today:
        while money >= p_today:
            stock += 1
            money -= p_today
    else:
        money += p_today * stock
        stock = 0

if stock > 0:
    money += prices[-1] * stock

print(money)

Fixed submission:
N = int(input())
prices = [int(n) for n in input().split()]
money = 1000
stock = 0
p_today = prices[0]
for n in range(N-1):
    p_tomm = prices[n+1]
    if p_tomm >= p_today:
        n_stock = money // p_today
        stock += n_stock
        money = money - p_today * n_stock
        # while money >= p_today:
        #     stock += 1
        #     money -= p_today
    else:
        money += p_today * stock
        stock = 0
    p_today = p_tomm

if stock > 0:
    money += prices[-1] * stock

print(money)
Buggy python submission (verdict: Runtime Error):
m = input()
print(m % 1000)

Fixed submission:
m = int(input())
mod = m % 1000
if mod == 0:
    print(0)
else:
    print(1000 - mod)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = map(int, input().split())

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)


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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)

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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)


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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
L = map(int, split(input()))

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)


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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#n, m, k = 3, 4, 730
#a = [60, 90, 120]
#b = [80, 150, 80, 150]

a = [0] + a
for i in range(n):
    a[i + 1] = a[i] + a[i + 1]

b = [0] + b
for i in range(m):
    b[i + 1] = b[i] + b[i + 1]
    
ans = 0
for i in range(n + 1):
    for j in range(ans - i + 1, m + 1):
        if a[i] + b[j] <= k:
            ans = i + j
        else:
            break

print(ans)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#n, m, k = 3, 4, 730
#a = [60, 90, 120]
#b = [80, 150, 80, 150]

a = [0] + a
for i in range(n):
    a[i + 1] = a[i] + a[i + 1]

b = [0] + b
for i in range(m):
    b[i + 1] = b[i] + b[i + 1]
    
ans = 0
for i in range(n + 1):
    for j in range(max(0, ans - i + 1), m + 1):
        if a[i] + b[j] <= k:
            ans = i + j
        else:
            break

print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

suma = [0]
for i in range(n):
    suma.append(suma[i] + a[i])
    
sumb = [0]
for i in range(m):
    sumb.append(sumb[i] + b[i])
    
ans = 0
for i in range(n + 1):
    for j in range(ans - i + 1, m + 1):
        if suma[i] + sumb[j] <= k:
            ans = i + j

print(ans)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#n, m, k = 3, 4, 730
#a = [60, 90, 120]
#b = [80, 150, 80, 150]

a = [0] + a
for i in range(n):
    a[i + 1] = a[i] + a[i + 1]

b = [0] + b
for i in range(m):
    b[i + 1] = b[i] + b[i + 1]
    
ans = 0
for i in range(n + 1):
    for j in range(max(0, ans - i + 1), m + 1):
        if a[i] + b[j] <= k:
            ans = i + j
        else:
            break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
fx = [0] * (n + 1)

for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        fx[j] += 1

l = [i * x for i, x in enumerate(fx)]
print(sum(l))

Fixed submission:
n = int(input())

ans = 0
for x in range(1, n + 1):
    ans += (x + n//x * x) * (n // x) / 2
    
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

# Input#
n = list(input())
# n, k = map(int, input().split())
# a = list(map(int, input().split()))

sum = 0
while len(n) > 1:
    sum += int(n.pop(0))


sum += int(n[0])
if sum % 9 == 0:
    print("Yes")
else:
    print("No")


# print("{}".format(ans))


Fixed submission:
# -*- coding: utf-8 -*-

# Input#
n = list(input())
# n, k = map(int, input().split())
# a = list(map(int, input().split()))
sum = 0
for i in n:
    sum += int(i)

if sum % 9 == 0:
    print("Yes")
else:
    print("No")


# print("{}".format(ans))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

# Input#
n = int(input())
# n, k = map(int, input().split())
# a = list(map(int, input().split()))

sum = 0
while n > 9:
    sum += n % 10
    n = int(n / 10)

sum += int(n)
if sum % 9 == 0:
    print("Yes")
else:
    print("No")


# print("{}".format(ans))


Fixed submission:
# -*- coding: utf-8 -*-

# Input#
n = list(input())
# n, k = map(int, input().split())
# a = list(map(int, input().split()))
sum = 0
for i in n:
    sum += int(i)

if sum % 9 == 0:
    print("Yes")
else:
    print("No")


# print("{}".format(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

# Input#
n = input()
# n, k = map(int, input().split())
# a = list(map(int, input().split()))

sum = 0
while len(n) > 1:
    sum += int(n[0])
    n = n[1:]

sum += int(n[0])
if sum % 9 == 0:
    print("Yes")
else:
    print("No")


# print("{}".format(ans))


Fixed submission:
# -*- coding: utf-8 -*-

# Input#
n = list(input())
# n, k = map(int, input().split())
# a = list(map(int, input().split()))
sum = 0
for i in n:
    sum += int(i)

if sum % 9 == 0:
    print("Yes")
else:
    print("No")


# print("{}".format(ans))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# from collections import deque
from sys import setrecursionlimit

setrecursionlimit(1000000)


# INF = float("inf")

# d = deque()
# ---Input---#
n = int(input())
# n, k = map(int, input().split())
p = list(map(float, input().split()))
p = [-1] + p

memo = [[-1 for _ in [0] * (n + 1)] for _ in [0] * (n + 1)]
memo[0][0] = 1
for i in range(len(p))[1:]:
    memo[0][i] = 0
    memo[i][0] = memo[i - 1][0] * (1 - p[i])
memo[0][0] = 1


def dp(i, j):
    if memo[i][j] == -1:
        memo[i][j] = dp(i - 1, j) * (1 - p[i]) + dp(i - 1, j - 1) * p[i]
    return memo[i][j]


ans = 0
tar = int(n / 2) + 1
for i in range(n + 1)[tar:]:
    ans += dp(n, i)


print("{}".format(ans))


Fixed submission:
# -*- coding: utf-8 -*-
# from collections import deque
from sys import setrecursionlimit

setrecursionlimit(1000000)


# INF = float("inf")

# d = deque()
# ---Input---#
n = int(input())
# n, k = map(int, input().split())
p = list(map(float, input().split()))
p = [-1] + p

memo = [[-1 for _ in [0] * (n + 1)] for _ in [0] * (n + 1)]
memo[0][0] = 1
for i in range(len(p))[1:]:
    memo[0][i] = 0
    memo[i][0] = memo[i - 1][0] * (1 - p[i])
memo[0][0] = 1


def dp(i, j):
    if memo[i][j] == -1:
        memo[i][j] = dp(i - 1, j) * (1 - p[i]) + dp(i - 1, j - 1) * p[i]
    return memo[i][j]


ans = 0
tar = int(n / 2) + 1
for i in range(n + 1):
    dp(i, i)
    dp(i, n)

for i in range(n + 1)[tar:]:
    ans += dp(n, i)


print("{}".format(ans))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# from collections import deque
# from sys import setrecursionlimit

# setrecursionlimit(1000000)


# INF = float("inf")

# d = deque()
# ---Input---#
n = int(input())
# n, k = map(int, input().split())
p = list(map(float, input().split()))
p = [-1] + p

memo = [[-1 for _ in [0] * (n + 1)] for _ in [0] * (n + 1)]
memo[0][0] = 1
for i in range(len(p))[1:]:
    memo[0][i] = 0
    memo[i][0] = memo[i - 1][0] * (1 - p[i])
memo[0][0] = 1


def dp(i, j):
    if memo[i][j] == -1:
        memo[i][j] = dp(i - 1, j) * (1 - p[i]) + dp(i - 1, j - 1) * p[i]
    return memo[i][j]


ans = 0
tar = int(n / 2) + 1
for i in range(n + 1)[tar:]:
    ans += dp(n, i)


print("{}".format(ans))


Fixed submission:
# -*- coding: utf-8 -*-
# from collections import deque
from sys import setrecursionlimit

setrecursionlimit(1000000)


# INF = float("inf")

# d = deque()
# ---Input---#
n = int(input())
# n, k = map(int, input().split())
p = list(map(float, input().split()))
p = [-1] + p

memo = [[-1 for _ in [0] * (n + 1)] for _ in [0] * (n + 1)]
memo[0][0] = 1
for i in range(len(p))[1:]:
    memo[0][i] = 0
    memo[i][0] = memo[i - 1][0] * (1 - p[i])
memo[0][0] = 1


def dp(i, j):
    if memo[i][j] == -1:
        memo[i][j] = dp(i - 1, j) * (1 - p[i]) + dp(i - 1, j - 1) * p[i]
    return memo[i][j]


ans = 0
tar = int(n / 2) + 1
for i in range(n + 1):
    dp(i, i)
    dp(i, n)

for i in range(n + 1)[tar:]:
    ans += dp(n, i)


print("{}".format(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import sys


sys.setrecursionlimit(10**9)


def readBook(i, j, time, cnt):
    if time < 0:
        return cnt - 1
    if i == N and j == M:
        return cnt
    elif i == N:
        res = readBook(i, j + 1, time - B[j], cnt + 1)
    elif j == M:
        res = readBook(i + 1, j, time - A[i], cnt + 1)
    else:
        res = max(readBook(i + 1, j, time - A[i], cnt + 1), readBook(i, j + 1, time - B[j], cnt + 1))
    return res


N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

print(readBook(0, 0, K, 0))


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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
def readBook(i, j, time, cnt):
    if time < 0:
        return cnt - 1
    if i == N and j == M:
        return cnt
    elif i == N:
        res = readBook(i, j + 1, time - B[j], cnt + 1)
    elif j == M:
        res = readBook(i + 1, j, time - A[i], cnt + 1)
    else:
        res = max(readBook(i + 1, j, time - A[i], cnt + 1), readBook(i, j + 1, time - B[j], cnt + 1))
    return res


N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

print(readBook(0, 0, K, 0))


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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np


N = int(input())

e = np.zeros(N + 1)
for i in range(1, N + 1):
    e[i:N+1:i] += 1
ans = 0
for i in range(1, N + 1):
    ans += i * int(e[i])
print(ans)


Fixed submission:
N = int(input())

def gfunc(n):
    return int((n * (n + 1)) / 2)


ans = 0
for i in range(1, N + 1):
    ans += i * gfunc(N // i)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

sumA = sum(A)
cnt_num = []
for i in range(10**5):
    cnt_num.append(A.count(i))

for i in range(Q):
    B, C = map(int, input().split())
    sumA += (C - B) * cnt_num[B]
    print(sumA)
    cnt_num[C] += cnt_num[B]
    cnt_num[B] = 0
    

Fixed submission:
import numpy as np


N = int(input())
A = list(map(int, input().split()))
Q = int(input())

sumA = sum(A)
cnt_num = np.zeros(10**5 + 1)

for i in A:
    cnt_num[i] += 1

for i in range(Q):
    B, C = map(int, input().split())
    sumA += (C - B) * cnt_num[B]
    print(int(sumA))
    cnt_num[C] += cnt_num[B]
    cnt_num[B] = 0

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

sumA = sum(A)
cnt_num = []
for i in range(10**5):
    cnt_num.append(A.count(i))

for i in range(Q):
    B, C = map(int, input().split())
    sumA += (C - B) * cnt_num[B]
    print(sumA)
    cnt_num[C] += cnt_num[B]
    cnt_num[B] = 0
    

Fixed submission:
import numpy as np


N = int(input())
A = list(map(int, input().split()))
Q = int(input())

sumA = sum(A)
cnt_num = np.zeros(10**5 + 1)

for i in A:
    cnt_num[i] += 1

for i in range(Q):
    B, C = map(int, input().split())
    sumA += (C - B) * cnt_num[B]
    print(int(sumA))
    cnt_num[C] += cnt_num[B]
    cnt_num[B] = 0
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = list(map(int, input().split()))

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)

Fixed submission:
x = list(map(int, input().split()))
for i in range(len(x)):
    if x[i] == 0:
        print(i+1)
Buggy python submission (verdict: Runtime Error):
import numpy as np


N = int(input())
A = list(map(int, input().split()))

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)

Fixed submission:
import numpy as np


N = int(input())
A = list(map(int, input().split())) + [10**7]

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())) + [10**7]

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)

Fixed submission:
import numpy as np


N = int(input())
A = list(map(int, input().split())) + [10**7]

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = 1
for i in range(n):
    b = b * a[i]

if b > 10**18:
    b = -1
print(b)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a_s = sorted(a)
b = 1
for i in range(n):
    b = b * a_s[i]
    if b > 10**18:
        b = -1
        break
    elif b == 0:
        break

print(b)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

n, m = map(int, input().split())
print(comb(n, 2, exact=True)+comb(m,2, exact=True))

Fixed submission:
from scipy.misc import comb

n, m = map(int, input().split())
print(comb(n, 2, exact=True)+comb(m,2, exact=True))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

n, m = map(int, input().split())
print(comb(n, 2, exact=True)+comb(m,2, exact=True))

Fixed submission:
from scipy.misc import comb

n, m = map(int, input().split())
print(comb(n, 2, exact=True)+comb(m,2, exact=True))
Buggy python submission (verdict: Time Limit Exceeded):
# from collections import deque
from collections import Counter
from scipy.misc import comb
from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
cnt_n = 0
a_n = deepcopy(a)
c = Counter(a_n)
for key in c:
    cnt_n += comb(c[key], 2, exact=True)

for k in range(len(a)):
    a_n = deepcopy(a)
    a_k = deepcopy(a[k])
    a_n.pop(k)
    cnt_k = a_n.count(a_k)
    print(cnt_n - cnt_k)


Fixed submission:
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
C = Counter(a)
S = 0
for key in C:
    S += comb(C[key], 2, exact=True)

for k in range(n):
    A = a[k]
    print(S - C[A] + 1)

Buggy python submission (verdict: Runtime Error):
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from scipy.special import comb
from copy import deepcopy

n = int(input())
k = list(map(int, input().split()))
for i in range(len(k)):
    ans = 0
    k_n = deepcopy(k)
    k_n.pop(i)
    c = Counter(k_n)
    for key in c:
        ans += comb(c[key], 2, exact=True)
    print(ans)

Fixed submission:
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
C = Counter(a)
S = 0
for key in C:
    S += comb(C[key], 2, exact=True)

for k in range(n):
    A = a[k]
    print(S - C[A] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from scipy.special import comb
from copy import deepcopy

n = int(input())
k = list(map(int, input().split()))
for i in range(len(k)):
    ans = 0
    k_n = deepcopy(k)
    k_n.pop(i)
    c = Counter(k_n)
    for key in c:
        ans += comb(c[key], 2, exact=True)
    print(ans)

Fixed submission:
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
C = Counter(a)
S = 0
for key in C:
    S += comb(C[key], 2, exact=True)

for k in range(n):
    A = a[k]
    print(S - C[A] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from scipy.special import comb

n = int(input())
k = list(map(int, input().split()))
for i in range(len(k)):
    ans = 0
    k_n = k.copy()
    k_n.pop(i)
    c = Counter(k_n)
    for key in c:
        ans += comb(c[key], 2, exact=True)
    print(ans)

Fixed submission:
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
C = Counter(a)
S = 0
for key in C:
    S += comb(C[key], 2, exact=True)

for k in range(n):
    A = a[k]
    print(S - C[A] + 1)
Buggy python submission (verdict: Runtime Error):
n = input()

if n[1] in [2, 4, 5, 7, 9]:
    print("hon")
elif n[1] in [0, 1, 6, 8]:
    print("pon")
else:
    print("bon")


Fixed submission:
# Nの1の位が
# 2,4,5,7,9のときhonNの1の位が0,1,6,8のときponNの1の位が3のときbonです。

a = int(input()) % 10
print('pphbhhphph'[a] + "on")
Buggy python submission (verdict: Runtime Error):
import math
import itertools

# a = 6
# b = 4
#
# print(math.gcd(a, b))
k = int(input())
kk = k + 1
ans = 0
for i in range(1, kk):
    # print(i)
    for ii in rangea(1, kk):
        # print(ii)
        for iii in range(1, kk):
            # print((i,ii,iii))
            gcd2 = math.gcd(ii, iii)
            gcd3 = math.gcd(i, gcd2)
            ans += gcd3

print(ans)


Fixed submission:
import math
import itertools

# a = 6
# b = 4
#
# print(math.gcd(a, b))
k = int(input())
kk = k + 1
ans = 0
for i in range(1, kk):
    # print(i)
    for ii in range(1, kk):
        # print(ii)
        for iii in range(1, kk):
            # print((i,ii,iii))
            gcd2 = math.gcd(ii, iii)
            gcd3 = math.gcd(i, gcd2)
            ans += gcd3

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import itertools

# a = 6
# b = 4
#
# print(math.gcd(a, b))
k = int(input())
kk = k + 1
ans = 0
for i in range(1, kk):
    # print(i)
    for ii in range(1, kk):
        # print(ii)
        for iii in range(1, kk):
            # print((i,ii,iii))
            gcd2 = math.gcd(ii, iii)
            gcd3 = math.gcd(i, gcd2)
            ans += gcd3

print(ans)


Fixed submission:
import math
import itertools

# a = 6
# b = 4
#
# print(math.gcd(a, b))
k = int(input())
kk = k + 1
ans = 0
for i in range(1, kk):
    # print(i)
    for ii in range(1, kk):
        # print(ii)
        for iii in range(1, kk):
            # print((i,ii,iii))
            gcd2 = math.gcd(ii, iii)
            gcd3 = math.gcd(i, gcd2)
            ans += gcd3

print(ans)
Buggy python submission (verdict: Runtime Error):
aa, bb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

couponMin = float("INF")
for i in range(m):
    x, y, c = map(int, input().split())
    cc = a[x - 1] + b[x - 1] - c
    couponMin = min(couponMin, cc)

print(min(min(a) + min(b), couponMin))




Fixed submission:
aa, bb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

couponMin = float("INF")
for i in range(m):
    x, y, c = map(int, input().split())
    cc = a[x - 1] + b[y - 1] - c
    couponMin = min(couponMin, cc)

print(min(min(a) + min(b), couponMin))
Buggy python submission (verdict: Runtime Error):
h, n, *L = map(int, open(0).read().split())
dp = [0] * (h + 1)
for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in zip(*[iter(L)] * 2))

print(dp[h])


Fixed submission:
h, n, *L = map(int, open(0).read().split())
dp = [0] * (h + 99999)
for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in zip(*[iter(L)] * 2))

print(dp[h])