Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())

# dp[i][j] := i文字目（1-index)まで割り算した余りがjになるような'?'の置き換えが何通りあるか。
dp = [[0]*13 for _ in range(100001)]

S_length = len(S)
MOD = 1000000007
dp[0][0] = 1  # dpの初期化。0文字目までの割り算の余りが0になるような置き換えが1通りあると考える。

# 今、計算をしているのがi文字目, dpのiは1-indexだが、Sへのアクセスは0インデックスで行う
for i in range(1, S_length+1):
    for remain in range(13):  # i-1文字目まで計算した余りを決め打ちしているループ変数remain
        if S[i-1] == '?':  # i文字目が'?'であったらそれぞれをjに置き換えて計算
            for j in range(10):
                next_remain = (remain*10+j) % 13  # (i-1)文字目までの余りがremainで，i文字目の'?'に置き換えた場合の，i文字目まで計算した余り

                # dpの遷移
                dp[i][next_remain] += dp[i-1][remain]
                dp[i][next_remain] %= MOD
        else:
            next_remain = (remain*10 + int(S[i-1])) % 13
            # dpの遷移
            dp[i][next_remain] += dp[i-1][remain]
            dp[i][next_remain] %= MOD

print(dp[S_length][5])  # 答えはS_length文字目(つまり最後の文字)まで計算した余りが5になるような'?'の置き換えが何通りあるか


Fixed submission:
S = str(input())

# dp[i][j] := i文字目（1-index)まで割り算した余りがjになるような'?'の置き換えが何通りあるか。
dp = [[0]*13 for _ in range(100001)]

S_length = len(S)
MOD = 1000000007
dp[0][0] = 1  # dpの初期化。0文字目までの割り算の余りが0になるような置き換えが1通りあると考える。

# 今、計算をしているのがi文字目, dpのiは1-indexだが、Sへのアクセスは0インデックスで行う
for i in range(1, S_length+1):
    for remain in range(13):  # i-1文字目まで計算した余りを決め打ちしているループ変数remain
        if S[i-1] == '?':  # i文字目が'?'であったらそれぞれをjに置き換えて計算
            for j in range(10):
                next_remain = (remain*10+j) % 13  # (i-1)文字目までの余りがremainで，i文字目の'?'に置き換えた場合の，i文字目まで計算した余り

                # dpの遷移
                dp[i][next_remain] += dp[i-1][remain]
                dp[i][next_remain] %= MOD
        else:
            next_remain = (remain*10 + int(S[i-1])) % 13
            # dpの遷移
            dp[i][next_remain] += dp[i-1][remain]
            dp[i][next_remain] %= MOD

print(dp[S_length][5])  # 答えはS_length文字目(つまり最後の文字)まで計算した余りが5になるような'?'の置き換えが何通りあるか
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

ans = 2019
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(((i % 2019) * (j % 2019)) % 2019, ans)
print(ans)


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

if R - L >= 2019:
    print(0)
    exit()

