Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
lr = [list(map(int, input().split())) for _ in range(q)]

ruisekiwa=[0]*(n+1)
for i in range(n):
    if s[i]=="A" and s[i+1]=="C":
        ruisekiwa[i+1]=ruisekiwa[i]+1
    else:
        ruisekiwa[i+1] = ruisekiwa[i]
for i in range(q):
    print(ruisekiwa[lr[i][1]-1]-ruisekiwa[lr[i][0]-1])


Fixed submission:
n,q=map(int,input().split())
s=input()
lr = [list(map(int, input().split())) for _ in range(q)]

ruisekiwa=[0]*n
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        ruisekiwa[i+1]=ruisekiwa[i]+1
    else:
        ruisekiwa[i+1] = ruisekiwa[i]
for i in range(q):
    print(ruisekiwa[lr[i][1]-1]-ruisekiwa[lr[i][0]-1])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
lr = [list(map(int, input().split())) for _ in range(q)]

ruisekiwa=[0]*(n+1)
for i in range(n):
    if s[i]=="A" and s[i+1]=="C":
        ruisekiwa[i+1]=ruisekiwa[i]+1
    else:
        ruisekiwa[i+1] = ruisekiwa[i]
for i in range(q):
    print(ruisekiwa[lr[i][1]-1]-ruisekiwa[lr[i][0]-1])


Fixed submission:
n,q=map(int,input().split())
s=input()
lr = [list(map(int, input().split())) for _ in range(q)]

ruisekiwa=[0]*n
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        ruisekiwa[i+1]=ruisekiwa[i]+1
    else:
        ruisekiwa[i+1] = ruisekiwa[i]
for i in range(q):
    print(ruisekiwa[lr[i][1]-1]-ruisekiwa[lr[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
lst = [list(map(int, input().split())) for _ in range(q)]

for i in range(q):
    s_part = s[(lst[i][0]-1):lst[i][1]]
    print(s_part.count("AC"))


Fixed submission:
n,q=map(int,input().split())
s=input()
lr = [list(map(int, input().split())) for _ in range(q)]

ruisekiwa=[0]*n
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        ruisekiwa[i+1]=ruisekiwa[i]+1
    else:
        ruisekiwa[i+1] = ruisekiwa[i]
for i in range(q):
    print(ruisekiwa[lr[i][1]-1]-ruisekiwa[lr[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
lst = [list(map(int, input().split())) for _ in range(q)]

for i in range(q):
    s_part = s[(lst[i][0]-1):lst[i][1]]
    print(s_part.count("AC"))


Fixed submission:
n,q=map(int,input().split())
s=input()
lr = [list(map(int, input().split())) for _ in range(q)]

ruisekiwa=[0]*n
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        ruisekiwa[i+1]=ruisekiwa[i]+1
    else:
        ruisekiwa[i+1] = ruisekiwa[i]
for i in range(q):
    print(ruisekiwa[lr[i][1]-1]-ruisekiwa[lr[i][0]-1])

Buggy python submission (verdict: Runtime Error):
n=map(int,input().split())
s=input()
l1,r1=map(int,input().split())
l2,r2=map(int,input().split())
l3,r3=map(int,input().split())

s1=s[(l1-1):r1]
s2=s[(l2-1):r2]
s3=s[(l3-1):r3]

print(s1.count("AC"))
print(s2.count("AC"))
print(s3.count("AC"))

Fixed submission:
n,q=map(int,input().split())
s=input()
lr = [list(map(int, input().split())) for _ in range(q)]

ruisekiwa=[0]*n
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        ruisekiwa[i+1]=ruisekiwa[i]+1
    else:
        ruisekiwa[i+1] = ruisekiwa[i]
for i in range(q):
    print(ruisekiwa[lr[i][1]-1]-ruisekiwa[lr[i][0]-1])