TnT/Multi_CodeNet4Repair huggingface dataset:
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):
n,q = map(int,input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=="AC" else 0)
print(t)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])


n,q = map(int,input().split())
s = input()
l = [list(map(int,input().split())) for i in range(q)]
s_len = len(s)
account = s.count('AC')
count = 0
for i in range(q):
    center = len(s[l[i][0]-1:s[l[i][1]]])
    if center <= s_len:
        print(s[l[i][0]-1:s[l[i][1]]].count('AC'))
    else:
        '''
        left = s[0:]
        if s[l[i][0]-1:l[i][0]+1] == 'AC':
            count += 1
        if s[l[i][1]-1:l[i][1]+!] =='AC':
            count += 1
        print(account-)
        '''
        pass


n,q = map(int,input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=="AC" else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])


Verdicts: Wrong Answer

Runtime Error

Accepted
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):
N,Q = map(int,input().split())
S = input()
ans = []
rl = []
for i in range(Q):
    a,b = map(int,input().split())
    rl += [[a,b]]

for i in range(Q):
    count = 0
    S_temp = [ S[j] for j in range(rl[i][0]-1,rl[i][-1]) ]
    count = S_temp.count("AC")
    ans.append(count)
    
for i in range(Q):
    print(ans[i])


N,Q = map(int,input().split())
S = input()
lr = []
S_temp = []
S_temp.append(0)
for i in range(1,N):
    if S[i-1] == "A" and S[i] == "C":
        S_temp.append(S_temp[i-1] + 1)
    else:
        S_temp.append(S_temp[i-1])
for i in range(Q):
    a,b = map(int,input().split())
    lr.append([a-1,b-1])

for i in range(Q):
    print(S_temp[lr[i][-1]] - S_temp[lr[i][0]])

    


Verdicts: Wrong Answer

Accepted
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):
N, Q = [int(_) for _ in input().split()]
S = input()
l_r_list = [[int(_) for _ in input().split()] for _ in range(Q)]

AC_accumulation = [0]

for i in range(1, N + 1):
    if S[i] == "C":
        if S[i - 1] == "A":
            AC_accumulation.append(AC_accumulation[-1] + 1)
    else:
        AC_accumulation.append(AC_accumulation[-1])


ans = []
for l, r in l_r_list:
    ans.append(str(AC_accumulation[r - 1] - AC_accumulation[l - 1]))

print("\n".join(ans))


N, Q = [int(_) for _ in input().split()]
S = input()
l_r_list = [[int(_) for _ in input().split()] for _ in range(Q)]

AC_accumulation = [0]

for i in range(1, N):
    if S[i] == "C" and S[i - 1] == "A":
        AC_accumulation.append(AC_accumulation[-1] + 1)
    else:
        AC_accumulation.append(AC_accumulation[-1])


ans = []
for l, r in l_r_list:
    ans.append(str(AC_accumulation[r - 1] - AC_accumulation[l - 1]))

print("\n".join(ans))


Verdicts: Runtime Error

Accepted
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):
N, Q = map(int, input().split())
S = input()
cnt = [0] * (N)

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

print(cnt)

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

N, Q = map(int, input().split())
S = input()
cnt = [0] * (N)

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


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


Verdicts: Wrong Answer

Accepted
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):
def main():
  n,q=map(int,input().split())
  s=input()
  t = [0] * (n + 1)
  for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
  for i in range(q):
    l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
if __name__=='__main__':
  main()

def main():
  n,q=map(int,input().split())
  s=input()
  t = [0] * (n + 1)
  for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
  for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

if __name__=='__main__':
  main()

Verdicts: Wrong Answer

Accepted
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):
N, Q = map(int, input().split())
S = input()

dp = [[0 for i in range(N + 1)] for j in range(N + 1)]

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

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


N, Q = map(int, input().split())
S = input()
W = [0 for i in range(N + 1)]
AC = [False for b in range(N + 1)]
for i in range(1, N):
    if S[i] == 'C' and S[i - 1] == 'A':
        W[i + 1] = W[i] + 1
        AC[i] = True
    else:
        W[i + 1] = W[i]

