Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]

ans=[]

for i in lr:
    l,r=map(int,i.split())
    #print(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2))
    #ans.append(str(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2)))
    st=s[l-1:r]
    ans.append(str(int((len(st)-len(st.replace('AC',"")))/2)))

print('\n'.join(ans))

Fixed submission:
n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]
cs=[0]*(n+1)

#端がACで-1で止まる文字列指定は大丈夫？.
for i in range(n):
    cs[i+1]=cs[i] + (1 if s[i:i+2] == 'AC' else 0)

for num in lr:
    l,r=map(int,num.split())
    print(cs[r-1] - cs[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]

ans=[]

for i in lr:
    l,r=map(int,i.split())
    #print(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2))
    ans.append(str(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2)))

print('\n'.join(ans))

Fixed submission:
n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]
cs=[0]*(n+1)

#端がACで-1で止まる文字列指定は大丈夫？.
for i in range(n):
    cs[i+1]=cs[i] + (1 if s[i:i+2] == 'AC' else 0)

for num in lr:
    l,r=map(int,num.split())
    print(cs[r-1] - cs[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n,q=map(int,input().split())
s=input()
lr=[input() for i in range(q)]

ans=[]

for i in range(q):
    l,r=map(int,lr[i].split())
    #print(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2))
    ans.append(str(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2)))

print('\n'.join(ans))

Fixed submission:
n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]
cs=[0]*(n+1)

#端がACで-1で止まる文字列指定は大丈夫？.
for i in range(n):
    cs[i+1]=cs[i] + (1 if s[i:i+2] == 'AC' else 0)

for num in lr:
    l,r=map(int,num.split())
    print(cs[r-1] - cs[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
lr=[input() for i in range(q)]

ans=[]

for i in range(q):
    l,r=map(int,lr[i].split())
    #print(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2))
    ans.append(str(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2)))

print('\n'.join(ans))

Fixed submission:
n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]
cs=[0]*(n+1)

#端がACで-1で止まる文字列指定は大丈夫？.
for i in range(n):
    cs[i+1]=cs[i] + (1 if s[i:i+2] == 'AC' else 0)

for num in lr:
    l,r=map(int,num.split())
    print(cs[r-1] - cs[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
lr=[input() for i in range(q)]

ans=[]

for i in range(q):
    l,r=map(int,lr[i].split())
    #print(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2))
    ans.append(str(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2)))

print('\n'.join(ans))

Fixed submission:
n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]
cs=[0]*(n+1)

#端がACで-1で止まる文字列指定は大丈夫？.
for i in range(n):
    cs[i+1]=cs[i] + (1 if s[i:i+2] == 'AC' else 0)

for num in lr:
    l,r=map(int,num.split())
    print(cs[r-1] - cs[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
lr=[input() for i in range(q)]

for i in range(q):
    l,r=map(int,lr[i].split())
    print(int((len(s[l-1:r])-len(s[l-1:r].replace('AC',"")))/2))


Fixed submission:
n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]
cs=[0]*(n+1)

#端がACで-1で止まる文字列指定は大丈夫？.
for i in range(n):
    cs[i+1]=cs[i] + (1 if s[i:i+2] == 'AC' else 0)

for num in lr:
    l,r=map(int,num.split())
    print(cs[r-1] - cs[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
lr=[input() for i in range(q)]

for i in range(q):
    l,r=map(int,lr[i].split())
    #print(s[l-1:r])
    print(s[l-1:r].count('AC'))


Fixed submission:
n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]
cs=[0]*(n+1)

#端がACで-1で止まる文字列指定は大丈夫？.
for i in range(n):
    cs[i+1]=cs[i] + (1 if s[i:i+2] == 'AC' else 0)

for num in lr:
    l,r=map(int,num.split())
    print(cs[r-1] - cs[l-1])