Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

def s_bannme(i,s):
    ans = [d for d in str(i)]
    if len(ans)>s:
        return int(ans[s])


def solve(N: int, M: int, S: "List[int]", C: "List[int]"):
            
    for i in range(1000):
        if M == 0:
            digits = len(str(i))
            if digits == N:
                pass
            else:
                exist = False
        else:
            exist = True
            for s, c in zip(S, C):
                digits = len(str(i))
                cons = s_bannme(i,s-1)
                if digits == N and cons == c:
                    pass
                else:
                    exist = False

        if exist:
            print(i)
            return
                
    print(-1)



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

def s_bannme(i,s):
    ans = [d for d in str(i)]
    if len(ans)>s:
        return int(ans[s])


def solve(N: int, M: int, S: "List[int]", C: "List[int]"):
            
    for i in range(1000):
        exist = True
        if M == 0:
            digits = len(str(i))
            if digits == N:
                pass
            else:
                exist = False
        else:
            for s, c in zip(S, C):
                digits = len(str(i))
                cons = s_bannme(i,s-1)
                if digits == N and cons == c:
                    pass
                else:
                    exist = False

        if exist:
            print(i)
            return
                
    print(-1)



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

def E(N):
    SUM = N*(N+1)/2
    return SUM / N

def solve(N: int, K: int, p: "List[int]"):
    P = [E(val) for val in p]

    memo = []
    for n in range(N):
        group = P[n:n+K]
        memo.append(sum(group))

    print(max(memo))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

def E(N):
    SUM = N*(N+1)/2
    return SUM / N

def solve(N: int, K: int, p: "List[int]"):
    P = [E(val) for val in p]

    group_sum = sum(P[:K])
    memo = [group_sum]

    for n in range(N-K):
        group_sum = group_sum - P[n] + P[n+K]
        memo.append(group_sum)

    print(max(memo))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math
H,A = list(map(int, input().split()))

print(math.ceil(H / a))

Fixed submission:
import math

