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

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

A_cs = A.cumsum()
A_cs = A_cs - A_cs[-1]/2
div = np.abs(A_cs).argmin()

print(abs(A[:div+1].sum() - A[div+1:].sum()))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

A_cs = A.cumsum()
A_cs = A_cs - A_cs[-1]/2
div = np.abs(A_cs).argmin()

print(abs(A[:div+1].sum - A[div+1:].sum()))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

A_cs = A.cumsum()
A_cs = A_cs - A_cs[-1]/2
div = np.abs(A_cs).argmin()

print(abs(A[:div+1].sum()A - [div+1:].sum()))
Problem p02866 (python)

Fixed submission:
from collections import Counter


def solve(n, arr):
    if arr[0] != 0:
        return 0

    c = Counter(arr)

    if c[0] != 1:
        return 0
    max_c = max(c)
    for i in range(max_c + 1):
        if i not in c:
            return 0

    c = list(c.items())
    c.sort()

    prev = 1
    ans = 1
    mod = 998244353

    for _, i in c[1:]:
        ans *= pow(prev, i) % mod
        ans %= mod
        prev = i

    return ans


n = int(input())
arr = list(map(int, input().split()))

print(solve(n, arr))

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter

n = int(input())
arr = list(map(int, input().split()))

c = list(Counter(arr).items())

c.sort()

if c[0][0] != 0 or c[0][1] != 1:
    print(0)
    sys.exit()

prev_k = 0
prev_v = 1
ans = 1
mod = 998244353
for k, v in c[1:]:
    if k - prev_k > 1:
        print(0)
        sys.exit()
    else:
        ans *= pow(prev, i) % mod
        ans %= mod
        prev_k = k
        prev_v = v

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter


def solve(n, arr):
    if arr[0] != 0:
        return 0

    c = Counter(arr)
    c.sort()

    if len(c) != max(c.keys()) + 1:
        return 0

    c = list(c.values())

    prev = c[0]
    ans = 1
    mod = 998244353

    for i in c[1:]:
        ans *= pow(prev, i) % mod
        ans %= mod
        prev = i

    return ans


n = int(input())
arr = list(map(int, input().split()))

print(solve(n, arr))
Problem p02882 (python)

Fixed submission:
import math
a, b, x = map(int, input().split())

if a**2 * b <= 2 * x:
    h = (a**2 * b - x) / a**2 * 2
    theta = h / (a**2 + h**2)**0.5
    ans = math.degrees(math.asin(theta))
else:
    h = 2 * x / a / b
    theta = h / (b**2 + h**2)**0.5
    ans = math.degrees(math.acos(theta))

print(ans)

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

if a**2 * b <= 2 * x:
    h = (a**2 * b - x) / a**2 * 2
    theta = h / (a**2 + h**2)**0.5
    ans = math.degrees(math.asin(theta))
else:
    h = 2 * x / a / b
    theta = h / (b**2 + h**2)**0.5
    ans = math.degrees(math.acos(theta))

print(ans)
Problem p02888 (python)

Fixed submission:
from bisect import bisect_left
import copy

n = int(input())
l = list(map(int, input().split()))
l.sort()


ans = 0
for small in range(n - 2):
    for mid in range(small + 1, n - 1):
        div = bisect_left(l, l[small] + l[mid], 0, n)
        if div > mid + 1:
            ans += div - mid - 1

print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_right
from itertools import combinations_with_replacement

n = int(input())
l = list(map(int, input().split()))
l.sort()

li = list(combinations_with_replacement(l, 2))
li = [x for x in li if x[0] != x[1] and x[1] != max(l)]

ans = 0
for small, mid in li:
    right = bisect_right(l, small + mid - 1)
    left = bisect_left(l, mid)
    ans += max(right - left - 1, 0)

print(ans)
Problem p02889 (python)

Fixed submission:
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

n, m, l = map(int, input().split())
INF = 1 << 60

dist = [[INF] * n for _ in range(n)]

for i in range(n):
    dist[i][i] = 0

for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    if c > l:
        continue
    dist[a][b] = c
    dist[b][a] = c


dist = floyd_warshall(csr_matrix(dist))

dist2 = np.full_like(dist, 1)
dist2[np.where(dist > l)] = INF
dist2 = floyd_warshall(dist2, directed=False)
dist2[dist2 == INF] = 0
dist2 = dist2.astype(int)

q = int(input())

