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

Fixed submission:
from math import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
g = gcd(n, m)
ans = n*m//g
sp_a, sp_b = m//g, n//g
jud = True
for i in range(ans//sp_a):
    if i*sp_a % sp_b == 0:
        if s[i % n] != t[i*sp_a//sp_b]:
            jud = False

if jud:
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from math import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())

ans = n*m//gcd(n, m)
sp_a, sp_b = ans//n, ans//m
l = [False]*(ans + 1)
jud = True
for i in range(n):
    l[i*sp_a] = s[i]

for i in range(m):
    if not l[i*sp_b]:
        l[i*sp_b] = t[i]
    else:
        if l[i*sp_b] != t[i]:
            jud = False
            break
if jud:
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from math import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())

ans = n*m//gcd(n, m)
sp_a, sp_b = ans//n, ans//m
l = [False]*ans
jud = True
for i in range(n):
    l[i*sp_a] = s[i]

for i in range(m):
    if not l[i*sp_b]:
        l[i*sp_b] = t[i]
    else:
        if l[i*sp_b] != t[i]:
            jud = False
            break
if jud:
    print(ans)
else:
    print(-1)

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

def gcd(a, b):
    while b != 0:
        c = a%b
        a = b
        b = c
    return a

ans = n*m//gcd(n, m)
sp_a, sp_b = ans//n, ans//m
l = [False]*ans
jud = True
for i in range(n):
    l[i*sp_a] = s[i]

for i in range(m):
    if not l[i*sp_b]:
        l[i*sp_b] = t[i]
    else:
        if l[i*sp_b] != t[i]:
            jud = False
            break
if jud:
    print(ans)
else:
    print(-1)
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
l = []
for h in range(H):
    l.append(input())

j = True
for h in range(H):
    if not j:
        break
    for w in range(W):
        if l[h][w] == "#":
            j = False
            if h != 0:
                if l[h - 1][w] == "#":
                    j = True
            if h != H - 1:
                if l[h + 1][w] == "#":
                    j = True
            if w != 0:
                if l[h][w - 1] == "#":
                    j = True
            if w != W - 1:
                if l[h][w + 1] == "#":
                    j = True
            if not j:
                break
if j:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
l = []
for h in range(H):
    l.append(input())

for h in range(H):
    for w in range(W):
        if l[h][w] == "#":
            j = False
            if h != 0:
                if l[h - 1][w] == "#":
                    j = True
            if h != H - 1:
                if l[h + 1][w] == "#":
                    j = True
            if w != 0:
                if l[h][w - 1] == "#":
                    j = True
            if w != W - 1:
                if l[h][w + 1] == "#":
                    j = True
            if not j:
                break
if j:
    print("Yes")
else:
    print("No")
Problem p03393 (python)

Fixed submission:
s = list(input())
l = [chr(i) for i in range(ord("a"), ord("z") + 1)]
if len(s) == 26:
    if s == l[-1::-1]:
        print(-1)
        exit()
    else:
        for i in range(26)[-2::-1]:
            for j in range(25, i, -1):
                if s[i] < s[j]:
                    s[i] = s[j]
                    print("".join(s[:i+1]))
                    exit()
for i in range(26)[-1::-1]:
    if l[i] in s:
        del l[i]
s.append(l[0])
print("".join(s))

Buggy submission (verdict: Runtime Error):
s = list(input())
l = [chr(i) for i in range(ord("a"), ord("z") + 1)]
if len(s) == 26:
    if s == reversed(l):
        print(-1)
        exit()
    else:
        fi = False
        for i in range(26)[-2::-1]:
            if fi:
                break
            for j in range(25, i, -1):
                if s[i] < s[j]:
                    s[i] = s[j]
                    s = s[:i+1]
                    fi = True
                    break
for i in range(26)[-1::-1]:
    if l[i] in s:
        del l[i]
s.append(l[0])
print("".join(s))
Problem p03627 (python)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
d = Counter(A)
key = d.keys()
ans = []
for k in key:
    if d[k] >= 2:
        ans.append(k)
        if d[k] >= 4:
            ans.append(k)
if len(ans) < 2:
    print(0)
else:
    ans.sort()
    print(ans[-1]*ans[-2])

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
v = x/W
h = y/H
if v and h == 0.5 :
    print(W*H/2, 1)
