Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
e=[]
for j in range(n-1):
    if s[j:j+2]=="AC":
        e.append(1)
    else :
        e.append(0)

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


Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

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

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
e=[]
for j in range(n-1):
    if s[j:j+2]=="AC":
        e.append(1)
    else :
        e.append(0)

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



Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

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

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

for i in range(q):
    l,r=map(int,input().split())
    m=0
    for j in range(l-1,r-1):
            if s[j:j+2]=="AC":
                m+=1
    print(m)



Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

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

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

for i in range(q):
    l,r=map(int,input().split())
    m=0
    for j in range(l-1,r-1):
            if s[j]=="A" and s[j+1]=="C":
                m+=1
    print(m)



Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

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

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

for i in range(q):
    l,r=map(int,input().split())
    ss=s[l-1:r]
    m=0
    for j in range(r-l):
            if ss[j]=="A" and ss[j+1]=="C":
                m+=1
    print(m)


Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

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

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

for i in range(q):
    l,r=map(int,input().split())
    ss=s[l-1:r]
    m=0
    for j in range(r-l+1):
        if j==r-l:
            continue
        else:
            if ss[j]=="A" and ss[j+1]=="C":
                m+=1
    print(m)


Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

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

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

for i in range(q):
    l,r=map(int,input().split())
    ss=s[l-1:r]
    m=0
    for j in range(r-l+1):
        if j==r-l+1:
            pass
        elif ss[j:j+2]=="AC":
            m+=1
    print(m)


Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

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