def main():
    H,A = list(map(int, input().split()))
 
    print(math.ceil(H / A))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, M = list(map(int,input().split())
    if N == M:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, M = list(map(int,input().split()))
    if N == M:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
    
def main():
    N = int(input())
    P = list(map(int, input().split()))
    
    count = 0
    for i in range(N):
        flag = True
        for j in range(i):
            if P[i] > P[j]: 
                flag = False
                break

        if flag:
            count += 1
    print(count)
if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    P = list(map(int, input().split()))
    
    count = 0
    k = 0
    for i in range(N):
        flag = True
        for j in range(k, i):
            if P[i] > P[j]: 
                flag = False
                break

        if flag:
            count += 1
            k = i
            
    print(count)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    P = list(map(int, input().split()))
    
    count = 0
    for i in range(N):
        flag = True
        for j in range(i):
            if P[i] > P[j]: 
                flag = False
                break

        if flag:
            count += 1
    print(count)
if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    P = list(map(int, input().split()))
    
    count = 0
    k = 0
    for i in range(N):
        flag = True
        for j in range(k, i):
            if P[i] > P[j]: 
                flag = False
                break

        if flag:
            count += 1
            k = i
            
    print(count)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, K, S = list(map(int, input().split()))

    arr = [] 
    for i in range(0, K):
        arr += [S]
    while len(arr) < N:
        arr += [S+1]
	print(len(arr))
if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, K, S = list(map(int, input().split()))

    salt = -1 if S >= 10**9 else 1
    if K == 0:
        arr = [S+salt] *N
    else:
        arr = [] 
        for i in range(0, K):
            arr += [S]
        while len(arr) < N:
                arr += [S+salt]

    print(' '.join(map(str,arr)))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def even(d):
    return d // 2

def odd(A, B, N):
    if abs(A-1) > abs(B-(N)):
        dist2edge = abs(B-(N))
        A += dist2edge
        B += dist2edge 
        assert B == N

        return even(abs((A+1)- B)) + 1 + dist2edge

    else:
        dist2edge = abs(A)
        A -= dist2edge
        B -= dist2edge
        assert A == 1
    
        return even(abs(A- (B-1))) + 1 + dist2edge


def main():
    N, A, B = map(int, input().split())
    diff = abs(A-B)

    if diff % 2 == 0:
        print(even(diff))
    else:
        print(odd(A, B, N))

if __name__ == "__main__":
    main()


Fixed submission:
def even(d):
    return d // 2

def odd(A, B, N):
    if abs(A-1) > abs(B-N):
        dist2edge = abs(B-N)
        A += dist2edge
        B += dist2edge 

        return even(abs((A+1)- B)) + 1 + dist2edge

    else:
        dist2edge = abs(A - 1)
        A -= dist2edge
        B -= dist2edge
    
        return even(abs(A- (B-1))) + 1 + dist2edge


def main():
    N, A, B = map(int, input().split())
    diff = abs(A-B)

    if diff % 2 == 0:
        print(even(diff))
    else:
        print(odd(A, B, N))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    a, b, c = list(map(int, input().split()))
    ret = 'bust' if sum(a,b,c) >= 22 else 'win'
    print(ret)

if __name__ == "__main__":
    main()


Fixed submission:
def main():
    a = list(map(int, input().split()))
    ret = 'bust' if sum(a) >= 22 else 'win'
    print(ret)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    S = input()
    lst = list(S)

    a = ['{:03d}'.format(i) for i in range(1000)]
    count = 0
    for i in range(len(a)):
        m,n,o = 0,1,2
        s = list(a[i])
        while m < n < o < len(lst) :
            if s[0] != lst[m]:
                m += 1
                n += 1
                o += 1
            elif s[1] != lst[n]:
                n += 1
                o += 1
            elif s[2] != lst[o]:
                o += 1
            else:
                count += 1
                break

    print(count)

if __name__ == "__main__":
    main()


Fixed submission:
def main():
    M1, D1  = list(map(int, input().split()))
    M2, D2  = list(map(int, input().split()))

    if D2 == 1 and M1 != M2:
        print(1)
    else:
        print(0)
    
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def count(S, m, n): 
    table = [0 for k in range(n+1)] 
  
    table[0] = 0
    if n <= 100:
        return 0
    if n <= 105:
        return 1

    table[100] = 1
    table[101] = 1
    table[102] = 1
    table[103] = 1
    table[104] = 1
    table[105] = 1

    for i in range(0,m): 
        for j in range(S[i],n+1): 
            table[j] += table[j-S[i]] 
  
    return table[n] 
  
def main():
    X = int(input())
    S = [100, 101, 102, 103, 104, 105, 106] 

    if count(S, 8, X):
        print(1)
    else:
        print(0)
    
if __name__ == "__main__":
    main()


Fixed submission:
def count(S, m, n): 
    if n < 100:
        return 0

    table = [False for k in range(n+1)]   
    table[100:106] = [True] * 6

    for i in range(106, n+1):
        table[i] = any([table[i-j] for j in range(S[0], S[-1]+1)])
  
    return 1 if table[n] else 0
  
def main():
    X = int(input())
    S = [100, 101, 102, 103, 104, 105] 
    print(count(S, len(S), X))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def count(S, m, n): 
    table = [0 for k in range(n+1)] 
  
    table[0] = 0
      for i in range(0,m): 
        for j in range(S[i],n+1): 
            table[j] += table[j-S[i]] 
  
    return table[n] 
  
def main():
    X = int(input())
    S = [100, 101, 102, 103, 104, 105, 106] 

    if count(S, 7, X):
        print(1)
    else:
        print(0)
    
if __name__ == "__main__":
    main()


Fixed submission:
def count(S, m, n): 
    if n < 100:
        return 0

    table = [False for k in range(n+1)]   
    table[100:106] = [True] * 6

    for i in range(106, n+1):
        table[i] = any([table[i-j] for j in range(S[0], S[-1]+1)])
  
    return 1 if table[n] else 0
  
def main():
    X = int(input())
    S = [100, 101, 102, 103, 104, 105] 
    print(count(S, len(S), X))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys

lines = sys.stdin.readlines()
S = lines[0]

lst = ['SUN','MON','TUE','WED','THU','FRI','SAT']

num = lst.index(S)
print(7 - num)

Fixed submission:
import sys

S = input()

lst = ['SUN','MON','TUE','WED','THU','FRI','SAT']

num = lst.index(S)
print(7 - num)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

lines = sys.stdin.readlines()
N = int(lines[0])

stdin = list(map(int,lines[1].split(' ')))
lst = np.zeros((3,N), dtype=np.int32)

lst[1] += sum(stdin)
for i, a in enumerate(stdin):
    lst[0,i:] += a
    lst[1,i:] -= a
    lst[2,i] = abs(lst[0,i]-lst[1,i])
    i += 1

print(min(lst[2]))

Fixed submission:
import sys
import numpy as np

lines = sys.stdin.readlines()
N = int(lines[0])

stdin = list(map(int,lines[1].split(' ')))

lst = []
S1, S2 = 0, sum(stdin)
for i, a in enumerate(stdin):
    S1 += a
    S2 -= a
    lst.append(abs(S1-S2))

print(min(lst))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def expand(bou_len, cost):
    bou_len += 1
    cost += 1
    return bou_len, cost

def shrink(bou_len, cost):
    bou_len -= 1
    cost += 1
    return bou_len, cost

lines = sys.stdin.readlines()
N = int(lines[0])

lst = []
for n in map(int,lines[1].split(' ')):
    lst.append(n)

lst_sum = sum(lst)
half_len = lst_sum / 2

center_idx = 0
bar_len = 0
center_dist = 1000000
for index, element in enumerate(lst):
    bar_len += element
    if abs(half_len - bar_len) < center_dist:
        center_idx = index
        center_dist = abs(half_len - bar_len)
        if center_dist == 0:
            break

left_half = lst[:center_idx+1]
right_half = lst[center_idx+1:]

left_sum = sum(left_half)
right_sum = sum(right_half)

cost = 0
while (left_sum != right_sum):
    if left_sum < right_sum:
        left_sum, cost = expand(left_sum, cost)
    if left_sum > right_sum:
        left_sum, cost = shrink(left_sum, cost)

print(cost)

Fixed submission:
import sys
import numpy as np

lines = sys.stdin.readlines()
N = int(lines[0])

stdin = list(map(int,lines[1].split(' ')))

lst = []
S1, S2 = 0, sum(stdin)
for i, a in enumerate(stdin):
    S1 += a
    S2 -= a
    lst.append(abs(S1-S2))

print(min(lst))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def expand(bou_len, cost):
    bou_len += 1
    cost += 1
    return bou_len, cost

def shrink(bou_len, cost):
    bou_len -= 1
    cost += 1
    return bou_len, cost

lines = sys.stdin.readlines()
N = int(lines[0])

lst = []
for n in map(int,lines[1].split(' ')):
    lst.append(n)

lst_sum = sum(lst)
half_len = lst_sum / 2

center_idx = 0
bar_len = 0
center_dist = 1000000
for index, element in enumerate(lst):
    bar_len += element
    if abs(half_len - bar_len) < center_dist:
        center_idx = index
        center_dist = abs(half_len - bar_len)
        if center_dist == 0:
            break

left_half = lst[:center_idx+1]
right_half = lst[center_idx+1:]

left_sum = sum(left_half)
right_sum = sum(right_half)

cost = 0
while (left_sum != right_sum):
    if left_sum < right_sum:
        left_sum, cost = expand(left_sum, cost)
    if left_sum > right_sum:
        left_sum, cost = shrink(left_sum, cost)

print(cost)

Fixed submission:
import sys
import numpy as np

lines = sys.stdin.readlines()
N = int(lines[0])

stdin = list(map(int,lines[1].split(' ')))

lst = []
S1, S2 = 0, sum(stdin)
for i, a in enumerate(stdin):
    S1 += a
    S2 -= a
    lst.append(abs(S1-S2))

print(min(lst))
Buggy python submission (verdict: Runtime Error):
import sys
from math import factorial
from scipy.misc import comb

def ncr(n, r, p): 
    return comb(n,r,exact=True) % p 

def check(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp

    n = x - y
    x -= 2 * n

    if (x + y) % 3 == 0:
        return True
    else:
        return False
    

# Read
line = sys.stdin.readlines()[0]
X, Y = map(int,line.split(' '))

# if not check(X, Y):
#     print(0)
#     exit(0)

m = int(1/3 * (2*Y - X))
n = int(Y - 2 * m)

if n < 0 or m < 0:
    print(0)
else:
    p = m if m < n else n
    print(ncr(n+m, p))


Fixed submission:
import sys

for line in sys.stdin:
    r = int(line.rstrip())
    print(r*r)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
import numpy as np

lines = sys.stdin.readlines()

N = int(lines[0].rstrip())
perms = list(itertools.permutations(range(N)))
combs = list(itertools.combinations(range(N), 2))

arr_2d = np.zeros((N,2))
arr_dist_memo = np.zeros((len(combs),len(combs)))
arr_dist_ave = np.zeros(len(perms))

for i, line in enumerate(lines[1:]):
    x, y = map(int,line.split(' '))
    arr_2d[i, 0] = x
    arr_2d[i, 1] = y

for i,j in combs:
    arr_dist_memo[i, j] = np.linalg.norm(arr_2d[i] - arr_2d[j])

for index, l in enumerate(perms):
    for i, j  in zip(range(N-1), range(1, N)):
        arr_dist_ave[index] += arr_dist_memo[l[i],l[j]]

print(np.mean(arr_dist_ave)*2)

Fixed submission:
import sys
import itertools
import numpy as np

lines = sys.stdin.readlines()

N = int(lines[0].rstrip())
perms = list(itertools.permutations(range(N)))
combs = list(itertools.combinations(range(N), 2))

arr_2d = np.zeros((N,2))
if N <= 2:
	arr_dist_memo = np.zeros((len(combs)+1,len(combs)+1))
else:
	arr_dist_memo = np.zeros((len(combs),len(combs)))

arr_dist_ave = np.zeros(len(perms))

for i, line in enumerate(lines[1:]):
    x, y = map(int,line.split(' '))
    arr_2d[i, 0] = x
    arr_2d[i, 1] = y

for i,j in combs:
    arr_dist_memo[i, j] = np.linalg.norm(arr_2d[i] - arr_2d[j])

for index, l in enumerate(perms):
    for i, j  in zip(range(N-1), range(1, N)):
        arr_dist_ave[index] += arr_dist_memo[l[i],l[j]]

print(np.mean(arr_dist_ave)*2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
import numpy as np

lines = sys.stdin.readlines()

N = int(lines[0].rstrip())
perms = list(itertools.permutations(range(N)))

arr_2d = np.zeros((N,2))
arr_dist = np.zeros(len(perms))

for i, line in enumerate(lines[1:]):
    x, y = map(int,line.split(' '))
    arr_2d[i, 0] = x
    arr_2d[i, 1] = y


index = 0
for l in perms:
    for i in range(N-1):
        arr_dist[index] += np.linalg.norm(arr_2d[l[i]] - arr_2d[l[i+1]])
    index += 1
    
print(np.mean(arr_dist))

Fixed submission:
import sys
import itertools
import numpy as np

lines = sys.stdin.readlines()

N = int(lines[0].rstrip())
perms = list(itertools.permutations(range(N)))
combs = list(itertools.combinations(range(N), 2))

arr_2d = np.zeros((N,2))
if N <= 2:
	arr_dist_memo = np.zeros((len(combs)+1,len(combs)+1))
else:
	arr_dist_memo = np.zeros((len(combs),len(combs)))

arr_dist_ave = np.zeros(len(perms))

for i, line in enumerate(lines[1:]):
    x, y = map(int,line.split(' '))
    arr_2d[i, 0] = x
    arr_2d[i, 1] = y

for i,j in combs:
    arr_dist_memo[i, j] = np.linalg.norm(arr_2d[i] - arr_2d[j])

for index, l in enumerate(perms):
    for i, j  in zip(range(N-1), range(1, N)):
        arr_dist_ave[index] += arr_dist_memo[l[i],l[j]]

print(np.mean(arr_dist_ave)*2)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(S: str):
    count = 0
    S = [s for s in S]
    
    while True:
        sub_count = 0
        for i in range(len(S)-1):
            if S[i] == 'B' and S[i+1] =='W':
                S[i], S[i+1] = 'W', 'B'
                sub_count += 1

        if sub_count == 0:
            break
        count += sub_count
        
    print(count)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(S: str):
    count = 0
    S = [s for s in S]

    count = 0
    sub_count = 0

    for s in S:
        if s == 'W':
            count += sub_count
        else:
            sub_count += 1
                
        
    print(count)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
if B>=C:
  print('Yes')
else:
  print('No')

Fixed submission:
K= int(input())
print('ACL'*K)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a<b && b<c:
  print('Yes')
  elif c<b && b<a:
    print('Yes')
else:
  print('No')

Fixed submission:
a, b, c = map(int, input().split())
if a<c & c<b:
  print('Yes')
elif b<c & c<a:
    print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
S = input()
#複数の定義はまとめられる
cntA, cntB = 0, 0

for i, t in enumerate(S):
    if i%2 == 0:
        if t == '0': #標準入力Sはstr型だから0ではなく'0'のようにする
            cntA += 1
        else:
            cntB += 1
    else:
        if t == '1':
            cntA += 1
        else:
            cntB += 1
print (min(ci, c2)) 

Fixed submission:
S = input()
#複数の定義はまとめられる
cntA, cntB = 0, 0

for i, t in enumerate(S):
    if i%2 == 0:
        if t == '0': #標準入力Sはstr型だから0ではなく'0'のようにする
            cntA += 1
        else:
            cntB += 1
    else:
        if t == '1':
            cntA += 1
        else:
            cntB += 1
print (min(cntA, cntB))
Buggy python submission (verdict: Runtime Error):
a, b, c, d, e = [int(input()) for i in range(5)]
list = [a, b, c, d, e]
nlist = [a%10, b%10, c%10, d%10, e%10]
nlist.remove('0')

#mod10で並べた数字のうち最小のものを削除
nlist.sort() 
nlist.remove(0)
mlist = map(10 - nlist)
Sum = sum(list) + sum(mlist)
print (Sum)

Fixed submission:
l = list(int(input()) for i in range(5))
nlist = []
Sum = 0

for i in range(5):
    if l[i]%10 == 0:
        nlist.append(0)
    else:
        nlist.append(10 - (l[i]%10))
        
if nlist[0] == nlist[1] == nlist[2] == nlist[3] == nlist[4] == 0:
    print(l[0]+l[1]+l[2]+l[3]+l[4])
else:
    #リストlにリストnlistをそれぞれ加える
    for i in range(5):
        Sum += l[i] + nlist[i]
    print(Sum - max(nlist))
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if (S[i-1:i+1] == "AC":)
    cnt += 1
    counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])

Fixed submission:
n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if S[i-1:i+1] == "AC":
    cnt += 1
  counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])

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

counts = [0 for i in range(N)]
cnt = 0

for i in range(n):
  if S[i-1:i+1] == "AC":
    cnt += 1
    counts[i] = cnt
    
for i in range(q):
  l, r = map(int, input().split())
  print (counts[r-1] - counts[l-1])

Fixed submission:
n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if S[i-1:i+1] == "AC":
    cnt += 1
  counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])

Buggy python submission (verdict: Runtime Error):
S = input()
import re
def appear(i, j)
 T = S[i:j+1]
 T.count('AC')

Fixed submission:
n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if S[i-1:i+1] == "AC":
    cnt += 1
  counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])