flag = True
ans = 2020
for i in range(L, R+1):
    for j in range(i+1, R+1):
        ans = min(((i % 2019) * (j % 2019)) % 2019, ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
N, M = map(int, input().split())  # N頂点, M辺
graph = [[] for _ in range(N)]

for _ in range(M):
    u, v = map(lambda x: int(x)-1, input().split())
    graph[u].append(v)

S, T = map(lambda x: int(x)-1, input().split())

dist = [[-1]*3 for _ in range(N)]
dist[S][0] = 0
q = []
heappush(q, (0, S))
while len(q):
    count, v = heappop(q)  # count, ノードのIndex
    for nv in graph[v]:  # nvは次のノードの番号
        np = (count + 1) % 3
        if dist[nv][np] == -1:  # 未到達なら
            dist[nv][np] = dist[v][count] + 1
            heappush(q, (nv, np))
if dist[T][0] == -1:
    print(-1)
else:
    print(dist[T][0]//3)


Fixed submission:
from heapq import heappop, heappush

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
S, T = map(lambda x: int(x)-1, input().split())

ans = -1
visited = set()
q = [(0, S)]
ans = -1
while q:
    c, v = heappop(q)  # cはカウント, vは頂点の番号
    key = (c % 3, v)
    if key in visited:
        continue
    visited.add(key)
    if v == T and c % 3 == 0:
        ans = c//3
        break
    c += 1
    d = c % 3
    for u in graph[v]:
        new_key = (d, u)
        if new_key in visited:
            continue
        heappush(q, (c, u))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())  # N段の階段, 壊れている床の個数M

# A = []

# flag = True
# for i in range(M):
#     A.append(int(input()))
#     if len(A) > 1:
#         if A[i] == A[i-1]+1:
#             print(0)
#             flag = False
#             break

# if flag:

A = [int(input()) for _ in range(M)]

dp = [0, 1]

for i in range(1, N+1):
    if i in A:
        dp.append(0)
    else:
        dp.append((dp[-2] + dp[-1]) % 1000000007)

print(dp[-1] % 1000000007)


Fixed submission:
N, M = map(int, input().split())  # N段の階段, 壊れている床の個数M

A = set([int(input()) for _ in range(M)])

dp = [0, 1]

for i in range(1, N+1):
    if i in A:
        dp.append(0)
    else:
        dp.append((dp[-2] + dp[-1]) % 1000000007)

print(dp[-1] % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())  # N段の階段, 壊れている床の個数M

# A = []

# flag = True
# for i in range(M):
#     A.append(int(input()))
#     if len(A) > 1:
#         if A[i] == A[i-1]+1:
#             print(0)
#             flag = False
#             break

# if flag:

A = [int(input()) for _ in range(M)]

dp = [0, 1]

for i in range(1, N+1):
    if i in A:
        dp.append(0)
    else:
        dp.append((dp[-2] + dp[-1]))

print(dp[-1] % 1000000007)


Fixed submission:
N, M = map(int, input().split())  # N段の階段, 壊れている床の個数M

A = set([int(input()) for _ in range(M)])

dp = [0, 1]

for i in range(1, N+1):
    if i in A:
        dp.append(0)
    else:
        dp.append((dp[-2] + dp[-1]) % 1000000007)

print(dp[-1] % 1000000007)
Buggy python submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())

A -= 1
B -= 1
C -= 1
D -= 1

S = str(input())

moziretu = S  # 保持しておく

# Bの人から動かす
zenhann = True
hoge = S[B+1]
for i in range(B+2, D):
    if hoge == S[i] and hoge == '#':
        zenhann = False
        break
    else:
        hoge = S[i]

if zenhann:
    str_list = list(S)
    str_list[D] = '#'
    S = "".join(str_list)

    hoge = S[A+1]
    for i in range(A+2, C):
        if hoge == S[i] and hoge == '#':
            zenhann = False
            break
        else:
            hoge = S[i]

kouhann = True
# Aの人から動かす
str_list = list(moziretu)
str_list[B] = '#'
moziretu = "".join(str_list)

hoge = moziretu[B]
for i in range(B+1, C+2):
    if hoge == moziretu[i] and hoge == '#':
        kouhann = False
        break
    else:
        hoge = moziretu[i]

fuga = moziretu[A+1]
for i in range(A+2, C):
    if fuga == moziretu[i] and fuga == '#':
        kouhann = False
        break
    else:
        fuga = S[i]
if kouhann:
    str_list = list(moziretu)
    str_list[C] = '#'
    moziretu = "".join(str_list)

    fuga = moziretu[B+1]
    for i in range(B+2, D):
        if fuga == moziretu[i] and fuga == '#':
            kouhann = False
            break
        else:
            fuga = moziretu[i]

if zenhann or kouhann:
    print('Yes')
else:
    print('No')


Fixed submission:
N, A, B, C, D = map(int, input().split())
S = str(input())

A -= 1
B -= 1
C -= 1
D -= 1

if '##' in S[A:C+1] or '##' in S[B:D+1]:
    print('No')  # そもそも移動経路の中に岩が二つ並んでいたら不可能ということ！
