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

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans =[]

for _ in range(N):
  ans.append(-1)

for i in range(N,0,-1):
  C = i*2
  BALL = A[i-1]
  while C <= N:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

print(ans.count(1))
ans2 = []
for i in range(N):
  if ans[i] == 1:
    ans2.append(i+1)

L=[str(a) for a in ans2]
L=" ".join(L)
print(L)

Buggy submission (verdict: Runtime Error):
n = int(input())
nums = [int(i) for i in input().split()]

box = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
    ball = nums[i - 1]
    t = i * 2
    while t <= n:
        ball ^= box[t - 1]
        t += i
    box[t - 1] = ball

ans = box.count(1)
index = []
for i in range(len(box)):
    if box[i]:
        index.append(i)
print(ans)
print(*index)
Problem p03231 (python)

Fixed submission:
# https://atcoder.jp/contests/agc028/tasks/agc028_a

n, m = map(int, input().split())
s = input()
t = input()

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

def lcm(x, y): #LCM
    # lowest_common_multiple
    return x * y // gcd(x, y)

l = lcm(n, m)
d = gcd(n, m)
n //= d
m //= d

for i in range(d):
    if s[i * n] != t[i * m]:
        print(-1)
        break
else:
    print(l)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/agc028/tasks/agc028_a

n, m = map(int, input().split())
s = input()
t = input()

def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

