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

Fixed submission:
times = [int(input()) for _ in range(5)]

amarino_times = [i % 10 for i in times]
#
# min_index = amarino_times.index(min(amarino_times))
#
# last_choose_time = times.pop(min_index)
#
#
# sum = 0
# for i in times:
#     sum += i
#     if i % 10 != 0:
#         sum += 10 - (i % 10)
#
# sum += last_choose_time
#
# hoge = 0
# for i in amarino_times:
#     if i == 0:
#         hoge += 1
# for i in range(hoge):
#     fuga = amarino_times.pop(amarino_times.index(min(amarino_times)))
# print(hoge)
# if hoge:
#     sum -= min(amarino_times)
#
#
# print(sum)

sum = 0
for i in times:
    if i % 10 == 0:
        sum += i
    else:
        sum += i + 10-i % 10

hoge = []
for i in range(len(amarino_times)):
    if amarino_times[i] != 0:
        hoge.append(amarino_times[i])

if any(amarino_times):
    sum -= (10-min(hoge))

print(sum)

Buggy submission (verdict: Runtime Error):
times = [int(input()) for _ in range(5)]

amarino_times = [i % 10 for i in times]

min_index = amarino_times.index(min(amarino_times))

last_choose_time = times.pop(min_index)


sum = 0
for i in times:
    sum += i
    if i % 10 != 0:
        sum += 10 - (i % 10)

sum += last_choose_time

hoge = 0
for i in amarino_times:
    if i == 0:
        hoge += 1
for i in range(hoge):
    fuga = amarino_times.pop(amarino_times.index(min(amarino_times)))
print(hoge)
if hoge:
    sum -= min(amarino_times)


print(sum)
Problem p03105 (python)

Fixed submission:
int_list = input().strip().split()

fee_per_sound = int(int_list[0])
takahasi_money = int(int_list[1])
satisfaction_number = int(int_list[2])

if takahasi_money >= fee_per_sound*satisfaction_number:
    print(satisfaction_number)
else:
    print(takahasi_money//fee_per_sound)

Buggy submission (verdict: Runtime Error):
a, b, c = map(input().split())
print(min(c, b//a))

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

int main(){
  //入力
  int A, B, C;
  cin >> A >> B >> C;

  //処理
  int ans = B / A;
  if (ans > C) ans = C;

  //出力
  cout << ans << endl;
}
Problem p03161 (python)

Fixed submission:
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]


def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0

    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]


print(frog(n, k, h))

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

dp = [1000000000] * (N+K+2)
HHH.extend([0]*(K+2))

dp[0] = 0
"配るdpでやる？"

for i in range(0, N):
    if N-i > K:  # もうK段残ってないなら
        K = N-i-K
    for j in range(1, K+1):  # 1段~K段飛ぶ
        dp[i+j] = min(dp[i+j], dp[i]+abs(HHH[i+j]-HHH[i]))

print(dp[N-1])

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

dp = [1000000000] * (N+K+2)
HHH.extend([0]*(K+2))

dp[0] = 0
"配るdpでやる？"

for i in range(0, N):
    if N-i > K:  # もうK段残ってないなら
        K = N-1-K
    for j in range(1, K+1):  # 1段~K段飛ぶ
        dp[i+j] = min(dp[i+j], dp[i]+abs(HHH[i+j]-HHH[i]))

print(dp[N-1])
Problem p03164 (python)

Fixed submission:
# import numpy as np
#
# N, W = map(int, input().split())
#
# dp = np.zeros(W+1, dtype=np.int64)
#
# for _ in range(N):
#     w, v = map(int, input().split())
#     np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])
#
# print(dp[-1])


import numpy as np

N, W = map(int, input().split())
dp = np.full(N * 1000 + 1, 10 ** 10, dtype=np.int64)
# print(dp)
# print(len(dp))
dp[0] = 0
for _ in range(N):
    w, v = map(int, input().split())
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
print(((dp <= W) * np.arange(N * 1000 + 1)).max())

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

N, W = map(int, input().split())

dp = np.zeros(W+1, dtype=np.int64)

for _ in range(N):
    w, v = map(int, input().split())
    np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

print(dp[-1])

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

N, W = map(int, input().split())

dp = np.zeros(W+1, dtype=np.int64)

for _ in range(N):
    w, v = map(int, input().split())
    np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

print(dp[-1])
Problem p03197 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

print("second" if all(A[i] % 2 == 0 for i in range(N)) else "first")

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

print("second" if all(a[i] % 2 == 0 for i in range(N)) else "first")
Problem p03238 (python)

Fixed submission:
import sys
N = int(sys.stdin.readline())

if N == 1:
    print('Hello World')
    sys.exit()

if N == 2:
    ans = 0
    for value in sys.stdin.readlines():
        ans += int(value)

    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(sys.stdin.readline())

if N == 1:
    print('Hello World')
    sys.exit()

if N == 2:
    ans = 0
    for value in sys.stdin.readlines():
        ans += value

    print(ans)
Problem p03239 (python)

Fixed submission:
import sys
N, T = map(int, sys.stdin.readline().strip().split())  # N個の帰宅経路, T時間以内に

cost = 1001
for line in sys.stdin.readlines():
    c, t = map(int, line.strip().split())
    if T >= t:
        cost = min(cost, c)

if cost == 1001:
    print('TLE')
else:
    print(cost)

Buggy submission (verdict: Runtime Error):
import sys
N, T = map(int, sys.stdin.readline().strip().split())  # N個の帰宅経路, T時間以内に

cost = 1001
for line in sys.stdin.readlines():
    c, t = line.strip().split()
    if T >= t:
        cost = min(cost, c)

if cost == 1001:
    print('TLE')
else:
    print(cost)
Problem p03241 (python)

Fixed submission:
N, M = map(int, input().split())  # 項数N, Aの和M

ans = 1
for i in range(1, int(M**(1/2))+1):
    if M % i != 0:
        continue
    j = M // i  # jはどんどん小さくなる
    if j >= N:
        ans = max(ans, i)
    if i >= N:
        ans = max(ans, j)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())  # 項数N, Aの和M