ans = []
for _ in range(q):
    s, t = map(int, input().split())
    if dist[s - 1, t - 1] == -1:
        ans.append(-1)
    else:
        ans.append(dist2[s - 1, t - 1] - 1)

print(*ans, sep="\n")

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

n, m, l = map(int, input().split())

graph = defaultdict(list)

for _ in range(m):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    graph[b].append((a, c))


def dfs(u):
    dist = [-1] * (n + 1)
    stack = [u]
    dist[u] = 0
    while stack:
        u = stack.pop()
        for v, d in graph[u]:
            nxt = dist[u] + d
            if dist[v] == -1 or dist[v] > nxt:
                dist[v] = nxt
                stack.append(v)
    return dist


dist = [[0] * n for _ in range(n)]
for i in range(1, n + 1):
    dist[i - 1] = dfs(i)[1:]

dist = np.array(dist)

graph2 = np.full((n, n), np.inf)
graph2[dist <= l] = 1
dist = floyd_warshall(graph2, directed=False)
dist = dist.astype(int)

q = int(input())

ans = []
for _ in range(q):
    s, t = map(int, input().split())
    ans.append(dist[s - 1, t - 1] - 1)

print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
sys.setrecursionlimit(10**7)

n, m, l = map(int, input().split())

graph = defaultdict(list)

for _ in range(m):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    graph[b].append((a, c))


def dfs(u, l, rest):
    dist = [-1] * (n + 1)
    stack = [u]
    dist[u] = 0
    while stack:
        u = stack.pop()
        tmp_rest = rest
        for v, d in graph[u]:
            rest = tmp_rest
            rest -= d
            if rest < 0:
                nxt = dist[u] + 1
                rest = l
            else:
                nxt = dist[u]
            if dist[v] == -1 or dist[v] > nxt:
                dist[v] = nxt
                stack.append(v)
    return dist


q = int(input())

ans = []
for _ in range(q):
    s, t = map(int, input().split())
    ans.append(dfs(s, l, l)[t])

print(ans, sep="\n")
Problem p02911 (python)

Fixed submission:
import numpy as np
N, K, Q = map(int, input().split())
A = np.array([int(input()) for _ in range(Q)])

ans = np.zeros(N)
ans += K

for a in A:
    ans[a-1] += 1

ans -= Q

for a in ans:
    if a>0:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = np.array([int(input()) for _ in range(Q)])

ans = np.zeros(N)
ans += K

for a in A:
    ans[a-1] += 1

ans -= Q

for a in ans:
    if a>0:
        print("Yes")
    else:
        print("No")
Problem p02924 (python)

Fixed submission:
import numpy as np
N = int(input())
print(N*(N-1)//2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
print((np.arange(N-1) + 1).sum())
Problem p02936 (python)

Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())

graph = defaultdict(set)

for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a].add(b)
    graph[b].add(a)

arr = [0] * (n + 1)

for i in range(q):
    p, x = map(int, input().split())
    arr[p] += x


def solve():
    stack = [1]
    visited = [True] * 2 + [False] * (n - 1)

    while stack:
        curr = stack.pop()
        for leaf in graph[curr]:
            if visited[leaf]:
                continue
            stack.append(leaf)
            visited[leaf] = True
            arr[leaf] += arr[curr]

    return arr


arr = solve()

print(*arr[1:])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict


def dfs(u, add):
    cnt[u] += add
    for nu in graph[u]:
        dfs(nu, add)


n, q = map(int, input().split())
graph = defaultdict(list)

for _ in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)

cnt = [0] * (n + 1)


for _ in range(q):
    p, x = map(int, input().split())
    dfs(p, x)

print(*cnt[1:])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from collections import deque
import sys
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())

graph = defaultdict(deque)

for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

arr = [0] * (n + 1)

for i in range(q):
    p, x = map(int, input().split())
    arr[p] += x


visited = [False] * (n + 1)


def dfs(curr):
    stack = graph[curr]

    while stack:
        leaf = stack.pop()
        if visited[leaf]:
            continue
        arr[leaf] += arr[curr]
        visited[leaf] = True
        dfs(leaf)


print(*ans[1:])
Problem p02939 (python)

Fixed submission:
S = input()

memo = []
memo.append(S[0])
p = 1

while p<len(S):
    if len(memo[-1])==2:
        memo.append(S[p])
        p += 1
    elif memo[-1]!=S[p]:
        memo.append(S[p])
        p += 1
    elif p+1==len(S):
        break
    else:
        memo.append(S[p:p+2])
        p += 2
print(len(memo))

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

last = S[0]
ans = 1
cnt = 1

while cnt < len(S):
    if len(last)==1:
        if last != S[cnt]:
            last = S[cnt]
            ans += 1
            cnt += 1
        else:
            last = S[cnt:cnt+2]
            ans += 1
            cnt += 2
    if len(last)==2:
        last = S[cnt]
        ans += 1
        cnt += 1

print(ans)
Problem p02953 (python)

Fixed submission:
import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))

tmp_1 = H[np.where(H==H.max())[0].min():]
ans_1 = min(tmp_1) > max(H)-2

tmp2 = H[1:] - H[:-1]

ans_2 = all(tmp2 > -2)

print("Yes") if ans_1 & ans_2 else print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))

ans_1 = min(H[np.where(H==H.max())[0].min():]) > max(H)-2

tmp = H[1:] - H[:-1]

ans_2 = all(tmp2 > -2)

print("Yes") if ans_1 & ans_2 else print("No")
Problem p02983 (python)

Fixed submission:
import sys
L, R = map(int, input().split())
ans = []

def calc_mod(x, y):
    return x * y % 2019

left = L % 2019
right = R % 2019

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

elif left > right:
    print(0)
    sys.exit(0)

elif left==0 or right==0:
    print(0)
    sys.exit(0)

for i in range(left, right):
    for j in range(i+1, right+1):
        ans.append(calc_mod(i, j))

print(min(ans))

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
ans = []

def calc_mod(x, y):
    return x * y % 2019

left = L % 2019
right = R % 2019

for i in range(left, right):
    for j in range(i+1, right+1):
        ans.append(calc_mod(i, j))

print(min(ans))
Problem p02995 (python)

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

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

G = C * D // gcd(C, D)

ans_b = B - B//C - B//D + B//G
ans_a = A - 1 - (A-1)//C - (A-1)//D + (A-1)//G

print(ans_b - ans_a)

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

a, b = map(int, input().split())

ans_c = (B - A) // C
ans_d = (B - A) // D
i = (B - A) // (C * D // gcd(C, D))

print(B - A - ans_c - ans_d + i)

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

def gcd(a, b):
    if (b==0):
        return a
    else:
        return gcd(b, a % b)

a, b = map(int, input().split())

print(a*b // gcd(a, b))

ans_c = (B - A) // C
ans_d = (B - A) // D
i = (B - A) // (C * D // gcd(C, D))

print(B - A - ans_c - ans_d + i)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

ans_c = (B - A) // C
ans_d = (B - A) // D
i = (B - A) // (C * D // math.gcd(C, D))

print(B - A - ans_c - ans_d + i)

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B, C, D = map(int, input().split())
s = np.arange(A, B+1)

s = s[np.where(s%C != 0)]
s = s[np.where(s%D != 0)]

print(s.shape[0])
Problem p02996 (python)

Fixed submission:
import sys

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])

now = 0

for a, b in ab:
    now += a
    if now > b:
        print("No")
        sys.exit()

print("Yes")

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

n = int(input())

a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = np.array(a)
b = np.array(b)

diff = b - a

li = []
for x, y, z in zip(diff, a, b):
    li.append((x, y, z))

li = sort()
li = li[::-1]

stack = 0
for _, a, b in li:
    stack += a
    if stack > b:
        print("No")
        sys.exit()

print("Yes")

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

n = int(input())

a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = np.array(a)
b = np.array(b)

diff = b - a

li = []
for x, y, z in zip(diff, a, b):
    li.append((x, y, z))

li = sorted(reverse=True)

stack = 0
for _, a, b in li:
    stack += a
    if stack > b:
        print("No")
        sys.exit()

print("Yes")

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

n = int(input())

a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = np.array(a)
b = np.array(b)

diff = b - a

li = []
for x, y, z in zip(diff, a, b):
    li.append((x, y, z))

li = sortted(reverse=True)

stack = 0
for _, a, b in li:
    stack += a
    if stack > b:
        print("No")
        sys.exit()

print("Yes")
Problem p03006 (python)

Fixed submission:
from collections import defaultdict
import numpy as np
import sys

n = int(input())
xy = np.array([list(map(int, input().split())) for _ in range(n)])

if n == 1:
    print(1)
    sys.exit()

memo = defaultdict(int)

for i in xy:
    for j in xy:
        if np.all(i == j):
            continue
        else:
            tmp = j - i
            if tmp[0] < 0:
                tmp *= -1
            elif tmp[0] == 0 and tmp[1] < 0:
                tmp *= -1
            memo[str(tmp)] += 1

