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

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

max_num = (N - 1) * (N - 2) // 2

if K > max_num:
    print(-1)
else:
    edges = []
    for i in range(2, N + 1):
        edges.append((1, i,))

    add = max_num - K

    candidates = []
    for i in range(2, N):
        for j in range(i + 1, N + 1):
            candidates.append((i, j,))

    for i in range(add):
        edges.append(candidates[i])

    print(len(edges))
    for edge in edges:
        print(' '.join(map(str, edge)))

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

max_num = (N - 1) * (N - 2) // 2

for i in range(2, N + 1):
    print(1, i)

add = max_num - K

edges = []
for i in range(2, N):
    for j in range(i + 1, N + 1):
        edges.append(i, j)

for i in range(add):
    print(edges[i])

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

max_num = (N - 1) * (N - 2) // 2

for i in range(2, N + 1):
    print(1, i)

add = max_num - K

edges = []
for i in range(2, N):
    for j in range(i + 1, N + 1):
        edges.append(i, j)

for i in range(add):
    print(edges[i])
Problem p03014 (python)

Fixed submission:
import numpy as np

h, w = map(int, input().split())
grid = [[False for j in range(w)] for i in range(h)]

for i in range(h):
    s = input()
    for j in range(w):
        if s[j] == '.':
            grid[i][j] = 1
        else:
            grid[i][j] = 0

grid = np.array(grid)

L = np.zeros((h, w), dtype=int)
R = np.zeros((h, w), dtype=int)
U = np.zeros((h, w), dtype=int)
D = np.zeros((h, w), dtype=int)

for j in range(w):
    if j == 0:
        L[:, j] = grid[:, j]
    else:
        L[:, j] = (L[:, j - 1] + 1) * grid[:, j]


for j in range(w - 1, -1, -1):
    if j >= w - 1:
        R[:, j] = grid[:, j]
    else:
        R[:, j] = (R[:, j + 1] + 1) * grid[:, j]

for i in range(h):
    if i <= 0:
        U[i, :] = grid[i, :]
    else:
        U[i, :] = (U[i - 1, :] + 1) * grid[i, :]


for i in range(h - 1, -1, -1):
    if i >= h - 1:
        D[i, :] = grid[i, :]
    else:
        D[i, :] = (D[i + 1, :] + 1) * grid[i, :]

print(np.max(L + R + U + D - 3))

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

h, w = map(int, input().split())
grid = [[False for j in range(w)] for i in range(h)]

for i in range(h):
    grid = []
    for i in range(h):
        grid.append(list(input()))
    grid = (np.array(grid) == ".") * 1  # ランプをおける:1, 障害物:0

grid = np.array(grid)

L = np.zeros((h, w), dtype=int)
R = np.zeros((h, w), dtype=int)
U = np.zeros((h, w), dtype=int)
D = np.zeros((h, w), dtype=int)

for j in range(w):
    if j == 0:
        L[:, j] = grid[:, j]
    else:
        L[:, j] = (L[:, j - 1] + 1) * grid[:, j]


for j in range(w - 1, -1, -1):
    if j >= w - 1:
        R[:, j] = grid[:, j]
    else:
        R[:, j] = (R[:, j + 1] + 1) * grid[:, j]

for i in range(h):
    if i <= 0:
        U[i, :] = grid[i, :]
    else:
        U[i, :] = (U[i - 1, :] + 1) * grid[i, :]


for i in range(h - 1, -1, -1):
    if i >= h - 1:
        D[i, :] = grid[i, :]
    else:
        D[i, :] = (D[i + 1, :] + 1) * grid[i, :]

print(np.max(L + R + U + D - 3))
Problem p03032 (python)

Fixed submission:
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for a in range(min(n, k) + 1):
    for b in range(min(n, k) - a + 1):
        li = v[:a]
        if b > 0:
            li += v[-b:]
        li.sort()
        count = 0
        while (a + b + count < k):
            if len(li) > 0 and li[0] < 0:
                count += 1
                li = li[1:]
            else:
                break
        ans = max(ans, sum(li))

