Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
list_ac=[]
number=0
for i in range(0,len(s)):
    if s[i]=='A':
        state=1
        list_ac.append(number)
    elif s[i]=='C':
        if state==1:
            number=number+1   
        list_ac.append(number)
        state=0
    else:
        state=0
        list_ac.append(number)
list_ac.append(list_ac[-1])
for i in range(0,q):
    l,r=map(int,input().split())
    print(list_ac[r-1]-list_ac[l-1])
        
    


Fixed submission:
n,q=map(int,input().split())
s=input()
list_ac=[0]
number=0
for i in range(0,n):
    if s[i:i+2]=='AC':
        number=number+1
        list_ac.append(number)
    else:
        list_ac.append(number)
for i in range(0,q):
    l,r=map(int,input().split())
    print(list_ac[r-1]-list_ac[l-1])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
list_ac=[]
number=0
for i in range(0,n):
    if s[i]=='A':
        state=1
        list_ac.append(number)
    elif s[i]=='C':
        if state==1:
            number=number+1   
        list_ac.append(number)
        state=0
    else:
        state=0
        list_ac.append(number)
print(list_ac)
for i in range(0,q):
    l,r=map(int,input().split())
    print(list_ac[r-1]-list_ac[l-1])
        
    


Fixed submission:
n,q=map(int,input().split())
s=input()
list_ac=[0]
number=0
for i in range(0,n):
    if s[i:i+2]=='AC':
        number=number+1
        list_ac.append(number)
    else:
        list_ac.append(number)
for i in range(0,q):
    l,r=map(int,input().split())
    print(list_ac[r-1]-list_ac[l-1])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
list_ac=[]
number=0
for i in range(0,len(s)):
    if s[i]=='A':
        state=1
        list_ac.append(number)
    elif s[i]=='C':
        if state==1:
            number=number+1   
        list_ac.append(number)
        state=0
    else:
        state=0
        list_ac.append(number)
for i in range(0,q):
    l,r=map(int,input().split())
    print(list_ac[r-1]-list_ac[l-1])
        
    


Fixed submission:
n,q=map(int,input().split())
s=input()
list_ac=[0]
number=0
for i in range(0,n):
    if s[i:i+2]=='AC':
        number=number+1
        list_ac.append(number)
    else:
        list_ac.append(number)
for i in range(0,q):
    l,r=map(int,input().split())
    print(list_ac[r-1]-list_ac[l-1])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
list_ac=[]
for i in range(0,len(s)):
    if s[i]=='A':
        place=i
        state=1
    elif s[i]=='C':
        if state==1:
            list_ac.append(place)
        state=0
    else:
        state=0      
for i in range(0,q):
    l,r=map(int,input().split())
    count=0
    for j in list_ac:
        if l-1<=j<=r-2:
            count=count+1
        elif j>r-2:
            break
    print(count)
        
    


Fixed submission:
n,q=map(int,input().split())
s=input()
list_ac=[0]
number=0
for i in range(0,n):
    if s[i:i+2]=='AC':
        number=number+1
        list_ac.append(number)
    else:
        list_ac.append(number)
for i in range(0,q):
    l,r=map(int,input().split())
    print(list_ac[r-1]-list_ac[l-1])