for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ans = W[r + 1] - W[l]
    if AC[l]:
        ans -= 1
print(ans)



N, Q = map(int, input().split())
S = input()
W = [0 for i in range(N + 1)]
AC = [False for b in range(N + 1)]
for i in range(1, N):
    if S[i] == 'C' and S[i - 1] == 'A':
        W[i + 1] = W[i] + 1
        AC[i] = True
    else:
        W[i + 1] = W[i]

for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ans = W[r + 1] - W[l]
    if AC[l]:
        ans -= 1
    print(ans)



Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
n,q = map(int,input().split())
S = input()
for i in range(q):
  l,r = map(int,input().split())
  A = S[l,r+1]
  cnt = A.count('AC')
  print(cnt)
  

n,q = map(int,input().split())
S = input()
for _ in range(q):
  l,r = map(int,input().split())
  A = S[l:r+1]
  cnt = A.count('AC')
  print(cnt)
  


import numpy as np
import sys
buf = sys.stdin.buffer
N,Q = map(int,buf.readline().split())
S = np.zeros(N+2, dtype='S1')
S[1:] = np.frombuffer(buf.read(N+1), dtype='S1')
A = (S == b'A')
C = (S == b'C')
AC = (A[:-1] & C[1:])
AC_cum = list(AC.cumsum())

for _ in range(Q):
  L,R = map(int,buf.readline().split())
  print(AC_cum[R-1] - AC_cum[L-1])


Verdicts: Runtime Error

Wrong Answer

Accepted
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):
N, Q = map(int, input().split())
S = input()

cc = []

for idx in range(len(S) - 1):
    if S[idx:idx + 2] == "AC":
        cc.append(1)
    else:
        cc.append(0)

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


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

cc = []

acc = 0

for idx in range(N):
    if S[idx:idx + 2] == "AC":
        acc = acc + 1
    cc.append(acc)

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

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

cc = []

acc = 0

for idx in range(N):
    if S[idx - 1:idx + 1] == "AC":
        acc = acc + 1
    cc.append(acc)

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


Verdicts: Runtime Error

Wrong Answer

Accepted
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 bisect


def read_input():
    n, q = map(int, input().split())
    s = list(input().strip())
    queries = []
    for _ in range(q):
        st, ed = map(int, input().split())
        queries.append((st - 1, ed - 1))

    return n, s, queries


def submit():
    n, s, queries = read_input()

    
    ac_st = []
    for i in range(n - 1):
        if s[i] == "A" and s[i + 1] == "C":
            ac_st.append(i)

    print(ac_st)

    for ql, qr in queries:
        print(bisect.bisect_right(ac_st, qr - 1) -\
              bisect.bisect_left(ac_st, ql))


if __name__ == "__main__":
    submit()


import bisect


def read_input():
    n, q = map(int, input().split())
    s = list(input().strip())
    queries = []
    for _ in range(q):
        st, ed = map(int, input().split())
        queries.append((st - 1, ed - 1))

    return n, s, queries


def submit():
    n, s, queries = read_input()

    
    ac_st = []
    for i in range(n - 1):
        if s[i] == "A" and s[i + 1] == "C":
            ac_st.append(i)

    for ql, qr in queries:
        print(bisect.bisect_right(ac_st, qr - 1) -\
              bisect.bisect_left(ac_st, ql))


if __name__ == "__main__":
    submit()

Verdicts: Wrong Answer

Accepted
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):
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

for i in range(q):
    print(s[lr[i][0] - 1:lr[i][1]])
    print(s[lr[i][0] - 1:lr[i][1]].count('AC'))

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
ac_list = [0] * (n+1)
for i in range(n):
    ac_list[i+1] = ac_list[i] + (1 if s[i:i+2] == 'AC' else 0)
# print(ac_list)
for i in range(q):
    print(ac_list[lr[i][1]-1] - ac_list[lr[i][0]-1])

Verdicts: Runtime Error

Accepted
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):
N, Q = map(int, input().split())
S = input()
AC = [0] * N

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

print(AC)

