Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0

    hasikko = [0]
    if M > 1:
        hasikko.aapned(M - 1)

    for i in hasikko:
        tmp = 1
        if M > i + 1:
            tmp += 1
        if N > 1:
            tmp += 1
        if N > 1 and M > i + 1:
            tmp += 1
        if N > 1 and i - 1 >= 0:
            tmp += 1
        if i > 0:
            tmp += 1

        ans += tmp % 2
        # print(tmp, ans)
    if M > 2 and N == 1:
        ans += M - 2

    if N >= 2:
        ans = ans * 2
    return ans


res = calc(_N, _M)

if _N >= 3:
    res += calc(_M, _N - 2)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

Fixed submission:
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0

    def hashicco(n, m):
        tmp = 1
        if n > 1:
            tmp += 1
        if m > 1:
            tmp += 1
            if n > 1:
                tmp += 1
        res = tmp % 2
        if n > 1:
            res *= 2
        if n > 1:
            res *= 2
        return res

    # ans += hashicco(N, M)

    v = 0
    if M > 2 and N == 1:
        v += M - 2
    h = 0
    if N > 2 and M == 1:
        h += N - 2

    return hashicco(N,M)+v+h


res = calc(_N, _M)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0
    for i in range(M):
        tmp = 1
        if M > i + 1:
            tmp += 1
        if N > 1:
            tmp += 1
        if N > 1 and M > i + 1:
            tmp += 1
        if N > 1 and i - 1 >= 0:
            tmp += 1
        if i > 0:
            tmp += 1

        ans += tmp % 2
        # print(tmp, ans)
    if N >= 2:
        ans = ans * 2
    return ans


res = calc(_N, _M)

if _N >= 3:
    res += calc(_M, _N - 2)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

Fixed submission:
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0

    def hashicco(n, m):
        tmp = 1
        if n > 1:
            tmp += 1
        if m > 1:
            tmp += 1
            if n > 1:
                tmp += 1
        res = tmp % 2
        if n > 1:
            res *= 2
        if n > 1:
            res *= 2
        return res

    # ans += hashicco(N, M)

    v = 0
    if M > 2 and N == 1:
        v += M - 2
    h = 0
    if N > 2 and M == 1:
        h += N - 2

    return hashicco(N,M)+v+h


res = calc(_N, _M)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)
Buggy python submission (verdict: Runtime Error):
N, M = [int(_) for _ in input().split()]

LRD = []
path = [[] for _ in range(N + 1)]
for _ in range(M):
    l, r, d = [int(_) for _ in input().split()]
    path[l].append((r, d))
    path[r].append((l, -d))
    LRD.append((l, r, d))

INF = -1e12
memo = [INF] * (N + 1)


def dfs(n):
    for ni, d in path[n]:
        if memo[ni] != INF: continue
        memo[ni] = memo[n] + d
        dfs(ni)


for i in range(1, N + 1):
    if memo[i] != INF: continue
    memo[i] = 0
    dfs(i)
for l, r, d in LRD:
    if not memo[l] + d == r:
        print('No')
        exit()
print('Yes')


Fixed submission:
import sys

sys.setrecursionlimit(10000000)
N, M = [int(_) for _ in input().split()]

LRD = []
path = [[] for _ in range(N + 1)]
for _ in range(M):
    l, r, d = [int(_) for _ in input().split()]
    path[l].append((r, d))
    path[r].append((l, -d))
    LRD.append((l, r, d))

INF = -1e12
memo = [INF] * (N + 1)


def dfs(n):
    for ni, d in path[n]:
        if memo[ni] != INF: continue
        memo[ni] = memo[n] + d
        dfs(ni)


for i in range(1, N + 1):
    if memo[i] != INF: continue
    memo[i] = 0
    dfs(i)
for l, r, d in LRD:
    if memo[l] + d != memo[r] and memo[l] - d != memo[r]:
        print('No')
        exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
N, M = [int(_) for _ in input().split()]

LRD = []
path = [[] for _ in range(N + 1)]
for _ in range(M):
    l, r, d = [int(_) for _ in input().split()]
    path[l].append((r, d))
    path[r].append((l, -d))
    LRD.append((l, r, d))

memo = [None] * (N + 1)


def dfs(n):
    for ni, d in path[n]:
        if memo[ni] is not None: continue
        memo[ni] = memo[n] + d
        dfs(ni)


