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

Fixed submission:
# 解説を見た

def solve(N, t, a, g) -> int:
    import sys

    sys.setrecursionlimit(10 ** 7)

    def calc_dist(init):
        dist = [-1] * N
        dist[init] = 0

        def _calc_dist(curr):
            for next_ in g[curr]:
                if dist[next_] != -1:
                    continue
                dist[next_] = dist[curr] + 1
                _calc_dist(next_)

        _calc_dist(init)
        return dist

    dist_a = calc_dist(a)
    dist_t = calc_dist(t)

    return max(dist_a[v] for v in range(N) if dist_t[v] < dist_a[v]) - 1


if __name__ == '__main__':
    N, t, a = map(int, input().split())
    t -= 1
    a -= 1

    g = tuple(set() for _ in range(N))
    for _ in range(N - 1):
        u, v = (int(x) - 1 for x in input().split())
        g[u].add(v)
        g[v].add(u)

    print(solve(N, t, a, g))

# 青木君からの距離 > 高橋君からの距離 となる頂点Xが目的地の候補
# 青木君と高橋君の共通祖先からの距離は等しいので、
# 共通祖先への距離は、 青木君 > 高橋君 となり、高橋君は必ずXに到達できる
# Xに着いた高橋君は、手前の頂点とXとを行ったり来たりする
# a-t->at-: aが一歩進んだときに高橋君に会う(-は無人のマス目)
# at: tが手前の頂点に移動したときに青木君に会う
# いずれも手前の頂点まで青木君が移動したときにゲームが終わる
# どのXを選んでも、Xの手前でゲームが終わるので、青木君から最も遠いXを選ぶのが最善
# 頂点X: 追いつめられる位置=葉

Buggy submission (verdict: Runtime Error):
# 解説を見た

def solve(N, t, a, g) -> int:
    def calc_dist(init):
        dist = [-1] * N
        dist[init] = 0

        def _calc_dist(curr):
            for next_ in g[curr]:
                if dist[next_] != -1:
                    continue
                dist[next_] = dist[curr] + 1
                _calc_dist(next_)

        _calc_dist(init)
        return dist

    dist_a = calc_dist(a)
    dist_t = calc_dist(t)

    return max(dist_a[v] for v in range(N) if dist_t[v] < dist_a[v]) - 1


if __name__ == '__main__':
    N, t, a = map(int, input().split())
    t -= 1
    a -= 1

    g = tuple(set() for _ in range(N))
    for _ in range(N - 1):
        u, v = (int(x) - 1 for x in input().split())
        g[u].add(v)
        g[v].add(u)

    print(solve(N, t, a, g))

# 青木君からの距離 > 高橋君からの距離 となる頂点Xが目的地の候補
# 青木君と高橋君の共通祖先からの距離は等しいので、
# 共通祖先への距離は、 青木君 > 高橋君 となり、高橋君は必ずXに到達できる
# Xに着いた高橋君は、手前の頂点とXとを行ったり来たりする
# a-t->at-: aが一歩進んだときに高橋君に会う(-は無人のマス目)
# at: tが手前の頂点に移動したときに青木君に会う
# いずれも手前の頂点まで青木君が移動したときにゲームが終わる
# どのXを選んでも、Xの手前でゲームが終わるので、青木君から最も遠いXを選ぶのが最善
# 頂点X: 追いつめられる位置=葉
Problem p02862 (python)

