Buggy python submission (verdict: Time Limit Exceeded):
n,q = list(map(int,input().split()))
s = list(input())
num = list()
check = [0]*n
for i in range(0,n-1):
    if s[i] == "A" and s[i+1] == "C":
        check[i] = 1
for i in range(0,q):
    num.append(list(map(int,input().split())))
    print(len([k for k in range(num[i][0]-1,num[i][1]-1) if check[k] == 1]))

Fixed submission:
n,q = list(map(int,input().split()))
s = list(input())
num = list()
check = [0]*n
for i in range(1,n):
        if s[i-1] == "A" and s[i] == "C":
                check[i] = check[i-1]+1
        else:
                check[i] = check[i-1]
ans = 0
for i in range(0,q):
        num = list(map(int,input().split()))
        ans = check[num[1]-1]-check[num[0]-1]
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,q = list(map(int,input().split()))
s = list(input())
num = list()
check = list()
for i in range(0,n-1):
    if s[i] == "A" and s[i+1] == "C":
        check.append(i+1)
for i in range(0,q):
    num.append(list(map(int,input().split())))
    print(len([k for k in check if k >= num[i][0] and k < num[i][1]]))

Fixed submission:
n,q = list(map(int,input().split()))
s = list(input())
num = list()
check = [0]*n
for i in range(1,n):
        if s[i-1] == "A" and s[i] == "C":
                check[i] = check[i-1]+1
        else:
                check[i] = check[i-1]
ans = 0
for i in range(0,q):
        num = list(map(int,input().split()))
        ans = check[num[1]-1]-check[num[0]-1]
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,q = list(map(int,input().split()))
s = list(input())
num = list()
check = list()
for i in range(0,n-1):
    if s[i] == "A" and s[i+1] == "C":
        check.append(i+1)
for i in range(0,q):
    num.append(list(map(int,input().split())))
    count = 0
    for k in check:
        if num[i][1] <=k:
            break
        if num[i][0] <= k:
            count +=1
    print(count)

Fixed submission:
n,q = list(map(int,input().split()))
s = list(input())
num = list()
check = [0]*n
for i in range(1,n):
        if s[i-1] == "A" and s[i] == "C":
                check[i] = check[i-1]+1
        else:
                check[i] = check[i-1]
ans = 0
for i in range(0,q):
        num = list(map(int,input().split()))
        ans = check[num[1]-1]-check[num[0]-1]
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,q = list(map(int,input().split()))
s = list(input())
num = list()
for i in range(0,q):
    num.append(list(map(int,input().split())))
check = list()
for i in range(0,n-1):
    if s[i] == "A" and s[i+1] == "C":
        check.append(i+1)
for i in range(0,q):
    count = 0
    for k in check:
        if num[i][1] <=k:
            break
        if num[i][0] <= k:
            count +=1
    print(count)

Fixed submission:
n,q = list(map(int,input().split()))
s = list(input())
num = list()
check = [0]*n
for i in range(1,n):
        if s[i-1] == "A" and s[i] == "C":
                check[i] = check[i-1]+1
        else:
                check[i] = check[i-1]
ans = 0
for i in range(0,q):
        num = list(map(int,input().split()))
        ans = check[num[1]-1]-check[num[0]-1]
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,q = list(map(int,input().split()))
s = list(input())
num = list()
for i in range(0,q):
    num.append(list(map(int,input().split())))
check = list()
for i in range(0,n-1):
    if s[i] == "A" and s[i+1] == "C":
        check.append(i+1)
count = list()
for i in range(0,q):
    for k in check:
        if num[i][0] <= k and num[i][1] > k:
            count.append(k)
    print(len(count))
    count = list()

Fixed submission:
n,q = list(map(int,input().split()))
s = list(input())
num = list()
check = [0]*n
for i in range(1,n):
        if s[i-1] == "A" and s[i] == "C":
                check[i] = check[i-1]+1
        else:
                check[i] = check[i-1]
ans = 0
for i in range(0,q):
        num = list(map(int,input().split()))
        ans = check[num[1]-1]-check[num[0]-1]
        print(ans)