Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = [x for x in list(map(str, input()))]
lr = []
for i in range(q):
    lr.append(list(map(int, input().split())))

result = []
for i in range(q):
    left = lr[i][0] - 1
    right = lr[i][1] - 1
    substring = s[left:right + 1]
    ans = 0
    for j in range(1, len(substring)):
        if substring[j - 1] == 'A' and substring[j] == 'C':
            ans += 1
    result.append(ans)

for i in range(len(result)):
    print(result[i])


Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():    
	N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():    
  	N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, Q = map(int, input().split())
    S = input()
    list = []

    #for i in range(int(Q)):
      #  list.append(map(int, input().split()))

    for i in range(int(Q)):
        #a, b = list[i]
        a, b = map(int, input().split())
        sss = S[a - 1:b]
        count = sss.count("AC")
        print(count)

    return 0


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = input().split()
S = input()
list = []

for i in range(int(Q)):
    list.append(int(x) for x in input().split())

for i in range(int(Q)):
    a, b = list[i]
    sss = S[a - 1:b]
    count = sss.count("AC")
    print(count)
   

Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = input().split()
S = input()
list = []

for i in range(int(Q)):
    list.append(int(x) for x in input().split())

for i in range(int(Q)):
    a, b = list[i]
    sss = S[a - 1:b]
    count = sss.count("AC")
    print(count)
   

Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, Q = input().split()
    S = input()
    list = []

    for i in range(int(Q)):
        list.append(int(x) for x in input().split())

    for i in range(int(Q)):
        a, b = list[i]
        sss = S[a - 1:   b]
        count = sss.count("AC")
        print(count)

    return 0


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, Q = input().split()
    S = input()

    for i in range(int(Q)):
        a, b = (int(x) for x in input().split())
        sss = S[a - 1: b]
        count = sss.count("AC")
        print(count)

    return 0


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, Q = input().split()
    S = input()

    for i in range(int(Q)):
        a, b = (int(x) for x in input().split())
        sss = S[a - 1: b]
        count = sss.count("AC")
        print(count)

    return 0


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, Q = input().split()
    S = input()

    for i in range(int(Q)):
        a, b = (int(x) for x in input().split())
        sss = S[a - 1: b]
        sss = sss.replace("AC", "1")
        count = sss.count("1")
        print(count)

    return 0


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, Q = input().split()
    S = input()
    list = []

    for i in range(int(Q)):
        list.append(input().split())

    for i in range(int(Q)):
        sss = S[int(list[i][0]) - 1: int(list[i][1])]
        sss = sss.replace("AC", "1")
        count = sss.count("1")
        print(count)

    return 0


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, Q = map(int, input().split())
    S = input()

    list = [0] * (N + 1)

    for i in range(N):
        list[i + 1] = list[i] + (1 if S[i:i + 2] == "AC" else 0)

    for i in range(Q):
        a, b = map(int, input().split())
        output = list[b - 1] - list[a - 1]
        print(output)


if __name__ == '__main__':
    main()