Buggy python submission (verdict: Runtime Error):
# coding: utf-8

n, q = map(int, input().split())
s = input()

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

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


Fixed submission:
# coding: utf-8

n, q = map(int, input().split())
s = input()

t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

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

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, q = map(int, input().split())
s = input()

ac = []
for i in range(n-1):
    if s[i:i+2] == 'AC':
        ac.append(i+1)

count = len(ac)
for i in range(q):
    l,r = (map(int, input().split()))
    x = sum(j<l for j in ac)
    y = sum(j+1>r for j in ac)
    print(count-x-y)

Fixed submission:
# coding: utf-8

n, q = map(int, input().split())
s = input()

t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

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

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, q = map(int, input().split())
s = input()

for i in range(q):
    f,e = (map(int, input().split()))
    st = s[f-1:e]
    count = 0
    for j in range(len(st)-1):
        if st[j] == 'A' and st[j+1] == 'C':
            count += 1
    print(count)


Fixed submission:
# coding: utf-8

n, q = map(int, input().split())
s = input()

t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

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

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, q = map(int, input().split())
s = input()

for i in range(q):
    f,e = (map(int, input().split()))
    st = s[f-1:e]
    # print(st.count('AC'))
    count = 0
    for j in range(len(st)-1):
        if st[j] == 'A' and st[j+1] == 'C':
            count += 1
    print(count)


Fixed submission:
# coding: utf-8

n, q = map(int, input().split())
s = input()

t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

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

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, q = map(int, input().split())
s = input()

for i in range(q):
    f,e = (map(int, input().split()))
    st = s[f-1:e]
    print(st.count('AC'))


Fixed submission:
# coding: utf-8

n, q = map(int, input().split())
s = input()

t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

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

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, q = map(int, input().split())
s = input()

for i in range(q):
    l = list(map(int, input().split()))
    f,e = l[0]-1,l[1]
    st = s[f:e]
    print(st.count('AC'))



Fixed submission:
# coding: utf-8

n, q = map(int, input().split())
s = input()

t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

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

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, q = map(int, input().split())
s = input()
lst = []
for i in range(q):
    l = list(map(int, input().split()))
    lst.append(l)

for i in range(q):
    f,e = lst[i][0]-1,lst[i][1]
    st = s[f:e]
    print(st.count('AC'))



Fixed submission:
# coding: utf-8

n, q = map(int, input().split())
s = input()

t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

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

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, q = map(int, input().split())
s = input()
lst = []
for i in range(q):
    l = list(map(int, input().split()))
    lst.append(l)

count_list = []
for i in range(q):
    f,e = lst[i][0]-1,lst[i][1]
    st = s[f:e]
    count_list.append(st.count('AC'))

for i in count_list:
    print(i) 



Fixed submission:
# coding: utf-8

n, q = map(int, input().split())
s = input()

t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

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