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


for i in range(q):
        t1,t2 = map(int,input().split())
        r1 =s[t1-1:t2]
        print(r1.count("AC"))

Fixed submission:
n,q = map(int,input().split())
s = list(input())
c = 0
t = [0]
for i in range(1,n):
        if s[i] == "C" and s[i-1] == "A":
                c = c + 1
        t.append(c)

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

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,q = map(int,input().split())
s = input()
a = np.array(s)


for i in range(q):
        t1,t2 = map(int,input().split())
        r1 =a[t1-1:t2]
        c_2 = np.count_nonzero(r1 == "AC")
        print(c_2)

Fixed submission:
n,q = map(int,input().split())
s = list(input())
c = 0
t = [0]
for i in range(1,n):
        if s[i] == "C" and s[i-1] == "A":
                c = c + 1
        t.append(c)

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

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

for i in range(q):
        t1,t2 = map(int,input().split())
        r1 =s[t1-1:t2]
        print(r1.count("AC"))

Fixed submission:
n,q = map(int,input().split())
s = list(input())
c = 0
t = [0]
for i in range(1,n):
        if s[i] == "C" and s[i-1] == "A":
                c = c + 1
        t.append(c)

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

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

for i in range(q):
        t1,t2 = map(int,input().split())
        r1 =s[t1-1:t2]
        print(r1.count("AC"))

Fixed submission:
n,q = map(int,input().split())
s = list(input())
c = 0
t = [0]
for i in range(1,n):
        if s[i] == "C" and s[i-1] == "A":
                c = c + 1
        t.append(c)

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

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

for i in range(q):
        t1,t2 = map(int,input().split())
        r1 = "".join(s[t1-1:t2])
        print(r1.count("AC"))

Fixed submission:
n,q = map(int,input().split())
s = list(input())
c = 0
t = [0]
for i in range(1,n):
        if s[i] == "C" and s[i-1] == "A":
                c = c + 1
        t.append(c)

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

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

for i in range(q):
        t1,t2 = map(int,input().split())
        r = s[t1-1:t2]
        r1 = ''.join(r)
        print(r1.count("AC"))

Fixed submission:
n,q = map(int,input().split())
s = list(input())
c = 0
t = [0]
for i in range(1,n):
        if s[i] == "C" and s[i-1] == "A":
                c = c + 1
        t.append(c)

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

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

for i in range(q):
        r = s[t[i][0]-1:t[i][1]]
        r1 = ''.join(r)
        print(r1.count("AC"))

Fixed submission:
n,q = map(int,input().split())
s = list(input())
c = 0
t = [0]
for i in range(1,n):
        if s[i] == "C" and s[i-1] == "A":
                c = c + 1
        t.append(c)

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