for i in range(Q):
    start, end = map(lambda x:int(x)-1, input().split())
    print(AC[end] - AC[start])

N, Q = map(int, input().split())
S = input()
AC = [0] * N

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


for i in range(Q):
    start, end = map(lambda x:int(x)-1, input().split())
    print(AC[end] - AC[start])

Verdicts: Wrong Answer

Accepted
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):
N,Q=map(int,input().split())
S=input()
list1=[list(map(int,input().split())) for _ in range(Q)]
list2=[0]*(N+1)
count=0
for i in range(N):
    if i>0:
        list2[i+1]=list2[i]
    if i==N-1:
        continue
    elif S[i:i+2]=="AC":
        list2[i+1]+=1
print(list2)
for tmp in list1:
    print(list2[tmp[1]-1]-list2[tmp[0]-1])

N,Q=map(int,input().split())
S=input()
list1=[list(map(int,input().split())) for _ in range(Q)]
list2=[0]*(N+1)
count=0
for i in range(N):
    if i>0:
        list2[i+1]=list2[i]
    if i==N-1:
        continue
    elif S[i:i+2]=="AC":
        list2[i+1]+=1
for tmp in list1:
    print(list2[tmp[1]-1]-list2[tmp[0]-1])

Verdicts: Wrong Answer

Accepted
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

def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [False] + [s[i : i + 2] == "AC" for i in range(n - 1)]
    for (l, r) in qs:
        print(sum(hoges[l : r - 1]))


if __name__ == "__main__":
    main()


n, q = [int(i) for i in input().aplit()]
s = input()
for _ in range(q):
    l, r = [int(i) for i in input().aplit()]
    print(
        len([i for i in [a + b for a, b in zip(s[l-1: r], s[l: r+1])] if i == 'AC']))

# -*- coding: utf-8 -*-
#!/usr/bin/env python3

import sys


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    for (l, r) in qs:
        print(s[l - 1 : r - 1].count("AC"))


if __name__ == "__main__":
    main()

n, q = [int(i) for i in input().split()]
s = input()
qs = [[int(i) for i in input().split()] for _ in range(q)]
hoges = [False] + [s[i: i + 2] == 'AC' for i in range(n - 1)]
for (l, r) in qs:
    print(sum(hoges[l:r-1]))


n, q = [int(i) for i in input().split()]
s = input()
qs = [[int(i) for i in input().split()] for _ in range(q)]
hoges = [False] + [s[i:i+2] == 'AC' for i in range(n - 1)]
print(hoges)
for (l, r) in qs:
    print(sum(hoges[l:r]))

# -*- coding: utf-8 -*-
#!/usr/bin/env python3

import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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):
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

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


N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

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


Verdicts: Runtime Error

Accepted
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):
n, q = map(int,input().split())
s = input()
l = [[int(i) for i in input().split()] for i in range(q)]
c = [0 for i in range(n)]
cc = 0
f = False
for i in range(n):
    if f:
        if s[i] == "C":
            cc += 1
            f = False
        else:
            f = False
    if s[i] == "A":
        f = True
    c[i] = cc
print(c)
for i in range(q):
    print(c[l[i][1]-1]-c[l[i][0]-1])

n, q = map(int,input().split())
s = input()
l = [[int(i) for i in input().split()] for i in range(q)]
c = [0 for i in range(n)]
cc = 0
f = False
for i in range(n):
    if f:
        f = False
        if s[i] == "C":
            cc += 1
    if s[i] == "A":
        f = True
    c[i] = cc
for i in range(q):
    print(c[l[i][1]-1]-c[l[i][0]-1])

Verdicts: Wrong Answer

Accepted
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):
N, Q = map(int, input().split())
S=input()
A=[]
AC=[0]*100001
count=0
total=0
for i in range (Q):
    A.append(list(map(int, input().split())))

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

for i in range(Q):
    total+=AC[int(A[i][1])-1]-AC[int(A[i][0])-1]
    #print(AC[int(A[i][1])-2])
    #print(AC[int(A[i][0])-1])
    print(total)
    total=0

