Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ans)

Fixed submission:
n,q=map(int,input().split())
s=input()+'Z'
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ans)

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ANS)

Fixed submission:
n,q=map(int,input().split())
s=input()+'Z'
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ans)

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

s=input()+'0'
X=[0]*(len(s)+1)
for i in range(len(s)-1):
    if s[i]=='A' and s[i+1]=='C':
        X[i+1]+=1
Y=[]
for i in range(n):
    Y.append(sum(X[:i+1]))

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

Fixed submission:
n,q=map(int,input().split())
s=input()+'Z'
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ans)

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

s=input()
X=[0]*len(s)
for i in range(len(s)-1):
    if s[i]=='A' and s[i+1]=='C':
        X[i]+=1

A=[]

for i in range(q):
    l,r=map(int,input().split())
    ans=(X[l-1:r]).count(1)
    if s[r-1]=='A' and s[r]=='C':
        A.append(ans-1)
    else:
        A.append(ans)
        
for x in A:
    print(x)

Fixed submission:
n,q=map(int,input().split())
s=input()+'Z'
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ans)

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

s=input()+'0'
X=[0]*len(s)
for i in range(len(s)):
    if s[i]=='A' and s[i+1]=='C':
        X[i]+=1

A=[]

for i in range(q):
    l,r=map(int,input().split())
    ans=sum(X[l-1:r])
    if s[r-1]=='A' and s[r]=='C':
        A.append(ans-1)
    else:
        A.append(ans)
        
for x in A:
    print(x)

Fixed submission:
n,q=map(int,input().split())
s=input()+'Z'
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ans)

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
V=[0]*n
X=[]
for i in range(q):
    l,r=map(int,input().split())
    X.append([l,r])

for i in range(n-1):
    if s[i:i+2]=='AC':
        V[i]+=1

for i in range(q):
    ans=sum(V[X[i][0]-1:X[i][1]])
    if s[X[i][1]-1]=='A' and s[X[i][1]]=='C':
        ans-=1
    print(ans)

Fixed submission:
n,q=map(int,input().split())
s=input()+'Z'
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ans)