Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
l = []
r = []
cnt = []
for i in range(q):
    _l,_r = [int(i) for i in input().split()]
    l.append(_l)
    r.append(_r)
for i in range(q):
    cnt.append(s[l[i]-1:r[i]].count('AC'))
for i in range(len(cnt)):
    print(cnt[i])


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readlines()
n,q = map(int,input().split())
s = input()
l = []
r = []
cnt = []
for i in range(q):
    _l,_r = [int(i) for i in input().split()]
    l.append(_l)
    r.append(_r)
for i in range(q):
    cnt.append(s[l[i]-1:r[i]].count('AC'))
for i in range(len(cnt)):
    print(cnt[i])


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(999999999999)
input = sys.stdin.readlines()
n,q = map(int,input().split())
s = input()
l = []
r = []
cnt = []
for i in range(q):
    _l,_r = [int(i) for i in input().split()]
    l.append(_l)
    r.append(_r)
for i in range(q):
    cnt.append(s[l[i]-1:r[i]].count('AC'))
for i in range(len(cnt)):
    print(cnt[i])


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readlines()
n,q = map(int,input().split())
s = input()
l = []
r = []
cnt = []
for i in range(q):
    _l,_r = [int(i) for i in input().split()]
    l.append(_l)
    r.append(_r)
for i in range(q):
    cnt.append(s[l[i]-1:r[i]].count('AC'))
for i in range(len(cnt)):
    print(cnt[i])


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])

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


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])

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


Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])