N, Q = map(int, input().split())
S=input()
A=[]
AC=[0]*100001
count=0
total=0
for i in range (Q):
    A.append(list(map(int, input().split())))

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

for i in range(Q):
    total+=AC[int(A[i][1])-1]-AC[int(A[i][0])-1]
    print(total)
    total=0

Verdicts: Wrong Answer

Accepted
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):
S = input()
question = []
for i in range(Q):
  question.append(list(map(int, input().split())))


index = []
for i in range(N-1):
  if S[i]+S[i+1] == "AC":
    index.append(i)

for i, q in enumerate(question):
  ans = 0
  for j in range(len(index)):
    if index[j] >= q[0]-1 and index[j]+1 <= q[1]-1:
      ans +=1
  print(ans)

import bisect

N, Q = map(int, input().split())
S = input()
question = []
for i in range(Q):
  question.append(list(map(int, input().split())))


index = []
for i in range(N-1):
  if S[i]+S[i+1] == "AC":
    index.append(i)


sum_index = [0]*N
sum_ac = 0
for i in range(N-1):
  if S[N-(i+2)]+S[N-(i+1)] == "AC":
    sum_ac += 1
  sum_index[N-(i+2)] = sum_ac

for i, q in enumerate(question):
  ans = sum_index[q[0]-1] - sum_index[q[1]-1]
  print(ans)
    



Verdicts: Runtime Error

Accepted
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):
#conding utf-8
N,Q=map(int,input().split())
S=input()
lr=[[int(i) for i in input().split()] for i in range(Q)]
print(lr)

AC=[0 for i in range(N)]

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

print(AC)

for i in range(Q):
  print(sum(AC[lr[i][0]-1:lr[i][1]-1]))

#conding utf-8
N,Q=map(int,input().split())
S=input()
lr=[[int(i) for i in input().split()] for i in range(Q)]

AC=[0]
tmp=0
for i in range(N-1):
  if S[i:i+2]=="AC":
    tmp=tmp+1
  AC.append(tmp)

for i in range(Q):
  print(AC[lr[i][1]-1]-AC[lr[i][0]-1])

Verdicts: Wrong Answer

Accepted
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):
N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))


count=[0 for i in range(N)]
ind=0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
      	ind+=1
        count[i+1]+=count[i+1]+ind

for i,j in lr:
    print(count[j-1]-count[i-1])


N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))


count=[0 for i in range(N)]
ind=0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
      	ind+=1
        count[i+1]+=ind

for i,j in lr:
    print(count[j-1]-count[i-1])


N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))


count=[0 for i in range(N)]
ind=0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        ind+=1
    count[i+1]+=count[i+1]+ind

for i,j in lr:
    print(count[j-1]-count[i-1])



Verdicts: Runtime Error

Runtime Error

Accepted
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):
n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for i in range(q)]

aclist = [0]
acsum = 0

for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        acsum += 1
    aclist.append(acsum)

for i in range(q):
    ans = aclist [lr[i][1]-1] - aclist [lr[i][0]-2]
    if aclist [lr[i][0]-1] - aclist [lr[i][0]-2] != 0:
        ans -= 1
    print(ans)

n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for i in range(q)]

aclist = [0]
acsum = 0

for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        acsum += 1
    aclist.append(acsum)

for i in range(q):
    ans = aclist [lr[i][0]-1] - aclist [lr[i][0]-2]
    if aclist [lr[i][0]-1] - aclist [lr[i][0]-2] != 0:
        ans -= 1
    print(ans)


n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for i in range(q)]

aclist = [0,0]
acsum = 0

for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        acsum += 1
    aclist.append(acsum)

for i in range(q):
    ans = aclist [lr[i][1]] - aclist [lr[i][0]-1]
    if aclist [lr[i][0]] - aclist [lr[i][0]-1] != 0:
        ans -= 1
    print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
n, q = map(int, input().split())
s = input()

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

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


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

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

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


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

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

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

for a in ans:
    print(a)


Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
N, Q = map(int, input().split())

S = str(input())

L = []
for i in range(Q):
    l,r = map(int, input().split())
    L.append((l-1,r-1))
    
    
check = []
for i in range(N-1):
    if S[i:i+2] == "AC":
        check.append(i)
        
for i in L:
    print(bisect_right(check, i[1]-1)-bisect_left(check, i[0]))

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

S = str(input())

L = []
for i in range(Q):
    l,r = map(int, input().split())
    L.append((l-1,r-1))
    
check = []
for i in range(N-1):
    if S[i:i+2] == "AC":
        check.append(i)
        
from bisect import bisect_left,bisect_right
for i in L:
    print(bisect_right(check, i[1]-1)-bisect_left(check, i[0]))

Verdicts: Runtime Error

Accepted
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 re
# pattern = r'[ACGT]+'
# ans = 0

# text = input()
# match_list = re.findall(pattern, text)
#
# # print(match_list)
# if match_list:
#     match_list_len = [len(x) for x in match_list]
#     ans = max(match_list_len)
#
# print(ans)

n, q = map(int, input().split())
text = input()
l = [0] * q
r = [0] * q
for i in range(q):
    l[i], r[i] = map(int, input().split())
# n = 8


# l = [3, 2, 1]
# r = [7, 3, 8]

pattern = r'AC'

m = re.finditer(pattern, text)
position_AC_lst = [x.start() for x in m]
print(position_AC_lst)

for x, y in zip(l, r):
    count = 0
    for i in range(len(position_AC_lst)):
        if x - 1 <= position_AC_lst[i] and position_AC_lst[i] + 1 <= y - 1:
            count += 1

    print(count)



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

t = [0] * (n + 1)

for i in range(1, n):
    t[i + 1] = t[i] + (1 if s[i - 1:i + 1] == 'AC' else 0)
for i in range(q):
    l, r = map(int, input().split())
    print(t[r] - t[l])



# 0 0 1 1 2 2 2 3 3
#  A C A C T A C G



# 8 3
# ACACTACG
# 3 7
# 2 3
# 1 8


# 2
# 0
# 3

Verdicts: Wrong Answer

Accepted
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):
from itertools import accumulate

n, q = map(int, input().split())
s = list(input())
#print(s)
z = []
for i in range(n-1):
    if s[i] + s[i+1] == 'AC':
        z.append(1)
    else:
        z.append(0)
print(z)

z = [0] + list(accumulate(z))
print(z)

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


from itertools import accumulate

n, q = map(int, input().split())
s = list(input())
#print(s)
z = []
for i in range(n-1):
    if s[i] + s[i+1] == 'AC':
        z.append(1)
    else:
        z.append(0)
#print(z)

z = [0] + list(accumulate(z))
#print(z)

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


Verdicts: Wrong Answer

Accepted
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):
n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]==A and s[i]==C:
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])



n,q=map(int,input().split())
s=list(input())

count=0


ans=[0 for i in range(n+2)]
for i in range(n-1):
  if s[i]+s[i+1]=='AC':
    count+=1
    ans[i+1]=count
  else:
    ans[i+1]=count
ans[n]=ans[n-1]
ans[n+1]=ans[n]

print(*ans)

for i in range(q):
  sita,ue=map(int,input().split())
  if s[ue-1]=='A' and s[ue]=='C':
    print(ans[ue]-ans[sita-1]-1)
  
  else:
    print(ans[ue]-ans[sita-1])
    
  

  



n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])


Verdicts: Runtime Error

Runtime Error

Accepted
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
    import sys
    
    import heapq
    import re
    import bisect
    import random
    import math
    import itertools
    from collections import defaultdict, deque
    from copy import deepcopy
    from decimal import *
     
    n, q = map(int, input().split())
    s = list(input())
     
    ss = ""
    a = [0] * n
    b = [0] * n
    for i in range(n):
        if s[i] == "A":
            ss = s[i]
        elif s[i] == "C":
            ss += s[i]
        if ss == "AC":
            a[i] = a[i - 1] - 1
            b[i] += b[i - 1] + 1
            ss = ""
        else:
            if i > 0:
                a[i] = a[i - 1]
                b[i] = b[i - 1]
     
    for i in range(q):
        x, y = map(int, input().split())
        print(max(0, b[y - 1] + a[x - 1]))