for i in range(N):
    if memo[i] is not None: continue
    memo[i] = 0
    dfs(i)
for l,r,d in LRD:
    if not memo[l] + d == memo[r]:

        print('No')
        exit()
print('Yes')


Fixed submission:
import sys

sys.setrecursionlimit(10000000)
N, M = [int(_) for _ in input().split()]

LRD = []
path = [[] for _ in range(N + 1)]
for _ in range(M):
    l, r, d = [int(_) for _ in input().split()]
    path[l].append((r, d))
    path[r].append((l, -d))
    LRD.append((l, r, d))

INF = -1e12
memo = [INF] * (N + 1)


def dfs(n):
    for ni, d in path[n]:
        if memo[ni] != INF: continue
        memo[ni] = memo[n] + d
        dfs(ni)


for i in range(1, N + 1):
    if memo[i] != INF: continue
    memo[i] = 0
    dfs(i)
for l, r, d in LRD:
    if memo[l] + d != memo[r] and memo[l] - d != memo[r]:
        print('No')
        exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math

X, Y = [int(_) for _ in input().split()]
print(math.floor(math.log2(Y / X)) + 1)

Fixed submission:
import math

X, Y = [int(_) for _ in input().split()]
tmp = math.floor(math.log2(Y / X))
if (2 ** tmp) * X > Y:
    tmp -= 1
print(tmp + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N, C = [int(_) for _ in input().split()]

MT = (20 ** 5 + 10)
memo_s = [0] * MT
memo_t = [0] * MT
for i in range(N):
    s, t, c = [int(_) for _ in input().split()]

    memo_s[s*2] += 1 << (c - 1)
    memo_t[t*2+1] += 1 << (c - 1)

ans = 0
cnt = 0
for i in range(1, MT):
    for c in range(C):
        if memo_s[i] & (1 << c) == 0: continue
        if memo_t[i] & (1 << c): continue  # 区間連続
        cnt += 1
    ans = max(ans, cnt)
    for c in range(C):
        if memo_s[i] & (1 << c) == 1: continue

        if memo_t[i] & (1 << c):
            cnt -= 1
print(ans)

Fixed submission:
N, C = [int(_) for _ in input().split()]

MT = (10 ** 5 + 10)

memo = [[0] * C for _ in range(MT)]

stc = sorted([[int(_) for _ in input().split()] for _ in range(N)])
for s, t, c in stc:
    if memo[s][c - 1] < 0:
        memo[s][c - 1] = 0
    else:
        memo[s - 1][c - 1] += 1
    memo[t][c - 1] -= 1
ans = 0
cnt = 0
for i in range(MT):
    cnt += sum(memo[i])
    ans = max(ans,cnt)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(_) for _ in input().split()]

paths = [[0] * (N + 1) for _ in range(N + 1)]


def has_path(c, t, arrived):
    if c == t: return True
    for i in range(1, N + 1):
        if i in arrived: continue
        if paths[c][i]:
            arrived.append(i)
            if has_path(i, t, arrived):
                return True
            arrived.pop()
    return False


edge = []
for i in range(M):
    a, b = [int(_) for _ in input().split()]
    paths[a][b] = 1
    paths[b][a] = 1
    edge.append((a, b,))

ans = 0
for e in edge:
    paths[e[0]][e[1]] = 0
    paths[e[1]][e[0]] = 0
    if not has_path(e[0], e[1], []):
        ans += 1
    paths[e[0]][e[1]] = 1
    paths[e[1]][e[0]] = 1
print(ans)

Fixed submission:
N, M = [int(_) for _ in input().split()]

paths = [[0] * (N + 1) for _ in range(N + 1)]


def has_path(c, t, arrived):
    if c == t: return True
    for i in range(1, N + 1):
        if i in arrived: continue
        if paths[c][i]:
            arrived.append(i)
            if has_path(i, t, arrived):
                return True
            arrived.pop()
    return False


edge = []
for i in range(M):
    a, b = [int(_) for _ in input().split()]
    paths[a][b] = 1
    paths[b][a] = 1
    edge.append((a, b,))

ans = 0
for e in edge:
    paths[e[0]][e[1]] = 0
    paths[e[1]][e[0]] = 0
    if not has_path(e[0], e[1], []):
        ans += 1
    paths[e[0]][e[1]] = 1
    paths[e[1]][e[0]] = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)


N = int(input())

G = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b, c = [int(_) for _ in input().split()]
    G[a].append((b, c))
    G[b].append((a, c))
