Problem: You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries:    * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does `AC` occurs as a substring?

Submission attempts (in order):
# -*- coding: utf-8 -*-
def main():
    n, q = inputAsIntArr()
    s = input()

    idxes = []
    for i in range(n):
        if s[i] != 'A':
            continue
        if s[i+1] == 'C':
            idxes.append(i)
            i += 1

    num_acs = ""
    for i in range(q):
        li, ri = inputAsIntArr()
        
        # num_acs += str(num_ac) + "\n"

    print(num_acs.strip())


def inputAsIntArr():
    return [int(i) for i in input().split(' ')]


if __name__ == '__main__':
    main()


def main():
    n, q = inputAsIntArr()
    s = input()

    idxes = []
    for i in range(n):
        if s[i] != 'A':
            continue
        if s[i+1] == 'C':
            idxes.append(i)
            i += 1

    # num_acs = ""
    
    #     li, ri = inputAsIntArr()
    
    #     num_acs += str(num_ac) + "\n"

    # print(num_acs.strip())


def inputAsIntArr():
    return [int(i) for i in input().split(' ')]


if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-
def main():
    n, q = inputAsIntArr()
    s = input()

    
    idxes = []
    for i in range(n):
        if s[i] != 'A':
            continue
        if s[i+1] == 'C':
            idxes.append(i)
            i += 1

    
    num_acs = ""
    for i in range(q):
        li, ri = inputAsIntArr()
        num_ac = len([v for v in idxes if li-2 < v < ri-1])
        num_acs += f"{str(num_ac)}\n"

    print(num_acs)


def inputAsIntArr():
    return [int(i) for i in input().split(' ')]


if __name__ == '__main__':
    main()

def main():
    n, q = split_and_to_int(input().strip())
    s = input().strip()

    res = ""
    for _ in range(q):
        l, r = split_and_to_int(input().strip())
        n = 0
        for i in range(l-1, r-2):
            if s[i] == 'A' and s[i+1] == 'C':
                n += 1
                i += 1
        res = res + "\n" + n

    print(res)


def split_and_to_int(s):
    return [int(i) for i in s.split()]


if __name__ == '__main__':
    main()


def main():
    n, q = split_and_to_int(input().strip())
    s = input().strip()

    res = ""
    for _ in range(q):
        l, r = split_and_to_int(input().strip())
        n = 0
        
        #     if s[i] == 'A' and s[i+1] == 'C':
        #         n += 1
        
        # res = res + "\n" + n

    print(res)


def split_and_to_int(s):
    return [int(i) for i in s.split()]


if __name__ == '__main__':
    main()


def main():
    n, q = split_and_to_int(input().strip())
    s = input().strip()

    res = ""
    for _ in range(q):
        l, r = split_and_to_int(input().strip())
        n = 0
        for i in range(l-1, r-2):
            if s[i] == 'A' and s[i+1] == 'C':
                n += 1
                i += 1
        # res = res + "\n" + n

    print(res)


def split_and_to_int(s):
    return [int(i) for i in s.split()]


if __name__ == '__main__':
    main()


def main():
    n, q = split_and_to_int(input().strip())
    s = input().strip()

    res = ""
    for _ in range(q):
        l, r = split_and_to_int(input())
        n = 0
        for i in range(l-1, r-1):
            if s[i] == 'A' and s[i+1] == 'C':
                n += 1
                i += 1
        res += f"{n}\n"

    print(res)


def split_and_to_int(s):
    return [int(i) for i in s.split()]


if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-
def main():
    n, q = inputAsIntArr()
    s = input()

    idxes = []
    for i in range(n):
        if s[i] != 'A':
            continue
        if s[i+1] == 'C':
            idxes.append(i)
            i += 1

    # num_acs = ""
    
    #     li, ri = inputAsIntArr()
    
    #     num_acs += str(num_ac) + "\n"

    # print(num_acs.strip())


def inputAsIntArr():
    return [int(i) for i in input().split(' ')]


if __name__ == '__main__':
    main()

def main():
    n, q = split_and_to_int(input().strip())
    s = input().strip()

    res = ""
    for _ in range(q):
        l, r = split_and_to_int(input().strip())
        n = 0
        for i in range(l-1, r-2):
            if s[i] == 'A' and s[i+1] == 'C':
                n += 1
                i += 1
        res = res + "\n" + str(n)

    print(res)


def split_and_to_int(s):
    return [int(i) for i in s.split()]


if __name__ == '__main__':
    main()


def main():
    n, q = split_and_to_int(input().strip())
    s = input().strip()

    res = ""
    for _ in range(q):
        l, r = split_and_to_int(input().strip())
        n = 0
        for i in range(l-1, r-1):
            if s[i] == 'A' and s[i+1] == 'C':
                n += 1
                i += 1
        res = res + "\n" + n

    print(res)


def split_and_to_int(s):
    return [int(i) for i in s.split()]


if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-
def main():
    n, q = inputAsIntArr()
    s = input()

    
    idxes = []
    for i in range(n):
        if s[i] != 'A':
            continue
        if s[i+1] == 'C':
            idxes.append(i)
            i += 1

    
    num_acs = ""
    for i in range(q):
        li, ri = inputAsIntArr()
        num_ac = len([v for v in idxes if li-2 < v < ri-1])
        num_acs += "{}\n".format(str(num_ac))

    print(num_acs)


def inputAsIntArr():
    return [int(i) for i in input().split(' ')]


if __name__ == '__main__':
    main()

def main():
    n, q = map(int, input().split())
    s = input()

    
    p = [0] * (n+1)
    for i in range(n):
        p[i+1] = p[i] + (1 if s[i:i+2] == "AC" else 0)

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


if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted