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

Fixed submission:
n = int(input())
aaa = list(map(int, input().split()))
n2 = 1 << n
dp = [[a, 0] for a in aaa]

for j in range(n):
    b = 1 << j
    for i in range(n2):
        if not i & b:
            dpi, dpk = dp[i], dp[i | b]
            if dpk[0] < dpi[0]:
                dpk[1] = max(dpk[0], dpi[1])
                dpk[0] = dpi[0]
            elif dpk[1] < dpi[0]:
                dpk[1] = dpi[0]

ans = []
tmp = 0
for a in dp[1:]:
    tmp = max(tmp, a[0] + a[1])
    ans.append(tmp)
print(*ans)

Buggy submission (verdict: Runtime Error):
from heapq import nlargest

n = int(input())
aaa = list(map(int, input().split()))
n2 = 1 << n
dp = [[0, a] for a in aaa]

for j in range(n):
    b = 1 << j
    for i in range(n2):
        if not i & b:
            dp[i | b] = nlargest(2, dp[i] + dp[i | b])

ans = []
tmp = 0
for a in dp[1:]:
    tmp = max(tmp, a)
    ans.append(tmp)
print(*ans)

Buggy submission (verdict: Runtime Error):
from heapq import nlargest
from itertools import accumulate

n = int(input())
aaa = list(map(int, input().split()))
n2 = 1 << n
dp = [[0, a] for a in aaa]

for j in range(n):
    b = 1 << j
    for i in range(n2):
        if not i & b:
            dp[i | b] = nlargest(2, dp[i] + dp[i | b])
    dp[b] = nlargest(2, dp[0] + dp[b])

ans = list(accumulate(map(sum, dp[1:]), func=max))
print(*ans)

Buggy submission (verdict: Runtime Error):
from heapq import nlargest
from itertools import accumulate

n = int(input())
aaa = list(map(int, input().split()))
n2 = 1 << n
mask = n2 - 1
dp = [[0, a] for a in aaa]

for j in range(n):
    b = 1 << j
    c = i = mask ^ b
    while i:
        dp[i | b] = nlargest(2, dp[i] + dp[i | b])
        i = (i - 1) & c
    dp[b] = nlargest(2, dp[0] + dp[b])

ans = list(accumulate(map(sum, dp[1:]), func=max))
print(*ans)

Buggy submission (verdict: Runtime Error):
from heapq import nlargest
from itertools import accumulate

n = int(input())
aaa = list(map(int, input().split()))
aaa_get = aaa.__getitem__
n2 = 1 << n
mask = n2 - 1

dp = [[i, 0] for i in range(n2)]
for j in range(n):
    b = 1 << j
    c = i = mask ^ b
    while i:
        dp[i | b] = nlargest(2, set(dp[i] + dp[i | b]), key=aaa_get)
        i = (i - 1) & c

ans = list(accumulate(map(lambda x: sum(map(aaa_get, x)), dp[1:]), func=max))
print(*ans)

Buggy submission (verdict: Runtime Error):
from heapq import nlargest
from itertools import accumulate

n = int(input())
aaa = list(map(int, input().split())) + [0]
aaa_get = aaa.__getitem__
n2 = 1 << n

dp = [[i, -1] for i in range(n2)]
for j in range(n):
    b = 1 << j
    for i in range(n2):
        if (i & b) == 0:
            dp[i | b] = nlargest(2, {*dp[i], *dp[i | b]}, key=aaa_get)
ans = list(accumulate(map(lambda x: sum(map(aaa_get, x)), dp[1:]), func=max))
print(*ans)
Problem p03319 (python)

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

if n == k:
    print(1)
