Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,Q = (int(X) for X in input().split())
S = input()
AIndex = np.array([Ind for Ind,Str in enumerate(S) if S[Ind:Ind+2]=='AC'])
if len(AIndex)==0:
    print('\n'.join(['0']*Q))
else:
    for T in range(0,Q):
        L,R = (int(X) for X in input().split())
        print(sum(((L-1)<=AIndex)&((R-1)>=AIndex+1)))

Fixed submission:
N,Q = (int(X) for X in input().split())
S = input()
T = [0]*(N+1)
for I in range(0,N):
     T[I+1] = T[I] + (S[I:I+2]=='AC')
for J in range(0,Q):
    L,R = (int(X)-1 for X in input().split())
    print(T[R]-T[L])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = (int(X) for X in input().split())
S = input()
AIndex = [Ind for Ind,Str in enumerate(S) if S[Ind:Ind+2]=='AC']
if len(AIndex)==0:
    print('\n'.join(['0']*Q))
else:
    CIndex = [X+1 for X in AIndex]
    for T in range(0,Q):
        L,R = (int(X) for X in input().split())
        if (L-1)>AIndex[-1] or (R-1)<CIndex[0]: print('0')
        else: print(sum([(L-1)<=X and (R-1)>=Y for X,Y in zip(AIndex,CIndex)]))

Fixed submission:
N,Q = (int(X) for X in input().split())
S = input()
T = [0]*(N+1)
for I in range(0,N):
     T[I+1] = T[I] + (S[I:I+2]=='AC')
for J in range(0,Q):
    L,R = (int(X)-1 for X in input().split())
    print(T[R]-T[L])

Buggy python submission (verdict: Runtime Error):
N,Q = (int(X) for X in input().split())
S = input()
AIndex = [Ind for Ind,Str in enumerate(S) if S[Ind:Ind+2]=='AC']
if len(AIndex)==0:
    print('\n'.join(['0']*Q))
else:
    CIndex = [X+1 for X in AIndex]
    for T in range(0,Q):
        L,R = (int(X) for X in input().split())
        LN = [(L-1)<=X for X in AIndex].index(True)
        RN = len(CIndex)-[(R-1)>=X for X in CIndex][::-1].index(True)
        print(RN-LN)

Fixed submission:
N,Q = (int(X) for X in input().split())
S = input()
T = [0]*(N+1)
for I in range(0,N):
     T[I+1] = T[I] + (S[I:I+2]=='AC')
for J in range(0,Q):
    L,R = (int(X)-1 for X in input().split())
    print(T[R]-T[L])

Buggy python submission (verdict: Runtime Error):
N,Q = (int(X) for X in input().split())
S = input()
AIndex = [Ind for Ind,Str in enumerate(S) if S[Ind]=='A' and S[Ind+1]=='C']
CIndex = [X+1 for X in AIndex]
for T in range(0,Q):
    L,R = (int(X) for X in input().split())
    LIndex = [(L-1)<=X for X in AIndex]
    RIndex = [(R-1)>=X for X in CIndex]
    print(sum([X and Y for X,Y in zip(LIndex,RIndex)]))

Fixed submission:
N,Q = (int(X) for X in input().split())
S = input()
T = [0]*(N+1)
for I in range(0,N):
     T[I+1] = T[I] + (S[I:I+2]=='AC')
for J in range(0,Q):
    L,R = (int(X)-1 for X in input().split())
    print(T[R]-T[L])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = (int(X) for X in input().split())
S = input()
for T in range(0,Q):
    L,R = (int(X) for X in input().split())
    print(S[L-1:R].count('AC'))

Fixed submission:
N,Q = (int(X) for X in input().split())
S = input()
T = [0]*(N+1)
for I in range(0,N):
     T[I+1] = T[I] + (S[I:I+2]=='AC')
for J in range(0,Q):
    L,R = (int(X)-1 for X in input().split())
    print(T[R]-T[L])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = (int(X) for X in input().split())
S = input()
for T in range(0,Q):
    L,R = (int(X) for X in input().split())
    print(S[L-1:R].count('AC'))

Fixed submission:
N,Q = (int(X) for X in input().split())
S = input()
T = [0]*(N+1)
for I in range(0,N):
     T[I+1] = T[I] + (S[I:I+2]=='AC')
for J in range(0,Q):
    L,R = (int(X)-1 for X in input().split())
    print(T[R]-T[L])