if N == 1:
    print(M)
    eixt()

# Mの約数を列挙する
primes = []
ans = 1


for i in range(1, int(M**(1/2))+1):
    if M % i == 0:
        primes.append(i)
        primes.append(M//i)

# 約数が全て手に入った
for d in primes:
    if M >= N * d:
        ans = d

print(d)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())  # 項数N, Aの和M

ans = 1

if N == 1:
    print(M)
    exit()

for i in range(1000000):
    if (M >= N * i) and (M % i == 0):
        ans = i

print(ans)
Problem p03268 (python)

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

ans = 0

num = [0] * (K+1)
for i in range(1, N+1):
    num[i % K] += 1

for a in range(K+1):
    b = (K-a) % K
    c = (K-a) % K
    if ((b+c) % K) == 0:
        ans += (num[a] * num[b] * num[c])

print(ans)

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

# Kが偶数の場合, 全てKの倍数または全てK//2に倍数の両方考える必要あり
num = [0]*(K)  # 1以上N以下の整数で余りが0~K-1の個数をカウントする
for i in range(1, N+1):
    num[i % K] += 1  # i % K の取りうる値は0~K-1

ans = 0
for a in range(K+1):  # aに関して全探索を行う
    b = (K-a) % K
    c = (K-a) % K
    if (b + c) % K == 0:
        ans += num[a] * num[b] * num[c]

print(ans)
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
if K == 1:
    print(S[0])
    exit()
else:
    for i in range(K):
        if S[i] != "1":
            print(S[i])
            exit()
print(1)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if K == 1:
    print(S[0])
elif S[K-1] == "1":
    print(1)
else:
    for i in range(len(S)):
        if S[i] != "1":
            print(S[i])
            exit()

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if K == 1:
    print(S[0])
elif S[K] == "1":
    print(1)
