Buggy python submission (verdict: Time Limit Exceeded):
#import re

i = int(input().split()[1])
s = input()
k = 0
f = []
e = []
result = []

for k in range(i):
    ff, ee = map(int, input().split())
    f.append(ff)
    e.append(ee)
    #result.append(s[ft - 1:et].count("AC"))
    #result.append(len(re.findall("AC", s[ft - 1:et])))

for k in range(i):
    print(s[f[k] - 1:e[k]].count("AC"))

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
#import re

i = int(input().split()[1])
s = input()
result = []

for k in range(i):
    ft, et = map(int, input().split())
    result.append(s[ft - 1:et].count("AC"))
    #result.append(len(re.findall("AC", s[ft - 1:et])))

for kekka in result:
    print(kekka)

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re

i = int(input().split()[1])
s = input()
k = 0
result = []

while k < i:
    ft, et = map(int, input().split())
    result.append(s[ft - 1:et].count("AC"))
    #result.append(len(re.findall("AC", s[ft - 1:et])))
    k += 1

for kekka in result:
    print(kekka)

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re

i = int(input().split()[1])
s = input()
k = 0
result = []

while k < i:
    ft, et = map(int, input().split())
    result.append(len(re.findall("AC", s[ft - 1:et])))
    k += 1

for kekka in result:
    print(kekka)

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re

i = int(input().split()[1])
s = input()
k = 0
result = []

while k < i:
    ft, et = [int(n) for n in input().split()]
    result.append(len(re.findall("AC", s[ft - 1:et])))
    k += 1

for kekka in result:
    print(kekka)

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Runtime Error):
import re

i = input().split()[1]
s = input()
k = 0
result = []

while k < i:
    ft, et = [int(n) for n in input().split()]
    result.append(len(re.findall("AC", s[ft - 1:et])))
    k += 1

for kekka in result:
    print(kekka)

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re

a, i = [int(n) for n in input().split()]
s = input()
k = 0
result = []

while k < i:
    ft, et = [int(n) for n in input().split()]
    result.append(len(re.findall("AC", s[ft - 1:et])))
    k += 1

for kekka in result:
    print(kekka)


Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re

a, i = [int(n) for n in input().split()]
s = input()
k = 0
f = []
e = []
result = []

while k < i:
    ft, et = [int(n) for n in input().split()]
    f.append(ft)
    e.append(et)
    result.append(len(re.findall("AC", s[ft - 1:et])))
    k += 1

for kekka in result:
    print(kekka)

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Runtime Error):
import re

input()
s = input()
b, c = [int(n) for n in input().split()]
d, e = [int(n) for n in input().split()]
f, g = [int(n) for n in input().split()]
print(len(re.findall("AC", s[b - 1:c])))
print(len(re.findall("AC", s[d-1:e])))
print(len(re.findall("AC", s[f-1:g])))

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])