Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for i in range(q)]
ac_list = [i+1 for i,(j,k) in enumerate(zip(s[0:len(s)-1],s[1:])) if j+k=='AC']
for i in lr:
    count = 0
    for j in ac_list:
        if j>=i[0] and j<=i[1]-1:
            count += 1
    print(count)


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()
l = [list(map(int,input().split())) for i in range(q)]
s_len = len(s)
account = s.count('AC')
count = 0
for i in range(q):
    center = len(s[l[i][0]-1:l[i][1]])
    if center <= s_len:
        print(s[l[i][0]-1:l[i][1]].count('AC'))
    else:
        '''
        left = s[0:]
        if s[l[i][0]-1:l[i][0]+1] == 'AC':
            count += 1
        if s[l[i][1]-1:l[i][1]+!] =='AC':
            count += 1
        print(account-)
        '''
        pass


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: Runtime Error):
n,q = map(int,input().split())
s = input()
l = [list(map(int,input().split())) for i in range(q)]
s_len = len(s)
account = s.count('AC')
count = 0
for i in range(q):
    center = len(s[l[i][0]-1:s[l[i][1]]])
    if center <= s_len:
        print(s[l[i][0]-1:s[l[i][1]]].count('AC'))
    else:
        '''
        left = s[0:]
        if s[l[i][0]-1:l[i][0]+1] == 'AC':
            count += 1
        if s[l[i][1]-1:l[i][1]+!] =='AC':
            count += 1
        print(account-)
        '''
        pass


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()
l = [list(map(int,input().split())) for i in range(q)]
count = 0
for i in range(q):
    for j in range(l[i][1]-l[i][0]):
        if s[l[i][0]+j-1] == 'A' and s[l[i][0]+j] == 'C':
            count += 1
    print(count)
    count = 0


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()
l = [list(map(int,input().split())) for i in range(q)]

for i in range(q):
    print(s[l[i][0]-1:l[i][1]].count('AC'))


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()
l = [list(map(int,input().split())) for i in range(q)]
ans = []
for i in range(q):
    ans.append(s[l[i][0]-1:l[i][1]].count('AC'))
for i in range(q):
    print(ans[i])


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])