print(n - max(memo.values()) // 2)

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

n = int(input())
xy = np.array([list(map(int, input().split())) for _ in range(n)])

x = xy[xy.argsort(axis=0)[:, 0]]
y = xy[xy.argsort(axis=0)[:, 1]]

x = [list(x) for x in np.diff(x, axis=0)]
y = [list(y) for y in np.diff(y, axis=0)]


memo_x = defaultdict(int)
memo_y = defaultdict(int)

for i, j in zip(x, y):
    memo_x[str(i)] += 1
    memo_y[str(j)] += 1

print(n - max(max(memo_x.values()), max(memo_x.values())))
Problem p03031 (python)

Fixed submission:
import numpy as np
from itertools import product

N, M = map(int, input().split())
switch = []

for i in range(M):
    switch.append(list(map(int, input().split()))[1:])

p = list(map(int, input().split()))

st = list(product([0,1],repeat=N))

ans = 0

for i, s in enumerate(st):
    tmp = []
    for j, sw in enumerate(switch):
        on = 0
        for x in sw:
            on += s[x-1]
        if (on%2)==p[j]:
            tmp.append(True)
        else:
            tmp.append(False)
    if all(tmp)==True:
        ans += 1

print(ans)

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

N, M = map(int, input().split())
switch = []

for i in range(M):
    switch.append(list(map(int, input().split()))[1:])

# 剰余がこうなれば正解
p = list(map(int, input().split()))

# スイッチの状態の組み合わせを全列挙
st = list(product([0,1],repeat=N))

ans = 0

for i, s in enumerate(st):
    tmp = []
    for sw in switch:
        on = 0
        for x in sw:
            on += s[x-1]
        if (on%2)==p[m]:
            tmp.append(True)
        else:
            tmp.append(False)
    if all(tmp)==True:
        ans += 1

print(ans)
Problem p03049 (python)

Fixed submission:
n = int(input())

ans = 0
last_a = 0
first_b = 0
cnt = 0

for i in range(n):
    s = input()
    ans += s.count("AB")
    if s[-1] == "A":
        last_a += 1
    if s[0] == "B":
        first_b += 1
    if s[-1] == "A" and s[0] == "B":
        cnt += 1

if last_a == first_b & cnt > 0:
    ans += min(last_a, first_b) - 1
else:
    ans += min(last_a, first_b)

print(ans)

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

ans = 0
last_a = 0
first_b = 0
cnt = 0

for i in range(n):
    s = input()
    ans += s.count("AB")
    if s[-1] == "A":
        last_a += 1
    if s[0] == "B":
        first_b += 1
    if s[-1] == "A" and s[0] == "B":
        cnt += 1

if last_a == last_b:
    ans += min(last_a, last_b) - 1
else:
    ans += min(last_a, last_b)

print(ans)
Problem p03050 (python)

Fixed submission:
n = int(input())


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def is_favorite(n, m):
    if x == 0:
        return False
    else:
        return n // m == n % m


li = make_divisors(n)
li = [x - 1 for x in li]


ans = 0
for x in li:
    if is_favorite(n, x):
        ans += x

print(ans)

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


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# 約数から1引いたものが候補
arr = make_divisors(n)
arr = [x - 1 for x in arr]

#　商と剰余が不一致ならbreakできる
ans = 0
for x in arr[::-1]:
    if n // x != n % x:
        break
    ans += x

print(ans)
Problem p03069 (python)

Fixed submission:
import sys
import numpy as np
n = int(input())
s = list(map(str, input().rstrip()))

ss = s.count("#")
sd = s.count(".")

if ss == 0 or sd == 0:
    print(0)
    sys.exit()

s = np.array([x == "#" for x in s])

dp = np.zeros([2, n], dtype=int)

# dp0は黒の数、dp0は白の数
dp[0] = s
dp[1] = ~s

dp = dp.cumsum(axis=1)

# 白の数は「それ以降の」と読み替える
dp[1] = dp[1].max() - dp[1]

print(min((dp[0] + dp[1]).min(), ss, sd))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
n = int(input())
s = list(map(str, input().rstrip()))

if s.count("#") == 0 or s.count(".") == 0:
    print(0)
    sys.exit()

s = np.array([x == "#" for x in s])

dp = np.zeros([2, n], dtype=int)

# dp0は黒の数、dp0は白の数
dp[0] = s
dp[1] = ~s

dp = dp.cumsum(axis=1)

# 白の数は「それ以降の」と読み替える
dp[1] = dp[1].max() - dp[1]

print((min(dp[0] + dp[1]).min(), s.count("#"), s.count("."))
Problem p03074 (python)

Fixed submission:
from itertools import accumulate
n, k = map(int, input().split())
s = input() + "_"

compressed = []

first = s[0]
prev = s[0]
cnt = 1
for x in s[1:]:
    if prev == x:
        cnt += 1
    else:
        if x == "1":
            compressed.append(cnt)
            cnt = 1
        else:
            compressed.append(cnt)
            cnt = 1
    prev = x


result = [0] + list(accumulate(compressed))

ans = []
if first == "1":
    for i in range(0, len(result), 2):
        ans.append(result[min(i + k * 2 + 1, len(result) - 1)] - result[i])
    for j in range(1, len(result), 2):
        ans.append(result[min(j + k * 2, len(result) - 1)] - result[j])
else:
    for i in range(0, len(result), 2):
        ans.append(result[min(i + k * 2, len(result) - 1)] - result[i])
    for j in range(1, len(result), 2):
        ans.append(result[min(j + k * 2 + 1, len(result) - 1)] - result[j])

print(max(ans))

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
n, k = map(int, input().split())
s = input()

compressed = []

first = s[0]
prev = s[0]
cnt = 1
for x in s[1:]:
    if prev == x:
        cnt += 1
    else:
        if x == "1":
            compressed.append(cnt)
            cnt = 1
        else:
            compressed.append(cnt)
            cnt = 1
    prev = x
compressed.append(cnt)


result = [0] + list(accumulate(compressed))

ans = []
if first == "1":
    for i in range(0, (len(s) - 2 * k) // 2, 2):
        ans.append(result[i + 2 * k + 1] - result[i])
    for i in range(1, (len(s) - 2 * k) // 2, 2):
        ans.append(result[i + 2 * k] - result[i])
else:
    for i in range(0, (len(s) - 2 * k) // 2, 2):
        ans.append(result[i + 2 * k] - result[i])
    for i in range(1, (len(s) - 2 * k) // 2, 2):
        ans.append(result[i + 2 * k + 1] - result[i])

print(max(ans))
Problem p03076 (python)

Fixed submission:
import numpy as np
A, B, C, D, E = [int(input()) for i in range(5)]

x = np.array([A, B, C, D, E])
ans = int((np.ceil((x / 10)) * 10).sum())
x = x %10

if x.sum()==0:
    tmp = 0
else:
    tmp = 10 - x[np.where(x>0)].min()

ans = ans - tmp

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B, C, D, E = [int(input()) for i in range(5)]

x = np.array([A, B, C, D, E])
ans = int((np.ceil((x / 10)) * 10).sum())
x = x %10
tmp = 10 - x[np.where(x>0)].min()
ans = ans - tmp

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B, C, D, E = [int(input()) for i in range(5)]

x = np.array([A, B, C, D, E])
ans = x.round(-1).sum()
x = x %10
tmp = 10 - x[np.where(x>0)].min()
ans = ans - tmp

print(ans)
Problem p03087 (python)

Fixed submission:
import numpy as np
n, q = map(int, input().split())
s = input()
ans = np.zeros(n, dtype=int)

for i in range(1, n):
    if s[i - 1:i + 1] == "AC":
        ans[i] = 1

ans = ans.cumsum()

result = []

for i in range(q):
    l, r = map(int, input().split())
    result.append(ans[r - 1] - ans[l - 1])

print(*result, sep="\n")

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()

ans = []

for i in range(q):
    l, r = map(int, input().split())
    S = s[l - 1:r]
    print(S)
    ans.append(S.count("AC"))

print(*ans, sep="\n")
Problem p03095 (python)

Fixed submission:
from collections import Counter

n = int(input())
s = list(map(str, input().rstrip()))

c = Counter(s)

dp = 1
for x in c.values():
    dp = dp * (x + 1)

dp = (dp - 1) % (10 ** 9 + 7)

print(dp)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = list(map(str, input().rstrip()))

whole = 2**n - 1


c = Counter(s)

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


c = [x for x in list(c.values()) if x >= 2]

ans = []
for i in c:
    for j in range(2, i + 1):
        if n - i >= 2:
            ans.append(cmb(i, j) * 2**(n - i) - 1)
        else:
            ans.append(cmb(i, j) * 2**(n - i))

print(whole - sum(ans))