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):
import numpy as np
from collections import Counter
import collections
import numpy as np 
from scipy import sqrt, power, exp, log10
from scipy.fftpack import fft, ifft, fftfreq
import tarfile
import re
import os
import glob
from datetime import datetime
import time
import numpy.linalg as LA

round = lambda x:(x*2+1)//2
a,b = list(map(int,input().split()))
S = input()
sub= "AC"
l = np.array([])
for i in range(len(S)):
  S1 = S[:i+1]
  l = np.append(l,S1.count(sub))
print(l)
for i in range(b):
    r,t = list(map(int,input().split()))
    n = l[t-1]-l[r-1]
    print(int(n))

import numpy as np
from collections import Counter
import collections
import numpy as np 
from scipy import sqrt, power, exp, log10
from scipy.fftpack import fft, ifft, fftfreq
import tarfile
import re
import os
import glob
from datetime import datetime
import time
import numpy.linalg as LA

round = lambda x:(x*2+1)//2
a,b = list(map(int,input().split()))
S = input()
sub= "AC"
for i in range(b):
    r,l = list(map(int,input().split()))
	S1 = S[r-1:l]
    n = S1.count(sub)
    print(n)

import numpy as np
from collections import Counter
import collections
import numpy as np 
from scipy import sqrt, power, exp, log10
from scipy.fftpack import fft, ifft, fftfreq
import tarfile
import re
import os
import glob
from datetime import datetime
import time
import numpy.linalg as LA
 
round = lambda x:(x*2+1)//2
a,b = list(map(int,input().split()))
S = input()
sub= "AC"
for i in range(b):
    r,l = list(map(int,input().split()))
    n = S1.count(sub,r-1,l-1)
    print(n)

import numpy as np
from collections import Counter
import collections
import numpy as np 
from scipy import sqrt, power, exp, log10
from scipy.fftpack import fft, ifft, fftfreq
import tarfile
import re
import os
import glob
from datetime import datetime
import time
import numpy.linalg as LA

round = lambda x:(x*2+1)//2
a,b = list(map(int,input().split()))
S = input()
sub= "AC"
for i in range(b):
    r,l = list(map(int,input().split()))
    print(S1)
    n = S1.count(sub)
    print(n)

import numpy as np

a,b = list(map(int,input().split()))
S = input()
sub= "AC"
l = np.zeros(len(S)+1)
for i in range(len(S)):
  l[i+1] = l[i] + (1 if S[i:i+2]=="AC" else 0)

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


Verdicts: Wrong Answer

Runtime Error

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

N, Q = map(int, input().split())
S = str(input())
 
#ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]
a = 0
lst = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    a += 1
  lst.append(a)