else:
    print(W*H/2, 0)
Problem p03665 (python)

Fixed submission:
n, p = map(int, input().split())
a = list(map(int, input().split()))

def comb(n, r):
    ans = 1
    if n < 2*r:
        r = n - r
    for i in range(r):
        ans *= (n - i)
        ans //= (i + 1)
    return ans

ev, od = 0, 0
for i in a:
    if i%2 == 0:
        ev += 1
    else:
        od += 1
ans = 0
if p == 0:
    for i in range(0, od+1, 2):
        for j in range(ev+1):
            ans += comb(od, i)*comb(ev, j)
else:
    for i in range(1, od+1, 2):
        for j in range(ev+1):
            ans += comb(od, i)*comb(ev, j) 
print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n, p = map(int, input().split())
a = list(map(int, input().split()))
ev, od = 0, 0
for i in a:
    if i%2 == 0:
        ev += 1
    else:
        od += 1
ans = 0
if p == 0:
    for i in range(0, od+1, 2):
        for j in range(ev+1):
            ans += comb(od, i, exact = True)*comb(ev, j, exact = True)
else:
    for i in range(1, od+1, 2):
        for j in range(ev+1):
            ans += comb(od, i, exact = True)*comb(ev, j, exact = True) 
print(ans)
Problem p03695 (python)

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

color = [False]*8
flex = 0
cnt = 0
for i in range(n):
    if a[i] < 400:
        color[0] = True
    elif a[i] < 800:
        color[1] = True
    elif a[i] < 1200:
        color[2] = True
    elif a[i] < 1600:
        color[3] = True
    elif a[i] < 2000:
        color[4] = True
    elif a[i] < 2400:
        color[5] = True
    elif a[i] < 2800:
        color[6] = True
    elif a[i] < 3200:
        color[7] = True
    else:
        flex += 1

for i in range(8):
    if color[i]:
        cnt += 1
mi = cnt
if mi == 0:
    mi = 1
cnt += flex

print(str(mi) + " " + str(cnt))

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

color = [0]*9
cnt = 0
for i in range(n):
    if a[i] < 400:
        color[0] += 1
    elif a[i] < 800:
        color[1] += 1
    elif a[i] < 1200:
        color[2] += 1
    elif a[i] < 1600:
        color[3] += 1
    elif a[i] < 2000:
        color[4] += 1
    elif a[i] < 2400:
        color[5] += 1
    elif a[i] < 2800:
        color[6] += 1
    elif a[i] < 3200:
        color[7] += 1
    else:
        color[8] += 1

for i in range(8):
    if color[i] != 0:
        cnt += 1
        mi = cnt
if cnt != 8:
    cnt += color[8]
    if cnt > 8:
        cnt = 8

print(str(mi) + " " + str(cnt))
Problem p02612 (python)

Fixed submission:
# input
N = int(input())
noguchi = [1000 * n for n in range(1, 11)]

# check
print(min([ngc - N for ngc in noguchi if (ngc - N) >= 0]))

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
noguchi = [1000 * n for n in range(1, 11)]

# check
print(min([ngc - N for ngc in noguchi if (ngc - N) > 0]))

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
noguchi = [1000 * n for n in range(1, 11)]

# check
print(min([ngc - N for ngc in noguchi if (ngc - N) < 0]))
Problem p02640 (python)

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

# check
if Y < 2 * X or Y > 4 * X or abs(Y - 2 * X) % 2 != 0:
    print("No")
else:
    print("Yes")

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

# check
if Y in set([sum(p) for p in set(product([2, 4], repeat=X))]):
    print("Yes")
else:
    print("No")
Problem p02681 (python)

Fixed submission:
# input
S = input()
T = input()

if T.startswith(S):
    print("Yes")
else:
    print("No")

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

if T.startswith(S):
    print("Yes")
else;
    print("No")
Problem p02717 (python)

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

# change box
tmp = A
A = B
B = tmp

tmp = A
A = C
C = tmp


# output
print("{} {} {}".format(A, B, C))

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

# change box
tmp = A
A = B
B = tmp

tmp = A
A = C
C = tmp
    

# output
print("{} {} {]".format(A, B, C))

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

# output
print("{} {} {]".format(C, A, B))
Problem p02730 (python)

