Buggy python submission (verdict: Runtime Error):
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])

Fixed submission:
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):
N,Q=map(int,input().split())
S=input()
A=[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])

Fixed submission:
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):
N,Q=map(int,input().split())
S=input()
l,r=[map(int,input().split()) for i in range(Q)]
for j in range(Q):
  print(S.count("AC",l[j],r[j]+1))

Fixed submission:
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):
N,Q=map(int,input().split())
S=input()
L=[]
R=[]
for i in range(Q):
  l,r=map(int,input().split())
  L.append(l)
  R.append(r)
for j in range(Q):
  print(str.count("AC",L[j].R[j]+1)

Fixed submission:
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):
N,Q=map(int,input().split())
S=input()
for i in range(Q):
  l,r=[list(map(int,input().split()))]
for j in range(Q):
  print(str.count("AC",l[j].r[j]+1)

Fixed submission:
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):
N,Q=map(int,input().split())
S=input()
for i in range(Q):
  l,r=list(map(int,input().split()))
for j in range(Q):
  print(str.count("AC",l[j].r[j]+1))

Fixed submission:
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):
N,Q=map(int,input().split())
S=int(input())
l,r=[list(map(int,input().split())) for i in range(Q)]
for j in range(Q):
  print(str.count("AC",l[j].r[j]+1))

Fixed submission:
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):
N,Q=map(int,input().split())
S=input()
l,r=list(map(int,input().split())) for i in range(Q)
def main():
  for i in range(Q):
    T=S[l[i]:r[i]+1]
    c=T.count('AC')
    print(c)
main()


Fixed submission:
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])