Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = list(input())
check = [0]*n
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = 1
for i in range(q):
    l,r = map(int,input().split())
    ans = 0
    for j in range(l,r):
        ans += check[j]
    print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = list(input())
check = [0]*n
const = 0
for i in range(n-1):
    check[i] = const
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = const + 1
        const += 1
        i += 1
check[-1] = const
for i in range(q):
    l,r = map(int,input().split())
    print(check[r-1]-check[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = list(input())
check = [0]*n
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = 1
for i in range(q):
    l,r = map(int,input().split())
    ans = 0
    for j in range(l,r):
        ans += check[j]
    print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = list(input())
check = [0]*n
const = 0
for i in range(n-1):
    check[i] = const
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = const + 1
        const += 1
        i += 1
check[-1] = const
for i in range(q):
    l,r = map(int,input().split())
    print(check[r-1]-check[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = list(input())
check = [0]*n
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = 1
for i in range(q):
    l,r = map(int,input().split())
    ans = 0
    for j in range(l,r):
        ans += check[j]
    print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = list(input())
check = [0]*n
const = 0
for i in range(n-1):
    check[i] = const
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = const + 1
        const += 1
        i += 1
check[-1] = const
for i in range(q):
    l,r = map(int,input().split())
    print(check[r-1]-check[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = list(input())
check = [0]*n
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = 1
for i in range(q):
    l,r = map(int,input().split())
    ans = 0
    for j in range(l,r):
        ans += check[j]
    print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = list(input())
check = [0]*n
const = 0
for i in range(n-1):
    check[i] = const
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = const + 1
        const += 1
        i += 1
check[-1] = const
for i in range(q):
    l,r = map(int,input().split())
    print(check[r-1]-check[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
for i in range(q):
  l,r = map(int,input().split())
  ss = s[l-1:r]
  print(ss.count('AC'))

Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = list(input())
check = [0]*n
const = 0
for i in range(n-1):
    check[i] = const
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = const + 1
        const += 1
        i += 1
check[-1] = const
for i in range(q):
    l,r = map(int,input().split())
    print(check[r-1]-check[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
for i in range(q):
  l,r = map(int,input().split())
  ss = s[l-1:r]
  print(ss.count('AC'))

Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = list(input())
check = [0]*n
const = 0
for i in range(n-1):
    check[i] = const
    if s[i] == 'A' and s[i+1] == 'C':
        check[i+1] = const + 1
        const += 1
        i += 1
check[-1] = const
for i in range(q):
    l,r = map(int,input().split())
    print(check[r-1]-check[l-1])