Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,q = map(int, input().split())
    S = input()
    N = [0]*n

    for i in range(n):
        if S[i:i+2] == 'AC':
            N[i] = 1
    for i in range(q):
        l,r = map(int,input().split())
        print(sum(N[l-1:r-1]))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n,q = map(int, input().split())
    S = input()
    N = [0]*(n+1)

    for i in range(n):
        N[i+1] += N[i]
        if S[i:i+2] == 'AC':
            N[i+1] += 1
    for i in range(q):
        l,r = map(int,input().split())
        print(N[r-1]-N[l-1])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,q = map(int, input().split())
    S = input()
    array = [list(map(int,input().split())) for _ in range(q)]
    N = [0]*n

    for i in range(n):
        if S[i:i+2] == 'AC':
            N[i] = 1
    for l,r in array:
        print(sum(N[l-1:r-1]))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n,q = map(int, input().split())
    S = input()
    N = [0]*(n+1)

    for i in range(n):
        N[i+1] += N[i]
        if S[i:i+2] == 'AC':
            N[i+1] += 1
    for i in range(q):
        l,r = map(int,input().split())
        print(N[r-1]-N[l-1])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,q = map(int, input().split())
    S = input()
    array = [list(map(int,input().split())) for _ in range(q)]
    N = [0]*n

    for i in range(n):
        if S[i:i+2] == 'AC':
            N[i] = 1
    for l,r in array:
        print(sum(N[l-1:r-1]))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n,q = map(int, input().split())
    S = input()
    N = [0]*(n+1)

    for i in range(n):
        N[i+1] += N[i]
        if S[i:i+2] == 'AC':
            N[i+1] += 1
    for i in range(q):
        l,r = map(int,input().split())
        print(N[r-1]-N[l-1])


if __name__ == '__main__':
    main()

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

    for i in range(q):
        count = 0
        S_temp = S[array[i][0]-1:array[i][1]]
        S_temp_len = len(S_temp)
        for j in range(S_temp_len-1):
            if S_temp[j:j+2] == 'AC':
                count += 1
        print(count)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n,q = map(int, input().split())
    S = input()
    N = [0]*(n+1)

    for i in range(n):
        N[i+1] += N[i]
        if S[i:i+2] == 'AC':
            N[i+1] += 1
    for i in range(q):
        l,r = map(int,input().split())
        print(N[r-1]-N[l-1])


if __name__ == '__main__':
    main()

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

    for i in range(q):
        count = 0
        S_temp = S[array[i][0]-1:array[i][1]]
        S_temp_len = len(S_temp)
        for j in range(S_temp_len):
            if j == S_temp_len-1:
                break
            if S_temp[j] == 'A':
                if S_temp[j+1] == 'C':
                    count += 1
        print(count)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n,q = map(int, input().split())
    S = input()
    N = [0]*(n+1)

    for i in range(n):
        N[i+1] += N[i]
        if S[i:i+2] == 'AC':
            N[i+1] += 1
    for i in range(q):
        l,r = map(int,input().split())
        print(N[r-1]-N[l-1])


if __name__ == '__main__':
    main()

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

    for i in range(q):
        count = 0
        S_temp = S[array[i][0]-1:array[i][1]]
        for j in range(len(S_temp)):
            if j == len(S_temp)-1:
                break
            if S_temp[j] == 'A':
                if S_temp[j+1] == 'C':
                    count += 1
        print(count)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n,q = map(int, input().split())
    S = input()
    N = [0]*(n+1)

    for i in range(n):
        N[i+1] += N[i]
        if S[i:i+2] == 'AC':
            N[i+1] += 1
    for i in range(q):
        l,r = map(int,input().split())
        print(N[r-1]-N[l-1])


if __name__ == '__main__':
    main()

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

    for i in range(q):
        count = 0
        S_temp = S[array[i][0]-1:array[i][1]]
        for j in range(len(S_temp)):
            if j == len(S_temp)-1:
                break
            if S_temp[j] == 'A':
                if S_temp[j+1] == 'C':
                    count += 1
        print(count)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n,q = map(int, input().split())
    S = input()
    N = [0]*(n+1)

    for i in range(n):
        N[i+1] += N[i]
        if S[i:i+2] == 'AC':
            N[i+1] += 1
    for i in range(q):
        l,r = map(int,input().split())
        print(N[r-1]-N[l-1])


if __name__ == '__main__':
    main()