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

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

Buggy submission (verdict: Runtime Error):
N = int(input())
M=N
ans=0

for i in range(2,int(N**(1/4))+1):
    e=1
    while N%(i**e)==0:
        N=N//(i**e)
        ans+=1
        e+=1
    if N<i:
        break
if M==1:
    ans=0
elif ans==0:
#    x = int(N**(1/5))
    y = int(N**(1/4))
    z = int(N**(1/3))
    a = int(N**(1/2))
#    if x**5==M:
#        ans = 2
    if y**4==M:
        ans = 2
    elif z**3==M:
        ans = 2
    elif a**2==M:
        ans = 1
    else:
        ans=1
print(ans)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
s = list(S)
t = list(T)
n = len(t)
t.pop(n-1)
if s == t:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
N , M , X =  map(int,input().split())
A = {}
B = {}
ANS = 100000000000
for i in range(1,N+1):
    A[i]=list(map(int,input().split()))
for i in range(1,2**N):
    l = str(bin(i))
    n = len(l)
    ans=0
    for s in range(1,M+1):
        B[s]=0
    for k in range(1,n+1):
        if l[-k] == "1":
            ans = ans + A[k][0]
            for s in range(1,M+1):
                B[s] += A[k][s]
    if all((B[l] >= X for l in range(1,M+1))):
        ANS = min(ans,ANS)
if ANS == 100000000000:
    print("-1")
else:
    print(ANS)

Buggy submission (verdict: Runtime Error):
N , K = map(int,input().split())
B = {}
C = {}
D = {0}
A = list(map(int,input().split()))
place = 0
num = 0
C[0] = 0
while True:
    place = int(A[place]) - 1
    num += 1   
    if place in D:
        Y = int(num) - int(C[place])
        break
    elif num == K:
        break
    else:
        B[num] = place
        C[place] = num
        D.add(place)
try:
    X = (K - num) % Y
    print(B[C[place] + X] + 1)
except:
    print(A[place])
Problem p02684 (python)

Fixed submission:
N , K = map(int,input().split())
B = {}
C = {}
D = {0}
A = list(map(int,input().split()))
place = 0
num = 0
C[0] = 0
while True:
    place = int(A[place]) - 1
    num += 1   
    if place in D:
        Y = int(num) - int(C[place])
        break
    elif num == K:
        break
    else:
        B[num] = place
        C[place] = num
        D.add(place)
try:
    X = (K - num) % Y
    print(B[C[place] + X] + 1)
except:
    print(place+1)

Buggy submission (verdict: Runtime Error):
N , K = map(int,input().split())
B = {}
C = {}
D = {0}
A = list(map(int,input().split()))
place = 0
num = 0
C[0] = 0
while True:
    place = int(A[place]) - 1
    num += 1   
    if place in D:
        Y = int(num) - int(C[place])
        break
    else:
        B[num] = place
        C[place] = num
        D.add(place)
X = (K - num) % Y
print(B[C[place] + X] + 1)

Buggy submission (verdict: Runtime Error):
N , K = map(int,input().split())
B = {}
C = {}
D = {0}
A = list(map(int,input().split()))
place = 0
num = 0
C[0] = 0
while True:
    place = int(A[place]) - 1
    num += 1   
    if place in D:
        Y = int(num) - int(C[place])
        break
    else:
        B[num] = place
        C[place] = num
        D.add(place)
if Y == 0:
    print(1)
else:
    X = (K - num) % Y
    print(B[int(C[place]) + X] + 1)
Problem p02687 (python)

Fixed submission:
name = input()
if name == "ARC":
    print("ABC")
else:
    print("ARC")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
l=0

for i in range(N):
    if A[i]>2*100000:
        A.remove(A[i])
N=len(A)
for i in range(N):
        for k in range(i+1 , N):
            if A[i]+A[k]==k-i or A[i]+A[k]==i-k:
                l+=1
print(l)
Problem p02760 (python)