Fixed submission:
# input
S = input()

# check
N = len(S)

if S[:int((N - 1) / 2)] == S[int((N + 2) / 2):]:
    print("Yes")
else:
    print("No")

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

# check
N = len(S)

print(f"{S}\t{S[:int((N - 1) / 2)]}\t{S[int((N + 2) / 2):]}")

if S[:int((N - 1) / 2)] == S[int((N + 2) / 2):]:
    print("Yes")
else:
    print("No")
Problem p02755 (python)

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

# check
ans = -1
for n in range(1000, -1, -1):
    if int(n * 0.08) == A and int(n * 0.1) == B:
        ans = n

print(ans)

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

# check
ans = -1
for n in range(100 / 0.1, -1, -1):
    if int(n * 0.08) == A and int(n * 0.1) == B:
        ans = n

print(ans)

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

# check
# kimeuchi = max([int(A / 0.08), int(B / 0.1)])
# if int(kimeuchi * 0.08) == A and int(kimeuchi * 0.1) == B:
#
#     print(kimeuchi)
# else:
#     print(-1)

ans = -1
for n in range(100 * 0.1, -1 , -1):
    if int(n * 0.08) == A and int(n * 0.1) == B:
        ans = n

print(ans)
Problem p02761 (python)

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

c = []

c_append = c.append

for i in range(M):
    sm, cm = map(int, input().split())
    c_append((sm, cm))

ans = -1

# check
for i in range(1000):
    str_i = str(i)

    if N < len(str_i):
        break

    if N == len(str_i) and False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:
        ans = i
        break

print(ans)

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

c = []

c_append = c.append

for i in range(M):
    sm, cm = map(int, input().split())
    c_append((sm, cm))

if (1, 0) in c:
    print(-1)
else:
    ans = -1

    # check
    for i in range(1000):
        str_i = str(i)

        if N < len(str_i):
            break

        if False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:
            ans = i
            break

    print(ans)
Problem p02802 (python)

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

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["ac"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1

AC_cnt = sum([1 for key in AC_questions.keys() if AC_questions[key]['ac'] is True])
WA_cnt = sum([AC_questions[key]["wa_cnt"] for key in AC_questions.keys() if AC_questions[key]["ac"] is True])

print(AC_cnt, WA_cnt)

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

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["wa_cnt"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1
        
AC_cnt = sum([1 for a in AC_questions if a['ac'] is True])
WA_cnt = sum([a["wa_cnt"] for a in AC_questions if a["ac"] is True])

print(AC_cnt, WA_cnt)
Problem p02861 (python)

Fixed submission:
from itertools import combinations
from math import sqrt

# input
N = int(input())
xy = []
xy_append = xy.append
for n in range(N):
    x, y = map(int, input().split())
    xy_append((x, y))

nC2 = list(combinations(xy, 2))
dist = []
d_append = dist.append
for a, b in nC2:
    d_append(sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2))

if len(dist) == 1:
    print(dist[0])
else:
    dist_sum = 0
    dist_case = list(combinations(dist, N - 1))
    for d in dist_case:
        dist_sum += sum(d)

    print(dist_sum / len(dist_case))

Buggy submission (verdict: Runtime Error):
from itertools import combinations, combinations_with_replacement
from math import sqrt

# input
N = int(input())
xy = []
xy_append = xy.append
for n in range(N):
    x, y = map(int, input().split())
    xy_append((x, y))

nC2 = list(combinations(xy, 2))
dist = []
d_append = dist.append
for a, b in nC2:
    d_append(sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2))

dist_sum = 0
dist_case = combinations_with_replacement(dist, 2)
for m, n in dist_case:
    dist_sum += m + n

print(dist_sum / len(dist_case))
Problem p02900 (python)

Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    z = None
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        return z


# 引用：https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def get_fact(n):
    arr = []
    a_append = arr.append
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1) + 1)):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            a_append([i, cnt])

    if temp != 1:
        a_append([temp, 1])

    if not arr:
        a_append([n, 1])

    return arr


# input
A, B = map(int, input().split())

# check
# 参考：https://drken1215.hatenablog.com/entry/2019/10/03/175800
# ①最大公約数の素因数分解を求める
g = gcd(A, B)
fact = [f[0] for f in get_fact(g)]

