Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]==A and s[i]==C:
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])



Fixed submission:

n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())

count=0


ans=[0 for i in range(n+2)]
for i in range(n-1):
  if s[i]+s[i+1]=='AC':
    count+=1
    ans[i+1]=count
  else:
    ans[i+1]=count
ans[n]=ans[n-1]
ans[n+1]=ans[n]


for i in range(q):
  sita,ue=map(int,input().split())
  if s[ue-1]=='A' and s[ue]=='C' and ue!=n:
    print(ans[ue]-ans[sita-1]-1)
  
  else:
    print(ans[ue]-ans[sita-1])
    
  


Fixed submission:

n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())

count=0


ans=[0 for i in range(n+2)]
for i in range(n-1):
  if s[i]+s[i+1]=='AC':
    count+=1
    ans[i+1]=count
  else:
    ans[i+1]=count
ans[n]=ans[n-1]
ans[n+1]=ans[n]


for i in range(q):
  sita,ue=map(int,input().split())
  if s[ue-1]=='A' and s[ue]=='C':
    print(ans[ue]-ans[sita-1]-1)
  
  else:
    print(ans[ue]-ans[sita-1])
    
  

  


Fixed submission:

n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())

count=0


ans=[0 for i in range(n+2)]
for i in range(n-1):
  if s[i]+s[i+1]=='AC':
    count+=1
    ans[i+1]=count
  else:
    ans[i+1]=count
ans[n]=ans[n-1]
ans[n+1]=ans[n]

print(*ans)

for i in range(q):
  sita,ue=map(int,input().split())
  if s[ue-1]=='A' and s[ue]=='C':
    print(ans[ue]-ans[sita-1]-1)
  
  else:
    print(ans[ue]-ans[sita-1])
    
  

  


Fixed submission:

n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])