Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = str(input())
count = [0]*(N+1)
lists = []
for i in range(N):
    if S[i] == "A" and S[i + 1] == "C":
        count[i + 1] = count[i] + 1
    else:
        count[i + 1] = count[i]
for i in range(Q):
    l, r = map(int, input().split())
    ans = count[r-1] - count[l-1]
    lists.append(ans)
for i in range(len(lists)):
    print(lists[i])


Fixed submission:
N, Q = map(int, input().split())
ruisekiwa = [0]
lists = []
cnt = 0
S = str(input())
for t in range(1, N):
    if S[t - 1] == "A" and S[t] == "C":
        cnt += 1
    ruisekiwa.append(cnt)
ruisekiwa.append(cnt)
for i in range(Q):
    l, r = map(int, input().split())
    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1]
    lists.append(ans)
for m in range(len(lists)):
    print(lists[m])

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = str(input())
cnt = 0
count = [0]*(N+1)
lists_l = []
lists_r = []
for i in range(N):
    if S[i] == "A" and S[i + 1] == "C":
        count[i + 1] = count[i] + 1
    else:
        count[i + 1] = count[i]
for i in range(Q):
    l, r = map(int, input().split())
    lists_l.append(l)
    lists_r.append(r)
for i in range(Q):
    L = lists_l[i]
    R = lists_r[i]
    print(count[R-1] - count[L-1])


Fixed submission:
N, Q = map(int, input().split())
ruisekiwa = [0]
lists = []
cnt = 0
S = str(input())
for t in range(1, N):
    if S[t - 1] == "A" and S[t] == "C":
        cnt += 1
    ruisekiwa.append(cnt)
ruisekiwa.append(cnt)
for i in range(Q):
    l, r = map(int, input().split())
    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1]
    lists.append(ans)
for m in range(len(lists)):
    print(lists[m])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
ruisekiwa = [0] * (N + 1)
lists = []
S = str(input())
for t in range(1, len(S)):
    if S[t - 1] == "A" and S[t] == "C":
        for k in range(t, len(ruisekiwa)):
            ruisekiwa[k] += 1
for i in range(Q):
    l, r = map(int, input().split())
    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1]
    lists.append(ans)
for m in range(len(lists)):
    print(lists[m])

Fixed submission:
N, Q = map(int, input().split())
ruisekiwa = [0]
lists = []
cnt = 0
S = str(input())
for t in range(1, N):
    if S[t - 1] == "A" and S[t] == "C":
        cnt += 1
    ruisekiwa.append(cnt)
ruisekiwa.append(cnt)
for i in range(Q):
    l, r = map(int, input().split())
    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1]
    lists.append(ans)
for m in range(len(lists)):
    print(lists[m])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = str(input())
lists = []
for i in range(Q):
    l,r = map(int,input().split())
    m = S[l-1:r]
    lists.append(m.count("AC"))
for i in range(len(lists)):
    print(lists[i]) 

Fixed submission:
N, Q = map(int, input().split())
ruisekiwa = [0]
lists = []
cnt = 0
S = str(input())
for t in range(1, N):
    if S[t - 1] == "A" and S[t] == "C":
        cnt += 1
    ruisekiwa.append(cnt)
ruisekiwa.append(cnt)
for i in range(Q):
    l, r = map(int, input().split())
    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1]
    lists.append(ans)
for m in range(len(lists)):
    print(lists[m])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
ruisekiwa = [0] * (N + 1)
lists = []
S = str(input())
for t in range(1, len(S)):
    if S[t - 1] == "A" and S[t] == "C":
        for k in range(t, len(ruisekiwa)):
            ruisekiwa[k] += 1
for i in range(Q):
    l, r = map(int, input().split())
    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1]
    lists.append(ans)
for m in range(len(lists)):
    print(lists[m])


Fixed submission:
N, Q = map(int, input().split())
ruisekiwa = [0]
lists = []
cnt = 0
S = str(input())
for t in range(1, N):
    if S[t - 1] == "A" and S[t] == "C":
        cnt += 1
    ruisekiwa.append(cnt)
ruisekiwa.append(cnt)
for i in range(Q):
    l, r = map(int, input().split())
    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1]
    lists.append(ans)
for m in range(len(lists)):
    print(lists[m])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = str(input())
lists = []
for i in range(Q):
    l,r = map(int,input().split())
    m = S[l-1:r]
    lists.append(m.count("AC"))
for i in range(len(lists)):
    print(lists[i]) 

Fixed submission:
N, Q = map(int, input().split())
ruisekiwa = [0]
lists = []
cnt = 0
S = str(input())
for t in range(1, N):
    if S[t - 1] == "A" and S[t] == "C":
        cnt += 1
    ruisekiwa.append(cnt)
ruisekiwa.append(cnt)
for i in range(Q):
    l, r = map(int, input().split())
    ans = ruisekiwa[r - 1] - ruisekiwa[l - 1]
    lists.append(ans)
for m in range(len(lists)):
    print(lists[m])