# ②指数を省き、カウントする(1は確実にあるので予めカウントしておく)
elem = [1]
e_append = elem.append
for f in fact:
    if f not in elem:
        e_append(f)

print(len(elem))

Buggy submission (verdict: Runtime Error):
# 引用：https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def get_fact(n):
    arr = []
    a_append = arr.append
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1) + 1)):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            a_append([i, cnt])

    if temp != 1:
        a_append([temp, 1])

    if not arr:
        a_append([n, 1])

    return arr


# input
A, B = map(int, input().split())

# check
# 参考：https://drken1215.hatenablog.com/entry/2019/10/03/175800
# ①最大公約数の素因数分解を求める
g = gcd(A, B)
fact = [f[0] for f in get_fact(g)]

# ②指数を省き、カウントする
elem = [1]
e_append = elem.append
for f in fact:
    if f not in elem:
        e_append(f)

print(len(elem))

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


def get_fact(n):
    arr = []
    a_append = arr.append
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1) + 1)):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            a_append([i, cnt])

    if temp != 1:
        a_append([temp, 1])

    if not arr:
        a_append([n, 1])

    return arr


# input
A, B = map(int, input().split())

# check

# ①最大公約数の素因数分解を求める
g = gcd(A, B)
fact = [f[0] for f in get_fact(g)]

# ②指数を省き、カウントする
elem = [1]
e_append = elem.append
for f in fact:
    if f not in elem:
        e_append(f)

print(elem)

print(len(elem))
Problem p02945 (python)

Fixed submission:
# input
A, B = map(int, input().split())
print(max([A + B, A - B, A * B]))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max([a + B, a - b, a * b]))
Problem p02971 (python)

Fixed submission:
# input
N = int(input())
A = []
append = A.append

for i in range(N):
    append(int(input()))

sort_A = sorted(A, reverse=True)[:2]

# check
for a in A:
    if a == sort_A[0]:
        print(sort_A[1])
    else:
        print(sort_A[0])

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
A = []
append = A.append

for i in range(N):
    append(int(input()))

# check
set_A = list(set(A))
for a in A:
    print(max([sa for sa in set_A if sa != a]))
Problem p02983 (python)

Fixed submission:
from itertools import combinations

# input
L, R = map(int, input().split())

# check
mod0 = [n for n in range(0, R + 1, 2019) if L <= n]
if not mod0:
    target_num = list(range(L, R + 1))
    nC2 = list(combinations(target_num, 2))
    mods_ans = [(i * j) % 2019 for i, j in nC2]

    print(min(mods_ans))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

# input
L, R = map(int, input().split())
mod0 = [n for n in range(0, R + 1, 2019) if L <= n <= R]
# check
target_num = list(range(L, R + 1))
if mod0:
    print(0)
else:
    nC2 = list(combinations(target_num, 2))
    mods_ans = [(i * j) % 2019 for i, j in nC2]

    print(min(mods_ans))

Buggy submission (verdict: Runtime Error):
from itertools import combinations

# input
L, R = map(int, input().split())

# check
target_num = list(range(L, R + 1))
nC2 = list(combinations(target_num, 2))
mods_ans = [(i * j) % 2019 for i, j in nC2]

print(min(mods_ans))
Problem p02993 (python)

Fixed submission:
# input
S = input()

fl = True
for i in range(0, 3):
    if S[i] == S[i + 1]:
        print("Bad")
        fl = False
        break

if fl is True:
    print("Good")

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

fl = True
for i in range(0, 4):
    if S[i] == S[i + 1]:
        print("Bad")
        fl = False
        break

if fl is True:
    print("Good")

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

fl = True
for i, s in range(0, 4):
    if S[i] == S[i + 1]:
        print("Bad")
        fl = False
        break

if fl is True:
    print("Good")
Problem p02995 (python)

Fixed submission:
# 判定機にmathがインストールされていないため、
# gcd=最小公倍数、lcm=最少公約数(返り値整数)を実装
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    z = None
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        return z


def lcm(m, n):
    return (m * n) // gcd(m, n)


# input
A, B, C, D = map(int, input().split())

# check
AB = B - (A - 1)

C_cnt = B // C - (A - 1) // C
D_cnt = B // D - (A - 1) // D