# coding: UTF-8
import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, q = map(int, input().split())
s = list(input())

ss = ""
b = [0] * n
for i in range(n):
    if s[i] == "A":
        ss = s[i]
    elif s[i] == "C":
        ss += s[i]
    else:
        ss = ""
    if ss == "AC":
        b[i] += b[i - 1] + 1
        ss = ""
    else:
        if i > 0:
            b[i] = b[i - 1]
for i in range(q):
    x, y = map(int, input().split())
    print(b[y - 1] - b[x - 1])



Verdicts: Runtime Error

Accepted
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 solve():
    N, Q = list(map(int, input().split()))
    S = input()

    dp = [0]*(N)
    dp[0] = 0
    for i in range(0, N-1):
        if S[i]=="A" and S[i+1]=="C":
            dp[i+1] = dp[i] + 1
        else:
            dp[i+1] = dp[i]
    
    for i in range(Q):
        l, r = list(map(int, input()))
        print(dp[r-1] - dp[l-1])
    
    

if __name__ == "__main__":
    solve()


# -*- coding:utf-8 -*-

def solve():
    N, Q = list(map(int, input().split()))
    S = input()

    dp = [0]*(N)
    dp[0] = 0
    for i in range(0, N-1):
        if S[i]=="A" and S[i+1]=="C":
            dp[i+1] = dp[i] + 1
        else:
            dp[i+1] = dp[i]
    
    for i in range(Q):
        l, r = list(map(int, input()))
        print(dp[r-1] - dp[l-1])
    
    

if __name__ == "__main__":
    solve()


# -*- coding:utf-8 -*-

def solve():
    N, Q = list(map(int, input().split()))
    S = input()

    dp = [0]*(N)
    dp[0] = 0
    for i in range(0, N-1):
        if S[i]=="A" and S[i+1]=="C":
            dp[i+1] = dp[i] + 1
        else:
            dp[i+1] = dp[i]
    
    for i in range(Q):
        l, r = list(map(int, input().split()))
        print(dp[r-1] - dp[l-1])
    


if __name__ == "__main__":
    solve()


Verdicts: Runtime Error

Runtime Error

Accepted
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):
n, q = map(int, input().strip().split(' '))
s = input()
ac = []
kazu = 0
for i in range(n-1):
    if s[i:i+2] == 'AC':
        kazu = kazu + 1
        ac.append(kazu)
    else:
        ac.append(kazu)
ac.append(0)
print(ac)
for i in range(q):
    num = 0
    l, r = map(int, input().strip().split(' '))
    print(ac[r-2]-ac[l-2])

n, q = map(int, input().strip().split(' '))
s = input()
ac = []
kazu = 0
for i in range(n-1):
    if s[i:i+2] == 'AC':
        kazu = kazu + 1
        ac.append(kazu)
    else:
        ac.append(kazu)
ac.append(0)
for i in range(q):
    num = 0
    l, r = map(int, input().strip().split(' '))
    print(ac[r-2]-ac[l-2])

Verdicts: Wrong Answer

Accepted
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 numpy as np

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

S = input()
cumurative_sum_lst = np.zeros(N)
for i in range(N-2):
    if S[i] == "A" and S[i+1] == "C":
        cumurative_sum_lst[i+2:] += 1



outputs = []
for i in range(Q):
    l, r = map(int, input().split())
    l, r = l - 1, r - 1
#    print(l, r)
#    print()
    tmp = cumurative_sum_lst[r] - cumurative_sum_lst[l]
    outputs.append(int(tmp))

for i in outputs:
    print(i)



import numpy as np

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

S = input()
cumurative_sum_lst = np.zeros(N+1)
for i in range(N-2):
    if S[i] == "A" and S[i+1] == "C":
        cumurative_sum_lst[i+2:] += 1



outputs = []
for i in range(Q):
    l, r = map(int, input().split())
    l, r = l - 1, r
#    print(l, r)
#    print()
    tmp = cumurative_sum_lst[r] - cumurative_sum_lst[l]
    outputs.append(int(tmp))

