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):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, Q = mi()
# print(N, Q)
S = li()
Alist = []
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
AClist = [0]*(N+1)
for i in range(N - 1):
    if i in Alist:
        AClist[i + 2] = AClist[i+1] + 1
    else:
        AClist[i+2] = AClist[i+1]

# print(AClist)

for i in range(Q):
    l, r = mi()
#     if AClist[l - 1] != AClist[l]:
#         print(AClist[r] - AClist[l])
#     else:
#         print(AClist[r] - AClist[l-1])


import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, Q = mi()
# print(N, Q)
S = li()
Alist = []
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
AClist = [0]*(N+1)


#         AClist[i + 2] = AClist[i+1] + 1
#     else:
#         AClist[i+2] = AClist[i+1]

# print(AClist)

for i in range(Q):
    l, r = mi()
#     if AClist[l - 1] != AClist[l]:
#         print(AClist[r] - AClist[l])
#     else:
#         print(AClist[r] - AClist[l-1])


import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, Q = mi()
S = li()
Alist = []
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
AClist = [0]*N
for i in range(N - 1):
    if i in Alist:
        AClist[i + 1] = AClist[i] + 1
    else:
        AClist[i+1] = AClist[i]
AClist.insert(0, 0)
print(AClist)
for i in range(Q):
    l, r = mi()
    print(AClist[r] - AClist[l])

import sys
# input = sys.stdin.readline




# # template


N, Q = map(int, sys.stdin.readline().rstrip().split())
print(N, Q)
S = list(sys.stdin.readline().rstrip())
Alist = []
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, sys.stdin.readline().rstrip().split())
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
AClist = [0]*(N+1)
for i in range(N - 1):
    if i in Alist:
        AClist[i + 2] = AClist[i+1] + 1
    else:
        AClist[i+2] = AClist[i+1]

# print(AClist)


#     if AClist[l[i] - 1] != AClist[l[i]]:
#         print(AClist[r[i]] - AClist[l[i]])
#     else:
#         print(AClist[r[i]] - AClist[l[i]-1])

import sys
# input = sys.stdin.readline




# # template


N, Q = map(int, sys.stdin.readline().rstrip().split())
print(N, Q)
S = list(sys.stdin.readline().rstrip())
Alist = []
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, sys.stdin.readline().rstrip().split())
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
AClist = [0]*(N+1)
for i in range(N - 1):
    if i in Alist:
        AClist[i + 2] = AClist[i+1] + 1
    else:
        AClist[i+2] = AClist[i+1]

# print(AClist)

for i in range(Q):
    if AClist[l[i] - 1] != AClist[l[i]]:
        print(AClist[r[i]] - AClist[l[i]])
    else:
        print(AClist[r[i]] - AClist[l[i]-1])

import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, Q = mi()
# print(N, Q)
S = li()
Alist = []

#     if S[i] == 'A' and S[i + 1] == 'C':
#         Alist.append(i)
# AClist = [0]*(N+1)


#         AClist[i + 2] = AClist[i+1] + 1
#     else:
#         AClist[i+2] = AClist[i+1]

# print(AClist)

import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, Q = mi()
# print(N, Q)
S = li()
Alist = []
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
Aset = set(Alist)
AClist = [0]*(N+1)
for i in range(N-1):
    if i in Aset:
        AClist[i + 2] = AClist[i + 1] + 1
    else:
        AClist[i+2] = AClist[i+1]
        # print(AClist)

for i in range(Q):
    l, r = mi()
    if AClist[l - 1] != AClist[l]:
        print(AClist[r] - AClist[l])
    else:
        print(AClist[r] - AClist[l-1])

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted