Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
x = []*(n+1)

for i in range(n):
    x[i+1] = x[i] + (1 if s[i:i+2] == "AC" else 0)

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

Fixed submission:
n, q = map(int, input().split())
s = input()
x = [0]*(n+1)

for i in range(n):
    x[i+1] = x[i] + (1 if s[i:i+2] == "AC" else 0)

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

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

for i in range(q):
    s1, e1 = [int(i) for i in input().split()]
    x.append(s[s1-1:e1])

for i in x:
    print(i.count("AC"))

Fixed submission:
n, q = map(int, input().split())
s = input()
x = [0]*(n+1)

for i in range(n):
    x[i+1] = x[i] + (1 if s[i:i+2] == "AC" else 0)

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

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
s1 = s
list = [0]*q

start = []
end = []
c = s.count("AC")

for i in range(q):
    s1, e1 = [int(i) for i in input().split()]
    start.append(s1-1)
    end.append((e1-1))

for i in range(c):
    list[i] = s.find("AC")
    s = s.replace("AC", "XX", 1)

result = [0]*q

for i in range(q):
    for j in range(c):
        #print(str(start[i]) + " : " + str(end[i]))
        if start[i] <= list[j] < end[i]:
            result[i] += 1


for i in result:
    print(i)



Fixed submission:
n, q = map(int, input().split())
s = input()
x = [0]*(n+1)

for i in range(n):
    x[i+1] = x[i] + (1 if s[i:i+2] == "AC" else 0)

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

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

for i in range(q):
    start,end = map(int, input().split())
    list[i] = s.count("AC", start-1, end)

for i in list:
    print(i)



Fixed submission:
n, q = map(int, input().split())
s = input()
x = [0]*(n+1)

for i in range(n):
    x[i+1] = x[i] + (1 if s[i:i+2] == "AC" else 0)

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

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

for i in range(q):
    start,end=map(int, input().split())
    list[i] = s.count("AC", start-1, end)

for i in list:
    print(i)



Fixed submission:
n, q = map(int, input().split())
s = input()
x = [0]*(n+1)

for i in range(n):
    x[i+1] = x[i] + (1 if s[i:i+2] == "AC" else 0)

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

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

for i in range(q):
    start,end=[int(i) for i in input().split()]
    list[i] = s.count("AC", start-1, end)

for i in list:
    print(i)



Fixed submission:
n, q = map(int, input().split())
s = input()
x = [0]*(n+1)

for i in range(n):
    x[i+1] = x[i] + (1 if s[i:i+2] == "AC" else 0)

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