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

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

S = input()
cumurative_sum_lst = np.zeros(N+1)
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        cumurative_sum_lst[i+1:] += 1

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

    tmp = cumurative_sum_lst[r] - cumurative_sum_lst[l]
    outputs.append(int(tmp))

for i in outputs:
    print(i)



Fixed submission:

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

S = input()
cumurative_sum_lst = [0]*(N+1)
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i] + 1
    else:
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i]

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

    tmp = cumurative_sum_lst[r] - cumurative_sum_lst[l]
    outputs.append(int(tmp))

for i in outputs:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, Q = map(int, input().split())

S = input()
AC_place_arr = np.zeros(N)
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        AC_place_arr[i] = 1


outputs = []
for i in range(Q):
    l, r = map(int, input().split())
    count = int(np.sum(AC_place_arr[l-1:r-1]))
    outputs.append(count)

for i in outputs:
    print(i)


Fixed submission:

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

S = input()
cumurative_sum_lst = [0]*(N+1)
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i] + 1
    else:
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i]

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

    tmp = cumurative_sum_lst[r] - cumurative_sum_lst[l]
    outputs.append(int(tmp))

for i in outputs:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())

S = input()
outputs = []
for i in range(Q):
    l, r = map(int, input().split())
    count = 0
    for j in range(l-1, r-1):
        if S[j] =="A" and S[j+1] == "C":
            count += 1
    outputs.append(count)

for i in outputs:
    print(i)


Fixed submission:

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

S = input()
cumurative_sum_lst = [0]*(N+1)
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i] + 1
    else:
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i]

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

    tmp = cumurative_sum_lst[r] - cumurative_sum_lst[l]
    outputs.append(int(tmp))

for i in outputs:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())

S = input()
outputs = []
for i in range(Q):
    l, r = map(int, input().split())
    count = 0
    for j in range(l-1, r-1):
        if S[j] =="A" and S[j+1] == "C":
            count += 1
    outputs.append(count)

for i in outputs:
    print(i)


Fixed submission:

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

S = input()
cumurative_sum_lst = [0]*(N+1)
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i] + 1
    else:
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i]

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

    tmp = cumurative_sum_lst[r] - cumurative_sum_lst[l]
    outputs.append(int(tmp))

for i in outputs:
    print(i)