for i in outputs:
    print(i)




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

S = input()
cumurative_sum_lst = [0]*(N+1)
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i] + 1
    else:
        cumurative_sum_lst[i+1] = cumurative_sum_lst[i]

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

    tmp = cumurative_sum_lst[r] - cumurative_sum_lst[l]
    outputs.append(int(tmp))

for i in outputs:
    print(i)



Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
N, Q = map(int, input().split())
S = input()
ac = [0, 0]
for i in range(len(S) - 1):
  if S[i] == "A" and S[i + 1] == "C":
    ac.append(ac[-1] + 1)
  else:
    ac.append(ac[-1])
for _ in range(Q):
  l, r = map(int, input().split())
  print(ac[r] - ac[l - 1])

N, Q = map(int, input().split())
S = input()
ac = [0, 0]
for i in range(len(S) - 1):
  if S[i] == "A" and S[i + 1] == "C":
    ac.append(ac[-1] + 1)
  else:
    ac.append(ac[-1])
for _ in range(Q):
  l, r = map(int, input().split())
  print(ac[r] - ac[l - 1])

N, Q = map(int, input().split())
S = input()
ac = [0, 0]
for i in range(len(S) - 1):
  if S[i] == "A" and S[i + 1] == "C":
    ac.append(ac[-1] + 1)
  else:
    ac.append(ac[-1])
for _ in range(Q):
  l, r = map(int, input().split())
  print(ac[r] - ac[l])

Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
t = [0]
count = 0
for i in range(1, n):
    if s[i-1] + s[i] == 'AC':
        count += 1
    t.append(count)
ans = []
for le, ri in lr:
    ans.append(t[ri-1] - t[le-1])
print(ans)


n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
t = [0]
count = 0
for i in range(1, n):
    if s[i-1] + s[i] == 'AC':
        count += 1
    t.append(count)
for le, ri in lr:
    print(t[ri-1] - t[le-1])

Verdicts: Wrong Answer

Accepted
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):
def counts(s, l, r):
    ans = s[l-1:r].count('AC')
    print(ans)

n, q = map(int, input().split())
s = input()
for i in xrange(q):
    l, r = map(int, input().split())
    counts(s, l, r)

import sys
input = sys.stdin.readline

n, q = map(int, input().split())
s = input()
memo = [0] * n
cnt = 0

for i in range(1, n):
    if s[i - 1] == 'A' and s[i] == 'C':
        cnt += 1
    memo[i] = cnt

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


Verdicts: Runtime Error

Accepted
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):
N, Q = map(int, input().split())
S = list(input())
L = [0]
cnt = 0

for i in range(1, N):
  if S[i-1] == "A" and S[i] == "C":
    cnt += 1
  L.append(cnt)

print(L)

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

N, Q = map(int, input().split())
S = list(input())
L = [0]
cnt = 0

for i in range(1, N):
  if S[i-1] == "A" and S[i] == "C":
    cnt += 1
  L.append(cnt)

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

Verdicts: Wrong Answer

Accepted
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 bisect
N, Q = map(int, input().split())
S = list(input())
lr = [list(map(int, input().split())) for i in range(Q)]

lst=[]
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        lst.append(i)

ans=[]
for j in range(Q):
    l,r = lr[j][0]-1, lr[j][1]-1
    ans.append(bisect.bisect_right(lst,r) - bisect.bisect_left(lst,l))

for a in ans:
    print(a)


N, Q = map(int, input().split())
S = list(input())
lr = [list(map(int, input().split())) for i in range(Q)]

lst=[]
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        lst.append(i)

ans=[]
for i in range(Q):
    count=0
    for p in lst:
        if lr[i][0] <= p and p+1 <= lr[i][1]:
            count += 1
    ans.append(count)

for a in ans:
    print(a)


import bisect
N, Q = map(int, input().split())
S = list(input())
lr = [list(map(int, input().split())) for i in range(Q)]

alst,clst=[],[]
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        alst.append(i)
        clst.append(i+1)


