Buggy python submission (verdict: Time Limit Exceeded):
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    print(S[li-1:ri].count("AC"))


Fixed submission:
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
t = [0] * (N)
for i in range(1, N):
  t[i] = t[i-1] + (1 if (S[i-1] == "A" and S[i] == "C") else 0)
for _ in " " * Q:
  l, r = [int(lr) for lr in input().split(" ")]
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Runtime Error):
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    print(s[li-1:ri].count("AC"))


Fixed submission:
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
t = [0] * (N)
for i in range(1, N):
  t[i] = t[i-1] + (1 if (S[i-1] == "A" and S[i] == "C") else 0)
for _ in " " * Q:
  l, r = [int(lr) for lr in input().split(" ")]
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
s = S.replace("AC", "NM")
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    print(s[li-1:ri].count("NM"))


Fixed submission:
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
t = [0] * (N)
for i in range(1, N):
  t[i] = t[i-1] + (1 if (S[i-1] == "A" and S[i] == "C") else 0)
for _ in " " * Q:
  l, r = [int(lr) for lr in input().split(" ")]
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Runtime Error):
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
s = S.replace("AC", "NM")
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    print(li, ri, S[li-1:ri])
    print(s[li-1:ri].count("NM"))


Fixed submission:
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
t = [0] * (N)
for i in range(1, N):
  t[i] = t[i-1] + (1 if (S[i-1] == "A" and S[i] == "C") else 0)
for _ in " " * Q:
  l, r = [int(lr) for lr in input().split(" ")]
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Runtime Error):
N, Q = input().split(" ")
N, Q = int(N), int(Q)
S = input()
s = S.replace("AC", "__")
counts = range(Q)
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    print(s[li, ri].count("__"))


Fixed submission:
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
t = [0] * (N)
for i in range(1, N):
  t[i] = t[i-1] + (1 if (S[i-1] == "A" and S[i] == "C") else 0)
for _ in " " * Q:
  l, r = [int(lr) for lr in input().split(" ")]
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Runtime Error):
N, Q = input().split(" ")
N, Q = int(N), int(Q)
S = input()
s = S.replace("AC", "__")
counts = range(Q)
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    counts[i] = s[li-1, ri].count("__")

print(max(counts))


Fixed submission:
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
t = [0] * (N)
for i in range(1, N):
  t[i] = t[i-1] + (1 if (S[i-1] == "A" and S[i] == "C") else 0)
for _ in " " * Q:
  l, r = [int(lr) for lr in input().split(" ")]
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Runtime Error):
N, Q = input().split(" ")
N, Q = int(N), int(Q)
S = input()
s = S.replace("AC", "__")
counts = []
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    counts[i] = s[li-1, ri].count("__")

print(max(counts))

Fixed submission:
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
t = [0] * (N)
for i in range(1, N):
  t[i] = t[i-1] + (1 if (S[i-1] == "A" and S[i] == "C") else 0)
for _ in " " * Q:
  l, r = [int(lr) for lr in input().split(" ")]
  print(t[r-1]-t[l-1])