Q, K = [int(_) for _ in input().split()]

# make tree
G2 = [-1] * (N + 1)


def f(v, c, p):
    if G2[v] != -1: return
    G2[v] = c

    for nv, nc in G[v]:
        if nv == p: continue
        f(nv, nc + c, v)


f(K, 0, 0)

for i in range(Q):
    x,y = [int(_) for _ in input().split()]
    print(G2[x]+G2[y])


Fixed submission:
import sys
from collections import deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
edges = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b, c = [int(_) for _ in input().split()]
    edges[a].append((b, c))
    edges[b].append((a, c))

L = [-1] * (N + 1)


def w(k):
    que = deque()
    L[k] = 0
    que.append((k, -1))
    while que:
        n, p = que.popleft()
        for nn, nv in edges[n]:
            if nn == p: continue
            L[nn] = L[n] + nv
            que.append((nn, n))


def main():
    q, k = [int(_) for _ in input().split()]
    w(k)
    for i in range(q):
        a, b = [int(_) for _ in input().split()]
        print(L[a] + L[b])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int(input())

G = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b, c = [int(_) for _ in input().split()]
    G[a].append((b, c))
    G[b].append((a, c))
Q, K = [int(_) for _ in input().split()]

# make tree
G2 = [-1] * (N + 1)


def f(v, c, p):
    if G2[v] != -1: return
    G2[v] = c

    for nv, nc in G[v]:
        if nv == p: continue
        f(nv, nc + c, v)


f(K, 0, 0)

for i in range(Q):
    x,y = [int(_) for _ in input().split()]
    print(G2[x]+G2[y])


Fixed submission:
import sys
from collections import deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
edges = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b, c = [int(_) for _ in input().split()]
    edges[a].append((b, c))
    edges[b].append((a, c))

L = [-1] * (N + 1)


def w(k):
    que = deque()
    L[k] = 0
    que.append((k, -1))
    while que:
        n, p = que.popleft()
        for nn, nv in edges[n]:
            if nn == p: continue
            L[nn] = L[n] + nv
            que.append((nn, n))


def main():
    q, k = [int(_) for _ in input().split()]
    w(k)
    for i in range(q):
        a, b = [int(_) for _ in input().split()]
        print(L[a] + L[b])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())

A = [int(_) for _ in input().split()]
ans = 0
s = A[0]

