Problem p03087 (python)

Fixed submission:
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * (N + 1)

    for i in range(1, N):
        if S[i-1] == 'A' and S[i] == 'C': sum[i] = sum[i-1] + 1
        else: sum[i] = sum[i-1]

    for i in range(Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)

Buggy submission (verdict: Runtime Error):
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * (N + 100)

    for i in range(N+1):
        if S[i] == 'A' and S[i+1] == 'C': sum[i+1] = sum[i] + 1
        else: sum[i+1] = sum[i]

    for i in range(Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)

Buggy submission (verdict: Runtime Error):
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * (N + 100)

    for i in range(N):
        if S[i] == 'A' and S[i+1] == 'C': sum[i+1] = sum[i] + 1
        else: sum[i+1] = sum[i]

    for i in range(Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)

Buggy submission (verdict: Runtime Error):
import time


def main():

    N, Q = map(int, input().split())
    S = input()
    l = [0] * Q
    r = [0] * Q
    for i in range(Q):
        l[i], r[i] = map(int, input().split())

    sum = [0] * (N + 1)

    for i in range(N):
        if S[i] == 'A' and S[i+1] == 'C': sum[i+1] = sum[i] + 1
        else: sum[i+1] = sum[i]

    for i in range(Q):
        print(sum[r[i]-1] - sum[l[i]-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)

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

sum = [0] * (N + 1)

for i in range(N):
    if S[i] == 'A' and S[i+1] == 'C': sum[i+1] = sum[i] + 1
    else: sum[i+1] = sum[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(sum[r-1] - sum[l-1])

Buggy submission (verdict: Runtime Error):
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * (N + 1)

    for i in range(N):
        if S[i] == 'A' and S[i+1] == 'C': sum[i+1] = sum[i] + 1
        else: sum[i+1] = sum[i]

    for i in range(Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)

Buggy submission (verdict: Runtime Error):
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * 100010

    for i in range(0, N):
        if S[i] == 'A' and S[i+1] == 'C': sum[i+1] = sum[i] + 1
        else: sum[i+1] = sum[i]

    for i in range(0, Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)

Buggy submission (verdict: Runtime Error):


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * 100010

    for i in range(0, N):
        if S[i] == 'A' and S[i+1] == 'C': sum[i+1] = sum[i] + 1
        else: sum[i+1] = sum[i]

    for i in range(0, Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)

Buggy submission (verdict: Runtime Error):
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0]

    for i in range(0, N):
        if S[i] == 'A' and S[i+1] == 'C': sum.append(sum[i] + 1)
        else: sum.append(sum[i])

    for i in range(0, Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)

Buggy submission (verdict: Runtime Error):
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0]

    for i in range(0, N):
        if S[i] == 'A' and S[i+1] == 'C': sum[i+1] = sum[i] + 1
        else: sum[i+1] = sum[i]

    for i in range(0, Q):
        l, r = map(int, input().split())
        print(sum[r] - sum[l])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    print(end - start)