Buggy python submission (verdict: Runtime Error):
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
print(T)
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])

Fixed submission:
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])

Buggy python submission (verdict: Runtime Error):
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r] - T[l-1])

Fixed submission:
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])

Buggy python submission (verdict: Runtime Error):
#coding: utf-8
N, Q = map(int, input().split())
S = input()
S_l = []
for i in range(len(S)):
    if S[i] == "A" and S[i+1] == "C":
        S_l.append([i+1, i+2])
for i in range(Q):
    l, r = map(int, input().split())
    cnt = 0
    for j in range(len(S_l)):
        if l <= S_l[j][0] <=r and l <= S_l[j][1] <= r:
            cnt += 1
    print(cnt)

Fixed submission:
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
N, Q = map(int, input().split())
S = input()
for _ in range(Q):
    l, r = map(int, input().split())
    print(S[l-1:r].count("AC"))

Fixed submission:
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
N, Q = map(int, input().split())
S = input()
for i in range(Q):
    q1, q2 = map(int, input().split())
    qs = S[q1-1: q2]
    print(qs.count("AC"))

Fixed submission:
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
N, Q = map(int, input().split())
S = input()
for i in range(Q):
    q1 = list(map(int, input().split()))
    cnt = 0
    qs = S[q1[0]-1: q1[1]]
    print(qs.count("AC"))

Fixed submission:
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])

Buggy python submission (verdict: Runtime Error):
#coding: utf-8
N, Q = map(int, input().split())
S = input()
for i in range(Q):
    q1 = list(map(int, input().split()))
    cnt = 0
    qs = S[q1[0]-1: q1[1]]
    print(qs)
    print(qs.count("AC"))

Fixed submission:
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
N, Q = map(int, input().split())
S = list(input())
for i in range(Q):
    q1 = list(map(int, input().split()))
    cnt = 0
    qs = S[q1[0]-1:q1[1]]
    for j in range(len(qs)-1):
        if qs[j] == "A" and qs[j+1] == "C":
            cnt += 1
    print(cnt)

Fixed submission:
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])