for _ in range(Q):
  l, r = map(int, input().split())
  print(lst[r-1] - lst[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 itertools
n,q = map(int, input().split())
s = input()
calc = [0]*n
prev = None
for i,c in enumerate(s):
    if prev == 'A' and c == 'C':
        calc[i] = 1
    prev = c
calc = list(itertools.accumulate(calc))
print(calc)
for _ in range(q):
    l,r = map(int,input().split())
    print(calc[r-1]-calc[l-1])

import itertools
n,q = map(int, input().split())
s = input()
calc = [0]*n
prev = None
for i,c in enumerate(s):
    if prev == 'A' and c == 'C':
        calc[i] = 1
    prev = c
calc = list(itertools.accumulate(calc))
for _ in range(q):
    l,r = map(int,input().split())
    print(calc[r-1]-calc[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())
mark = [0]*(n+1)
for i in range(2,n+1):
  if s[i-2]=='A' and s[i-1]=='C':
    mark[i] = mark[i-1]+1
  else:
    mark[i] = mark[i-1]
print(mark)
for i in range(q):
  l,r = map(int,input().split())
  l = l-1
  r = r-1
  print(mark[r+1]-mark[l+1])

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

count = [0]*n
for i in range(1,n):
  if s[i]=='C' and s[i-1]=='A': 
    count[i] = count[i-1] + 1
  else: 
    count[i] = count[i-1]

for i in range(q):
  l,r = map(int,input().split())
  l -= 1
  r -= 1
  print(count[r]-count[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):
N,Q=map(int,input().split())
S=input()
a=[0]*N
for i in range(N-1):
  a[i+1]=a[i]+(1 if S[i:i+2]=="AC" else 0)
for i in range(Q):
  l,r=map(int,input().split())
  print(a[l-1]-a[r-1])


N,Q=map(int,input().split())
S=input()
a=[0]*N
for i in range(N-1):
  a[i+1]=a[i]+(1 if S[i:i+2]=="AC" else 0)
for i in range(Q):
  l,r=map(int,input().split())
  print(a[r-1]-a[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 = input()
l,r = [],[]
index = []
for i in range(Q):
    tmp1,tmp2 = map(int,input().split())
    l.append(tmp1)
    r.append(tmp2)
counter = 0
index.append(counter)
for i in range(1,len(S)):
    if(S[i-1] == 'A' and S[i] == 'C'):
        counter += 1
    index.append(counter)
print(index)
def f(l,r):
    return index[r-1] - index[l-1]
for i in range(Q):
    print(f(l[i],r[i]))

N,Q = map(int,input().split())
S = input()
l,r = [],[]
index = []
for i in range(Q):
    tmp1,tmp2 = map(int,input().split())
    l.append(tmp1)
    r.append(tmp2)
counter = 0
index.append(counter)
for i in range(1,len(S)):
    if(S[i-1] == 'A' and S[i] == 'C'):
        counter += 1
    index.append(counter)
def f(l,r):
    return index[r-1] - index[l-1]
for i in range(Q):
    print(f(l[i],r[i]))

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())
li=[0]*n

for i in range(n):
  if i==0:
    continue
  if s[i-1]=="A" and s[i]=="T":
    li[i]=1

for i in range(q):
  l,r=map(int,input())
  tmp=li[l:r]
  print(sum(temp))


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

for i in range(n):
  if i==0:
    continue
  if s[i-1]=="A" and s[i]=="C":
    cnt+=1  
  li[i]=cnt
    
for i in range(q):
  l,r=map(int,input().split())
  ans=li[r]-li[l]
  print(ans)


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

for i in range(n):
  if i==0:
    continue
  if s[i-1]=="A" and s[i]=="C":
    cnt+=1  
  li[i]=cnt
    
for i in range(q):
  l,r=map(int,input().split())
  ans=li[r-1]-li[l-1]
  print(ans)

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):
import sys
#from collections import defaultdict, deque, Counter

#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    #n = int(stdin.readline().rstrip())
    #l = list(map(int, stdin.readline().rstrip().split()))
    n,q = map(int, stdin.readline().rstrip().split())
    s = str(stdin.readline().rstrip())
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    
    cum = [0]*(n)
    cum[0] = 0
    for i in range(1,n):
        if s[i-1:i+1] == "AC":
            cum[i] = cum[i-1] + 1
        else:
            cum[i] = cum[i-1]
    print(cum)
    for i in range(q):
        l,r = map(int, stdin.readline().rstrip().split())
        print(cum[r-1] - cum[l-1])

main()


import sys
#from collections import defaultdict, deque, Counter

#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    #n = int(stdin.readline().rstrip())
    #l = list(map(int, stdin.readline().rstrip().split()))
    n,q = map(int, stdin.readline().rstrip().split())
    s = str(stdin.readline().rstrip())
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    
    cum = [0]*(n)
    cum[0] = 0
    for i in range(1,n):
        if s[i-1:i+1] == "AC":
            cum[i] = cum[i-1] + 1
        else:
            cum[i] = cum[i-1]
    for i in range(q):
        l,r = map(int, stdin.readline().rstrip().split())
        print(cum[r-1] - cum[l-1])

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()
flag = False
count = 0
li = [0]

for i in s:
    if i == "A":
        flag = True
    if i == "C" and flag is True:
        count += 1
        flag = False
    li.append(count)
    print(li)

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


n, q = map(int, input().split())
s = input()
flag = False
count = 0
li = []

for i in range(n):
    if s[i] == "A":
        flag = True
    if s[i] == "C" and flag is True:
        count += 1
        flag = False
    li.append(count)
    print(li)

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


n, q = map(int, input().split())
s = input()
flag = False
count = 0
li = []

for i in range(n):
    if s[i] == "A":
        flag = True
    elif s[i] == "C" and flag is True:
        count += 1
        flag = False
    else:
        flag = False
    li.append(count)

for i in range(q):
    l, r = map(int, input().split())
    print(li[r-1] - li[l-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):
import numpy as np

N, Q = map(int, input().split())
S = input()
t = np.zeros(N+1)
for i in range(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(int(t[r]-t[l-1]))

import numpy as np

N, Q = map(int, input().split())
S = input()
t = np.zeros(N+1)
for i in range(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(int(t[r]-t[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):
import sys  
from itertools import accumulate
input = sys.stdin.readline  

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

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

s = list(S)
ac = [0] * N

for i in range(N-1):
    if s[i] == 'A':
        if s[i+1] == 'C':
            s[i] = "AC"
            ac[i] += 1


#ans = [0] + ans



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

import sys  
from itertools import accumulate
input = sys.stdin.readline  

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

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

s = list(S)
ac = [0] * N

for i in range(N-1):
    if s[i] == 'A':
        if s[i+1] == 'C':
            s[i] = "AC"
            ac[i] += 1

ans = list(accumulate(ac))
ans = [0] + ans


for i in range(Q):
    print(ans[r[i]-1]- ans[l[i]-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
input = sys.stdin.readline

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

    dec_a = [0] * (N)
    for x in range(1, N):
        if S[x] == 'C' and S[x-1] == 'A':
            S[x-1] = 'a'
        dec_a[x] = S[:x+1].count('a')


    L = [0] * Q
    R = [0] * Q
    for i in range(Q):
        L[i], R[i] = map(int, input().split())

    print(dec_a)
    for j in range(Q):
        print(dec_a[R[j]-1] - dec_a[L[j]-1])

main()

import sys
input = sys.stdin.readline
 
def main():
    N, Q = map(int, input().split())
    S = input().rstrip()
 
    cnt_ac = 0
    arr_ac = [0] * (N)
    for x in range(0, N-1):
        if S[x:x+2] == 'AC':
            cnt_ac += 1
        arr_ac[x+1] = cnt_ac
 
    for i in range(Q):
        L, R = map(int, input().split())
        print(arr_ac[R-1] - arr_ac[L-1])
 
 
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):
#C
def f(x):
    return int(x) - 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)
print(t)
for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])

#C
def f(x):
    return int(x) - 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)
# print(t)
for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[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   = input()
Query = []
for _ in range(Q):
    l,r = map(int, input().split())
    Query.append([l, r])

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

for l,r in Query:
    print(s[r-1]-s[l-1])

N,Q = map(int, input().split())
S   = input()
Query = []
for _ in range(Q):
    l,r = map(int, input().split())
    Query.append([l, r])

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

for l,r in Query:
    print(s[r-1]-s[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())
S.append(0)
par = [0]*(N+1)
Ans = []
for i in range(N):
        par [i+1]=par[i]+(1 if (S[i]=='A') & (S[i+1]=='C') else 0)
        print(par)
for i in range(Q):
        x,y = map(int,input().split())
        print(par[y]-par[x-1])
        


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

n,q = map(int,input().split())
s = input()
s += ' '
ruiseki = []
i = 0
while i<n:
    if s[i]+s[i+1]=='AC':
        ruiseki.append('')
        ruiseki.append('AC')
        i= i+1
    else:
        ruiseki.append(s[i])
    i+=1
t = [0] * (n+1)
for i in range(n):
    if ruiseki[i] == 'AC':
        t[i+1] = t[i]+1
    else:
        t[i+1] = t[i]
for i in range(q):
    l,r = map(int,input().split())
    print(t[r]-t[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):
import re
n = int(input().split()[1])
s = input()
for i in range(n):
  l, r = map(int, input().split())
  ls = [len(i) for i in re.findall('AC', s[l-1: r])] + [0]
  print(max(ls))


import re
n = int(input().split()[1])
s = input()

counts = [0]
for i in range(len(s)):
  counts.append(counts[i] + (1 if s[i : i + 2] == 'AC' else 0))

for i in range(n):
  l, r = map(int, input().split())
  print(counts[r - 1] - counts[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 re

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

S = re.sub('[^AC]+', 'X', S)
print(S)

for i in range(Q):
  l, r = T[i][0], T[i][1]
  s = S[l-1:r]
  count = 0
  if r-l == 0:
    count = 0
  else:
    for j in range(r-l):
      if s[j] == 'A' and s[j+1] == 'C':
        count += 1
  print(count)

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

total_list = []
total = 0
for i in range(N-1):
  if S[i] == 'A' and S[i+1] == 'C':
    total += 1
  total_list.append(total)

for i in range(Q):
  l, r = T[i][0], T[i][1]
  if l != 1:
    print(total_list[r-2]-total_list[l-2])
  else:
    print(total_list[r-2])

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 numpy as np
import re
from sys import stdin

N, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()

def func(Str):
  idx = Str.find("AC")
  return idx

i = 0
ac_idx = []
while i<N:
  a = func(S[i:])
  if a != -1:
    ac_idx.append(a+i)
    i = a+i+2
  else:
    break

ac_idx = np.array(ac_idx)
print("ac:",ac_idx)
for j in range(Q):
  l,r = [int(x) for x in stdin.readline().rstrip().split()]
  L = ac_idx >= l-1
  R = ac_idx < r-1
  print(np.sum(np.logical_and(L, R)))
  

from sys import stdin

N, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()

ac_idx = [0]
count = 0

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

for j in range(Q):
  l,r = [int(x) for x in stdin.readline().rstrip().split()]
  print(ac_idx[r-1]-ac_idx[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())
raw_list = list(input())
def count_ac(l,r):
    cnt = 0
    sliced_list = raw_list[l-1:r+1]
    for idx,char in enumerate(sliced_list):
        if idx == len(sliced_list)-1:
            break
        if sliced_list[idx] == "A":
            if sliced_list[idx+1] =="C":
                cnt += 1

    print(cnt)

for i in range(q):
    li, ri = map(int,input().split())
    count_ac(li, ri)


def count_ac(rawlist,l,r):
    cnt = 0
    sliced_list = rawlist[l-1:r+1]
    for idx,char in enumerate(sliced_list):
        if idx == len(sliced_list)-1:
            break
        if sliced_list[idx] == "A":
            if sliced_list[idx+1] =="C":
                cnt += 1

    print(cnt)

n,q = map(int,input().split())
s = list(input())
for i in range(q):
    li,ri = map(int,input().split())
    count_ac(s,li,ri)

# testlist = ["A","C","D","A","C"]
# l=1
# r=5
# print(testlist[0:6])
# count_ac(testlist,l,r)

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

ac_count = [0]*N
temp = 0
for i in range(1,N):
    if S[i] == 'C' and S[i-1] == 'A':
        temp += 1
        ac_count[i] = temp
    else:
        ac_count[i] = temp
#print(ac_count)
for _ in range(Q):
    l,r = map(int,input().split())
    if S[l-1] != 'C':
        print(ac_count[r-1]-ac_count[l-1])
    else:
        print(ac_count[r-1]-ac_count[l-1])

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

n, q = map(int, input().split())
s = str(input())
ls = [list(map(int, input().split())) for i in range(q)]
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 = ls[i][0], ls[i][1]
    ans = t[r - 1] - t[l - 1]
    print(ans)

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(i) for i in input().split()]
s = input()
l = [0] * q
r = [0] * q
ans = ""
table = [1 if s[i:i+2] == "AC" else 0 for i in range(n)]   
for i in range(q):
  l[i], r[i] = [int(j) for j in input().split()]
  ans = ans+str(sum(table[l[i]-1:r[i]-1]))+"\n"
print(ans)

n, q = [int(i) for i in input().split()]
s = input()
l = [0] * q
r = [0] * q
ans = ""
for i in range(q):
  l[i], r[i] = [int(j) for j in input().split()]
  ans = ans+str(s[l[i]-1:r[i]].count("AC"))+"\n"
print(ans)
  
  

n, q = [int(i) for i in input().split()]
s = input()
l = [0] * q
r = [0] * q
ans = ""
for i in range(q):
  l[i], r[i] = [int(j) for j in input().split()]
  t = s[l[i]-1:r[i]]
  cnt = 0
  for k in range(len(t)-1):
    if t[k:k+2] == "AC":
      cnt += 1
      k += 1
  ans = ans+str(cnt)+"\n"
print(ans)

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

Verdicts: Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

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 = []
for i in range(Q):
    L.append([int(a) for a in input().split()])

Temp = [0 for i in range(N)]
num = 0
ac = 0
while num <= N-2:
    if S[num] == "A" and S[num+1] == "C":
        Temp[num] = ac
        Temp[num+1] = ac
        num += 2
        ac += 1
    else:
        Temp[num] = ac
        num += 1
if Temp[-1] == 0:
    Temp[-1] = Temp[-2]
for j in range(Q):
    ini = L[j][0]-1
    fin = L[j][1]-1
    print(Temp[fin]-Temp[ini])

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

Temp = [0 for i in range(N)]
num = 0
while num <= N-2:
    if S[num] == "A" and S[num+1] == "C":
        Temp[num] = 1
        Temp[num+1] = 2
    num += 1

for j in range(Q):
    Temp2 = Temp[L[j][0]-1:L[j][1]]
    c = sum(Temp2)
    if c%3 == 0:
        if Temp2[0] != 2
            print(int(c/3))
        else:
            print(int(c/3-1))
    elif c%3 == 1:
        print(int((c-1)/3))
    else:
        print(int((c-2)/3))

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

Temp = [0 for i in range(N)]
num = 0
ac = 0
while num <= N-2:
    if S[num] == "A" and S[num+1] == "C":
        Temp[num] = ac
        Temp[num+1] = ac+1
        num += 2
        ac += 1
    else:
        Temp[num] = ac
        Temp[num+1] = ac
        num += 1
if Temp[-1] == 0:
    if S[-2] != "A" or S[-1] != "C":
        Temp[-1] = ac
Temp.append(ac)
print(Temp)
for j in range(Q):
    ini = L[j][0]-1
    fin = L[j][1]-1
    
    print(Temp[fin]-Temp[ini])

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

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

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

Verdicts: Wrong Answer

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()
tmp = [0] * N
for i in range(1, N):
    if S[i-1] + S[i] == 'AC':
        tmp[i] += 1

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


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

tmp = [0] * N
cnt = 0
for i in range(1, N):
    if S[i-1] + S[i] == 'AC':
        cnt += 1
    tmp[i] = cnt

for l, r in l_r_list:
    print(tmp[r-1] - tmp[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 = 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: 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()

l = [0] * q
r = [0] * q

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

s_list = list(s)

ac_list = [0] * (n-1)

for i in range(0,n-1):
    if s_list[i] == "A" and s_list[i+1] == "C":
        ac_list[i] = 1

for i in range(0,q):

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

l = [0] * q
r = [0] * q

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

s_list = list(s)

ac_list = [0] * (n-1)

for i in range(0,n-1):
    if s_list[i] == "A" and s_list[i+1] == "C":
        ac_list[i] = 1

#print(ac_list)

w = [0] * (n-1)

w[0] = ac_list[0]

for i in range(1,n-1):
    w[i] = w[i-1] + ac_list[i]

#print(w)

for i in range(0,q):
    if l[i] == 0:
        print(w[r[i]-1])
    else:
        print(w[r[i]-1]-w[l[i]-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()

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

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

    print(out)

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

c=0
s=[0]
for i in range(1,N):
    if S[i-1]=='A' and S[i]=='C':
        c+=1
    s.append(c)
    
for i in range(Q):
    l,r=map(int,input().split())
    out=s[r-1]-s[l-1]

    print(out)


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()
m = list(map(int,input().split for i in range(q)))
count = [0]*(N+1)

for i in range(n):
    if S[i:i+2] == 'AC':
        comu[i+1] = comu[i] + 1
    else:
        comu[i+1] = comu[i]

for l,r in list:
    print(count[r-1]-count[l-1])
~


n,q = map(int,input().split())
s = input()
m = [list(map(int,input().split())) for i in range(q)]
count = [0]*(N+1)
 
for i in range(n):
    if S[i:i+2] == 'AC':
        comu[i+1] = comu[i] + 1
    else:
        comu[i+1] = comu[i]
 
for l,r in list:
    print(count[r-1]-count[l-1])

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

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

n,q = map(int(input().split()))
s = input()
m = list(map(int,input().split for i in range(q)))
count = [0]*(N+1)

for i in range(n):
    if S[i:i+2] == 'AC':
        comu[i+1] = comu[i] + 1
    else:
        comu[i+1] = comu[i]

for l,r in list:
    print(count[r-1]-count[l-1])
~


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

n,q = map(int,input().split())
s = input()
m = [list(map(int,input().split())) for i in range(q)]
count = [0]*(N+1)
 
for i in range(n):
    if S[i:i+2] == 'AC':
        comu[i+1] = comu[i] + 1
    else:
        comu[i+1] = comu[i]
 
for l,r in m:
    print(count[r-1]-count[l-1])

n,q = map(int,input().split())
s = input()
m = list(map(int,input().split for i in range(q)))
count = [0]*(N+1)

for i in range(n):
    if S[i:i+2] == 'AC':
        comu[i+1] = comu[i] + 1
    else:
        comu[i+1] = comu[i]

for l,r in list:
    print(count[r-1]-count[l-1])
~


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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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 math
import sys
import itertools
import numpy as np


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


s = list(input())


x = [[int(i) for i in input().split()] for i in range(q)] 
c = [0]



count = 0
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        count += 1
    c.append(count)
    
print(c)

for i in range(q):
    if x[i][0] == 1:
        print(c[x[i][1]-1])
    else:
        print(c[x[i][1]-1]-c[x[i][0]-1])





# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


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


s = list(input())


x = [[int(i) for i in input().split()] for i in range(q)] 
c = [0]



count = 0
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        count += 1
    c.append(count)
    
#print(c)

for i in range(q):
    if x[i][0] == 1:
        print(c[x[i][1]-1])
    else:
        print(c[x[i][1]-1]-c[x[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,m=map(int,input().split())
l=list(input())
count=0
clist=[0]
for i in range(1,n):
  if l[i-1]=="A" and l[i]=="C":
    count+=1
  clist.append(count)
for i in range(m):
  i1,i2=map(int,input().split())
  if l[i1-1]=="C" and l[i1-2]=="A":
    ans=clist[i2-1]-clist[i1-1]-1
  else:
    ans=clist[i2-1]-clist[i1-1]
  print(ans)

n,m=map(int,input().split())
l=list(input())
l1=[0]
i=0
for i in range(n-1):
  if l[i]=="A" and l[i+1]=="C":
    i+=1
    l1.append(i)
  else:
    l1.append(i)
for t in range(m):
  i,j=map(int,input().split())
  print(l1[j-1]-l1[i-1])


n,m=map(int,input().split())
l=list(input())
count=0
clist=[0]
for i in range(1,n):
  if l[i-1]=="A" and l[i]=="C":
    count+=1
  clist.append(count)
for i in range(m):
  i1,i2=map(int,input().split())
  if i1==1:
    ans=clist[i2-1]
  elif l[i1-1]=="C" and l[i1-2]=="A":
    ans=clist[i2-1]-clist[i1-1]-1
  else:
    ans=clist[i2-1]-clist[i1-1]
  print(ans)

n,m=map(int,input().split())
l=list(input())
l1=[0]
p=0
for i in range(n-1):
  if l[i]=="A" and l[i+1]=="C":
    p+=1
    l1.append(p)
  else:
    l1.append(p)
for t in range(m):
  i,j=map(int,input().split())
  print(l1[i-1]-l1[j-1])

n,m=map(int,input().split())
l=list(input())
count=0
clist=[0]
for i in range(1,n):
  if l[i-1]=="A" and l[i]=="C":
    count+=1
  clist.append(count)
for i in range(m):
  i1,i2=map(int,input().split())
  if i1==1:
    ans=clist[i2-1]
  elif l[i1-1]=="C" and l[i1-2]=="A":
    ans=clist[i2-1]-clist[i1-2]-1
  else:
    ans=clist[i2-1]-clist[i1-2]
  print(ans)


Verdicts: Wrong Answer

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):
import sys

_ = input()
S = input().strip()
idx = [i+1 for i in range(len(S)-1) if S[i:i+2] == 'AC']
print(idx)

for line in sys.stdin:
  l,r = list(map(int, line.strip().split(' ')))
  print(sum([1 for i in idx if l <= i <= r-1]))

import sys
_ = input()
S = input().strip()

ps = [0]*(len(S)+1)
for i in range(2, len(S)+1):
  ps[i] = ps[i-1]+int(S[i-2:i] == 'AC')

for line in sys.stdin:
  l,r = map(int, line.strip().split(' '))
  print(ps[r]-ps[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):
n,q=map(int,input().split())
s=input()
d=[0]*(n+1)
for i in range(1,n):
  if s[i]=="C" and s[i-1]=="A":
    d[i]=d[i-1]+1
  else:
    d[i]=d[i-1]
d[n-1]=d[n-2]
print(d)
for j in range(q):
  l,r=map(int,input().split())
  print(d[r-1]-d[l-1])


n,q=map(int,input().split())
s=input()
d=[0]*(n+1)
for i in range(1,n):
  if s[i]=="C" and s[i-1]=="A":
    d[i]=d[i-1]+1
  else:
    d[i]=d[i-1]

for j in range(q):
  l,r=map(int,input().split())
  print(d[r-1]-d[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 = list(map(int, input().split()))
S = input()

def gen_idx_list(S):
  result_list = []
  for i in range(len(S) - 1):
    if S[i] == "A" and S[i+1] == "C":
      result_list.append(i+1)
  return result_list

idx_list = gen_idx_list(S)
print(idx_list)

for _ in range(Q):
  l, r = list(map(int, input().split()))
  print(len([x for x in idx_list if l <= x and x < r]))

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

def gen_idx_list(S):
  result_list = []
  for i in range(len(S) - 1):
    if S[i] == "A" and S[i+1] == "C":
      result_list.append(i)
  return result_list

idx_list = gen_idx_list(S)
print(idx_list)

for _ in range(Q):
  l, r = list(map(int, input().split()))
  print(len([x for x in idx_list if l-1 <= x and x < r-1]))

N, Q = list(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 = list(map(int, input().split()))
  print(t[r-1] - t[l-1])

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()
l = [ 0 for i in range(q)]
r = [ 0 for i in range(q)]
for i in range(q):
    _l,_r = map(int,input().split())
    l[i] = _l
    r[i] = _r

counter = 0
lis = [0]*len(s)
for i in range(len(s)-1):
    if s[i:i+2] == 'AC':
        counter+=1
    lis[i+1]=counter
print(lis)
for b,e in zip(l,r):
    print(lis[e-1]-lis[b-1])

n,q = map(int,input().split())
s = input()
l = [ 0 for i in range(q)]
r = [ 0 for i in range(q)]
for i in range(q):
    _l,_r = map(int,input().split())
    l[i] = _l
    r[i] = _r

counter = 0
lis = [0]*len(s)
for i in range(len(s)-1):
    if s[i:i+2] == 'AC':
        counter+=1
    lis[i+1]=counter
for b,e in zip(l,r):
    print(lis[e-1]-lis[b-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
stdin = sys.stdin

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, q = na()
s = ns()
ac = [0]
now = 0
f = False
for si in s:
    if si == "C" and f:
        now += 1
        f = False
    elif si == "A":
        f = True
    else:
        f = False
    ac.append(now)
for _ in range(q):
    l, r = na()
    print(ac[r] - ac[l-1])

import sys
stdin = sys.stdin

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, q = na()
s = ns()
ac = []
now = 0
f = False
for si in s:
    if si == "C" and f:
        now += 1
        f = False
    elif si == "A":
        f = True
    else:
        f = False
    ac.append(now)
ac.append(now)
for _ in range(q):
    l, r = na()
    print(ac[r] - ac[l-1])

import sys
stdin = sys.stdin

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, q = na()
s = ns()
ac = list()
now = 0
f = False
for si in s:
    if si == "C" and f:
        now += 1
        f = False
    elif si == "A":
        f = True
    else:
        f = False
    ac.append(now)
for _ in range(q):
    l, r = na()
    l -= 1; r -= 1
    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()

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

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

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

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

Verdicts: Wrong Answer

Accepted