else:
    for i in range(len(S)):
        if S[i] != "1":
            print(S[i])
            exit()

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
for i in range(len(S):
    if S[i] != 1:
        print(S[i])
        exit()
Problem p03309 (python)

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

for i in range(len(A)):
    B.append(A[i] - (i+1))

b = statistics.median(B)

ans = 0
for i in range(len(B)):
    ans += abs(B[i] - b)

print(int(ans))

Buggy submission (verdict: Runtime Error):
import statistics
N = int(input())
A = list(map(int, input().split()))
B = []

for i in range(len(A)):
    B.append(A[i] - (i+1))

b = statistics.median(B)

ans = 0
for i in range(len(B)):
    ans += abs(B[i] - b)

print(int(ans))
Problem p03340 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
l,r = 0,0
ans = 0
s = 0
while l < n:
  if r < n and s+a[r] == s^a[r]:
    s += a[r]
    r += 1
    #print(s)
  else:
    ans += r-l
    s -= a[l]
    #print(s)
    l += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = N
for i in range(N-1):
    wa = 0
    if A[i] & A[i+1] != 0:
        continue
    ans += 1
    wa = A[i] ^ A[i+1]
    for j in range(i+2, 20):  # 全部0だった時にTLEを起こす
        if wa & A[j] == 0:
            wa = wa ^ A[j]
            ans += 1
        else:
            break
print(ans)
Problem p03351 (python)

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

if d >= abs(a-c):
    print("Yes")
elif abs(a-b) <= d and abs(b-c) <= d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

if abs(a-c) =< d:
  print("Yes")
elif abs(a-b) =< d and abs(b-c) =< d:
  print("Yes")
else:
  print("No")
Problem p03407 (python)

Fixed submission:
A, B, C = map(int, input().split())
if A+B >= C:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input.split())
if A+B >= C:
  print("Yes")
else:
  print("No")
Problem p03476 (python)

Fixed submission:
def eratosutenes(n):
    primes = [1] * (n+1)  # 0からnまでの素数リスト, 最初は全てが素数だと仮定する
    primes[0] = 0
    primes[1] = 0

    for i in range(2, int(n**(1/2))+1):
        if primes[i] == 0:
            continue
        if primes[i] == 1:
            for j in range(i * 2, n+1, i):
                primes[j] = 0
    return primes


# 素数に1がたち、素数でないものに0がたつリストができた
primes = eratosutenes(100001)

Q = int(input())
query = []

for _ in range(Q):
    l, r = map(int, input().split())
    query.append((l, r))

like_numbers_ruisekiwa = [0]  # 0のときは0