else:
    if C < D:  # この状態ならBにいる人をDに動かしてから、AをCに動かすだけでOK
        print('Yes')
    elif C > D:  # Aの目的地が、Bの目的地よりも右にあるなら
        # B-1からD+2にまでの中にBくんを退避させることが可能なスペースがあるか。
        # BくんはDまでしか動けない
        if "..." in S[B-1:D+2]:
            print('Yes')
        else:
            print('No')
Buggy python submission (verdict: Runtime Error):
N, M = int(input().split())  # N個のスイッチ, M個の電球

# M個の電球がそれぞれどこのスイッチと繋がっているかを格納
SSS = [list(map(int, input().split()))[1:] for i in range(M)]
P = list(map(int, input().split()))

ans = 0

for i in range(1 << N):  # 2のN乗の値になる, bit全探索
    for mask in range(M):
        ans_2 = 0
        for s in SSS[mask]:
            if (1 << s-1) & i != 0:
                ans_2 += 1

        if ans_2 % 2 != P[mask]:
            break
    else:
        ans += 1

print(ans)


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

# 繋がってるスイッチの情報
S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

# print(S)
# print(P)

ans = 0

for i in range(1 << N):
    # print(i)
    for m in range(M):
        cnt = 0
        for s in S[m]:  # Sは繋がっているスイッチの情報
            if i & (1 << (s-1)) != 0:
                cnt += 1
        if cnt % 2 != P[m]:
            break
    else:
        ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = int(input().split())  # N個のスイッチ, M個の電球

# M個の電球がそれぞれどこのスイッチと繋がっているかを格納
SSS = [list(map(int, input().split()))[1:] for i in range(M)]
P = list(map(int, input().split()))

ans = 0

for i in range(1 << N):  # 2のN乗の値になる, bit全探索
    for mask in range(M):
        ans_2 = 0
        for s in SSS[mask]:
            if (1 << s-1) & i != 0:
                ans_2 += 1

        if ans_2 % 2 != P[m]:
            break
    else:
        ans += 1

print(ans)
        

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

# 繋がってるスイッチの情報
S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

# print(S)
# print(P)

ans = 0

for i in range(1 << N):
    # print(i)
    for m in range(M):
        cnt = 0
        for s in S[m]:  # Sは繋がっているスイッチの情報
            if i & (1 << (s-1)) != 0:
                cnt += 1
        if cnt % 2 != P[m]:
            break
    else:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

L, R = map(int, input().split())
hoge = set(list(range(L, R+1)))

for i in range(1, M):
    L, R = map(int, input().split())
    hoge = hoge & set(list(range(L, R+1)))

print(len(hoge))


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

L, R = map(int, input().split())

for i in range(1, M):
    hoge, fuga = map(int, input().split())
    L = max(L, hoge)
    R = min(R, fuga)


if L > R:
    print(0)
else:
    print(R-L+1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

L, R = map(int, input().split())
hoge = list(range(L, R+1))
hoge = set(hoge)

for i in range(1, M):
    L, R = map(int, input().split())
    fuga = list(range(L, R+1))
    hoge = hoge & set(fuga)

print(len(hoge))


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

L, R = map(int, input().split())

for i in range(1, M):
    hoge, fuga = map(int, input().split())
    L = max(L, hoge)
    R = min(R, fuga)


if L > R:
    print(0)
else:
    print(R-L+1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())  # N枚のカード, 操作内容がMセット
A = list(map(int, input().split()))


for i in range(M):
    B, C = map(int, input().split())
    A.extend([C]*B)

A.sort(reverse=True)
print(sum(A[:N]))


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

# 二次元配列を作る
BC = []
for i in range(M):
    b, c = list(map(int, input().split()))
    BC.append([b, c])

BC = sorted(BC, reverse=True, key=lambda x: x[1])  # Cの値で降順にソートされる

cnt = 0
com = []

for b, c in BC:
    cnt += b
    if cnt > N:  # 操作を加える回数がNを超えることはない
        add = N-cnt+b  # comの要素数の調整
        com.extend([c]*add)
        break
    else:
        com.extend([c]*b)

A.extend(com)

A.sort(reverse=True)
print(sum(A[:N]))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())  # N枚のカード, 操作内容がMセット
A = list(map(int, input().split()))