else:
    i = 0
    for i, a in enumerate(map(int, input().split())):
        if a == 1:
            break
    left = (i - 1) // (k - 1) + 1
    lr = (k - 1) * left + 1
    print(left + (n - lr - 1) // (k - 1) + 1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
print((n - 2) // (k - 2) + 1)
Problem p03341 (python)

Fixed submission:
from itertools import accumulate

n = int(input())
s = [c == 'W' for c in input()]
l = accumulate([0] + s[:-1])
r = accumulate([0] + [not c for c in reversed(s[1:])])
print(min(e + w for e, w in zip(l, reversed(list(r)))))

Buggy submission (verdict: Runtime Error):
8
WWWWWEEE
Problem p03347 (python)

Fixed submission:
def solve(n, aaa):
    if aaa[0] > 0:
        return -1
    if any(a1 - a0 > 1 for a0, a1 in zip(aaa, aaa[1:])):
        return -1
    ans = 0
    a0 = 0

    for a1 in aaa[1:]:
        if a1 - a0 != 1:
            ans += a0
        a0 = a1

    return ans + a0


n = int(input())
aaa = list(map(int, (input() for _ in range(n))))
print(solve(n, aaa))

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


def solve(n, aaa):
    if aaa[0] > 0:
        return -1
    if any(a1 - a0 > 1 for a0, a1 in zip(aaa, aaa[1:])):
        return -1
    ans = 0
    aaa.reverse()

    while any(aaa):
        new = [0] * (len(aaa) - 1)
        a1 = aaa[0]
        ap = 0
        for i, a0 in enumerate(aaa[1:]):
            if a1 == 0:
                a1 = a0
                continue
            ans += 1
            if a1 - a0 < 1:
                new[i] = ap = max(a1 - 1, ap)
            else:
                new[i] = ap
            a1 = a0
            if ap:
                ap -= 1
        aaa = np.trim_zeros(new)
        if a1:
            ans += 1
    return ans


n = int(input())
aaa = list(map(int, (input() for _ in range(n))))
print(solve(n, aaa))
Problem p03361 (python)

Fixed submission:
def solve(field):
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if field[i][j] == '.':
                continue
            if field[i - 1][j] == field[i + 1][j] == field[i][j - 1] == field[i][j + 1] == '.':
                return False
    return True


h, w = list(map(int, input().split()))
field = ['.' + input() + '.' for _ in range(h)]
field = ['.' * (w + 2)] + field + ['.' * (w + 2)]
print('Yes' if solve(field) else 'No')

Buggy submission (verdict: Runtime Error):
def solve(field):
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if field[i][j] == '.':
                continue
            if field[i - 1][j] == field[i + 1][j] == field[i][j - 1] == field[i][j + 1] == '.':
                return False
    return True


h, w = list(map(int, input().split()))
field = ['.' + input() + '.' for _ in range(h)]
field = ['.' * w] + field + ['.' * w]
print('Yes' if solve(field) else 'No')
Problem p03386 (python)

Fixed submission:
a, b, k = map(int, input().split())
s = set(range(a, min(b + 1, a + k)))
s.update(range(b, max(a - 1, b - k), -1))
s = sorted(s)
print('\n'.join(map(str, s)))

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
l = list(range(a, b + 1))
s = set(l[:k])
s.update(l[-k:])
s = sorted(s)
print('\n'.join(map(str, s)))
Problem p03395 (python)

Fixed submission:
from scipy.sparse.csgraph import dijkstra


def make_graph(m, subset):
    matrix = [[0] * (m + 1) for _ in range(m + 1)]
    for k in subset:
        for s in range(k, m + 1):
            matrix[s][s % k] = 1
    return dijkstra(matrix)


def solve(n, aaa, bbb):
    for a, b in zip(aaa, bbb):
        if a < b:
            return -1
    m = max(aaa)
    subset = set(range(1, m + 1))
    sp = make_graph(m, subset)
    if any(sp[a, b] > 50 for a, b in zip(aaa, bbb)):
        return -1

    for k in range(m, 0, -1):
        subset.remove(k)
        sp = make_graph(m, subset)
        if any(sp[a, b] > 50 for a, b in zip(aaa, bbb)):
            subset.add(k)
    return sum(1 << k for k in subset)


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
print(solve(n, aaa, bbb))

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall
import numpy as np


def make_graph(m):
    matrix = np.zeros([m + 1, m + 1, m + 1])
    for k in range(1, m + 1):
        for s in range(k, m + 1):
            matrix[k, s, s % k] = 1
    return matrix


def is_disable(matrix, subset, aaa, bbb):
    sub_matrix = matrix[list(subset)].max(axis=0)
    sp = floyd_warshall(sub_matrix)
    return any(sp[a, b] > 50 for a, b in zip(aaa, bbb))


def solve(aaa, bbb):
    for a, b in zip(aaa, bbb):
        if a < b:
            return -1
    m = max(aaa)
    matrix = make_graph(m)
    subset = set(range(1, m + 1))
    if is_disable(matrix, subset, aaa, bbb):
        return -1

    for k in range(m, 0, -1):
        subset.remove(k)
        if is_disable(matrix, subset, aaa, bbb):
            subset.add(k)
    return sum(1 << k for k in subset)


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
print(solve(aaa, bbb))
Problem p03408 (python)

Fixed submission:
from collections import defaultdict
d = defaultdict(int)

n = int(input())
for _ in range(n):
    d[input()] += 1
m = int(input())
for _ in range(m):
    d[input()] -= 1
print(max(0, max(d.values())))

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

n = int(input())
for _ in range(n):
    d[input()] += 1
m = int(input())
for _ in range(n):
    d[input()] -= 1
print(max(0, max(d.values())))

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

n = int(input())
for _ in range(n):
    d[input()] += 1
m = int(input())
for _ in range(n):
    d[input()] -= 1
print(max(d.values()))
Problem p03422 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10000000)
from math import ceil


def grundy(a, k):
    if a < k:
        return 0
    d, m = divmod(a, k)
    if m == 0:
        return d
    d1 = d + 1
    if d > k:
        return grundy(a - d1, k)
    e = ceil(m / d1) * d1
    return grundy(a - e, k)


n = int(input())
nim = 0
for _ in range(n):
    a, k = map(int, input().split())
    nim ^= grundy(a, k)
print('Takahashi' if nim > 0 else 'Aoki')

Buggy submission (verdict: Runtime Error):
from math import ceil


def grundy(a, k):
    if a < k:
        return 0
    d, m = divmod(a, k)
    if m == 0:
        return d
    d1 = d + 1
    if d > k:
        return grundy(a - d1, k)
    e = ceil(m / d1) * d1
    return grundy(a - e, k)


n = int(input())
nim = 0
for _ in range(n):
    a, k = map(int, input().split())
    nim ^= grundy(a, k)
print('Takahashi' if nim > 0 else 'Aoki')

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(100000000)


def grundy(a, k):
    if a < k:
        return 0
    d, m = divmod(a, k)
    if m == 0:
        return d
    return grundy(a - d - 1, k)


n = int(input())
nim = 0
for _ in range(n):
    a, k = map(int, input().split())
    nim ^= grundy(a, k)
print('Takahashi' if nim > 0 else 'Aoki')

Buggy submission (verdict: Runtime Error):
def grundy(a, k):
    if a < k:
        return 0
    d, m = divmod(a, k)
    if m == 0:
        return d
    return grundy(a - d - 1, k)


n = int(input())
nim = 0
for _ in range(n):
    a, k = map(int, input().split())
    nim ^= grundy(a, k)
print('Takahashi' if nim > 0 else 'Aoki')
Problem p03428 (python)

Fixed submission:
import numpy as np
from scipy.spatial import ConvexHull
from scipy.spatial.qhull import QhullError


def solve(n, pts):
    ans = [0] * n

    try:
        hull = ConvexHull(pts)
    except QhullError:
        lm = np.argmin(pts, axis=0)
        rm = np.argmax(pts, axis=0)
        if lm[0] != rm[0]:
            l, r = lm[0], rm[0]
        elif lm[1] != rm[0]:
            l, r = lm[1], rm[0]
        else:
            l, r = lm[0], rm[1]
        ans[l] = ans[r] = 0.5
        return ans

    ps = np.array(list(map(pts.__getitem__, hull.vertices)))
    vs = ps - np.roll(ps, 1, axis=0)

    vt = vs.T
    vt[0] *= -1
    arcs = np.arctan2(*vt)
    arcs = np.append(arcs, arcs[0])
    da = np.diff(arcs) / (2 * np.pi) % 1

    for i, a in zip(hull.vertices, da):
        ans[i] = a

    return ans


n = int(input())
pts = [list(map(int, input().split())) for _ in range(n)]
print('\n'.join(map(str, solve(n, pts))), end='')

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


def solve(n, pts):
    ans = [0] * n

    div = 200000
    a = np.linspace(0, 2 * np.pi, div)
    b = np.dot(pts, [np.sin(a), np.cos(a)])
    c = np.argmax(b, axis=0)
    for i, v in zip(*np.unique(c, return_counts=True)):
        ans[i] = v / div
    return ans


n = int(input())
pts = [list(map(int, input().split())) for _ in range(n)]
print('\n'.join(map(str, solve(n, pts))))

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


def solve(n, pts):
    ans = [0] * n

    div = 1000000
    a = np.linspace(0, 2 * np.pi, div)
    b = np.dot(pts, [np.sin(a), np.cos(a)])
    c = np.argmax(b, axis=0)
    for i, v in zip(*np.unique(c, return_counts=True)):
        ans[i] = v / div
    return ans


n = int(input())
pts = [list(map(int, input().split())) for _ in range(n)]
print('\n'.join(map(str, solve(n, pts))))

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.spatial import ConvexHull


def solve(n, pts):
    if n == 2:
        return [0.5, 0.5]

    hull = ConvexHull(pts)
    ps = np.array(list(map(pts.__getitem__, hull.vertices)))
    vs = ps - np.roll(ps, 1, axis=0)

    vt = vs.T
    vt[0] *= -1
    arcs = np.arctan2(*vt)
    arcs = np.append(arcs, arcs[0])
    da = np.diff(arcs) / (2 * np.pi) % 1
    
    ans = [0] * n
    for i, a in zip(hull.vertices, da):
        ans[i] = a

    return ans


n = int(input())
pts = np.array([list(map(int, input().split())) for _ in range(n)])
print('\n'.join(map(str, solve(n, pts))), end='')
Problem p03441 (python)

Fixed submission:
import sys

sys.setrecursionlimit(100000)


def dfs(v, p, links):
    lv = links[v]
    if len(lv) == 1:
        return 0
    cnt0 = 0
    ret = 0
    for l in lv:
        if l == p:
            continue
        res = dfs(l, v, links)
        ret += res
        if res == 0:
            cnt0 += 1
    if cnt0:
        ret += cnt0 - 1
    return ret


def solve(n, links):
    if n == 2:
        return 1
    for i, l in enumerate(links):
        if len(l) > 2:
            return dfs(i, None, links)
    else:
        return 1


n = int(input())
links = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    links[a].add(b)
    links[b].add(a)
print(solve(n, links))

Buggy submission (verdict: Runtime Error):
def dps(v, p, links):
    lv = links[v]
    if not lv:
        return 0
    cnt0 = 0
    ret = 0
    for l in lv:
        if l == p:
            continue
        res = dps(l, v, links)
        ret += res
        if res == 0:
            cnt0 += 1
    if cnt0:
        ret += cnt0 - 1
    return ret


def solve(n, links):
    if n == 2:
        return 1
    for i, l in enumerate(links):
        if len(l) > 1:
            return dps(i, None, links)


n = int(input())
links = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    links[a].add(b)
    links[b].add(a)
print(solve(n, links))
Problem p03452 (python)

Fixed submission:
import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if checked[j]:
            continue
        if j not in xs:
            xs[j] = xi + d
        elif xi + d != xs[j]:
            return False
        children.add(j)
    checked[i] = True
    for j in children:
        if not check(j, xs, checked):
            return False
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            res = check(i, xs, checked)
            if not res:
                return False
            mn, mx = min(xs.values()), max(xs.values())
            if mx - mn > 1e9:
                return False
    return True


n, m = map(int, input().split())
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print('Yes' if solve() else 'No')

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if checked[j]:
            continue
        if j not in xs:
            xs[j] = xi + d
        elif xi + d != xs[j]:
            return False
        children.add(j)
    checked[i] = True
    return all(check(j, xs, checked) for j in children)


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = map(int, input().split())
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print('Yes' if solve() else 'No')

Buggy submission (verdict: Runtime Error):
def check(i, xs):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if j in checked:
            continue
        xj = xs[j]
        if xj is None:
            xs[j] = xi + d
        elif xi + d != xj:
            return False
        children.add(j)
    checked.add(i)
    for jc in children:
        if not check(jc, xs):
            return False
    return True


def solve():
    for i in range(n):
        if i not in checked:
            xs = [None] * n
            xs[i] = 0
            res = check(i, xs)
            if not res:
                return False
            xf = list(filter(lambda x: x is not None, xs))
            mn, mx = min(xf), max(xf)
            if mx - mn > 1e9:
                return False
    return True


n, m = map(int, input().split())
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
checked = set()
print('Yes' if solve() else 'No')
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
print(['Even', 'Odd'][a * b % 2])

Buggy submission (verdict: Runtime Error):
a, b = map(int, input.split())
print(['Even', 'Odd'][a * b % 2])
Problem p03456 (python)

Fixed submission:
n = int(input().replace(' ', ''))
m = int(n ** 0.5 + 1e-6)
print('Yes' if n == m * m else 'No')

Buggy submission (verdict: Runtime Error):
n = input().replace(' ', '')
m = int(n ** 0.5 + 1e-6)
print('Yes' if n == m * m else 'No')
Problem p03472 (python)

Fixed submission:
from bisect import bisect, bisect_left
from itertools import accumulate
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    bf = list(filter(lambda x: x > max_a, bb))
    if not bf:
        return ceil(h / max_a)
    bf.sort(reverse=True)
    bba = list(accumulate(bf))
    remain = h - bba[-1]
    slash_cnt = max(0, ceil(remain / max_a))
    slash_dmg = slash_cnt * max_a
    throw_dmg = h - slash_dmg
    for i, dmg in enumerate(bba):
        if dmg >= throw_dmg:
            break
    return slash_cnt + i + 1


n, h = map(int, input().split())
aa, bb = [], []
for _ in range(n):
    a, b = map(int, input().split())
    aa.append(a)
    bb.append(b)

print(solve(h, aa, bb))

Buggy submission (verdict: Runtime Error):
from bisect import bisect, bisect_left
from itertools import accumulate
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    bf = list(filter(lambda x: x > max_a, bb))
    bf.sort(reverse=True)
    bba = list(accumulate(bf))
    remain = h - bba[-1]
    slash_cnt = max(0, ceil(remain / max_a))
    slash_dmg = slash_cnt * max_a
    throw_dmg = h - slash_dmg
    for i, dmg in enumerate(bba):
        if dmg >= throw_dmg:
            break
    return slash_cnt + i + 1


n, h = map(int, input().split())
aa, bb = [], []
for _ in range(n):
    a, b = map(int, input().split())
    aa.append(a)
    bb.append(b)

print(solve(h, aa, bb))
Problem p03491 (python)

Fixed submission:
import sys

sys.setrecursionlimit(100000)


def dfs(cur, dep=0):
    if cur == -1:
        x = l - dep
        return x & -x
    return dfs(trie[cur][0], dep + 1) ^ dfs(trie[cur][1], dep + 1)


n, l = map(int, input().split())
trie = [[-1, -1] for _ in range(100001)]
idx = 1
for s in (input() for _ in range(n)):
    cur = 0
    for c in map(int, s):
        if trie[cur][c] == -1:
            trie[cur][c] = idx
            idx += 1
        cur = trie[cur][c]

xor = dfs(trie[0][0]) ^ dfs(trie[0][1])
print('Alice' if xor else 'Bob')

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(100000)


def dfs(cur, dep=0):
    if cur == -1:
        x = l - dep
        return x & -x
    return dfs(trie[cur][0], dep + 1) ^ dfs(trie[cur][1], dep + 1)


n, l = map(int, input().split())
trie = [[-1, -1] for _ in range(100001)]
idx = 1
for s in (input() for _ in range(n)):
    cur = 0
    for c in map(int, s):
        if trie[cur][c] == -1:
            trie[cur][c] = idx
            idx += 1
        cur = trie[cur][c]

xor = dfs(trie[0][0]) ^ dfs(trie[0][1])
print('Alice' if xor else 'Bob')

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(100000)


def dfs(cur, dep=0):
    if cur == -1:
        x = l - dep
        return x & -x
    return dfs(trie[cur][0], dep + 1) ^ dfs(trie[cur][1], dep + 1)


n, l = map(int, input().split())
trie = [[-1, -1] for _ in range(100001)]
idx = 1
for s in (input() for _ in range(n)):
    cur = 0
    for c in map(int, s):
        if trie[cur][c] == -1:
            trie[cur][c] = idx
            idx += 1
        cur = trie[cur][c]

xor = dfs(trie[0][0]) ^ dfs(trie[0][1])
print('Alice' if xor else 'Bob')
Problem p03506 (python)

Fixed submission:
n, q = map(int, input().split())

if n == 1:
    def solve(v, w):
        return min(v, w)
else:
    def solve(v, w):
        while v != w:
            if v > w:
                v, w = w, v
            w = (w + n - 2) // n
        return v

print('\n'.join(map(str, (solve(*map(int, input().split())) for _ in range(q)))))

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


def solve(v, w):
    vl = bisect(table, v)
    wl = bisect(table, w)
    if vl > wl:
        for i in range(vl - wl):
            v = (v + m) // n
    elif wl < vl:
        for i in range(wl - vl):
            w = (w + m) // n
    while v != w:
        if v > w:
            v, w = w, v
        w = (w + m) // n
    return v


n, q = map(int, input().split())
m = n - 2
table, k = [], 1
while True:
    table.append(k)
    k *= n
    if k > 1e9:
        break
table = accumulate(table)

print('\n'.join(map(str, (solve(*map(int, input().split())) for _ in range(q)))))
Problem p03533 (python)

Fixed submission:
import re

print('YES' if re.match('A?KIHA?BA?RA?$', input()) else 'NO')

Buggy submission (verdict: Runtime Error):
2import re

print('Yes' if re.match('A?KIHA?BA?RA?', input()) else 'No')
Problem p03535 (python)

Fixed submission:
from collections import Counter


def solve(n, ds):
    if n >= 24:
        return 0
    freq = Counter(ds)
    if (0 in freq) or (freq[12] >= 2) or max(freq.values()) >= 3:
        return 0
    up_low = [0, 0]
    switch = 0
    ans = 25
    for d, s in sorted(freq.items()):
        if s == 2:
            ans = min(ans, d - up_low[0], d - up_low[1])
            up_low[0] = up_low[1] = d
        else:
            ans = min(ans, d - up_low[switch])
            up_low[switch] = d
            switch ^= 1
    ans = min(ans, 24 - sum(up_low))
    return ans


print(solve(int(input()), list(map(int, input().split()))))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from itertools import product, combinations


def solve(n, ds):
    if n >= 24:
        return 0
    freq = Counter(ds)
    if 0 in freq or freq[12] >= 2 or max(freq.values()) >= 3:
        return 0
    cmp = set()
    alt = []
    for d, l in freq.items():
        if l == 2 or d == 12:
            cmp.add(d)
            cmp.add(24 - d)
        else:
            alt.append((d, 24 - d))
    ans = min((abs(x - y) for x, y in combinations(cmp, 2)), default=0)
    for prd in product((0, 1), repeat=len(alt)):
        tmp_cmp = cmp.copy().union(x[i] for x, i in zip(alt, prd))
        tmp = min(abs(x - y) for x, y in combinations(tmp_cmp, 2))
        tmp = min(tmp, min(freq.keys()))
        ans = max(ans, tmp)
    return ans


print(solve(int(input()), list(map(int, input().split()))))
Problem p03551 (python)

Fixed submission:
n,m=map(int,input().split())
q=(n-m)*100+m*1900
print(q*(1<<m))

Buggy submission (verdict: Runtime Error):
n,z,w=map(int,input().split())
aa=input().split()
an=int(aa[-1])
if len(aa) > 1:
    am=int(aa[-2])
    print(max(abs(an-w),abs(an-am)))
else:
    print(abs(an-w))
Problem p03552 (python)

Fixed submission:
n,z,w=map(int,input().split())
aa=input().split()
an=int(aa[-1])
if len(aa) > 1:
    am=int(aa[-2])
    print(max(abs(an-w),abs(an-am)))
else:
    print(abs(an-w))

Buggy submission (verdict: Runtime Error):
n,z,w=map(int,input().split())
aa=input().split()
an,am=int(aa[-1]),int(aa[-2])
print(max(abs(an-w),abs(an-am)))