print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
import copy

n, k = map(int, input().split())
v = list(map(int, input().split()))


def dfs(q, have, count, operate):
    if operate == 0:
        heapq.heappush(have, q[0])
        q = q[1:]
    elif operate == 1:
        heapq.heappush(have, q[-1])
        q = q[:-1]
    elif operate == 2:
        sub = heapq.heappop(have)
        q.insert(0, sub)
    elif operate == 3:
        sub = heapq.heappop(have)
        q.append(sub)

    count += 1
    if count >= k:
        return sum(have)

    a = dfs(copy.deepcopy(q), copy.deepcopy(have), count, 0)
    b = dfs(copy.deepcopy(q), copy.deepcopy(have), count, 1)
    c = -float('inf')
    d = -float('inf')
    e = dfs(q, have, count, -1)  # 何もしない
    if len(have) > 0:
        c = dfs(copy.deepcopy(q), copy.deepcopy(have), count, 2)
        d = dfs(copy.deepcopy(q), copy.deepcopy(have), count, 3)

    return max(a, b, c, d, e)


print(dfs(v, [], -1, -1))
Problem p03040 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from heapq import heappush, heappop

qn = int(input())

low = []
high = []
ans = 0
num = 0

for i in range(qn):
    q = [int(i) for i in input().split()]
    if q[0] == 1:
        # update
        ans += q[2]
        a = q[1]
        heappush(low, -a)
        heappush(high, a)
        if -low[0] > high[0]:
            low0 = heappop(low)
            high0 = heappop(high)
            heappush(low, -high0)
            heappush(high, -low0)
            ans += -low0 - high0
    if q[0] == 2:
        print(-low[0], ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from heapq import heappush, heappop

qn = int(input())

low = []
high = []
ans = 0
num = 0

for i in range(qn):
    q = [int(i) for i in input().split()]
    if q[0] == 1:
        ans += q[2]
        a = q[1]
        if a < -low[0]:
            ans += -low[0] - a
        elif a > high[0]:
            ans += a - high[0]

        # lowは降順に並べたいので-aを入れる
        heappush(low, -a)
        heappush(high, a)
        if -low[0] > high[0]:
            low0 = heappop(low)
            high0 = heappop(high)
            # lowとhighで正負が逆なので注意する
            heappush(low, -high0)
            heappush(high, -low0)
    elif q[0] == 2:
        print(-low[0], ans)
Problem p03044 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(100100)

n = int(input())
g = [[] for i in range(n)]
c = [-1 for i in range(n)]

for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    w = w % 2
    g[u].append([v, w])
    g[v].append([u, w])


def dfs(p, d):
    if c[p] == -1:
        c[p] = d
        for x, w in g[p]:
            dfs(x, d ^ w)


dfs(0, 0)

for i in range(len(c)):
    print(c[i])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
g = [[] for i in range(n)]
c = [-1 for i in range(n)]

for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    w = w % 2
    g[u].append([v, w])
    g[v].append([u, w])


def dfs(p, d):
    if c[p] == -1:
        c[p] = d
        for x, w in g[p]:
            dfs(x, d ^ w)


dfs(0, 0)

for i in range(len(c)):
    print(c[i])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
g = [[] for i in range(n)]
c = [-1 for i in range(n)]

for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append([v, w % 2])
    g[v].append([u, w % 2])


def dfs(p, d):
    if c[p] == -1:
        c[p] = d
        for x, w in g[p]:
            dfs(x, (d + w) % 2)


dfs(0, 0)

for i in range(len(c)):
    print(c[i])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
g = [[] for i in range(n)]
c = [-1 for i in range(n)]

for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])


def dfs(p, d):
    if c[p] == -1:
        c[p] = d
        for x, w in g[p]:
            dfs(x, (d + w) % 2)


dfs(0, 0)

for i in range(len(c)):
    print(c[i])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
g = [[] for i in range(n)]
c = [-1 for i in range(n)]

for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])


