Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if s[i]=='A' and s[i+1]=='C':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split()) # input:"2 2"
s = str(input())
#どこにACがあるかを計算しておいて、あとからL,Rでsplitする
ans=[0]*(n+1)
for i in range(n):
  if s[i]=='A' and s[i+1]=='C':
    ans[i+1]=ans[i]+1
  else:
    ans[i+1]=ans[i]
#ti =「S の 1 文字目から i 文字目までに出現する a の数」として数列 t = {t0, t1, . . . , tN } を考えると、問 i の答えは tri−1 − tli−1
for i in range(q):
  l, r = map(int, input().split()) #ループ内で一行ずつ読み込む
  print(ans[r-1]-ans[l-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split()) # input:"2 2"
s = str(input())
#どこにACがあるかを計算しておいて、あとからL,Rでsplitする
ans=[0]*n
for i in range(n):
  if s[i]=='A' and s[i+1]=='C':
    ans[i]=1
for i in range(q):
  tmp=0
  l, r = map(int, input().split()) #ループ内で一行ずつ読み込む
  tmp=sum(ans[l-1:r-1])
  print(tmp)

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split()) # input:"2 2"
s = str(input())
#どこにACがあるかを計算しておいて、あとからL,Rでsplitする
ans=[0]*n
for i in range(n):
  if s[i]=='A' and s[i+1]=='C':
    ans[i]=1
for i in range(q):
  l, r = map(int, input().split()) #ループ内で一行ずつ読み込む
  print(sum(ans[l-1:r-1]))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split()) # input:"2 2"
s = str(input())
#どこにACがあるかを計算しておいて、あとからL,Rでsplitする
ans=[0]*n
for i in range(n):
  if s[i]=='A' and s[i+1]=='C':
    ans[i]=1
for i in range(q):
  l, r = map(int, input().split()) #ループ内で一行ずつ読み込む
  print(sum(ans[L[i]-1:R[i]-1]))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split()) # input:"2 2"
s = str(input())
Row=q
L=[]
R=[]
for i in range(Row):
    l,r=input().split()
    L.append(int(l))
    R.append(int(r))
#どこにACがあるかを計算しておいて、あとからL,Rでsplitする
ans=[0]*n
for i in range(n):
  if s[i]=='A' and s[i+1]=='C':
    ans[i]=1
for i in range(q):
  print(sum(ans[L[i]-1:R[i]-1]))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split()) # input:"2 2"
s = str(input())
Row=q
L=[]
R=[]
for i in range(Row):
    l,r=input().split()
    L.append(int(l))
    R.append(int(r))
#どこにACがあるかを計算しておいて、あとからL,Rでsplitする
ans=[0]*n
for i in range(n):
  if s[i]=='A' and s[i+1]=='C':
    ans[i]=1
for i in range(len(L)):
  tmp=0
  print(sum(ans[L[i]-1:R[i]-1]))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])