lcm_CD = lcm(C, D)
lcm_cnt = B // lcm_CD - (A - 1) // lcm_CD

ans = AB - C_cnt - D_cnt + lcm_cnt

print(ans)

Buggy submission (verdict: Runtime Error):
# 判定機にmathがインストールされていないため、
# gcd=最小公倍数、lcm=最少公約数(返り値整数)を実装
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    z = None
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        return z


def lcm(m, n):
    return (m * n) // gcd(m, n)


# input
A, B, C, D = map(int, input().split())

# check
AB = len(list(range(A, B + 1)))

C_cnt = B // C - (A - 1) // C
D_cnt = B // D - (A - 1) // C

lcm_CD = lcm(C, D)
lcm_cnt = B // lcm_CD - (A - 1) // lcm_CD

print(AB - C_cnt - D_cnt + lcm_cnt)

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

# input
A, B, C, D = map(int, input().split())

# check
AB = len(list(range(A, B + 1)))

C_cnt = B // C - (A - 1) // C
D_cnt = B // D - (A - 1) // C

lcm_CD = C * D // gcd(C, D)
lcm_cnt = B // lcm_CD - (A - 1) // lcm_CD

print(AB - C_cnt - D_cnt + lcm_cnt)

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

# check
ans = len([1 for i in range(A, B + 1) if i % C != 0 and i % D != 0])

print(ans)
Problem p03037 (python)

Fixed submission:
# input & check
N, M = map(int, input().split())
x, y = 0, N
for i in range(1, M + 1):
    L, R = map(int, input().split())
    x = max(x, L)
    y = min(y, R)

print(len(range(x, y + 1)))

Buggy submission (verdict: Runtime Error):
# input
N, M = map(int, input().split())
check = []
c_append = check.append
for i in range(1, M + 1):
    L, R = map(int, input().split())
    c_append(set(list(range(L, R + 1))))

# check
mastar_keys = set(list(range(1, N + 1)))
for k in sorted(check, key=lambda x: len(x)):
    mastar_keys = mastar_keys & check[k]
    if len(mastar_keys) == 0:
        break

print(len(mastar_keys))
Problem p03061 (python)

Fixed submission:
from fractions import gcd


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

# 累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (gcd(left[i], a[i]))
    right[n - i - 1] = (gcd(right[n - i], a[n - 1 - i]))

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i + 1]))
print(ans)

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

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

# check
A.sort(reverse=True)
max_gcd = A[0]
change = False
for a in A:
    ans = gcd(max_gcd, a)
    if ans < max_gcd and change is False:
        change = True
        continue
    max_gcd = ans

print(max_gcd)

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

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

# check
A.sort(reverse=True)
max_gcd = A[0]
change = False
for a in A:
    ans = gcd(ans, a)
    if ans < max_gcd and change is False:
        continue
    max_gcd = ans

print(max_gcd)
Problem p03087 (python)

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

a = [0] * N
c = [False] * N
for i in range(1, N):
    if S[i - 1:i + 1] == "AC":
        a[i] = a[i - 1] + 1
        c[i] = True
    else:
        a[i] = a[i - 1]

for i in range(Q):
    l, r = map(int, input().split())
    if l - 1 == 0:
        print(a[r - 1])
    elif c[l - 1] is True:
        print(a[r - 1] - a[l - 1])
    else:
        print(a[r - 1] - a[l - 1])

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

substrs = []
s_append = substrs.append
for i in range(Q):
    l, r = map(int, input().split())
    s_append(S[l - 1:r])

# check
for substr in substrs:
    substr_len = len(substr)
    AC_cnt = sum(
        [
            1
            for i in range(0, substr_len - 1)
            if substr[i:i + 2] == "AC"
        ]
    )

    print(AC_cnt)
Problem p03106 (python)

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

# check
div_nums = [1]
append = div_nums.append
for i in range(2, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        append(i)

print(div_nums[-K])

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

# check
if K == 1:
    print(1)
else:
    cnt, op = 1, 1
    div_nums = []
    append = div_nums.append
    for i in range(2, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            append(i)
    
    print(div_nums[-K])
Problem p03136 (python)

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

if max(L) < sum(L) - max(L):
    print("Yes")
else:
    print("No")

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

if max(L) < sum(L) - max(L):
    print("Yes")
else;
    print("No")