i = 1
while i < N:
    a = A[i]
    # print(i, s, ans)

    sign = (s // abs(s))
    abs_min = abs(s) + 1
    if a == 0:
        ans += abs_min
        s = -sign

        i += 1
        continue

    abs_a = abs(a)
    a_sign = (a // abs_a)
    if a_sign == sign:
        A[i] = 0
        ans += abs_a
    else:
        if abs_min <= abs_a:
            s = (abs_a - abs(s)) * a_sign
        else:
            ans += abs_min - abs_a
            s = -sign
        i += 1
print(ans)


Fixed submission:
N = int(input())

A = [int(_) for _ in input().split()]


def f(sign):
    ans = 0
    s = 0
    for i in range(N):
        a = A[i]
        s += a
        if s == 0:
            ans += 1
            s = sign
        else:
            a_sign = s // abs(s)
            if a_sign != sign:
                ans += abs(s) + 1
                s = sign
        sign *= -1
    return ans


print(min(f(1), f(-1)))
Buggy python submission (verdict: Runtime Error):
N, M = [int(_) for _ in input().split()]
INF = 10 ** 10
costs = [[INF] * 101 for _ in range(101)]

for i in range(N + 1):
    costs[i][i] = 0
paths = []
for i in range(M):
    a, b, c = [int(_) for _ in input().split()]
    costs[a][b] = c
    costs[b][a] = c
    paths.append((a, b, c))

for k in range(N + 1):
    for i in range(N + 1):
        for j in range(N + 1):
            costs[i][j] = min(costs[i][j], costs[i][k] + costs[j][k])
            costs[j][i] = costs[i][j]

for i in range(N):
    paths2 = paths.copy()
    for p in paths:
        # 点i から 経路p をつかってp[1]への経路をもつかチェック
        if costs[i][p[0]] + p[2] == costs[i][p[1]]:
            paths2.remove(p)
    paths = paths2
print(len(paths))

Fixed submission:
N, M = [int(_) for _ in input().split()]
INF = 10 ** 10
costs = [[INF] * 101 for _ in range(101)]

for i in range(N + 1):
    costs[i][i] = 0
paths = []
for i in range(M):
    a, b, c = [int(_) for _ in input().split()]
    costs[a][b] = c
    costs[b][a] = c
    paths.append((a, b, c))

for k in range(N + 1):
    for i in range(N + 1):
        for j in range(N + 1):
            costs[i][j] = min(costs[i][j], costs[i][k] + costs[j][k])
            costs[j][i] = costs[i][j]

for i in range(1, N + 1):
    paths2 = paths.copy()
    for p in paths:
        # 点i から 経路p をつかってp[1]への経路をもつかチェック
        if costs[i][p[0]] >= INF or costs[i][p[1]] >= INF: continue
        if costs[i][p[0]] + p[2] == costs[i][p[1]]:
            paths2.remove(p)
    paths = paths2
print(len(paths))
Buggy python submission (verdict: Runtime Error):
a,b,c=[int(_) for _ in input().split()]
print('A'+b[0]+'C')

Fixed submission:
a,b,c=[_ for _ in input().split()]
print('A'+b[0]+'C')
Buggy python submission (verdict: Runtime Error):
N, A = [int(_) for _ in input().split()]

MAX_I = 2000
memo = [[0] * MAX_I for _ in range(N + 2)]


def cnv(v):
    return v - A + (MAX_I // 2)


X = [int(_) for _ in input().split()]
for i in range(N):
    offset = X[i] - A
    # print('x', offset)

    mm = memo[i]
    for j in range(MAX_I):
        if mm[j] > 0:
            memo[i + 1][j + offset] += mm[j]
        memo[i + 1][j] += mm[j]

    memo[i + 1][cnv(X[i])] += 1

print(memo[N][MAX_I//2])


Fixed submission:
N, A = [int(_) for _ in input().split()]

MAX_I = 5000
memo = [[0] * MAX_I for _ in range(N + 2)]


def cnv(v):
    return v - A + (MAX_I // 2)


X = [int(_) for _ in input().split()]
for i in range(N):
    offset = X[i] - A
    # print('x', offset)

    mm = memo[i]
    for j in range(MAX_I):
        if mm[j] > 0:
            memo[i + 1][j + offset] += mm[j]
        memo[i + 1][j] += mm[j]

    memo[i + 1][cnv(X[i])] += 1

print(memo[N][MAX_I//2])

Buggy python submission (verdict: Runtime Error):
N, A = [int(_) for _ in input().split()]

MAX_I = 1000
memo = [[0] * MAX_I for _ in range(N + 2)]


def cnv(v):
    return v - A + (MAX_I // 2)


X = [int(_) for _ in input().split()]
for i in range(N):
    offset = X[i] - A
    # print('x', offset)

    mm = memo[i]
    for j in range(MAX_I):
        if mm[j] > 0:
            memo[i + 1][j + offset] += mm[j]
        memo[i + 1][j] += mm[j]

    memo[i + 1][cnv(X[i])] += 1

print(memo[N][MAX_I//2])


Fixed submission:
N, A = [int(_) for _ in input().split()]

MAX_I = 5000
memo = [[0] * MAX_I for _ in range(N + 2)]


def cnv(v):
    return v - A + (MAX_I // 2)


X = [int(_) for _ in input().split()]
for i in range(N):
    offset = X[i] - A
    # print('x', offset)

    mm = memo[i]
    for j in range(MAX_I):
        if mm[j] > 0:
            memo[i + 1][j + offset] += mm[j]
        memo[i + 1][j] += mm[j]

    memo[i + 1][cnv(X[i])] += 1

print(memo[N][MAX_I//2])

Buggy python submission (verdict: Runtime Error):
N, A = [int(_) for _ in input().split()]

MAX_I = 200
memo = [[0] * MAX_I for _ in range(N + 2)]


def cnv(v):
    return v - A + (MAX_I // 2)


X = [int(_) for _ in input().split()]
for i in range(N):
    offset = X[i] - A
    # print('x', offset)

    mm = memo[i]
    for j in range(MAX_I):
        if mm[j] > 0:
            # print('j+x', j + offset)
            memo[i + 1][j + offset] += mm[j]
        memo[i + 1][j] += mm[j]

    memo[i + 1][cnv(X[i])] += 1
    # print(memo[i + 1][90:110])

print(memo[i + 1][100])


Fixed submission:
N, A = [int(_) for _ in input().split()]

MAX_I = 5000
memo = [[0] * MAX_I for _ in range(N + 2)]


def cnv(v):
    return v - A + (MAX_I // 2)


X = [int(_) for _ in input().split()]
for i in range(N):
    offset = X[i] - A
    # print('x', offset)

    mm = memo[i]
    for j in range(MAX_I):
        if mm[j] > 0:
            memo[i + 1][j + offset] += mm[j]
        memo[i + 1][j] += mm[j]

    memo[i + 1][cnv(X[i])] += 1

print(memo[N][MAX_I//2])
Buggy python submission (verdict: Time Limit Exceeded):
H, W, A, B = [int(_) for _ in input().split()]
p = 10 ** 9 + 7


# 二分累乗法 で n^x % p を求める
# pow(n,x,p) で得られるので次からはそっちつかう
def power(n, x, p):
    a = n  # a^(2^0), a^(2^1), ...
    ans = 1
    while x > 0:
        if x & 1:
            ans = (ans * a) % p
        x = x >> 1
        a = (a ** 2) % p
    return ans


def solve():
    kaijo = [0] * (H + W + 1)
    kaijo[0] = kaijo[1] = 1
    for i in range(2, H + W + 1):
        kaijo[i] = (i * kaijo[i - 1]) % p
    gyaku = [0] * (H + W + 1)
    gyaku[0] = gyaku[1] = 1
    for i in range(2, H + W + 1):
        gyaku[i] = power(kaijo[i], p - 2, p)

    # for i in range(H + W + 1):
    #     assert (kaijo[i] * gyaku[i]) % p == 1, (kaijo[i], gyaku[i])

    def conb(_x, _y):
        return (kaijo[_x] * gyaku[_y] * gyaku[_x - _y]) % p

    # h = H - A - 1
    # h2 = H - (H - A)
    ans = 0
    for i in range(W - B):
        ans = (ans + conb(H - A - 1 + B + i, H - A - 1) * conb(A - 1 + W - 1 - B - i, A - 1)) % p
    # for i in range(B, W):
    #     tmp1 = kaijo[h + i] * gyaku[h + i] * gyaku[h + i - max(h, i)]
    #     j = W - i - 1
    #     tmp2 = kaijo[h2 + j] * gyaku[h2 + j] * gyaku[h2 + j - max(h2, j)]
    #     ans = (ans + tmp1 * tmp2) % p
    # print(ans)
    print(ans)


if __name__ == '__main__':
    solve()

Fixed submission:
H, W, A, B = [int(_) for _ in input().split()]
p = 10 ** 9 + 7


# 二分累乗法 で n^x % p を求める
# pow(n,x,p) で得られるので次からはそっちつかう
def power(n, x, p):
    return pow(n,x,p)
    # a = n  # a^(2^0), a^(2^1), ...
    # ans = 1
    # while x > 0:
    #     if x & 1:
    #         ans = (ans * a) % p
    #     x = x >> 1
    #     a = (a ** 2) % p
    # return ans


def solve():
    kaijo = [0] * (H + W + 1)
    kaijo[0] = kaijo[1] = 1
    for i in range(2, H + W + 1):
        kaijo[i] = (i * kaijo[i - 1]) % p
    gyaku = [0] * (H + W + 1)
    gyaku[0] = gyaku[1] = 1
    for i in range(2, H + W + 1):
        gyaku[i] = power(kaijo[i], p - 2, p)

    # for i in range(H + W + 1):
    #     assert (kaijo[i] * gyaku[i]) % p == 1, (kaijo[i], gyaku[i])

    def conb(_x, _y):
        return (kaijo[_x] * gyaku[_y] * gyaku[_x - _y]) % p

    # h = H - A - 1
    # h2 = H - (H - A)
    ans = 0
    for i in range(W - B):
        ans = (ans + conb(H - A - 1 + B + i, H - A - 1) * conb(A - 1 + W - 1 - B - i, A - 1)) % p
    # for i in range(B, W):
    #     tmp1 = kaijo[h + i] * gyaku[h + i] * gyaku[h + i - max(h, i)]
    #     j = W - i - 1
    #     tmp2 = kaijo[h2 + j] * gyaku[h2 + j] * gyaku[h2 + j - max(h2, j)]
    #     ans = (ans + tmp1 * tmp2) % p
    # print(ans)
    print(ans)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if c-a-b>0:
  if 4*a*b<(c-a-b)**2:
  	print('Yes')
  else:
  	print('No')
else:
  print('No')

Fixed submission:
K=int(input())
li=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
li=[]
N,A,B=map(int,input().split())
for i in range((N//(A+B))):
    for i in range(A):
        li.append("b")
    for i in range(B):
        li.append("r")
ctpossible=li.count("b")#ペアでカウント可能
if N%(A+B)<=A:
    adding=N%(A+B)
else:
    adding=A
print(ctpossible+adding)


Fixed submission:
N,A,B=map(int,input().split())
ctpossible=A*(N//(A+B))#ペアでカウント可能
if N%(A+B)<=A:
    adding=N%(A+B)
else:
    adding=A
print(ctpossible+adding)
Buggy python submission (verdict: Runtime Error):
s=input()
if s+%2==0:
  print(s/2)
  else:
    print((s+1)/2)

Fixed submission:
s=int(input())
if s%2==0:
  print(int(s/2))
else:
  print(int((s+1)/2))
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(min(S),max(S)):
    summ = 0
    for j in range(0,N):#実際にsumを求める
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(min(S)-100,max(S)+100):
    summ = 0
    for j in range(0,N):#実際にsumを求める
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(S[0],S[N-1]):
    summ = 0
    for j in range(0,N):#実際にsumを求める
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(min(S)-100,max(S)+100):
    summ = 0
    for j in range(0,N):#実際にsumを求める
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
print(S)
memo=[]
for i in range(S[0],S[N-1]):
    summ = 0
    for j in range(0,N):#実際にsumを求める
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(min(S)-100,max(S)+100):
    summ = 0
    for j in range(0,N):#実際にsumを求める
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
binary=(format(n,"b"))#二進数に変換
templi=[binary[i] for i in range(len(str(binary)))]
templi.reverse()
res=2
beki=1
for i in range(0,len(templi)):
    if templi[i]=="1":
        beki*=res
    else:
        beki*=1
    res=res**2
firs=beki-1
#conbination_algorithm
def kaijo(k):
    sum=1
    for j in range(1,k+1):
        sum*=j
    return sum
def comb(n,k):
    ans=int(kaijo(n))/(int(kaijo(k))*int(kaijo(n-k)))
    return int(ans)
#subtract
sub_1=comb(n,a)+comb(n,b)
print((firs-sub_1)%(10**9+7))

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9+7
def comb(n, r, mod):
    if r == 0 or r == n:
        return 1
    r = min([r, n-r])
    x, y = 1, 1
    for i in range(1, r+1):
        x *= n+1-i
        x %= mod
        y *= i
        y %= mod
    return x*pow(y, mod-2, mod)%mod

ans = (pow(2, n, mod)-1-comb(n, a, mod)-comb(n, b, mod))%mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
firs=2**n-1
#conbination_algorithm
def kaijo(k):
    sum=1
    for j in range(1,k+1):
        sum*=j
    return sum
def comb(n,k):
    ans=int(kaijo(n))/(int(kaijo(k))*int(kaijo(n-k)))
    return int(ans)
#subtract
sub_1=comb(n,a)+comb(n,b)
print((firs-sub_1)%(10**9+7))

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9+7
def comb(n, r, mod):
    if r == 0 or r == n:
        return 1
    r = min([r, n-r])
    x, y = 1, 1
    for i in range(1, r+1):
        x *= n+1-i
        x %= mod
        y *= i
        y %= mod
    return x*pow(y, mod-2, mod)%mod

ans = (pow(2, n, mod)-1-comb(n, a, mod)-comb(n, b, mod))%mod
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
list=[]#素因数の格納
for i in range(1,int(math.sqrt(N))):
    if N//i==N/i:
        list.append(N//i+i)
print(min(list)-2)

Fixed submission:
import math
N=int(input())
list=[]#素因数の格納
for i in range(1,int(math.sqrt(N))+2):
    if N//i==N/i:
        list.append(N//i+i)
print(min(list)-2)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
list=[S[i] for i in range(N)]
for i in range(N-1):
    for j in range(i+1,N):
        if list[i]==list[j]:
            list[j]="0"
        else:
            break
list=[s for s in list if s != '0']
print(len(list))


Fixed submission:
N=int(input())
S=input()
list=[S[i] for i in range(N)]
for i in range(N-1):
        if list[i]==list[i+1]:
            list[i]="0"
list=[s for s in list if s != '0']
print(len(list))