A.sort()
kakikae = []

for i in range(M):
    B, C = map(int, input().split())
    for i in range(B):
        kakikae.append(C)

kakikae.sort(reverse=True)

for i in range(N):
    if kakikae[i] > A[i]:
        A[i] = kakikae[i]
    else:
        break
print(sum(A))


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

# 二次元配列を作る
BC = []
for i in range(M):
    b, c = list(map(int, input().split()))
    BC.append([b, c])

BC = sorted(BC, reverse=True, key=lambda x: x[1])  # Cの値で降順にソートされる

cnt = 0
com = []

for b, c in BC:
    cnt += b
    if cnt > N:  # 操作を加える回数がNを超えることはない
        add = N-cnt+b  # comの要素数の調整
        com.extend([c]*add)
        break
    else:
        com.extend([c]*b)

A.extend(com)

A.sort(reverse=True)
print(sum(A[:N]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=False)

# 最小値との大小を比較するだけ
for i in range(M):
    B, C = map(int, input().split())
    if A[0] >= C:
        continue
    for j in range(B):
        if A[j] >= C:
            break
        else:
            A[j] = C
    A.sort(reverse=False)

print(sum(A))


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

# 二次元配列を作る
BC = []
for i in range(M):
    b, c = list(map(int, input().split()))
    BC.append([b, c])

BC = sorted(BC, reverse=True, key=lambda x: x[1])  # Cの値で降順にソートされる

cnt = 0
com = []

for b, c in BC:
    cnt += b
    if cnt > N:  # 操作を加える回数がNを超えることはない
        add = N-cnt+b  # comの要素数の調整
        com.extend([c]*add)
        break
    else:
        com.extend([c]*b)

A.extend(com)

A.sort(reverse=True)
print(sum(A[:N]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
graph = [[] for _ in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, w))
# これによって木が定義できた
# print(graph)

flag = [None for _ in range(N)]  # まだどの頂点も探索していない


def k(v, distance):  # distanceは0or1
    flag[v] = distance  # 最初は0

    for next_v, w in graph[v]:
        if flag[next_v] == 1 or flag[next_v] == 0:  # 到達済み（親）であればcontinue
            continue
        if (w % 2) == 0:  # そのノードへの距離が偶数であればそのまま（最初は0なので）
            k(next_v, distance)
        else:
            k(next_v, 1-distance)


k(0, 0)  # 親を強制的に決めてよい, この場合は0のノードを親にしている
for i in range(N):
    print(int(flag[i]))


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

hoge = ""
for i in range(len(S)):
    if i == K-1:
        hoge += S[i].lower()
    else:
        hoge += S[i]

print(hoge)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())  # R個の箱, G個の箱, B個の箱
ans = 0
for r in range(N+1):  # 1
    for g in range(N+1):  # 0
        b = N - (r*R + g*G)  # b = 4 - (1*1 + 0*2) = 3
        if b % B == 0 and b >= 0:
            # print(r, g, b)  # 1, 0, 1のパターンが抜けている
            ans += 1

print(ans)


Fixed submission:
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N//R + 1):
    for g in range((N - (R*r))//G + 1):
        if(N - (R*r) - (G*g)) % B == 0:
            ans += 1
print(ans)
Buggy python 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)


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 python submission (verdict: Runtime Error):
N, *capacity = [int(input()) for _ in range(6)]

min_index = capacity.index(min(capacity))

ans = N // capacity[min_index]

if N <= capacity[0] and max(capacity) == capacity[0] and capacity[1:] not in capacity[0]:
    print(ans+4)
    exit()
print(ans+5)


Fixed submission:
import math


N, *capacity = [int(input()) for _ in range(6)]

# min_index = capacity.index(min(capacity))

ans = math.ceil(N/min(capacity))

print(ans+4)
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a_b = []
for i in range(X):
    for j in range(Y):
        a_b.append(A[i]+B[j])

ans = []
for k in range(len(a_b)):
    for l in range(Z):
        ans.append(a_b[k]+C[l])
ans = sorted(ans, reverse=True)
for m in range(K):
    print(ans[m])


Fixed submission:
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a_b = []
for i in range(X):
    for j in range(Y):
        a_b.append(A[i]+B[j])
a_b = sorted(a_b, reverse=True)
ans = []
for k in range(min(K, len(a_b))):
    for l in range(min(K, len(C))):
        ans.append(a_b[k]+C[l])
ans = sorted(ans, reverse=True)
for m in range(K):
    print(ans[m])

Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a_b = []
for i in range(X):
    for j in range(Y):
        a_b.append(A[i]+B[j])

ans = []
for k in range(len(a_b)):
    for l in range(Z):
        ans.append(a_b[k]+C[l])
ans = sorted(ans, reverse=True)
for m in range(K):
    print(ans[m])


Fixed submission:
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a_b = []
for i in range(X):
    for j in range(Y):
        a_b.append(A[i]+B[j])
a_b = sorted(a_b, reverse=True)
ans = []
for k in range(min(K, len(a_b))):
    for l in range(min(K, len(C))):
        ans.append(a_b[k]+C[l])
ans = sorted(ans, reverse=True)
for m in range(K):
    print(ans[m])
Buggy python submission (verdict: Time Limit Exceeded):
import re

target = 'AC'

N, Q = map(int, input().split())  # 長さNとQ個の問い

S = str(input())  # 文字列S

starts_ends = []

for _ in range(Q):
    starts_ends.append(list(map(int, input().split())))

for i in range(Q):
    start, end = starts_ends[i]
    portion_S = S[start-1:end]
    print(len(re.findall('AC', portion_S)))


Fixed submission:
# 累積和を使う
N, Q = map(int, input().split())  #長さN, Q個の問い

S = str(input())  # 長さNの文字列S(これはA, C, G, Tのいずれかの文字のみ)

starts_ends = []
# 始点lと終点rがQセット与えられる
for _ in range(Q):
    starts_ends.append(list(map(int, input().split())))

# print('hoge')
# print(N)
# print(Q)
# print(S)
# print(starts_ends)

# 'AC'を探す旅に出る
cumulative_sum = [0, 0]
for i in range(1, len(S)):
    if S[i] == 'C' and S[i-1] == 'A':
        cumulative_sum.append(cumulative_sum[i]+1)
    else:
        cumulative_sum.append(cumulative_sum[i])

for i in range(Q):
    start, end = starts_ends[i]
    print(cumulative_sum[end] - cumulative_sum[start])
Buggy python submission (verdict: Runtime Error):
a, b, c = map(input().split())
print(min(c, b//a))


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 python 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;
}


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 python submission (verdict: Runtime Error):
N, M = map(int, input().split())  # N個のコマ, M個の訪れるべき座標

if N >= M:
    print(0)
else:
    A = sorted(list(map(int, input().split())))
    B = sorted(A[i]-A[i-1] for i in range(1, len(A)))
    print(sum[B[:M-N]])


Fixed submission:
N, M = map(int, input().split())  # N個のコマ, M個の訪れるべき座標

if N >= M:
    print(0)
else:
    A = sorted(list(map(int, input().split())))
    B = sorted(A[i]-A[i-1] for i in range(1, len(A)))
    print(sum(B[0:M-N]))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())  # N個のコマ, M個の訪れるべき座標

if N >= M:
    print(0)
else:
    A = sorted(list(map(int, input().split())))
    B = sorted(A[i]-A[i-1] for i in range(1, len(A)))
    print(sum[B[0:M-N]])


Fixed submission:
N, M = map(int, input().split())  # N個のコマ, M個の訪れるべき座標

if N >= M:
    print(0)
else:
    A = sorted(list(map(int, input().split())))
    B = sorted(A[i]-A[i-1] for i in range(1, len(A)))
    print(sum(B[0:M-N]))
Buggy python 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])


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 python 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])


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())