Fixed submission:
def solve():
    mod = 10 ** 9 + 7

    x, y = map(int, input().split())

    sum_ = x + y

    q, r = divmod(sum_, 3)
    if r != 0:
        return 0

    a = (x * 2 - y) // 3

    b = (y * 2 - x) // 3

    if a < 0 or b < 0:
        return 0

    def cmb(n, r):
        return (fact[n] * finv_t[r] * finv_t[n - r]) % mod

    fact = [1, 1]
    inv_t = [0, 1]
    finv_t = [1, 1]
    for i in range(2, q + 1):
        fact.append((fact[-1] * i) % mod)
        inv_t.append((-inv_t[mod % i] * (mod // i)) % mod)
        finv_t.append((finv_t[-1] * inv_t[-1]) % mod)

    return cmb(q, a)


print(solve())

Buggy submission (verdict: Runtime Error):
def solve():
    mod = 10 ** 9 + 7

    x, y = map(int, input().split())

    sum_ = x + y

    q, r = divmod(sum_, 3)
    if r != 0:
        return 0

    a = (x * 2 - y) // 3

    # b = (y * 2 - x) // 3

    def cmb(n, r):
        return (f[n] * invs[r] * invs[n - r]) % mod

    f = [-1] * (q + 1)
    f[0] = 1
    t = 1
    for i in range(1, q + 1):
        t *= i
        t %= mod
        f[i] = t

    inv = pow(t, mod - 2, mod)
    invs = [-1] * (q + 1)
    invs[q] = inv
    for i in range(q - 1, 0, -1):
        inv *= (i + 1)  # <-直した
        inv %= mod
        invs[i] = inv

    return cmb(q, a)


print(solve())

Buggy submission (verdict: Runtime Error):
def solve():
    mod = 10 ** 9 + 7

    x, y = map(int, input().split())

    sum_ = x + y

    q, r = divmod(sum_, 3)
    if r != 0:
        return 0

    a = (x * 2 - y) // 3

    # b = (y * 2 - x) // 3

    def cmb(n, r):
        return (fact[n] * finv_t[r] * finv_t[n - r]) % mod

    fact = [1, 1]
    inv_t = [0, 1]
    finv_t = [1, 1]
    for i in range(2, q + 1):
        fact.append((fact[-1] * i) % mod)
        inv_t.append((-inv_t[mod % i] * (mod // i)) % mod)
        finv_t.append((finv_t[-1] * inv_t[-1]) % mod)

    return cmb(q, a)


print(solve())
Problem p03033 (python)

Fixed submission:
# 理解する時間がなかったので、とりあえず写経
from bisect import bisect_left
from operator import itemgetter

N, Q = [int(i) for i in input().split()]
Construction = [tuple(int(i) for i in input().split()) for j in range(N)]
D = [int(input()) for _ in range(Q)]

ans = [-1] * Q
skip = [-1] * Q

Construction.sort(key=itemgetter(2))

for s, t, x in Construction:
    l = bisect_left(D, s - x)
    r = bisect_left(D, t - x)
    t = l
    while t < r:
        if skip[t] == -1:
            ans[t] = x  # lからr-1の時刻に出発した人は座標xの工事に引っかかる
            skip[t] = r  # lからr-1の時刻に出発した人はもう調べないようにする
            t += 1
        else:
            t = skip[t]  # tが指定する人はもう調べ終わっているので飛ばす
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc128/submissions/8312583
# 写経

def solve():
    from heapq import heappush, heappop
    from collections import defaultdict
    from operator import itemgetter
    import sys

    input = sys.stdin.readline

    inf = 1 << 31

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

    S = [0] * n
    T = [0] * n
    X = [0] * n
    for i in range(n):
        S[i], T[i], X[i] = map(int, input().split())

    e = [*((t - x, 0, x) for t, x in zip(T, X)),
         *((s - x, 1, x) for s, x in zip(S, X)),
         *((int(input()), 2, idx) for idx in range(q))
         ]
    e.sort(key=itemgetter(0))
    # 安定ソートなので、0,1,2順になる（はず

    cnt = defaultdict(int)
    cnt[inf] = 1
    h = [inf]
    ret = [-1] * q
    for time, type, x in e:
        if type == 0:
            cnt[x] -= 1
        elif type == 1:
            heappush(h, x)
            cnt[x] += 1
        else:
            while not (cnt[h[0]]):
                heappop(h)
            curr = h[0]
            if curr != inf:
                ret[x] = curr

    print(*ret, sep='\n')


if __name__ == '__main__':
    solve()
Problem p03053 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
a = [input() for _ in range(H)]

dist = [[-1] * W for _ in range(H)]
dq = deque()

for r in range(H):
    for c in range(W):
        if a[r][c] == '#':
            dist[r][c] = 0
            dq.append((r, c))


def in_range(r, c):
    return 0 <= r < H and 0 <= c < W


dr_s = (0, 0, -1, 1)
dc_s = (-1, 1, 0, 0)

d = 0
while dq:
    r, c = dq.popleft()
    d = dist[r][c]
    for dr, dc in zip(dr_s, dc_s):
        nr = r + dr
        nc = c + dc
        if not in_range(nr, nc): continue
        if dist[nr][nc] != -1: continue
        dist[nr][nc] = d + 1
        dq.append((nr, nc))

print(d)

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

readline = sys.stdin.readline

H, W = map(int, readline().split())
a = tuple(readline() for _ in range(H))


def adjacent_vertices(v):
    r, c = divmod(v, H)

    if r > 0:
        yield v - H
    if r < H - 1:
        yield v + H
    if c > 0:
        yield v - 1
    if c < W - 1:
        yield v + 1


gen = (r * H + c for r in range(H) for c in range(W) if a[r][c] == '#')

# BFSで黒から最遠点までの距離を求める
dist = [-1] * (H * W)
q = deque()
for v in gen:
    dist[v] = 0
    q.append(v)
while q:
    v = q.popleft()
    d = dist[v]
    for nv in filter(lambda x: dist[x] == -1, adjacent_vertices(v)):
        dist[nv] = d + 1
        q.append(nv)

print(d)

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

H, W = map(int, input().split())
a = [input() for _ in range(H)]

dist = np.full((H, W), -1, dtype='int8')
dq = deque()

for r in range(H):
    for c in range(W):
        if a[r][c] == '#':
            dist[r, c] = 0
            dq.append((r, c))


def in_range(r, c):
    return 0 <= r < H and 0 <= c < W


dr_s = (0, 0, -1, 1)
dc_s = (-1, 1, 0, 0)

d = 0
while dq:
    r, c = dq.popleft()
    d = dist[r][c]
    for dr, dc in zip(dr_s, dc_s):
        nr = r + dr
        nc = c + dc
        if not in_range(nr, nc): continue
        if dist[nr][nc] != -1: continue
        dist[nr][nc] = d + 1
        dq.append((nr, nc))

print(d)
Problem p03201 (python)

Fixed submission:
# https://beta.atcoder.jp/contests/agc029/submissions/3804087
from collections import Counter

N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
b = Counter(a)

ans = 0
for t in a:
    s = (1 << t.bit_length()) - t
    if t == s:
        ans += b[t] // 2
        b[t] %= 2
    else:
        u = min(b[s], b[t])
        ans += u
        b[s] -= u
        b[t] -= u

print(ans)

Buggy submission (verdict: Runtime Error):
from math import log2, ceil
from bisect import bisect_left, bisect_right

N = int(input())
a = list(map(int, input().split()))
a = sorted(a)
b = [True for _ in range(N)]

ans = 0
for i in list(range(N))[::-1]:
    if not b[i]: continue
    t = a[i]
    flg = False
    for j in list(range(ceil(log2(t)), int(log2(t * 2)) + 1))[::-1]:
        pair = 2 ** j - t
        left = bisect_left(a, pair)
        right = bisect_right(a, pair)
        # print(t, pair, a, b, left, right)
        if left == right:
            if left < N and left != i:
                if a[left] == pair and b[left]:
                    b[left] = False
                    b[i] = False
                    ans += 1
                    flg = True
                    break
        else:
            k = right - 1
            k = min(right - 1, N - 1)
            while k >= max(0, left):
                if a[k] == pair and b[k] and k != i:
                    b[k] = False
                    b[i] = False
                    ans += 1
                    flg = True
                    break
                k -= 1
            if flg:
                break

print(ans)
Problem p03221 (python)

Fixed submission:
from bisect import bisect_left

n, m = map(int, input().split())
qs = [list(map(int, input().split())) for _ in range(m)]
pys = [[] for _ in range(n)]
for q in qs:
    p, y = q
    p -= 1
    pys[p].append(y)

for i in range(n):
    pys[i] = sorted(pys[i])

for q in qs:
    p, y = q
    p -= 1
    number = bisect_left(pys[p], y) + 1

    print(str(p + 1).zfill(6) + str(number).zfill(6))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
pys = [[] for _ in range(n + 1)]

ans = [None for _ in range(m)]

for i in range(m):
    p, y = map(int, input().split())
    lst = [y, i]
    pys[p].append(lst)

for p in range(1, n + 1):
    t = sorted(pys[p], key=lambda x: x[0])
    for j, [y, i] in enumerate(t, 1):
        ans[i] = f'{p:06}{j:06}'

print('\n'.join(ans))

'''
zero padding: 
f'{i:03}'
002etc
'''
Problem p03253 (python)

Fixed submission:
MOD = 10 ** 9 + 7


def prime_factorization(n):
    i = 2
    res = []
    while i * i <= n:
        cnt = 0
        while n % i == 0:
            n /= i
            cnt += 1
        if cnt > 0:
            res.append(cnt)
        i += 1
    if n > 1:
        res.append(1)
    return res


def comb(a, b):
    b = min(b, a - b)
    if b < 0:
        return 0
    elif b == 0:
        return 1
    elif b == 1:
        return a
    else:
        return (a % MOD) * pow(b, MOD - 2, MOD) % MOD * comb(a - 1, b - 1) % MOD


N, M = map(int, input().split())

ans = 1
for power in prime_factorization(M):
    ans *= comb(N - 1 + power, power)
    ans %= MOD

print(ans)

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

mod = 10 ** 9 + 7


def cmb(n, r):
    if n < r:
        return 0  # <-直した
    if r > n - r:
        return cmb(n, n - r)
    if r == 0:
        return 1
    if r == 1:
        return n
    res = f[n]
    res *= invs[r]
    res %= mod
    res *= invs[n - r]
    res %= mod
    return res


N, M = map(int, input().split())
d = defaultdict(int)

x = M
i = 2
while i * i <= M:
    t = 0
    while x % i == 0:
        x //= i
        t += 1
    if t > 0:
        d[i] = t
    i += 1
if x > 1:
    d[x] = 1

max_v = max(d.values())

f = [-1] * (N - 1 + max_v + 1)
f[0] = 1
t = 1
for i in range(1, N - 1 + max_v + 1):
    t *= i
    t %= mod
    f[i] = t

# print(d)

inv = pow(t, mod - 2, mod)
invs = [-1] * (N - 1 + max_v + 1)
invs[N - 1 + max_v] = inv
for i in range(N - 1 + max_v - 1, 0, -1):
    inv *= (i + 1)  # <-直した
    inv %= mod
    invs[i] = inv

ans = 1
for cnt in d.values():
    ans *= cmb(N - 1 + cnt, cnt)
    ans %= mod
print(ans)
Problem p03291 (python)

Fixed submission:
s = input()
ls = len(s)
dp = [[0 for _ in range(4)] for _ in range(ls+1)]
dp[0][0] = 1
mod = 10 ** 9 + 7

for i in range(1, ls+1):
    for j in range(4):
        #'?'のとき'ABC'の3通りに分岐させ、いずれも取らないので3倍
        dp[i][j] += dp[i-1][j] * (3 if s[i-1] == '?' else 1)
        if j > 0:
            #ほしい文字に変えた場合　または　ほしい文字の場合で取ったとき
            dp[i][j] += dp[i-1][j-1] if s[i-1] == 'ABC'[j-1] or s[i-1] == '?' else 0
        dp[i][j] %= mod
print(dp[ls][3])

Buggy submission (verdict: Runtime Error):
def main():
    MOD = 10 ** 9 + 7

    s = input()
    n = len(s)

    acc_a = [0] * (n + 1)
    acc_c = [0] * (n + 1)
    acc_q = [0] * (n + 1)

    a = 0
    c = 0
    q = 0
    for i, char in enumerate(s, 1):
        if char == 'A':
            a += 1
        elif char == 'C':
            c += 1
        elif char == '?':
            q += 1
        acc_a[i] = a
        acc_c[i] = c
        acc_q[i] = q

    sq = [1]
    for _ in range(acc_q[n]):
        sq.append(sq[-1] * 3 % MOD)

    ans = 0
    for i, char in enumerate(s, 1):
        if char == 'B' or char == '?':
            is_q = int(char == '?')
            rq = acc_q[n] - acc_q[i]
            rc = acc_c[n] - acc_c[i]
            t = (acc_a[i - 1] * (
                    rc * sq[acc_q[n] - is_q]
                    + rq * sq[acc_q[n] - 1 - is_q]
            ) + acc_q[i - 1] * (
                         rc * sq[acc_q[n] - 1 - is_q]
                         + rq * sq[acc_q[n] - 2 - is_q]
                 )) % MOD
            ans = (ans + t) % MOD
    print(ans)


if __name__ == '__main__':
    main()
Problem p03806 (python)

Fixed submission:
N, Ma, Mb = map(int, input().split())
e = [tuple(map(int, input().split())) for _ in range(N)]

N_max = 40
a_max = 10
b_max = 10
c_max = 100

inf = N_max * c_max + 1
dp = [[[inf for _ in range(N_max * b_max + 1)] for _ in range(N_max * a_max + 1)] for _ in range(N_max + 1)]
dp[0][0][0] = 0

# print(dp[N])

for i, (aa, bb, cc) in enumerate(e, 1):
    for a in range(a_max * i + 1):
        for b in range(b_max * i + 1):
            dp[i][a][b] = min(dp[i][a][b], dp[i - 1][a][b])
            if a + aa < N_max * a_max + 1 and b + bb < N_max * b_max + 1:
                dp[i][a + aa][b + bb] = min(dp[i][a + aa][b + bb], dp[i - 1][a][b] + cc)

# print(dp[N])

ans = inf
for a in range(N_max * a_max + 1):
    for b in range(N_max * b_max + 1):
        # a:b=Ma:Mb
        # b*Ma=a*Mb
        if b * Ma == a * Mb and a * b > 0:
            ans = min(ans, dp[N][a][b])

print(ans if ans < inf else -1)

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

    inf = 100 * 40 + 1

    N, Ma, Mb = map(int, input().split())

    dp = [inf] * (400 * N * 2 + 10)
    # dp[x]:=minimum price

    # (b-a)(Mb+Ma)-(b+a)(Mb-Ma)=0を目指す
    for _ in range(N):
        a, b, p = map(int, input().split())
        x = (b - a) * (Mb + Ma) - (b + a) * (Mb - Ma)
        for key in range(400 * N * 2 + 10):
            if dp[key] == inf: continue
            nkey = key + x
            dp[nkey] = min(dp[nkey], dp[key] + p)
        dp[x] = min(dp[x], p)

    if dp[0] == inf:
        print(-1)
    else:
        print(dp[0])


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Buggy submission (verdict: Runtime Error):
N, Ma, Mb = map(int, input().split())
e = [tuple(map(int, input().split())) for _ in range(N)]

N_max = 40
a_max = 10
b_max = 10
c_max = 100

inf = N_max * c_max + 1
dp = [[[inf for _ in range(N_max * b_max + 1)] for _ in range(N_max * a_max + 1)] for _ in range(N_max + 1)]
dp[0][0][0] = 0

# print(dp[N])

for i, (aa, bb, cc) in enumerate(e, 1):
    for a in range(a_max * i + 1):
        for b in range(b_max * i + 1):
            dp[i][a][b] = min(dp[i][a][b], dp[i - 1][a][b])
            dp[i][a + aa][b + bb] = min(dp[i][a + aa][b + bb], dp[i - 1][a][b] + cc)

# print(dp[N])

ans = inf
for a in range(N_max * a_max + 1):
    for b in range(N_max * b_max + 1):
        # a:b=Ma:Mb
        # b*Ma=a*Mb
        if b * Ma == a * Mb and a * b > 0:
            ans = min(ans, dp[N][a][b])

print(ans if ans < inf else -1)
Problem p02634 (python)

Fixed submission:

p = 998244353

a,b,c,d = map(int,input().split())
dp = [[0 for _ in range(d+1)] for k in range(c+1)]
for i in range(a, c+1):
	for j in range(b, d+1):
		if i == a:
			if j == b:
				dp[i][j] = 1
			else:
				dp[i][j] = dp[i][j-1] * i % p
		elif j == b:
			dp[i][j] = dp[i-1][j] * j % p
		else:
			dp[i][j] = (dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1)) % p

print(dp[c][d])

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

p = 998244353

a,b,c,d = map(int,input().split())
dp = [[0 for _ in range(d+1)] for k in range(c+1)]
for i in range(a, c+1):
	for j in range(b, d+1):
		if i == a:
			if j == b:
				dp[i][j] = 1
			else:
				dp[i][j] = dp[i][j-1] * i % p
		elif j == b:
			dp[i][j] = dp[i-1][j] * j % p
		else:
			dp[i][j] = (dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1)) % p

print(dp[c][d])

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

p = 998244353

a,b,c,d = map(int,input().split())
dp = np.zeros((c+1, d+1), dtype=np.int64)
for i in range(a, c+1):
	for j in range(b, d+1):
		if i == a:
			if j == b:
				dp[i][j] = 1
			else:
				dp[i][j] = dp[i][j-1] * i % p
		elif j == b:
			dp[i][j] = dp[i-1][j] * j % p
		else:
			dp[i][j] = (dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1)) % p

print(dp[c][d])
Problem p02711 (python)

Fixed submission:
print(["No","Yes"]["7" in input()])

Buggy submission (verdict: Runtime Error):
# これは, u749194f さんの改造です。
# オリジナルではございません。
# https://atcoder.jp/contests/abc162/submissions/11825963
n = int(input())
s = input()
flag = True
if len(set(s))<=2:
    print(0)
    flag = False
if flag:
    r = [i+1 for i in range(n) if s[i]=='R']
    b = [i+1 for i in range(n) if s[i]=='B']
    g = [i+1 for i in range(n) if s[i]=='G']
    minus = 0
    def cnt_cmb(a, b, c):
        cnt = 0
        for i in a:
            for j in b:
                if (i+j)/2 in c:
                    cnt += 1
        return cnt
    minus += cnt_cmb(r, b, g)
    minus += cnt_cmb(b, g, r)
    minus += cnt_cmb(g, r, b)
    print(len(r)*len(b)*len(g)-minus)
Problem p02729 (python)

Fixed submission:
n,m=map(int, input().split())
r = 0
if n>=2:
	r += n*(n-1)//2
if m>=2:
	r += m*(m-1)//2
print(r)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
print((n(n-1)//2)*(m(m-1)//2))
Problem p02753 (python)

Fixed submission:
s=input()
if s=="AAA" or s=="BBB":
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
s=input()
q=int(input())
for _ in range(q):
	k=input()
	if k[0] == "1":
		s = s[::-1]
	else:
		if k[2] == "1":
			s = k[4:]+s
		else:
			s = s+k[4:]
print(s)
Problem p02759 (python)

Fixed submission:
n = int(input())
print((n+1)//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
q = int(input())
for i in range(q):
	c=list(input().split())
	if c[0]=="1":
		s=s[:int(c[1])-1]+c[2]+s[int(c[1]):]
	else:
		print(len(set(s[int(c[1])-1:int(c[2])])))
Problem p02771 (python)

Fixed submission:
a,b,c = map(int, input().split())
count = 0
if a==b:
  count = count + 1
if b==c:
  count = count + 1
if c==a:
  count = count + 1
if count == 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int, input.split())
count = 0
if a==b:
  count = count + 1
if b==c:
  count = count + 1
if c==a:
  count = count + 1
if count == 1:
  print("Yes")
else:
  print("No")
Problem p02773 (python)

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(input())
s.sort()
k = 0
f = s
maxk = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    k = k+1
    if k == maxk :
      maxk = k
      f.append(s[i])
    elif k > maxk :
      maxk = k
      f = [s[i]]
  else:
    k = 0
for i in range(len(f)):
  print(f[i])

Buggy submission (verdict: Runtime Error):
from collections import Counter
 
#まずは代入
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s).most_common() #もうリストにしちゃった<3
#この時点で, cは個数が多い順に並んでる
#たとえば入力例1だと
#[('vet', 2), ('beet', 2), ('beat', 1), ('bed', 1), ('bet', 1)]
 
ans = []
max = c[0][1] #最大の個数は何か? 数値を代入
for item,count in c:
	if count==max:
		ans.append(item)
	else:
		break #もうこれ以下は弱いのしかないのでbreakします
 
ans.sort() #辞書順に並べる
 
for i in range(len(ans)):
	print(ans[i])
Problem p02777 (python)

Fixed submission:
s,t=map(str,input().split())
a,b=map(int,input().split())
u=input()
if u == s:
	print(a-1, b)
if u == t:
	print(a, b-1)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(map(int,input().split()))
u = sum(p[0:k])
maxsum = u
for i in range(1, n-k+1):
	u = u + p[i+k-1] - p[i-1]
	if u >= maxsum:
		maxsum = u
print((maxsum+k)/2)
Problem p02819 (python)

Fixed submission:
import math
x=int(input())
primemode = True
while primemode:
  sos = True
  for n in range(math.floor(math.sqrt(x))):
    if n+1 != 1:
      if x%(n+1) == 0:
        sos = False
  if sos:
    primemode = False
  else:
    x = x+1
print(x)

Buggy submission (verdict: Runtime Error):
import math
x=int(input())
primemode = True
while primemode:
  sos = True
  for n in range(math.floor(math.sqrt(x))):
    if n+1 != 1:
      if x\(n+1) == 0:
        sos = False
  if sos:
    primemode = False
  x = x+1
print(x)
Problem p02831 (python)

Fixed submission:
import fractions
a,b=map(int,input().split())
print(a*b//fractions.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print((a*b)//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(a*b//math.gcd(a,b))
Problem p02835 (python)

Fixed submission:
f = map(int, input().split())
s = sum(f)
def u(n):
  if n>=22:
    return "bust"
  else:
    return "win"
print(u(s))

Buggy submission (verdict: Runtime Error):
r=0
s=input()
for n in len(s):
  if s[n] != s[(-1)*(n+1)]:
    r+=1
print(r/2)
Problem p02836 (python)

Fixed submission:
r = 0
s = input()
for n in range(len(s)):
  if s[n] != s[-n-1]:
    r += 1
print(r//2)

Buggy submission (verdict: Runtime Error):
r = 0
s = input()
for n in len(s):
  k = (-1)*(n+1)
  if s[n] != s[k]:
    r += 1
print(r/2)

Buggy submission (verdict: Runtime Error):
r = 0
s = input()
for n in len(s):
  if s[n] != s[(-1)*(n+1)]:
    r = r+1
print(r/2)

Buggy submission (verdict: Runtime Error):
r=0
s=input()
for n in len(s):
  if s[n] != s[(-1)*(n+1)]:
    r+=1
print(r/2)

Buggy submission (verdict: Runtime Error):
r=0
s=input()
for n in len(s):
  if s[n]!=s[-(n+1)]:
    r+=1
print(r/2)

Buggy submission (verdict: Runtime Error):
r=0
s=input()
for n in len(s):
  if s[n]!=s[-n]:
    r+=1
print(r/2)
Problem p02879 (python)

Fixed submission:
a,b=map(int,input().split());print([a*b,-1][a>9 or b>9])

Buggy submission (verdict: Runtime Error):
s=input();print([int(s[0])*int(s[2]),-1][len(s)!=3])
Problem p03286 (python)

Fixed submission:
n = int(input())
ansl = []
if n == 0:
	print(0)
	exit()
while n != 0:
	if n % 2 == 1:
		ansl.append("1")
		n -= 1
	else:
		ansl.append("0")
	n //= -2
print("".join(ansl)[::-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
ansl = []
if n == 0:
	print(0)
    exit()
while n != 0:
	if n % 2 == 1:
		ansl.append("1")
		n -= 1
	else:
		ansl.append("0")
	n //= -2
print("".join(ansl)[::-1])
Problem p02546 (python)

Fixed submission:
s = input()
if(s[-1] == 's'):
    s += 'es'
else:
    s += 's'
print(s)

Buggy submission (verdict: Runtime Error):
s = raw_input()
if(s[-1] == 's'):
    s += 'es'
else:
    s += 's'
print(s)
Problem p02570 (python)

Fixed submission:
d,t,s = map(int, input().split())
if(d <= t*s):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
d = int(input())
t = int(input())
s = int(input())
if(d <= t*s):
    print("Yes")
else:
    print("No")