def distance(p, d):
    if c[p] == -1:
        c[p] = d
        for x, w in g[p]:
            distance(x, (d + w) % 2)


distance(0, 0)

for v in c:
    print(v)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
g = [[] for i in range(n)]
c = [-1 for i in range(n)]

for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])


def distance(p, d):
    if c[p] == -1:
        c[p] = d % 2
        print(p, d, c[p])
        for x, w in g[p]:
            distance(x, d + w)


distance(0, 0)

for v in c:
    print(v)
Problem p03059 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a, b, t = map(int, input().split())

print(b * (t // a))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

ans = 0
count = 0
for i in range(n):
    if a[i] < 0:
        a[i] = -a[i]
        count += 1
    ans += a[i]

if count % 2 == 0:
    print(ans)
else:
    print(ans - min(a) * 2)
Problem p03074 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
s = input()
nums = []
now = 1

cnt = 0
for i in range(n):
    if s[i] == str(int('0') + now):
        cnt += 1
    else:
        nums.append(cnt)
        now = 1 - now
        cnt = 1

if cnt != 0:
    nums.append(cnt)

ans = 0
left = 0
right = 0
tmp = 0

for i in range(0, len(nums), 2):
    next_left = i
    next_right = min(i + 2 * k + 1, len(nums))

    while (left < next_left):
        tmp -= nums[left]
        left += 1

    while (right < next_right):
        tmp += nums[right]
        right += 1

    ans = max(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
s = input()
bl = []

left = -1
right = 0
for i in range(len(s)):
    if s[i] == '0':
        if left < 0:
            left = i
        if i == n - 1:
            right = n
            bl.append((left, right))
    else:
        if left >= 0:
            right = i
            bl.append((left, right))
            left = -1


def change(index, count, ts):
    if count >= k or index >= len(bl):
        max_seq = 0
        seq = 0
        for i in range(len(ts)):
            if ts[i] == '1':
                seq += 1
                if i == n - 1:
                    max_seq = max(max_seq, seq)
            else:
                max_seq = max(max_seq, seq)
                seq = 0
        return max_seq

    new_s = ts[:bl[index][0]] + '1' * \
        (bl[index][1] - bl[index][0]) + ts[bl[index][1]:]
    return max(change(index + 1, count + 1, new_s),
               change(index + 1, count, ts))


if k >= len(bl):
    print(len(s))
else:
    print(change(0, 0, s))
Problem p03078 (python)

Fixed submission:
import heapq

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.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

cnt = 0
q = []
arg = (0, 0, 0)
visited = {}
visited[arg] = True
heapq.heappush(q, (-(a[arg[0]] + b[arg[1]] + c[arg[2]]),) + arg)

while cnt < k:
    score, ia, ib, ic = heapq.heappop(q)
    print(-score)
    cnt += 1
    arg_a = (ia + 1, ib, ic)
    arg_b = (ia, ib + 1, ic)
    arg_c = (ia, ib, ic + 1)
    if arg_a[0] <= x - 1 and arg_a not in visited:
        heapq.heappush(
            q, (-(a[arg_a[0]] + b[arg_a[1]] + c[arg_a[2]]),) + arg_a)
        visited[arg_a] = True
    if arg_b[1] <= y - 1 and arg_b not in visited:
        heapq.heappush(
            q, (-(a[arg_b[0]] + b[arg_b[1]] + c[arg_b[2]]),) + arg_b)
        visited[arg_b] = True
    if arg_c[2] <= z - 1 and arg_c not in visited:
        heapq.heappush(
            q, (-(a[arg_c[0]] + b[arg_c[1]] + c[arg_c[2]]),) + arg_c)
        visited[arg_c] = True

Buggy submission (verdict: Runtime Error):
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()))

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])


ab.sort(reversed=True)
c.sort(reversed=True)

abc = []
for i in range(k):
    for j in range(z):
        abc.append(ab[i] + c[i])


abc.sort(reversed=True)
for i in range(k):
    print(abc[i])