l = n * m // gcd(n, m)
x = [''] * (l)
ans = l
for i in range(n):
    p = i * (l // n)
    x[p] = s[i]
for i in range(m):
    p = i * (l // m)
    if x[p] == '':
        x[p] = t[i]
    else:
        if x[p] == t[i]:
            continue
        else:
            ans = -1
            break
print(ans)
Problem p03244 (python)

Fixed submission:
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter
n = int(input())
nums = [int(i) for i in input().split()]

odd = Counter(nums[1::2]).most_common()
even = Counter(nums[::2]).most_common()
odd.append((0, 0))
even.append((0, 0))
if odd[0][0] != even[0][0]:
    ans = n - (odd[0][1] + even[0][1])
else:
    s = n - (odd[0][1] + even[1][1])
    t = n - (odd[1][1] + even[0][1])
    ans = min(s, t)
print(ans)
'''
6
1 1 1 1 2 1
'''

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc111/tasks/arc103_a
from collections import Counter
n = int(input())
nums = [int(i) for i in input().split()]

for i in range(n - 1):
    if nums[i + 1] != nums[i]:
        break
else:
    print(n // 2)
    sys.exit()


odd = Counter(nums[1::2]).most_common()
even = Counter(nums[::2]).most_common()
odd.append((0, 0))
even.append((0, 0))
if odd[0][0] != even[0][0]:
    ans = n - (odd[0][1] + even[0][1])
else:
    s = n - (odd[0][1] + even[1][1])
    t = n - (odd[1][1] + even[0][1])
    ans = min(s, t)
print(ans)
Problem p03380 (python)

Fixed submission:
# https://atcoder.jp/contests/abc094/tasks/arc095_b
n = int(input())
nums = [int(i) for i in input().split()]

# すべてを計算する時間はなさそう
# 最大のモノを選らんで、それと絶対値差が大きいモノを選ぶ。いや、ここは全部やればいいのかな。
# numsの値がめちゃくちゃでかいので、全部はできない。

MAX = max(nums)
t = 0
ans = 0
for num in nums:
    if num == MAX:
        continue
    d = min(MAX - num, num)
    if t < d:
        t = d
        ans = num
print(MAX, ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc094/tasks/arc095_b
n = int(input())
nums = [int(i) for i in input().split()]

# すべてを計算する時間はなさそう
# 最大のモノを選らんで、それと絶対値差が大きいモノを選ぶ。いや、ここは全部やればいいのかな。
mod = (10 ** 9 + 7) ** 2
MAX = 2 * (10 ** 5) + 1 # これは変動するので注意。せいぜい10 ** 6くらいまでがTLEの限界

def com_init(MAX, mod):
    fac = [0] * MAX
    finv = [0] * MAX
    inv = [0] * MAX
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        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

fac, finv = com_init(MAX, mod)

def nCr(n, r):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod

t = -float('inf')
MAX = max(nums)
ans = None
for num in nums:
    if num == MAX:
        continue
    r = nCr(MAX, num)
    if r > t:
        t = r
        ans = (MAX, num)
print(*ans)
Problem p03387 (python)

Fixed submission:
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
a, b, c = map(int, input().split()) # 入力が複数
nums = sorted([a, b, c])

ans = 0
if (nums[1] - nums[0]) % 2 != 0:
    nums[2] += 1
    nums[1] += 1
    ans += 1
ans += (nums[1] - nums[0]) // 2
ans += nums[2] - nums[1]
print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc093/tasks/arc094_a
a, b, c = map(int, input().split())

nums = [a, b, c]
nums.sort()

ans = 0
if (nums[1] - nums[0]) % 2 == 1:
    # 小さい2つの差が奇数の場合、偶数になるように
    # 小さい2つの数字両方にならないように、1を足す。
    # ここでは、二番目に大きいのと、最大の数に1を足す。
    nums[1] += 1
    nums[2] += 1
    ans += 1
ans += (nums[1] - nums[0]) // 2　# 一番小さい数が、二番目に大きい数に追いつくようにする。それには2ずつ足すのが良い。
ans += (nums[2] - nums[1]) # 一番目も二番目も同じかずになったので、両方に１つづ足していき、最大の数と同じになる様にする。
print(ans)
Problem p03651 (python)

Fixed submission:
# https://atcoder.jp/contests/agc018/tasks/agc018_a

n, k = map(int, input().split())
nums = [int(i) for i in input().split()]

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

MAX = max(nums)
GCD = nums[0]
for num in nums:
    GCD = gcd(GCD, num)

if k <= MAX and k % GCD == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/agc018/tasks/agc018_a

n, k = map(int, input().split())
nums = [int(i) for i in input().split()]
# ボールはどんどん増えていく
nums.sort()
if k <= nums[-1]:
    diff = set([])
    for i in range(1, n):
        diff.add(abs(nums[i] - nums[i - 1]))

    diff = list(diff)
    dp = [False] * (k + 1)
    dp[0] = True
    for num in nums:
        if num <= k:
            dp[num] = True
    for i in range(len(diff)):
        num = nums[i]
        for j in range(k + 1):
            if j - num >= 0:
                dp[j] = dp[j - num] or dp[j]

    if dp[k]:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    print('IMPOSSIBLE')
Problem p03699 (python)

Fixed submission:
# https://atcoder.jp/contests/abc063/tasks/arc075_a

n = int(input())
nums = []
for _ in range(n):
    nums.append(int(input()))

total = sum(nums)
dp = [[False for _ in range(total + 1)] for _ in range(n + 1)]
dp[0][0] = True
for i in range(n):
    num = nums[i]
    dp[i + 1][num] = True
    for j in range(total + 1):
        if dp[i][j] and num + j <= total:
            dp[i + 1][num + j] = True

        dp[i + 1][j] = dp[i][j] or dp[i + 1][j]

for i in range(len(dp[0]))[::-1]:
    if dp[-1][i] and i % 10 != 0:
        print(i)
        break
else:
    print(0)

Buggy submission (verdict: Runtime Error):
mport sys

n = int(input())
nums = []
for _ in range(n):
    nums.append(int(input()))
s = sum(nums)
if s % 10 != 0:
    print(s)
else:
    nums.sort()
    for num in nums:
        t = s - num
        if t % 10 != 0:
            print(t)
            break
    else:
        print(0)
Problem p03837 (python)

Fixed submission:
from copy import deepcopy
N, M = map(int, input().split())

graph = [[float('infinity')] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c
ans = 0
# 頂点g -> eまでの最短経路コストと、その経路を記録する

for i in range(N):
    for j in range(N):
        if i == j:
            graph[i][j] = 0

original = deepcopy(graph)

def warshall_floyd(graph, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

warshall_floyd(graph, N)

ans = 0
for i in range(N):
    for j in range(i):
        if original[i][j] != float('infinity') and graph[i][j] != original[i][j]:
            ans += 1
print(ans)

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

graph = [[float('infinity') for _ in range(N + 1)] for _ in range(N + 1)]
for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a][b] = c
    graph[b][c] = c
ans = 0
# 頂点g -> 頂点vへのコストを計算する。直接のpathが最小なら、カウントしない。
# そうでなければ、他の経路があるので、カウントする。
for g in range(1, len(graph)):
    for v in range(1, N + 1):
        if g == v:
            continue
        paths = graph[g]
        direct = paths[v]
        if direct == float('infinity'):
            continue
        min_path = float('infinity')
        for i in range(len(paths)):
            p = paths[i]
            cost = p + graph[i][v]
            if min_path > cost:
                min_path = cost
        if direct > min_path:
            ans += 1
print(ans)
Problem p03994 (python)

Fixed submission:
# https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c

s = input()
k = int(input())
n = len(s)
ans = []
for i in range(n):
    t = (ord('z') - ord(s[i]) + 1) % 26
    if k - t >= 0:
        ans.append('a')
        k -= t
    else:
        ans.append(s[i])
if k > 0:
    k %= 26
    ans[-1] = chr(ord(ans[-1]) + k)
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c

s = input()
k = int(input())
n = len(s)
ans = []
for i in range(n):
    t = (ord('z') - ord(s[i]) + 1) % 26
    if t <= k:
        ans.append('a')
        k -= t
    else:
        ans.append(s[i])
ans[-1] = chr(ord(ans[-1]) + k)
print(''.join(ans))
Problem p03999 (python)

Fixed submission:
# https://atcoder.jp/contests/abc045/tasks/arc061_a

s = input()

length = len(s)
if length == 1:
    print(s)
else:
    ans = 0
    for i in range(2 << length - 2):
        temp = []
        for j in range(length):
            t = (i >> j) & 1
            temp.append(s[j])
            if t:
                temp.append('+')
        ans += eval(''.join(temp))
    print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc045/tasks/arc061_a

s = input()

length = len(s)
ans = 0
for i in range(2 << length - 2):
    temp = []
    for j in range(length):
        t = (i >> j) & 1
        temp.append(s[j])
        if t:
            temp.append('+')
    ans += eval(''.join(temp))
print(ans)
Problem p02696 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

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

    x = min(B-1, N)
    print(int(A*x/B)-A*int(x/B))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

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

    # num = N//B

    # score = 0
    # for x in range(1, N+1):
    #     tmp = int(A*x/B) - A*int(x/B)
    #     if score <= tmp:
    #         score = tmp
    # print(score)

    import numpy as np

    arr = np.arange(N)
    arr = np.modf(arr/B)[0]
    print(int(max(arr*A)))


if __name__ == "__main__":
    main()
Problem p02756 (python)

Fixed submission:
def main():
    from collections import deque
    S = deque(input())
    Q = int(input())

    q_list = [input().split() for _ in range(Q)]

    flag = False
    for q in q_list:
        if len(q) == 1:
            t = q[0]
        else:
            t, f, c = q

        if t == '1':
            flag = not flag
        else:
            if (f == '1') ^ flag:
                S.appendleft(c)
            else:
                S.append(c)
    prS(S, flag)
    # prS(S, flag)


def prS(S, flag):
    if flag:
        S.reverse()
    print("".join(S))
    if flag:
        S.reverse()


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():

    S = input().split()
    s = S
    Q = int(input())
    s_ind = 0

    q_list = [input().split() for _ in range(Q)]
    for q in q_list:
        if len(q) == 1:
            t = q[0]
        else:
            t, f, c = q

        if t == '1' or t == 1:
            front = S[:s_ind]
            end = S[s_ind+1:]
            s_ind = len(S)-s_ind
            end.append(s)
            end.extend(front)
            S = end
        else:
            if f == '1' or f == 1:
                S.insert(0, c)
                s_ind += 1
            else:
                S.append(c)

    print("".join(S))


if __name__ == '__main__':
    main()
Problem p02761 (python)

Fixed submission:
# import numpy as np
def main():
  N,M =map(int, input().split())
  s,c=[],[]
  for i in range(M):
    si,ci = map(int, input().split())
    s.append(si)
    c.append(ci)
  
  res=['']*N
  for si,ci in zip(s,c):
    if res[si-1]== '':
      res[si-1]=str(ci)	
    elif res[si-1]!= str(ci):
      print(-1)
      exit()

  
  if res[0]=='0':
    if N==1:
      print(0)
      exit()
    else:
      print(-1)
      exit()
  elif res[0]=='':
    res[0]=str(1)
   
  for i in range(N):
    if res[i]=='':
      res[i]=str(0)
  if M==0 and N==1:
    print(0)
    exit()
  print(int("".join(res)))
  
    
if __name__=="__main__":
  main()

Buggy submission (verdict: Runtime Error):
def main():
  N,M =map(int, input().split())
  s,c=[],[]
  for i in range(M):
    si,ci = map(int, input().split())
    s.append(si)
    c.append(ci)
  
  res=[0]*N
  for si,ci in zip(s,c):
    if res[si-1]== 0:
      res[si-1]=str(ci)	
    elif res[si-1]!= str(ci):
      print(-1)
      exit()
  
  if res==['0']*N:
    print(-1)
    exit()
  su = int("".join(res))
  if su < 10**(N-1):
    print(-1)
    exit()
    
  print(int("".join(res)))
  
    
if __name__=="__main__":
  main()

Buggy submission (verdict: Runtime Error):
# import numpy as np
def main():
  N,M =map(int, input().split())
  s,c=[],[]
  for i in range(M):
    si,ci = map(int, input().split())
    s.append(si)
    c.append(ci)
  
  res=[0]*N
  for si,ci in zip(s,c):
    if res[si-1]== 0:
      res[si-1]=str(ci)	
    elif res[si-1]!= str(ci):
      print(-1)
      exit()
#  print(res)
      
#  for i in range(N):
#    if res[i] =='':
#      res[i]=str(0)
  
  if res==['0']*N:
    print(-1)
    exit()
  su = int("".join(res))
  if su < 10**(N-1):
    print(-1)
    exit()
    
  print(int("".join(res)))
  
    
if __name__=="__main__":
  main()
Problem p02814 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

    N, M = map(int, input().split())
    A = list(set(map(lambda x: int(x)//2, input().split())))

    l = 1
    div2_count = count_div2(A[0])

    for a in A:
        l = l*a // gcd(l, a)
        c = count_div2(a)
        if div2_count != count_div2(a):
            print(0)
            exit()
    #     div2_count.append(max(count_div2(a), 1))
    # print(div2_count)
    # l *= min(div2_count)
    # print(l)
    # l の奇数倍が1より大きくM以下にいくつあるか

    print((M//l + 1)//2)


def count_div2(x):
    ans = 0
    while x % 2 == 0:
        x = x//2
        ans += 1
    return ans


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np

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

    p_max = M//np.min(A)
    X = np.zeros((p_max, N))
    # print(A)
    # print(X)
    # print(p_max)
    for p in range(p_max):
        X[p] = A*(p+0.5)

    ans = 0
    p_min = M//np.max(A)
    for p in range(p_min):
        x = np.max(A)*(p+0.5)
        if np.sum(x == X) == N:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()
Problem p03160 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

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

    inf = float("inf")
    dp = [inf]*N

    dp[0] = 0
    step1, step2 = inf, inf

    for i in range(1, N):
        step1 = abs(H[i-1]-H[i]) + dp[i-1]
        if i >= 2:
            step2 = abs(H[i-2]-H[i]) + dp[i-2]
        step = min(step1, step2)

        dp[i] = min(dp[i], step)
    print(dp[-1])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

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

    import math
    dp = [math.inf]*N

    dp[0] = 0
    step1, step2 = math.inf, math.inf

    for i in range(1, N):
        step1 = abs(H[i-1]-H[i]) + dp[i-1]
        if i >= 2:
            step2 = abs(H[i-2]-H[i]) + dp[i-2]
        step = min(step1, step2)

        dp[i] = min(dp[i], step)
    print(dp[-1])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

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

    from scipy.sparse import csgraph, csr_matrix

    start = [i for i in range(N-1)] + [i for i in range(N-2)]
    end = [i+1 for i in range(N-1)] + [i+2 for i in range(N-2)]
    cost = [abs(h1-h2) for h1, h2 in zip(H[0:-1], H[1:])] + \
        [abs(h1-h2) for h1, h2 in zip(H[0:-2], H[2:])]
    csr = csr_matrix((cost, (start, end)), shape=(N, N))
    d = csgraph.shortest_path(csr, method='D')

    print(int(d[0][N-1]))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

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

    from scipy.sparse import csgraph, csr_matrix

    start = [i for i in range(N-1)] + [i for i in range(N-2)]
    end = [i+1 for i in range(N-1)] + [i+2 for i in range(N-2)]
    cost = [abs(h1-h2) for h1, h2 in zip(H[0:-1], H[1:])] + \
        [abs(h1-h2) for h1, h2 in zip(H[0:-2], H[2:])]
    csr = csr_matrix((cost, (start, end)), shape=(N, N))
    d = csgraph.shortest_path(csr, indices=0)

    print(int(d[N-1]))


if __name__ == "__main__":
    main()
Problem p02705 (python)

Fixed submission:
import math

if __name__ == "__main__":
    R = int(input())
    print(2*math.pi*R)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    # 1 <= N <= 2 * 10^5
    # 1 <= K <= N + 1
    N, K = map(int, input().split(" "))

    total_num = 0
    for k in range(K, N+2):
        # NからN-(k-1)までの和
        sum_max = k*(2*N - k + 1) / 2
        # 0から(k-1)までの和
        sum_min = k*(k-1) / 2
        # 個数を計上
        total_num += sum_max - sum_min + 1
        total_num %= 1000000007
    
    print(total_num)
Problem p03071 (python)

Fixed submission:
#coding:utf-8

if __name__ == "__main__":
    A, B = map(int, input().split())
    total = 0
    for n in range(2):
        if A < B:
            total += B
            B = B - 1
        else:
            total += A
            A = A - 1
    
    print(total)

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

if __name__ == "__main__":
    N = int(input())
    tmp = input().split()
    Hs = []
    for t in tmp:
        Hs.append(int(t))
    total = 0

    for n in range(N):
        n_count = 0
        for i in range(0, n):
            if Hs[i] > Hs[n]:
                break
            n_count += 1
        if n_count == n:
            total += 1
        
    print("\n"+str(total))

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

if __name__ == "__main__":
    N = int(input())
    tmp = input().split()
    Hs = []
    for t in tmp:
        Hs.append(int(t))
    total = 0

    for n in range(N):
        n_count = 0
        for i in range(0, n):
            if Hs[i] > Hs[n]:
                break
            n_count += 1
        if n_count == n:
            total += 1
        
    print(str(total)+"\n")

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

if __name__ == "__main__":
    N = int(input())
    tmp = input().split()
    Hs = []
    for t in tmp:
        Hs.append(int(t))
    total = 0

    for n in range(N):
        n_count = 0
        for i in range(0, n):
            if Hs[i] > Hs[n]:
                break
            n_count += 1
        if n_count == n:
            total += 1
        
    print(total)
Problem p03109 (python)

Fixed submission:
#coding:utf-8

if __name__ == "__main__":
    date = input()
    year, month, day = date.split("/")

    if int(year) <= 2019:
        if int(month) <= 4:
            if int(day) <= 30:
                print("Heisei")
                exit()
    
    print("TBD")

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import sys

BAMB_NUM = 0
BAMB_A = 0
BAMB_B = 0
BAMB_C = 0
BAMB_LIST = []

def calcMP(idx, lenA, lenB, lenC):
    """
    calculate MP.
    """
    # when classified all bamboos
    if (idx == BAMB_NUM):
        return abs(lenA - BAMB_A) + abs(lenB - BAMB_B) + abs(lenC - BAMB_C) - 30 if min(lenA, lenB, lenC) > 0 else sys.maxsize
    
    # don't use idx-th bamboo
    mp1 = calcMP(idx + 1, lenA, lenB, lenC)
    # use idx-th bamboo
    mp2 = calcMP(idx + 1, lenA + BAMB_LIST[idx], lenB, lenC) + 10
    mp3 = calcMP(idx + 1, lenA, lenB + BAMB_LIST[idx], lenC) + 10
    mp4 = calcMP(idx + 1, lenA, lenB, lenC + BAMB_LIST[idx]) + 10

    return min(mp1, mp2, mp3, mp4)

if __name__ == "__main__":
    """
    http://drken1215.hatenablog.com/entry/2019/02/24/224100
    """
    # requested bamboo lengths
    BAMB_NUM, BAMB_A, BAMB_B, BAMB_C = map(lambda x: int(x), input().split())
    # available bamboo lengths
    for bamb in range(BAMB_NUM):
        BAMB_LIST.append(int(input()))

    mp = calcMP(0, 0, 0, 0)
    print(mp)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import sys

BAMB_NUM = 0
BAMB_A = 0
BAMB_B = 0
BAMB_C = 0
BAMB_LIST = []

def calcMP(idx, lenA, lenB, lenC):
    # when classified all bamboos
    if (idx == BAMB_NUM):
        # exists a zero length bamboo
        if (lenA <= 0 or lenB <= 0 or lenC <= 0):
            return sys.maxsize
        return abs(lenA - BAMB_A) + abs(lenB - BAMB_B) + abs(lenc - BAMB_C)
    
    # don't use idx-th bamboo
    mp = calcMP(idx+1, lenA, lenB, lenC)

    # use idx-th bamboo
    mp = min(mp, calcMP(idx + 1, lenA + BAMB_LIST[idx], lenB, lenC) + (BAMB_A > 0 ? 10 : 0))
    mp = min(mp, calcMP(idx + 1, lenA, lenB + BAMB_LIST[idx], lenC) + (BAMB_B > 0 ? 10 : 0))
    mp = min(mp, calcMP(idx + 1, lenA, lenB, lenC + BAMB_LIST[idx]) + (BAMB_C > 0 ? 10 : 0))

    return mp

if __name__ == "__main__":
    """
    http://drken1215.hatenablog.com/entry/2019/02/24/224100
    """
    # requested bamboo lengths
    bamb_num, bambA, bambB, bambC = map(lambda x: int(x), input().split())
    # available bamboo lengths
    bamb_list = []
    for bamb in range(bamb_num):
        bamb_list.append(int(input()))

    mp = calcMP(0, 0, 0, 0)
    print(mp)
Problem p03110 (python)

Fixed submission:
#coding:utf-8

if __name__ == "__main__":
    num = int(input())
    money = []
    mtype = []
    for p in range(num):
        m_tmp, mt_tmp = input().split()
        money.append(float(m_tmp))
        mtype.append(mt_tmp)
    
    total = 0
    for m, mt in zip(money, mtype):
        if mt == "JPY":
            total += m
        else:
            total += m * 380000.0
    
    print(total)

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

if __name__ == "__main__":
    num = int(input())
    money = []
    mtype = []
    for p in range(num):
        m_tmp, mt_tmp = input().split()
        money.append(float(m_tmp))
        mtype.append(mt_tmp)
    
    total = 0
    for m, mt in zip(money, mtype):
        if mt == "JPY":
            total += m
        else:
            total += mt * 380000.0
    
    print(total)