Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,mondaisuu=map(int,input().split())
s=input()
li=np.zeros(n)
dp = [[-1 for i in range(n)] for j in range(n)]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    li[i]=1
for i in range(mondaisuu):
  l,r=map(int,input().split())
  if dp[l-1][r-1]==-1:
    ans=int(np.sum(li[l-1:r-1]))
    print(ans)
    dp[l-1][r-1]=ans
  else:
    print(dp[l-1][r-1])

Fixed submission:
n,mondaisuu=map(int,input().split())
s=input()
dp=[0]*n
for i in range(1,n):
  dp[i]=dp[i-1] + (1 if s[i]=="C" and s[i-1]=="A" else 0)
for i in range(mondaisuu):
  l,r=map(int,input().split())
  print(dp[r-1]-dp[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,mondaisuu=map(int,input().split())
s=input()
li=np.zeros(n)
dp = [[0 for i in range(n)] for j in range(n)]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    li[i]=1
for i in range(mondaisuu):
  l,r=map(int,input().split())
  if dp[l-1][r-1]==0:
    ans=int(np.sum(li[l-1:r-1]))
    print(ans)
    dp[l-1][r-1]=ans
  else:
    print(dp[l-1][r-1])

Fixed submission:
n,mondaisuu=map(int,input().split())
s=input()
dp=[0]*n
for i in range(1,n):
  dp[i]=dp[i-1] + (1 if s[i]=="C" and s[i-1]=="A" else 0)
for i in range(mondaisuu):
  l,r=map(int,input().split())
  print(dp[r-1]-dp[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,mondaisuu=map(int,input().split())
s=input()
li=np.zeros(n)
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    li[i]=1
for i in range(mondaisuu):
  l,r=map(int,input().split())
  print(int(np.sum(li[l-1:r-1])))

Fixed submission:
n,mondaisuu=map(int,input().split())
s=input()
dp=[0]*n
for i in range(1,n):
  dp[i]=dp[i-1] + (1 if s[i]=="C" and s[i-1]=="A" else 0)
for i in range(mondaisuu):
  l,r=map(int,input().split())
  print(dp[r-1]-dp[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,mondaisuu=map(int,input().split())
s=input()
li=[0]*n
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    li[i]=1
for i in range(mondaisuu):
  l,r=map(int,input().split())
  print(sum(li[l-1:r-1]))

Fixed submission:
n,mondaisuu=map(int,input().split())
s=input()
dp=[0]*n
for i in range(1,n):
  dp[i]=dp[i-1] + (1 if s[i]=="C" and s[i-1]=="A" else 0)
for i in range(mondaisuu):
  l,r=map(int,input().split())
  print(dp[r-1]-dp[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,mondaisuu=map(int,input().split())
s=input()
for i in range(mondaisuu):
  ans=0
  l,r=map(int,input().split())
  prob=s[l-1:r]
  print(prob.count("AC"))

Fixed submission:
n,mondaisuu=map(int,input().split())
s=input()
dp=[0]*n
for i in range(1,n):
  dp[i]=dp[i-1] + (1 if s[i]=="C" and s[i-1]=="A" else 0)
for i in range(mondaisuu):
  l,r=map(int,input().split())
  print(dp[r-1]-dp[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,mondaisuu=map(int,input().split())
s=input()
for i in range(mondaisuu):
  ans=0
  l,r=map(int,input().split())
  prob=s[l-1:r]
  for j in range(len(prob)-1):
    if prob[j]=="A" and prob[j+1]=="C":
      ans+=1
  print(ans)

Fixed submission:
n,mondaisuu=map(int,input().split())
s=input()
dp=[0]*n
for i in range(1,n):
  dp[i]=dp[i-1] + (1 if s[i]=="C" and s[i-1]=="A" else 0)
for i in range(mondaisuu):
  l,r=map(int,input().split())
  print(dp[r-1]-dp[l-1])