Buggy submission (verdict: Runtime Error):
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()))

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])


ab.sort(reversed=True)
c.sort(reversed=True)

abc = []
for i in range(k):
    for j in range(z):
        abc.append(ab[i] + c[i])


abc.sort(reversed=True)
for i in range(k):
    print(abc[i])
Problem p03148 (python)

Fixed submission:
import heapq

N, K = map(int, input().split())
sushi = []
for i in range(N):
    t, d = map(int, input().split())
    heapq.heappush(sushi, (-d, t))

total = 0
types = set()
remain = []
for i in range(K):
    d, t = heapq.heappop(sushi)
    total -= d
    if t not in types:
        types.add(t)
    else:
        # 余りの寿司はremainにappend
        heapq.heappush(remain, -d)

types_len = len(types)
ans = total + types_len ** 2

while sushi and remain:
    d, t = heapq.heappop(sushi)
    if t not in types:
        types.add(t)
        remain_d = heapq.heappop(remain)
        total = total - d - remain_d
        types_len += 1
        ans = max(ans, total + types_len ** 2)

print(ans)

Buggy submission (verdict: Runtime Error):
import heapq

N, K = map(int, input().split())
sushi = []
for i in range(N):
    t, d = map(int, input().split())
    heapq.heappush(sushi, (-d, t))

total = 0
types = set()
remain = []
for i in range(K):
    d, t = heapq.heappop(sushi)
    total -= d
    if t not in types:
        types.append(t)
    else:
        # 余りの寿司はremainにappend
        heapq.heappush(remain, -d)

types_len = len(types)
ans = total + types_len ** 2

while sushi and remain:
    d, t = heapq.heappop(sushi)
    if t not in types:
        types.append(t)
        remain_d = heapq.heappop(remain)
        total = total - d - remain_d
        types_len += 1
        ans = max(ans, total + types_len ** 2)

print(ans)
Problem p02555 (python)

Fixed submission:
S = int(input())

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

ans = [0 for _ in range(2001)]

ans[3] = 1
ans[4] = 1
ans[5] = 1

for i in range(6, S+1):
    ans[i] = ans[i-3] + ans[i-1]

print(ans[S] % 1000000007)

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

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

ans = [0 for _ in range(S+1)]

ans[3] = 1
ans[4] = 1
ans[5] = 1

for i in range(6, S+1):
    ans[i] = ans[i-3] + ans[i-1]

print(ans[S] % 1000000007)
Problem p02609 (python)

Fixed submission:
N = int(input())
S = input()
X = int(S, 2)
pcx = S.count('1')
# ビット反転で1が0になる場合
pc1 = X % (pcx - 1) if pcx > 1 else 0
# ビット反転で0が1になる場合
pc2 = X % (pcx + 1)


def f(j):
    cnt = 0
    while j:
        j %= bin(j).count('1')
        cnt += 1
    return cnt


for i, y in enumerate(S):
    k = N - i - 1
    if y == "0":  # modを分配するときは、分配してからもう１回modを作用させれば良い
        print(f((pc2 + pow(2, k, pcx + 1)) % (pcx + 1)) + 1)
    elif pcx > 1:
        print(f((pc1 - pow(2, k, pcx - 1)) % (pcx - 1)) + 1)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = input()
flag1 = 0
flag0 = 0


def popcount(n: int):
    bin_n = bin(n)
    return str(bin_n).count('1')


popcount_X = popcount(int(X, 2))

for i in range(N):
    count = 0
    if X[i] == '1':
        tmp = int(X)
        tmp -= 10 ** (N - i - 1)
        flag1 += 1
    else:
        tmp = int(X)
        tmp += 10 ** (N - i - 1)
        flag0 += 1
    tmp = int(str(tmp), 2)

    while True:
        if tmp == 0:
            print(count)
            break
        elif flag1:
            count += 1
            tmp = tmp % (popcount_X-1)
            flag1 = 0
        elif flag0:
            count += 1
            tmp = tmp % (popcount_X+1)
            flag0 = 0
        else:
            count += 1
            tmp = tmp % popcount(tmp)

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