for j in range(Q):
    l,r = lr[j][0]-1, lr[j][1]-1
    ans = bisect.bisect_right(clst,r) - bisect.bisect_left(alst,l)
    print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
N,Q=map(int,input().split())
S=input()
c=[0]
t = 0
for i in range(1,N):
    t += 1 if  S[i-1:i+1]=='AC' else 0
    c.append(t)
print(c)
for _ in range(Q):
    l,r=map(int, input().split())
    print(c[r-1]-c[l-1])


N,Q=[int(i) for i in input().split()]
S=input()

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

for _ in range(Q):
    l,r=[int(x)-1 for x in input().split()]
    print(c[r]-c[l+1])


N,Q=map(int,input().split())
S=input()
c=[0]
t = 0
for i in range(1,N):
    t += 1 if  S[i-1:i+1]=='AC' else 0
    c.append(t)
for _ in range(Q):
    l,r=map(int, intput().split))
    print(c[r]-c[l])


N,Q=map(int,input().split())
S=input()
c=[0]
t = 0
for i in range(1,N):
    t += 1 if  S[i-1:i+1]=='AC' else 0
    c.append(t)
for _ in range(Q):
    l,r=map(int, input().split())
    print(c[r-1]-c[l-1])


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
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):
N, Q = map(int, input().split())
S=input()
li = [list(map(int, input().split())) for _ in range(Q)]

A=[0]*(N)

for i in range(N-1):
    if S[i:i+2]=='AC':
        A[i+1]=A[i]+1
    else:
        A[i+1]=A[i]

print(A)

for k in li:
    l=k[0]-1
    r=k[1]-1
    print(A[r]-A[l])

N, Q = map(int, input().split())
S=input()
li = [list(map(int, input().split())) for _ in range(Q)]

A=[0]*(N)

for i in range(N-1):
    if S[i:i+2]=='AC':
        A[i+1]=A[i]+1
    else:
        A[i+1]=A[i]

for k in li:
    l=k[0]-1
    r=k[1]-1
    print(A[r]-A[l])

Verdicts: Wrong Answer

Accepted
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):

NQ = input().split()
N,Q = int(NQ[0]), int(NQ[1])
S = input()
P = [input().split() for i in range(Q)]


ruiseki = [0]*N
for i in range(1,N):
    if(S[i] == "C" and S[i-1] == "A"):
        print(i)
        ruiseki[i] = ruiseki[i-1] + 1
    else:
        ruiseki[i] = ruiseki[i-1]

for j in range(Q):
    print(ruiseki[int(P[j][1]) - 1] - ruiseki[int(P[j][0]) - 1])


NQ = input().split()
N,Q = int(NQ[0]), int(NQ[1])
S = input()
P = [input().split() for i in range(Q)]
 

ruiseki = [0]*N
for i in range(1,N):
    if(S[i] == "C" and S[i-1] == "A"):
        ruiseki[i] = ruiseki[i-1] + 1
    else:
        ruiseki[i] = ruiseki[i-1]
 
for j in range(Q):
    print(ruiseki[int(P[j][1]) - 1] - ruiseki[int(P[j][0]) - 1])

Verdicts: Wrong Answer

Accepted
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):
N, Q = map(int, input().split())
S = str(input())
count = [0]*(N+1)
lists = []
for i in range(1, N):
    if S[i-1] == "A" and S[i] == "C":
        count[i + 1] = count[i] + 1
    else:
        count[i + 1] = count[i]
for i in range(Q):
    l, r = map(int, input().split())
    ans = count[r-1] - count[l-1]
    lists.append(ans)
for i in range(len(lists)):
    print(lists[i])


N, Q = map(int, input().split())
S = str(input())
count = [0]*(N+1)
lists = []
for i in range(1, N):
    if S[i-1] == "A" and S[i] == "C":
        count[i] = count[i-1] + 1
    else:
        count[i] = count[i-1]
for i in range(Q):
    l, r = map(int, input().split())
    ans = count[r-1] - count[l-1]
    lists.append(ans)
for i in range(len(lists)):
    print(lists[i])


Verdicts: Wrong Answer

Accepted