Buggy python submission (verdict: Runtime Error):
import sys
from itertools import accumulate

N, Q = map(int, input().split())
S = input()
lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l-1, r])

t = [0] * N

for i in range(1, N):
    s = S[i-1:i+1]
    if s == 'AC':
        t[i] += 1

T = list(accumulate(t))
 
for i in lr:
    print(T[i[1]] - T[i[0]])

Fixed submission:
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)
 
for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]
 
 
for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])

Buggy python submission (verdict: Runtime Error):
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]

Fixed submission:
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)
 
for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]
 
 
for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S =  input()
qlist = [list(map(int, input().split())) for i in range(Q)]
AC = 'AC'

for i in qlist:
    tmp = S[i[0]-1:i[1]]
    print(tmp.count(AC))

Fixed submission:
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)
 
for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]
 
 
for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])

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

for i in range(Q):
    s, e = map(int, input().split())
    qlist.append([s-1, e])

for i in qlist:
    tmp = S[i[0]:i[1]]
    print(tmp.count(AC))

Fixed submission:
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)
 
for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]
 
 
for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])

Buggy python submission (verdict: Runtime Error):
AC = 'AC'
qlist = []
S =  input()
N, Q = map(int, input().split())

for i in range(Q):
    s, e = map(int, input().split())
    qlist.append([s-1, e])

for q in qlist:
    tmp = S[q[0]:q[1]]
    print(tmp.count(AC))

Fixed submission:
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)
 
for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]
 
 
for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S =  input()
qlist = []
AC = 'AC'
for i in range(Q):
    s, e = map(int, input().split())
    qlist.append([s-1, e])

for i in qlist:
    tmp = S[i[0]:i[1]]
    print(tmp.count(AC))

Fixed submission:
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)
 
for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]
 
 
for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])