dp = [0] * (2 ** N + 1)


def popcount(n: int):
    bin_n = bin(n)
    return str(bin_n).count('1')


for i in range(N):
    count = 0
    if X[i] == '1':
        tmp = int(X)
        tmp -= 10 ** (N - i - 1)
    else:
        tmp = int(X)
        tmp += 10 ** (N - i - 1)

    tmp = int(str(tmp), 2)
    origin = tmp

    while True:
        if tmp == 0:
            dp[origin] = count
            print(count)
            break
        elif tmp == 1:
            dp[origin] = count + 1
            print(count + 1)
            break
        elif tmp == 2:
            dp[origin] = count + 1
            print(count + 1)
            break
        elif dp[tmp] != 0:
            dp[origin] = count + dp[tmp]
            print(count + dp[tmp])
            break
        else:
            count += 1
            tmp = tmp % popcount(tmp)
Problem p02641 (python)

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

if N == 0:
    print(X)

else:
    p = list(map(int, input().split()))
    q = [i for i in range(-1, 102)]

    for r in p:
        idx = q.index(r)
        del q[idx]

    if X in q:
        print(X)

    else:
        q.sort()
        mindif = 1000

        for num in q:
            dif = abs(X - num)
            if mindif <= dif:
                break
            else:
                mindif = dif
                ans = num
        print(ans)

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

if N == 0:
    print(X)

else:
    p = list(map(int, input().split()))
    q = [i for i in range(-1, 102)]

    for r in p:
        idx = q.index(r)
        del q[idx]

    if X in q:
        print(X)

    else:
        q.sort()
        mindif = 100

        for num in q:
            dif = abs(X - num)
            if mindif <= dif:
                break
            else:
                mindif = dif
                ans = num
        print(ans)

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

if N == 0:
    print(X)

else:
    p = list(map(int, input().split()))
    q = [i for i in range(0, 101)]

    for r in p:
        idx = q.index(r)
        del q[idx]

    if X in q:
        print(X)

    else:
        q.sort()
        mindif = 100

        for num in q:
            dif = abs(X - num)
            if mindif <= dif:
                break
            else:
                mindif = dif
                ans = num
        print(ans)
Problem p02642 (python)

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

max_A = A[-1] + 1
ans = [0] * max_A

for i in A:
    ans[i] += 1
    if ans[i] == 1:
        for j in range(i*2, max_A, i):
            ans[j] = 2

print(ans.count(1))

Buggy submission (verdict: Runtime Error):
import copy

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

A.sort()


def div_by_min(a: list, start: int):
    dic = {k: 0 for k in a}
    for i in range(start+1, len(a)):
        if not dic:
            break
        if a[i] % a[start] == 0:
            del dic[a[i]]
    ans_list = list(dic.keys())
    return ans_list


Start = 0
prev_len = 1000000
tmp = A

while True:
    if Start >= len(tmp):
        break
    else:
        tmp = div_by_min(tmp, Start)
        if prev_len == len(tmp):
            Start += 1
        else:
            prev_len = len(tmp)
            Start = 0

print(len(tmp))
Problem p02645 (python)

Fixed submission:
S = input()
print(S[0:3])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
tmp = [0] * N
count = 0
keys = [i for i in range(N)]
bulb_to_check = {key: 0 for key in keys}

for t in range(K):
    if not bulb_to_check:
        break
    for i in bulb_to_check:  # i番目の電球の明るさを決定する
        if A[i] == N:
            del bulb_to_check[i]  # 最大値に達した電球を対象から除く
        else:
            for j in range(N):  # 各電球jが、電球iを照らしているかを確認する
                if j - A[j] - 0.5 <= i <= j + A[j] + 0.5:
                    count += 1
            tmp[i] = count
        count = 0
    for l in range(N):
        A[l] = tmp[l]

print(*A)
Problem p02657 (python)

Fixed submission:
A, B = map(int, input().split())

