Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Fixed submission:
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    print(a[t-1]-a[u-1])

Fixed submission:
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[-1]+1)
    else:
        a.append(a[-1])
print(a)
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    print(a[t-1]-a[u-1])

Fixed submission:
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
c = 0
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    print(a[t-1]-a[u-1])

Fixed submission:
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
c = 0
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[i-1]+1)
    else:
        a.append(a[i-1])
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    print(a[t-1]-a[u-1])

Fixed submission:
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
c = 0
a = [-1]*10**5
for i in range(n-1):
    if s[i] == "A":
        if s[i+1] == "C":
            a[i] = i
a = list(set(a))
a.sort()
del a[0]
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    for k in a:
        if (k >= u-1) and (k <= t-2):
            c += 1
    print(c)
    c = 0

Fixed submission:
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
c = 0
a = []
for i in range(n-1):
    if s[i] == "A":
        if s[i+1] == "C":
            a.append(i)
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    for k in a:
        if k in range(u-1,t-1):
            c += 1
    print(c)
    c = 0

Fixed submission:
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
p = ""
k = 0
for i in range(q):
    for j in range(ls[i][0]-1,ls[i][1]-1):
        if s[j] == "A":
            if s[j+1] == "C":
                k += 1
    print(k)
    k = 0

Fixed submission:
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])