Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
#!/usr/bin/env python3

import sys


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    for (l, r) in qs:
        print(s[l - 1 : r].count("AC"))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


if __name__ == "__main__":
    main()

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


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [False] + [s[i : i + 2] == "AC" for i in range(n - 1)]
    for (l, r) in qs:
        print(sum(hoges[l:r]))


if __name__ == "__main__":
    main()

Fixed submission:
import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n, q = [int(i) for i in input().split()]
s = input()
hoges = [s[i:i+2] == 'AC' for i in range(n - 1)]
hoges.insert(0, False)
for _ in range(q):
    l, r = [int(i) for i in input().split()]
    print(sum(hoges[l:r]))

Fixed submission:
import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n, q = [int(i) for i in input().split()]
s = input()
for _ in range(q):
    l, r = [int(i) for i in input().split()]
    print(
        len([i for i in [a + b for a, b in zip(s[l-1: r-1], s[l: r+1])] if i == 'AC']))

Fixed submission:
import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
n, q = [int(i) for i in input().aplit()]
s = input()
for _ in range(q):
    l, r = [int(i) for i in input().aplit()]
    print(
        len([i for i in [a + b for a, b in zip(s[l-1: r], s[l: r+1])] if i == 'AC']))

Fixed submission:
import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


if __name__ == "__main__":
    main()