Buggy python submission (verdict: Time Limit Exceeded):
import re
n = input().split()
N = int(n[0])
Q = int(n[1])
S = input()

for i in range(Q):
    lr = input().split()
    tmp = S[int(lr[0])-1:int(lr[1])]
    j = -1
    for j, m in enumerate(re.finditer('AC', tmp)):
        pass
    j += 1
    print(str(j))




Fixed submission:
from itertools import accumulate

N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

tmp = []
for i in range(N-1):
    tmp_S  = S[i:i+2]
    if tmp_S == 'AC':
        tmp.append(1)
    else:
        tmp.append(0)

tmp2 = [0] + tmp
tmp2 = list(accumulate(tmp2))
#print(tmp2)

for j in A:
    print(tmp2[j[1]-1] - tmp2[j[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re
n = input().split()
N = int(n[0])
Q = int(n[1])
S = input()


for i in range(Q):
    lr = input().split()
    tmp = S[int(lr[0])-1:int(lr[1])]
    count = len(re.findall('AC', tmp))
    print(str(count))




Fixed submission:
from itertools import accumulate

N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

tmp = []
for i in range(N-1):
    tmp_S  = S[i:i+2]
    if tmp_S == 'AC':
        tmp.append(1)
    else:
        tmp.append(0)

tmp2 = [0] + tmp
tmp2 = list(accumulate(tmp2))
#print(tmp2)

for j in A:
    print(tmp2[j[1]-1] - tmp2[j[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = input().split()
N = int(n[0])
Q = int(n[1])
S = input()

#tmp_list = np.zeros(N)
#ans = []
#for i in range(N-1):
#    if S[i] == 'A' and S[i+1] == 'C':
#        ans.append(int(i))

for i in range(Q):
    lr = input().split()
    tmp = S[int(lr[0])-1:int(lr[1])]
    tmp.replace("G", "").replace("T", "")
    count = tmp.count('AC')
    print(str(count))

Fixed submission:
from itertools import accumulate

N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

tmp = []
for i in range(N-1):
    tmp_S  = S[i:i+2]
    if tmp_S == 'AC':
        tmp.append(1)
    else:
        tmp.append(0)

tmp2 = [0] + tmp
tmp2 = list(accumulate(tmp2))
#print(tmp2)

for j in A:
    print(tmp2[j[1]-1] - tmp2[j[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = input().split()
N = int(n[0])
Q = int(n[1])
S = input()

#import numpy as np
#tmp_list = np.zeros(N)

#for i in range(N-1):
#    if S[i] == 'A' and S[i+1] == 'C':
#        tmp_list[i] = 1

for i in range(Q):
    lr = input().split()
    l = int(lr[0])
    r = int(lr[1])
    tmp = S[l-1:r]
    tmp_num = 0
    for j in range(len(tmp)-1):
        if tmp[j] == 'A' and tmp[j+1] == 'C':
            tmp_num += 1
    print(str(tmp_num))


Fixed submission:
from itertools import accumulate

N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

tmp = []
for i in range(N-1):
    tmp_S  = S[i:i+2]
    if tmp_S == 'AC':
        tmp.append(1)
    else:
        tmp.append(0)

tmp2 = [0] + tmp
tmp2 = list(accumulate(tmp2))
#print(tmp2)

for j in A:
    print(tmp2[j[1]-1] - tmp2[j[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = input().split()
N = int(n[0])
Q = int(n[1])
S = input()

ans = []
for i in range(Q):
    lr = input().split()
    l = int(lr[0])
    r = int(lr[1])
    tmp = S[l-1:r]
    count = tmp.count('AC')
    print(str(count))



Fixed submission:
from itertools import accumulate

N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

tmp = []
for i in range(N-1):
    tmp_S  = S[i:i+2]
    if tmp_S == 'AC':
        tmp.append(1)
    else:
        tmp.append(0)

tmp2 = [0] + tmp
tmp2 = list(accumulate(tmp2))
#print(tmp2)

for j in A:
    print(tmp2[j[1]-1] - tmp2[j[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = input().split()
N = int(n[0])
Q = int(n[1])
S = input()

ans = []
for i in range(Q):
    lr = input().split()
    l = int(lr[0])
    r = int(lr[1])
    tmp = S[l-1:r]
    count = tmp.count('AC')
    ans.append(count)

for i in range(Q):
    print(str(ans[i]))




Fixed submission:
from itertools import accumulate

N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

tmp = []
for i in range(N-1):
    tmp_S  = S[i:i+2]
    if tmp_S == 'AC':
        tmp.append(1)
    else:
        tmp.append(0)

tmp2 = [0] + tmp
tmp2 = list(accumulate(tmp2))
#print(tmp2)

for j in A:
    print(tmp2[j[1]-1] - tmp2[j[0]-1])