Buggy python submission (verdict: Time Limit Exceeded):
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[]
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    s.append(1)
    s.append(0)
    j+=1
  else:s.append(0)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][0]-1:a[i][1]-1]
  print(sum(p))





Fixed submission:
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[]
while (j<len(x)-1):
  if (x[j]=="A"):
    if (x[j+1]=="C"):
      s.append(1)
      s.append(0)
      j+=1
    else:s.append(0)
  else:s.append(0)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=np.array(s[a[i][0]-1:a[i][1]-1])
  print(np.sum(p))





Fixed submission:
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[]
while (j<len(x)-1):
  if (x[j]=="A"):
    if (x[j+1]=="C"):
      s.append(1)
      s.append(0)
      j+=1
    else:s.append(0)
  else:s.append(0)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][0]-1:a[i][1]-1]
  print(sum(p))





Fixed submission:
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[]
while (j<len(x)-1):
  if (x[j]=="A"):
    if (x[j+1]=="C"):
      s.append(1)
      s.append(0)
      j+=1
    else:s.append(0)
  else:s.append(0)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][0]-1:a[i][1]-1]
  answer=0
  for j in range(len(p)):
    if p[j]==1:answer+=1
  print(answer)





Fixed submission:
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[]
while (j<len(x)-1):
  if (x[j]=="A"):
    if (x[j+1]=="C"):
      s.append(j+1)
      j+=1
  j+=1
for i in range(0,Q):
  if s==[]:
    print(0)
    continue
  a.append([int(j) for j in input().split()])
  answer=0
  j=0
  while s[j]<a[i][0]:
    j+=1
    if len(s)<=j:break
  k=0
  while s[k]<a[i][1]:
    k+=1
    if len(s)<=k:break
  print(k-j)




Fixed submission:
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)

Buggy python submission (verdict: Runtime Error):
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[]
while (j<len(x)-1):
  if (x[j]=="A"):
    if (x[j+1]=="C"):
      s.append(j+1)
      j+=1
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  answer=0
  j=0
  while s[j]<a[i][0]:
    j+=1
    if len(s)<=j:break
  k=0
  while s[k]<a[i][1]:
    k+=1
    if len(s)<=k:break
  print(k-j)




Fixed submission:
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=(int(i) for i in input().split())
x=input()
a=[]
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  answer=0
  l=x[a[i][0]-1:a[i][1]]
  j=0
  while (j<len(l)-1):
    if (l[j]=="A"):
      if (l[j+1]=="C"):
        answer+=1
        j+=1
    j+=1
  print(answer)

Fixed submission:
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=(int(i) for i in input().split())
x=input()
a=[]
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  answer=0
  l=x[a[i][0]-1:a[i][1]]
  for j in range(0,len(l)-1):
    if (l[j]=="A"):
      if (l[j+1]=="C"):
        answer+=1
  print(answer)

Fixed submission:
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=(int(i) for i in input().split())
x=input()
a=[]
for i in range(0,Q):
  a.append([int(j) for j in input().split()])


for i in range(0,Q):
  answer=0
  l=x[a[i][0]-1:a[i][1]]
  for j in range(0,len(l)-1):
    if (l[j]=="A"):
      if (l[j+1]=="C"):
        answer+=1
  print(answer)

Fixed submission:
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)