for i in range(1, len(primes)):
    if i % 2 == 1:  # 奇数のときだけ処理をする
        if primes[i] == 1 and primes[(i+1)//2] == 1:  # 両方素数ならインクリメントする
            like_numbers_ruisekiwa.append(like_numbers_ruisekiwa[-1] + 1)
        else:
            like_numbers_ruisekiwa.append(like_numbers_ruisekiwa[-1])
    if i % 2 == 0:
        like_numbers_ruisekiwa.append(like_numbers_ruisekiwa[-1])


for i in range(len(query)):
    l, r = query[i]
    print(like_numbers_ruisekiwa[r] - like_numbers_ruisekiwa[l-1])

Buggy submission (verdict: Runtime Error):
def eratosutenes(n):
    primes = [1] * (n+1)  # 0からnまでの素数リスト, 最初は全てが素数だと仮定する
    primes[0] = 0
    primes[1] = 0

    for i in range(2, int(n**(1/2))+1):
        if primes[i] == 0:
            continue
        if primes[i] == 1:
            for j in range(i * 2, n+1, i):
                primes[j] = 0
    return primes


# 素数に1がたち、素数でないものに0がたつリストができた
primes = eratosutenes(2017)

Q = int(input())
query = []

for _ in range(Q):
    l, r = map(int, input().split())
    query.append((l, r))

like_numbers_ruisekiwa = [0]  # 0のときは0

for i in range(1, len(primes)):
    if i % 2 == 1:  # 奇数のときだけ処理をする
        if primes[i] == 1 and primes[(i+1)//2] == 1:  # 両方素数ならインクリメントする
            like_numbers_ruisekiwa.append(like_numbers_ruisekiwa[-1] + 1)
        else:
            like_numbers_ruisekiwa.append(like_numbers_ruisekiwa[-1])
    if i % 2 == 0:
        like_numbers_ruisekiwa.append(like_numbers_ruisekiwa[-1])


for i in range(len(query)):
    l, r = query[i]
    print(like_numbers_ruisekiwa[r] - like_numbers_ruisekiwa[l-1])
Problem p03502 (python)

Fixed submission:
X = str(input())
tmp = 0
for i in range(len(X)):
  tmp += int(X[i])

if int(X) % tmp == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
X = str(input())
tmp = 0
for i in range(len(X)):
  tmp += int(X[i])

if X % tmp == 0:
  print('Yes')
else:
  print('No')
Problem p03608 (python)

Fixed submission:
# from scipy.sparse.csgraph import floyd_warshall
import itertools


def warshal_floyd(d):
    # d[i][j] := iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    # "今現在求まっているiからjへの最短距離"と"今現在求まっているiからkへの最短距離 + 今現在求まっているkからjへの最短距離 の和"を比較する
    return d


N, M, R = map(int, input().split())  # N個の町, M本の道, R個の町を訪れることになった
town = list(map(lambda x: int(x)-1, input().split()))
distant = [[float('inf')]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    distant[a][b] = c
    distant[b][a] = c
for i in range(N):
    distant[i][i] = 0

warshal_floyd(distant)
# print(distant)  # Rは最大8だから全てを試しても大丈夫
ans = 10**9
for x in itertools.permutations(town):
    x = list(x)
    now = x[0]
    tmp = 0
    for i in range(1, len(x)):
        tmp += distant[now][x[i]]
        now = x[i]
    ans = min(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall
import itertools


def warshal_floyd(d):
    # d[i][j] := iからjへの最短距離
    global N
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    # "今現在求まっているiからjへの最短距離"と"今現在求まっているiからkへの最短距離 + 今現在求まっているkからjへの最短距離 の和"を比較する
    return d


N, M, R = map(int, input().split())  # N個の町, M本の道, R個の町を訪れることになった
town = list(map(lambda x: int(x)-1, input().split()))
distant = [[float('inf')]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    distant[a][b] = c
    distant[b][a] = c
for i in range(N):
    distant[i][i] = 0
floyd_warshall(distant)
# warshal_floyd(distant)
# print(distant)  # Rは最大8だから全てを試しても大丈夫
ans = 10**9
for x in itertools.permutations(town):
    x = list(x)
    now = x[0]
    tmp = 0
    for i in range(1, len(x)):
        tmp += distant[now][x[i]]
        now = x[i]
    ans = min(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall
import itertools


def warshal_floyd(d):
    # d[i][j] := iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    # "今現在求まっているiからjへの最短距離"と"今現在求まっているiからkへの最短距離 + 今現在求まっているkからjへの最短距離 の和"を比較する
    return d


N, M, R = map(int, input().split())  # N個の町, M本の道, R個の町を訪れることになった
town = list(map(lambda x: int(x)-1, input().split()))
distant = [[float('inf')]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    distant[a][b] = c
    distant[b][a] = c
for i in range(N):
    distant[i][i] = 0

warshal_floyd(distant)
# print(distant)  # Rは最大8だから全てを試しても大丈夫
ans = 10**9
for x in itertools.permutations(town):
    x = list(x)
    now = x[0]
    tmp = 0
    for i in range(1, len(x)):
        tmp += distant[now][x[i]]
        now = x[i]
    ans = min(ans, tmp)
print(ans)
Problem p03665 (python)

Fixed submission:
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


N, P = map(int, input().split())  # 袋がN個, 2をPにしたい
A = list(map(lambda x: int(x)%2, input().split()))
# print(A)

kisuu = sum(A)  # 奇数個の袋の数
guusuu = N-kisuu  # 偶数個の袋の数

# Pが1のとき，偶数側の袋を任意の数と，奇数側の数を奇数個選ぶ
if P == 1:
    tmp_guusuu = 0
    tmp_kisuu = 0
    # 偶数側を任意の個数選ぶ
    for i in range(guusuu+1):
        tmp_guusuu += cmb(guusuu, i)
    for i in range(kisuu+1):
        if i % 2 == 0:
            continue
        tmp_kisuu += cmb(kisuu, i)
    print(tmp_guusuu*tmp_kisuu)

# Pが0のとき，偶数側の袋を任意の数と，奇数側の数を偶数個選ぶ
elif P == 0:
    tmp_guusuu = 0
    tmp_kisuu = 0
    # 偶数側を任意の個数選ぶ
    for i in range(guusuu+1):
        tmp_guusuu += cmb(guusuu, i)
    # 奇数側を0個数以上の偶数個選ぶ
    for i in range(kisuu+1):
        if i % 2 == 1:
            continue
        tmp_kisuu += cmb(kisuu, i)
    print(tmp_guusuu*tmp_kisuu)

Buggy submission (verdict: Runtime Error):
# 二項係数を"やるだけ"にしてくれるライブラリ
from collections import Counter
MAX = 1000005
MOD = 10**9+7
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX


# テーブルを作る前処理
def COMinit():
    global factrial, inverse, factrial_inverse
    factrial[0] = 1
    factrial[1] = 1
    inverse[1] = 1
    factrial_inverse[0] = 1
    factrial_inverse[1] = 1
    for i in range(2, MAX):
        factrial[i] = factrial[i-1] * i % MOD
        inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD
        factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD


# 二項係数計算
def COM(n, k):
    global factrial, inverse, factrial_inverse
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD


# 前処理完了
COMinit()


N, P = map(int, input().split())  # 袋がN個, mod2をPにしたい
A = list(map(lambda x: int(x)%2, input().split()))
# print(A)

kisuu = sum(A)  # 奇数個の袋の数
guusuu = N-kisuu  # 偶数個の袋の数

# Pが1のとき，偶数側の袋を任意の数と，奇数側の数を奇数個選ぶ
if P == 1:
    aaa
    tmp_guusuu = 0
    tmp_kisuu = 0
    # 偶数側を任意の個数選ぶ
    for i in range(guusuu+1):
        tmp_guusuu += COM(guusuu, i)
    for i in range(kisuu+1):
        if i % 2 == 0:
            continue
        tmp_kisuu += COM(kisuu, i)
    print(tmp_guusuu*tmp_kisuu)

# Pが0のとき，偶数側の袋を任意の数と，奇数側の数を偶数個選ぶ
elif P == 0:
    tmp_guusuu = 0
    tmp_kisuu = 0
    # 偶数側を任意の個数選ぶ
    for i in range(guusuu+1):
        tmp_guusuu += COM(guusuu, i)
    # 奇数側を0個数以上の偶数個選ぶ
    for i in range(kisuu+1):
        if i % 2 == 1:
            continue
        tmp_kisuu += COM(kisuu, i)
    print(tmp_guusuu*tmp_kisuu)
Problem p03696 (python)

Fixed submission:
# 始めカッコの個数を先に確定させる
# ある特定の時点で")"の方が多いなら、あとから"("が出て来ても遅い
ans = 0  # これの最小値になった絶対値分を文頭につける
N = int(input())
S = input()
hazimekakko = 0
owarikakko = 0
for i in range(N):
    if S[i] == "(":
        hazimekakko += 1
    else:
        owarikakko += 1
    ans = max(ans, owarikakko-hazimekakko)
# 終わりかっこの方が多いタイミングのその量を確定させる
S = abs(ans)*"(" + S

hazimekakko = 0
owarikakko = 0
for i in range(len(S)):
    if S[i] == "(":
        hazimekakko += 1
    else:
        owarikakko += 1

S = S + (hazimekakko-owarikakko)*")"
print(S)

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

for i in reversed(range(N)):
    if S[i] == ")":
        tmp = i
        break
left = ""
for i in range(N-tmp-1):
    left += ")"

migi_kakko = 0
hidari_kakko = 0
for i in range(tmp+1):
    if S[i] == ")":
        migi_kakko += 1
    else:
        hidari_kakko += 1

right = ""
for i in range(migi_kakko-hidari_kakko):
    right += "("
for i in range(hidari_kakko-migi_kakko):
    left += ")"

ans = ""
ans += right
ans += S
ans += left
print(ans)
Problem p03848 (python)

Fixed submission:
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()

if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    print(2**(N//2) % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    print(2**(N//2) % mod)

Buggy submission (verdict: Runtime Error):
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()

if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    print(2**(N//2) % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    print(2**(N//2) % mod)
Problem p04001 (python)

Fixed submission:
S = list(input())
ans = 0

for state in range(1 << len(S)-1):
    ans += eval(S[0] + ''.join(('+' if state >> i & 1 else '') + x for i, x in enumerate(S[1:])))

print(ans)

Buggy submission (verdict: Runtime Error):
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if ((mask >> i) & 1):
            ans += f"{S[i]}+"
        else:
            ans += f"{S[i]}"
    ans += "+"

print(int(eval(ans[:-1])))

Buggy submission (verdict: Runtime Error):
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if (mask >> i) & 1:
            ans += f"{S[i]}+"
        else:
            ans += f"{S[i]}"
    ans += "+"
print(int(eval(ans[:-1])))

Buggy submission (verdict: Runtime Error):
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if (mask >> i) & 1:
            ans += f"{S[i]}+"
        else:
            ans += f"{S[i]}"
    ans += "+"
print(eval(ans[:-1]))