Fixed submission:
# ABC157b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと
    bing = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    for num in b:
        for i in bing:
            try:
                while True:
                    t = i.index(num)
                    i[t] = -1
            except:
                continue
    # print(bing)

    naname = [((0, 0), (1, 1), (2, 2)), (2, 0), (1, 1), (0, 2)]
    if sum(bing[0]) == -3 or sum(bing[1]) == -3 or sum(bing[2]) == -3 or bing[0][0]+bing[1][0]+bing[2][0] == -3 or bing[0][1]+bing[1][1]+bing[2][1] == -3 or bing[0][2]+bing[1][2]+bing[2][2] == -3 or bing[0][0]+bing[1][1]+bing[2][2] == -3 or bing[0][2]+bing[1][1]+bing[2][0] == -3:
        print('Yes')
        exit(0)

    print('No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# ABC157b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと
    bing = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    for num in b:
        for i in bing:
            try:
                while True:
                    t = i.index(num)
                    i[t] = -1
            except:
                continue
    # print(bing)

    naname = [((0, 0), (1, 1), (2, 2)), (2, 0), (1, 1), (0, 2)]
    if sum(bing[0]) == -3 or sum(bing[1]) == -3 or sum(bing[2]) == -3 or bing[0][0]+bing[1][0]+bing[2][0] == -3 or bing[0][1]+bing[1][1]+bing[2][1] == -3 or bing[0][2]+bing[0][2]+bing[0][2] == -3 or bing[0][0]+bing[1][1]+bing[2][2] == -3 or bing[0][2]+bing[1][1]+bing[2][0] == -3:
        print('Yes')
        exit(0)

    print('No')

    d = [(1, 0), (1, 1), (0, 1)]
    for i in range(3):
        if sum(bing[i]) == -3:
            


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

Fixed submission:
# ABC154d


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0
    pos = 0

    def cum(array):
        result = [0]
        for i in range(len(array)):
            result.append(array[i]+result[i])
        return result

    def calc(N):
        t = 0
        for i in range(1, N+1):
            t += i / N
        return t

    p2 = cum(p)

    for i in range(n - k+1):
        if ans < p2[i+k]-p2[i]:
            ans = p2[i+k]-p2[i]
            pos = i

    ans = 0
    for i in range(pos, pos + k):
        ans += calc(p[i])
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    maxI = 0
    maxT = 0
    t = 0
    for i in range(n):
        t += p[i]
        if k <= i:
            t -= p[i-k]
        if maxT < t:
            maxT = t
            maxI = i
    ans = 0
     
     
    def calc(n):
        ans = 0
        for i in range(1, n+1):
            ans += i/n
        return ans
     
     
    for i in range(maxI-k+1, maxI+1):
        #print(i, p[i])
        ans += calc(p[i])
    # print(p)
    #print(maxT, maxI)
    print(ans)
Problem p02882 (python)

Fixed submission:
# ABC144d


def main():
    import sys
    import math
    import numpy as np
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    a, b, x = map(int, input().split())
    if x > a*a*b/2:
        print(np.rad2deg(np.arctan(2*(a*a*b-x)/(a*a*a))))
        # print(math.degrees(math.atan(2*(a*a*b-x)/(a*a*a))))
        exit(0)
    # print(math.degrees(math.atan(a*b*b/2/x)))
    print(np.rad2deg(np.arctan(a*b*b/2/x)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# ABC144d


def main():
    import sys
    import math
    import numpy as np
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    a, b, x = map(int, input().split())
    if x > a*a*b/2:
        # print(np.rad2deg(np.arctan(2*(a*a*b-x)/(a*a*a))))
        print(math.degrees(math.atan(2*(a*a*b-x)/(a*a*a))))
        exit(0)
    print(math.degrees(math.atan(a*b*b/2/x)))
    # print(np.rad2deg(np.arctan(a*b*b/2/x)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# ABC144d


def main():
    import sys
    import math
    import numpy as np
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    a, b, x = map(int, input().split())
    if x > a*a*b/2:
        print(np.rad2deg(np.arctan(2*(a*a*b-x)/(a*a*a))))
        # print(math.degrees(math.atan(2*(a*a*b-x)/(a*a*a))))
        exit(0)
    # print(math.degrees(math.atan(a*b*b/2/x)))
    print(np.rad2deg(np.arctan(a*b*b/2/x)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# ABC144d


def main():
    import sys
    import math
    import numpy as np
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    a, b, x = map(int, input().split())
    if x > a*b*b/2:
        print(np.rad2deg(np.arctan(2*(a*a*b-x)/(a*a*a))))
        # print(math.degrees(math.atan(2*(a*a*b-x)/(a*a*a))))
        exit(0)
    # print(math.degrees(math.atan(a*b*b/2/x)))
    print(np.rad2deg(np.arctan(a*b*b/2/x)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# ABC144d


def main():
    import sys
    import math
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    a, b, x = map(int, input().split())
    if a*b*b/2 >= x:
        print(math.degrees(math.atan(b*b*a/2/x)))
        exit(0)
    print(math.degrees(atan((b-x/a/a)/a*2)))


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

Fixed submission:
# ABC141d
import sys
import heapq
import math
import fractions
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())
cd = []


def prime_decomposition(n):
    i = 2
    table = set()
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.add(i)
        i += 1
    if n > 1:
        table.add(n)
    return table


print(len(prime_decomposition(a).intersection(prime_decomposition(b)))+1)
exit()

for i in range(1, fractions.gcd(a, b) + 1):
    if (a % i != 0 or b % i != 0):
        continue
    flag = True
    for j in cd:
        if (j == 1):
            continue
        if (i % j == 0):
            flag = False
            break
    if (flag):
        cd.append(i)
print(len(cd))

Buggy submission (verdict: Runtime Error):
# ABC141d
import sys
import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())
cd = []
for i in range(1, math.gcd(a, b) + 1):
    if (a % i != 0 or b % i != 0):
        continue
    flag = True
    for j in cd:
        if (j == 1):
            continue
        if (i % j == 0):
            flag = False
            break
    if (flag):
        cd.append(i)
print(len(cd))
Problem p02945 (python)

Fixed submission:
# ABC137a
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())
print(max(a+b, a-b, a*b))

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())
print(max(a+b, a-b, a*b))
Problem p02995 (python)

Fixed submission:
from fractions import gcd

a,b,c,d=map(int,input().split())
lcm=int(c*d/gcd(c,d))
A=a-1
x1=A-A//c-A//d+A//lcm
x2=b-b//c-b//d+b//lcm
print(x2-x1)

Buggy submission (verdict: Runtime Error):
# 最初に入れておくとinputが早くなる
import sys
from math import gcd
input = sys.stdin.readline

a, b, c, d = map(int, input().split())
a -= 1
# warikireru = set()
# for i in range(b//c+1):
#    for j in range(b // d+1):
#        k = c ** i * d ** j
#        if(a <= k <= b):
#            warikireru.add(k)
# print(warikireru)
# print(b-a+1-len(warikireru))

k = c * d / gcd(c, d)

print(b-a-b//c+a//c-b//d+b//k+a//d-a//k)

Buggy submission (verdict: Runtime Error):
# 最初に入れておくとinputが早くなる
import sys
import math
input = sys.stdin.readline

a, b, c, d = map(int, input().split())
# warikireru = set()
# for i in range(b//c+1):
#    for j in range(b // d+1):
#        k = c ** i * d ** j
#        if(a <= k <= b):
#            warikireru.add(k)
# print(warikireru)
# print(b-a+1-len(warikireru))

k = c * d / math.gcd(c, d)

print(b-a-b//c+a//c-b//d+b//k+a//d-a//k)
Problem p03006 (python)

Fixed submission:
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

ans = dict()

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

for i in range(n):
    for j in range(n):
        if (i == j):
            continue
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        if ans.get((p, q)) == None:
            ans[(p, q)] = 1
        else:
            ans[(p, q)] += 1
# print(ans)
print(n-max(ans.values()))

Buggy submission (verdict: Runtime Error):
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

ans = dict()

for i in range(n):
    for j in range(i+1, n):
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        if ans.get((p, q)) == None:
            ans[(p, q)] = 1
        else:
            ans[(p, q)] += 1
print(list(ans.values()).count(max(ans.values())))
Problem p03014 (python)

Fixed submission:
#解説コードコピペです

import numpy as np
 
def solve():
    H, W = list(map(int, input().split()))
    grid = []
    for i in range(H):
        grid.append(list(input()))
    #print((np.array(grid) == ".") * 1) #行列演算 "." ならTrue そうでなければFalseの行列をつくる *1で1と0に変換
    grid = (np.array(grid) == ".") * 1  # ランプをおける:1, 障害物:0
 
    L = np.zeros((H,W), dtype=int) #0でうめつくした行列をつくる
    R = np.zeros((H,W), dtype=int)
    U = np.zeros((H,W), dtype=int)
    D = np.zeros((H,W), dtype=int)
    
    for j in range(W): #列単位で処理
        if j == 0:
            L[:, j] = grid[:, j]
        else:
            L[:, j] = (L[:, j-1] + 1) * grid[:, j] #gridでかけることで 障害物があったときにそのマスを0にする
    
    for j in range(W-1, -1, -1):
        if j == W-1:
            R[:, j] = grid[:, j]
        else:
            R[:, j] = (R[:, j+1] + 1) * grid[:, j]
 
    for i in range(H):
        if i == 0:
            U[i] = grid[i] * 1
        else:
            U[i] = (U[i-1] + 1) * grid[i]
    
    for i in range(H-1, -1, -1):
        if i == H-1:
            D[i] = grid[i]
        else:
            D[i] = (D[i+1] + 1) * grid[i]
 
    ans = np.max(L+R+U+D-3)
    print(ans)
 
 
if __name__ == "__main__": #ここはしらん
    solve()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())

result = 0
#memo = {}


def terasu(x, y, d):
    #print(x, y, h, w)
    if y < 0 or x < 0 or y >= h or x >= w:
        return 0
    # if (x, y) in memo.keys():
    #    return 0
    if s[y][x] == "#":
        return 0
    #memo[(x, y)] = True
    if d == "f":
        return 1 + terasu(x + 1, y, "e") + terasu(x, y - 1, "s") + terasu(x, y+1, "n") + terasu(x-1, y, "w")
    elif d == "e":
        return 1 + terasu(x + 1, y, "e")
    elif d == "s":
        return 1 + terasu(x, y - 1, "s")
    elif d == "n":
        return 1 + terasu(x, y+1, "n")
    elif d == "w":
        return 1 + terasu(x-1, y, "w")


for y in range(h):
    for x in range(w):
        result = max(result, terasu(x, y, "f"))
print(result)
Problem p03031 (python)

Fixed submission:
n, m = map(int, input().split())
switches = []
for _ in range(m):
    switches.append(list(map(int, input().split()))[1:])
p = list(map(int, input().split()))

ans = 0
switchState = [0]*n


def dfs(i, tukeru):
    #print(i, tukeru)
    if(i == n):
        sumOfTento = 0
        for denkyu in range(m):
            sumOfswitch = 0
            for switch in switches[denkyu]:
                sumOfswitch += switchState[switch-1]
            if(sumOfswitch % 2 == p[denkyu]):
                sumOfTento += 1
        # print(switchState)
        if(sumOfTento == m):
            return 1
        else:
            return 0
    switchState[i] = tukeru
    return dfs(i+1, 0) + (dfs(i+1, 1) if i != n-1 else 0)


print(dfs(0, 0)+dfs(0, 1))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
k = []
for _ in range(m):
    k.append(list(map(int, input().split())))
p = list(map(int, input().split()))

denkyu = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
memo = []
memos = []


def erabu(i, n, c, d):
    if (i > len(k[d][1:])):
        if(c % 2 == p[d]):
            memo.append(n)
        return
    if(i+1 in k[d][1:]):
        erabu(i+1, n.append(i+1), c+1, d)
    erabu(i + 1, n, c, d)


print(memo)

for i in range(m):
    erabu(0, 0, 0, i)
    memos.append(memo)

# for i in range(len(memos[0])):

# def isOK(i, n):
 #   if (n ^ memos[i][j] not 0)
Problem p03044 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n = int(input())
    edge = [dict() for _ in range(n)]
    dist = [0]*n
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        edge[u-1].update({v-1: w})
        edge[v-1].update({u-1: w})

    def dfs(i, pre, d):
        dist[i] = d
        for v in edge[i].keys():
            if v == pre:
                continue
            dfs(v, i, d+edge[i][v])

    dfs(0, -1, 0)
    # print(dist)

    for i in dist:
        if i % 2 == 0:
            print(0)
        else:
            print(1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# Union-Find木
import sys
input = sys.stdin.readline

n = int(input())
tree = [0]
for i in range(1, n+1):
    tree.append(i)


def root(x):
    if(tree[x] == x):
        return x
    tree[x] = root(tree[x])
    return tree[x]  # 経路圧縮


def same(x, y):  # xとyが同じ木に属するか
    return root(x) == root(y)


def unite(x, y):
    x = root(x)
    y = root(y)
    if(x == y):
        return
    tree[x] = y


for _ in range(n-1):
    u, v, w = map(int, input().split())
    if(w % 2 == 0):
        unite(u, v)

for i in range(1, n+1):
    if (same(1, i)):
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
tree = [0]
for i in range(1, n+1):
    tree.append(i)


def root(x):
    if(tree[x] == x):
        return x
    tree[x] = root(tree[x])
    return tree[x]  # 経路圧縮


def same(x, y):  # xとyが同じ木に属するか
    return root(x) == root(y)


def unite(x, y):
    x = root(x)
    y = root(y)
    if(x == y):
        return
    tree[x] = y


for _ in range(n-1):
    u, v, w = map(int, input().split())
    if(w % 2 == 0):
        unite(u, v)

for i in range(1, n+1):
    if (same(1, i)):
        print(0)
    else:
        print(1)
Problem p03074 (python)

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

sl = []
c = 1
if (s[0] == "1"):
    sl.append(0)
for i in range(n):
    if (i != 0):
        if (s[i] == s[i-1]):
            c += 1
        else:
            sl.append(c)
            c = 1
sl.append(c)

ruisekiwa = [0]
sums = []
ans = 0
w = 2*k+1

if (w > len(sl)):
    print(n)
    exit()
for i in range(len(sl)):
    ruisekiwa.append(ruisekiwa[i] + sl[i])
# print(sl)
# print(ruisekiwa)
for i in range(len(sl)):
    if(k % 2 == 1 and i % 2 == 0 or k % 2 == 0 and i % 2 == 1):
        left = i-k
        if (left < 0):
            left = 0
        right = i + k+1
        if (right >= len(ruisekiwa)):
            right = len(ruisekiwa)-1
        # print(ruisekiwa[right], "-", ruisekiwa[left],
        #      "=", ruisekiwa[right]-ruisekiwa[left])
        ans = max(ans, ruisekiwa[right]-ruisekiwa[left])
print(ans)

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

sl = []
c = 1
if (s[0] == "1"):
    sl.append(0)
for i in range(n):
    if (i != 0):
        if (s[i] == s[i-1]):
            c += 1
        else:
            sl.append(c)
            c = 1
sl.append(c)

ruisekiwa = [0]
sums = []
for i in range(len(sl)):
    ruisekiwa.append(ruisekiwa[i] + sl[i])
# print(sl)
# print(ruisekiwa)
for i in range(len(sl)):
    if(k % 2 == 1 and i % 2 == 0 or k % 2 == 0 and i % 2 == 1):
        left = i-k
        if (left < 0):
            left = 0
        right = i + k+1
        if (right >= len(ruisekiwa)):
            right = len(ruisekiwa)-1
        # print(ruisekiwa[right], "-", ruisekiwa[left],
        #      "=", ruisekiwa[right]-ruisekiwa[left])
        sums.append(ruisekiwa[right]-ruisekiwa[left])
print(max(sums))
Problem p03078 (python)

Fixed submission:
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab = sorted(x+y for x in a for y in b)[:-k-1:-1]
abc = sorted(x+y for x in ab[:k] for y in c)[:-k-1:-1]
print(*abc, sep='\n')

Buggy submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
a=list(map(int,input().split())).sort(reverse=True)
b=list(map(int,input().split())).sort(reverse=True)
c=list(map(int,input().split())).sort(reverse=True)

ab=[]

for i in a[:k]:
    for j in b[:k]:
        ab.append(i+j)
ab.sort(reverse=True)

abc=[]
for i in ab[:k]:
    for j in c[:k]:
        abc.append(i+j)
abc.sort(reverse=True)

for i in abc[:k]:
    print(i)
Problem p03087 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy submission (verdict: Runtime Error):
import re

i = input().split()[1]
s = input()
k = 0
result = []

while k < i:
    ft, et = [int(n) for n in input().split()]
    result.append(len(re.findall("AC", s[ft - 1:et])))
    k += 1

for kekka in result:
    print(kekka)

Buggy submission (verdict: Runtime Error):
import re

input()
s = input()
b, c = [int(n) for n in input().split()]
d, e = [int(n) for n in input().split()]
f, g = [int(n) for n in input().split()]
print(len(re.findall("AC", s[b - 1:c])))
print(len(re.findall("AC", s[d-1:e])))
print(len(re.findall("AC", s[f-1:g])))
Problem p03244 (python)

Fixed submission:
# ABC111c
from collections import Counter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def calc():
    ans = 0
    for i in range(len(v)):
        if i % 2 == 0:
            if v[i] != f:
                ans += 1
        else:
            if v[i] != f2:
                ans += 1
    return ans


n = int(input())
v = list(map(int, input().split()))
V1 = Counter(v[::2]).most_common()
V2 = Counter(v[1::2]).most_common()
f = V1[0][0]
f2 = V2[0][0]
if f == f2:
    if len(V2) > 1:
        f2 = V2[1][0]
    else:
        f2 = 'x'
    a = calc()
    if len(V1) > 1:
        f = V1[1][0]
    else:
        f = 'x'
    f2 = V2[0][0]
    print(min(a, calc()))
else:
    print(calc())

Buggy submission (verdict: Runtime Error):
# ABC111c
from collections import Counter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def calc():
    ans = 0
    for i in range(len(v)):
        if i % 2 == 0:
            if v[i] != f:
                ans += 1
        else:
            if v[i] != f2:
                ans += 1
    return ans


n = int(input())
v = list(map(int, input().split()))
f = Counter(v[::2]).most_common()[0][0]
f2 = Counter(v[1::2]).most_common()[0][0]
if f == f2:
    f2 = Counter(v[1::2]).most_common()[1][0]
    a = calc()
    f = Counter(v[::2]).most_common()[1][0]
    f2 = Counter(v[1::2]).most_common()[0][0]
    print(min(a, calc()))
else:
    print(calc())