print(A * B)

Buggy submission (verdict: Runtime Error):
A, B = input().split()


A = int(A)
x = int(B[0]) * 100
y = int(B[1]) * 10
z = int(B[2]) * 1

C = x + y + z

print((A * C) // 100)
Problem p02789 (python)

Fixed submission:
N, M = map(int, input().split())
if N == M:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
D = {i: 0 for i in range(100)}
for i in range(1, N+1):
    if i % 10 != 0:
        s = str(i)
        D[int(s[0])*10+int(s[-1])] += 1
S = 0
for i in range(10):
    for j in range(10):
        S += D[i*10+j] * D[j*10+i]
print(S)
Problem p02811 (python)

Fixed submission:
K, X = map(int, input().split())
wealth = 500 * K
if wealth >= X:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
K, X = map(int, input().split())
wealth = 500 * K
if K >= X:
  print('Yes")
else:
  print('No')

Buggy submission (verdict: Runtime Error):
K, X = int(input())
wealth = 500 * K
if K >= X:
  print('Yes")
else:
  print('No')
Problem p02898 (python)

Fixed submission:
N, K = map(int, input().split())
heights = list(map(int, input().split()))
qualified = 0

for height in heights:
    if height >= K:
        qualified += 1

print(qualified)

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

for height in heights:
    if height < K:
        unqualified += 1

print(unqualified)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
count = 0

for i in range(3):
    if S[i] == T[i]:
        count += 1
        
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(N * (N-1) // 2)
Problem p02960 (python)

Fixed submission:
S = input()
N = len(S)
dp = []
for _ in range(N+1):
    dp.append([0] * 13)
dp[0][0] = 1
p = 10**9+7

for i in range(1, N+1):
    X = S[N-i]
    if X == '?':
        for j in range(10):
            X = (j * pow(10, i-1, 13)) % 13
            for k in range(13):  # 上段の各あまりに対して、xのあまりを加える
                Y = dp[i-1][k]
                Z = (X + k) % 13  # 新たなあまり
                dp[i][Z] += Y % p

    else:
        X = int(X)
        X = (X * pow(10, i-1, 13)) % 13
        for k in range(13):  # 上段の各あまりに対して、xのあまりを加える
            Y = dp[i-1][k]
            Z = (X + k) % 13  # 新たなあまり
            dp[i][Z] += Y % p

print(dp[-1][5] % 1000000007)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
dp = []
for _ in range(N+1):
    dp.append([0] * 13)

for i in range(1, N+1):
    X = S[N-i]
    if X == '?':
        if i == 1:
            for j in range(10):
                dp[1][j] += 1
            continue
        for j in range(10):
            X = (j * pow(10, i-1, mod=13)) % 13
            for k in range(13):  # 上段の各あまりに対して、xのあまりを加える
                Y = dp[i-1][k]
                Z = (X + k) % 13  # 新たなあまり
                dp[i][Z] += Y

    else:
        X = int(X)
        X = (X * pow(10, i-1, mod=13)) % 13
        if i == 1:
            dp[1][X] += 1
            continue
        for k in range(13):  # 上段の各あまりに対して、xのあまりを加える
            Y = dp[i-1][k]
            Z = (X + k) % 13  # 新たなあまり
            dp[i][Z] += Y

print(dp[-1][5] % 1000000007)
Problem p02993 (python)

Fixed submission:
S = input()
flag = 0

for i in range(3):
    if S[i] == S[i+1]:
        flag += 1

if flag:
    print('Bad')
else:
    print('Good')

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

for i in range(3):
    if S[i] == S[i+1]:
        flag += 1

if flag:
    print('Bad')
else:
    print('Good')
Problem p03000 (python)

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

coordinate = 0
count = 0

while count < N:
    coordinate += L[count]
    if coordinate > X:
        break
    else:
        count += 1

print(count+1)

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

coordinate = 0
count = 1

while True:
    coordinate += L[count-1]
    if coordinate > X:
        break
    else:
        count += 1

print(count)