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

N, Q = map(int, input().split())
S = input()


num = [0] * (N+1)
for i in range(N):
    if S[i]=='A' and S[i+1]=='C':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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


Fixed submission:
# coding: utf-8

N, Q = map(int, input().split())
S = input()

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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

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

N, Q = map(int, input().split())
S = input()


num = [0] * (N+1)
i = 0
for i in range(N):
    if S[i]=='A' and S[i+1]=='C':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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


Fixed submission:
# coding: utf-8

N, Q = map(int, input().split())
S = input()

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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

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

N, Q = map(int, input().split())
S = input()

## S中で、'AC'であるインデックスを求める
num = [0] * (N+1)
i = 0
for i in range(N):
    if S[i]=='A' and S[i+1]=='C':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

#print(num)

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


Fixed submission:
# coding: utf-8

N, Q = map(int, input().split())
S = input()

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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

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

N, Q = map(int, input().split())
S = input()

## S中で、'AC'であるインデックスを求める
index = [0] * N
i = 0
while i < len(S)-1:
    if S[i]=='A' and S[i+1]=='C':
        index[i] = 1
        i += 2
    else:
        i += 1
num = [sum(index[i]) for i in range(N)]

#print('\n')
#print(index)

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


Fixed submission:
# coding: utf-8

N, Q = map(int, input().split())
S = input()

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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

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

N, Q = map(int, input().split())
S = input()

## S中で、'AC'であるインデックスを求める
index = [0] * N
i = 0
while i < len(S)-1:
    if S[i]=='A' and S[i+1]=='C':
        index[i] = 1
        i += 2
    else:
        i += 1

#print('\n')
#print(index)

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


Fixed submission:
# coding: utf-8

N, Q = map(int, input().split())
S = input()

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

## S中で、'AC'であるインデックスを求める
index = [0] * N
i = 0
while i < len(S)-1:
    if S[i]=='A' and S[i+1]=='C':
        index[i] = 1
        i += 2
    else:
        i += 1

#print('\n')
#print(index)

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


Fixed submission:
# coding: utf-8

N, Q = map(int, input().split())
S = input()

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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