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 sys
input = sys.stdin.readlines()
n,q = map(int,input().split())
s = input()
l = []
r = []
cnt = []
for i in range(q):
    _l,_r = [int(i) for i in input().split()]
    l.append(_l)
    r.append(_r)
for i in range(q):
    cnt.append(s[l[i]-1:r[i]].count('AC'))
for i in range(len(cnt)):
    print(cnt[i])


import sys
input = sys.stdin.readlines()
n,q = map(int,input().split())
s = input()
l = []
r = []
cnt = []
for i in range(q):
    _l,_r = [int(i) for i in input().split()]
    l.append(_l)
    r.append(_r)
for i in range(q):
    cnt.append(s[l[i]-1:r[i]].count('AC'))
for i in range(len(cnt)):
    print(cnt[i])


import sys
sys.setrecursionlimit(999999999999)
input = sys.stdin.readlines()
n,q = map(int,input().split())
s = input()
l = []
r = []
cnt = []
for i in range(q):
    _l,_r = [int(i) for i in input().split()]
    l.append(_l)
    r.append(_r)
for i in range(q):
    cnt.append(s[l[i]-1:r[i]].count('AC'))
for i in range(len(cnt)):
    print(cnt[i])


import sys
input = sys.stdin.readline
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

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):
# ABC122-C
import numpy as np
N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]
ind = []
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ind.append(i+1)
print(ind)
ind = np.array(ind)
print(ind)
for i in range(Q):
    print(np.count_nonzero((lr[i][0] <= ind) & (ind <= lr[i][1] - 1)))

# ABC122-C
N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]
cnt_list = [0] * N
tmp = 0
for i in range(N-1):
    cnt_list[i] = tmp
    if S[i] == "A" and S[i+1] == "C":
        tmp += 1
cnt_list[N-1] = tmp
##print(cnt_list)
for i in range(Q):
    l = lr[i][0] - 1
    r = lr[i][1] - 1
    print(cnt_list[r] - cnt_list[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= list(map(int, input().split()))
S=list(input())

for i in range(q):
  a,b=list(map(int, input().split()))
  counter=0
 
  for j in range(len(s)-1):
    if S[a-1:b][j] == "A":
      if S[a-1:b][j+1] == "C":
        counter +=1

  print(counter)

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

t=[0]*n

s=s.replace("AC", "Ac")

for i in range(n):
  if s[i] == "c":
    if i !=0:
      t[i]=1+t[i-1]
    else:
      t[i]=1
  else:
    t[i]=t[i-1]

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

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

t=[0]*n

s=s.replace("AC", "Ac")

for i in range(n):
  if s[i] == "c":
    if i !=0:
      t[i]=1+t[i-1]
    else:
      t[i]=1
  else:
    t[i]=t[i-1]

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

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

line = np.zeros([n,])
count = 0
for i in range(1,n):
    if (s[i-1:i+1]=="AC"): 
        count += 1
    line[i]=count 
        
print(line)
for i in range(q):
    l,r = map(int,input().split())
    target = line[r-1] - line[l-1]
    print(int(target))

import numpy as np

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

line = np.zeros([n,])
count = 0
for i in range(1,n):
    if (s[i-1:i+1]=="AC"): 
        count += 1
    line[i]=count 
        
for i in range(q):
    l,r = map(int,input().split())
    target = line[r-1] - line[l-1]
    print(int(target))

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()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

flag = [0] * (n - 1)

for i in range(n - 1):
	if s[i:i+2] == 'AC':
		flag[i] = 1
	
for j in range(q):
	print(sum(flag[ls[j][0] - 1:ls[j][1] - 2]))

n, q = map(int, input().split())
s = input()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

csm = [0]
cnt = 0

for i in range(n - 1):
	if s[i:i+2] == 'AC':
		cnt += 1
	csm.append(cnt)

print(csm)
	
for j in range(q):
	print(csm[ls[j][1] - 1] - csm[ls[j][0] - 1])

n, q = map(int, input().split())
s = input()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

csm = [0]
cnt = 0

for i in range(n - 1):
	if s[i:i+2] == 'AC':
		cnt += 1
	csm.append(cnt)
	
for j in range(q):
	print(csm[ls[j][1] - 1] - csm[ls[j][0] - 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 = input().split()
Q = int(Q)
S = input()

list1 = []

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

for i in range(Q):
    print(S[list1[i][0]:list1[i][1]].count('AC'))


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

list1 = []

for i in range(Q):
    l,r = map(int,input().split())
    l = l - 1
    w_string = S[l:r]
    for j in w_string:
        if 'AC' in s[j:j+1]:
            count = count + 1
    list1.append(count)
    count = 0

for i in list1:
    print(i)


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

S = input()
list1 = [0] * (N + 1)

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

Verdicts: Wrong Answer

Runtime Error

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()
QList = []
Data  = [0]*N
for _ in range(Q):
    l,r = map(int,input().split())
    QList.append([l,r])

CFound = False
AFound = False

for i in range(N):
    if AFound == False:
        if S[i] == 'A':
            AFound = True
    else:
        if S[i] == 'C':
            CFound = True
    if CFound:
        # i>1
        Data[i] = Data[i-1]+1
        CFound = False
        AFound = False
    else:
        Data[i] = Data[i-1]

print(Data)

for q in QList:
    [l,r] = q
    print( Data[r-1]-Data[l-1])

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

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

Acc = [0]*(N+1)
for i in range(N):
    Acc[i+1] = Acc[i]+Data[i]

#print(Acc)
for q in QList:
    l = q[0]
    r = q[1]
    ans = Acc[r]-Acc[l-1]
    if l >= 2:
        if S[l-1] == 'C' and S[l-2] == 'A':
            ans -= 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 = list(map(int,input().split()))
S = (input())
lr = [list(map(int,input().split())) for _ in range(Q)]

cnt = [0]*N
tmp = 0
for i,c in enumerate(S):
    if tmp == 0 and c == "A":
        tmp =1
        cnt[i] = cnt[i-1]
    elif tmp == 1 and c == "C":
        tmp =0
        cnt[i] = cnt[i-1]+1
    else:
        tmp = int(c == "A")
        cnt[i] = cnt[i-1]

for l,r in lr:
    print(cnt[r-1]-cnt[l-1] , " : " ,S[l-1:r])

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

cnt = [0]*N
tmp = 0
for i,c in enumerate(S):
    if tmp == 0 and c == "A":
        tmp =1
        cnt[i] = cnt[i-1]
    elif tmp == 1 and c == "C":
        tmp =0
        cnt[i] = cnt[i-1]+1
    else:
        tmp = int(c == "A")
        cnt[i] = cnt[i-1]

for l,r in lr:
    print(cnt[r-1]-cnt[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()
lr = []
for i in range(Q):
    lr.append(list(map(int, input().split())))

for idx in lr:
    sub = S[idx[0] - 1:idx[1]]
    cnt = sub.count("AC")
    print("cnt = {}, sub = {}".format(cnt, sub))
    print(str(cnt))


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

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


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

import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n, q = map(int, readline().rstrip().split())
    s = readline().rstrip()
    LRList = [list(map(int, readline().rstrip().split())) for _ in range(q)]
    sumAC = 0
    ACList = [0] * (n)
    for i in range(1, n):
        if s[i - 1: i + 1] == 'AC':
            sumAC += 1
        ACList[i] = sumAC
    for j in range(q):
        l, r = LRList[j][0], LRList[j][1]
        print(ACList[r-1] - ACList[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=str(input())
a=[0]*(n+1)
a[0]=0
for i in range(n):
    if s[i:i+2]=="AC":
        a[i+1]=a[i]+1
    else:
        a[i+1]=a[i]+0
b=[0]*q
c=[0]*q
for i in range(q):
    b[i],c[i]=map(int,input().split())
    print(int(a[c[i-1]]-a[b[i-1]]))

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

n,q=map(int,input().split())
s=str(input())
a=[0]*(n+1)
a[0]=0
for i in range(n):
    if s[i:i+2]=="AC":
        a[i+1]=a[i]+1
    else:
        a[i+1]=a[i]+0
for i in range(q):
    b,c=map(int,input().split())
    print(int(a[c-1]-a[b-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):
#ABC122C
def main():
    import sys
    S = sys.stdin.readline().rstrip()
    #print(S)
    cnt = 0
    ans = 0
    for s in S:
        if s in ['A', 'G', 'C', 'T']:
            cnt +=1
        else:
            ans = max(ans, cnt)
            cnt=0
    
    ans = max(ans, cnt)
    print(ans)   
            
                    
    

if __name__=='__main__':
    main()

#ABC122C
def main():
    import sys, re
    N, Q = map(int, sys.stdin.readline().split())
    S = sys.stdin.readline().rstrip()
    L = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]
    #print(S)
    
    W = [0 for _ in range(N+1)]
    for m in re.finditer('AC', S):
        W[m.span()[1]] = 1
    for i in range(N):
        W[i+1] += W[i]
    #print(W)
    for i in range(Q):
        print(W[L[i][1]]-W[L[i][0]])

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

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

print(indices)
for i in range(Q):
  l,r=lr[i]
  print(indices[r-1]-indices[l-1])

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

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

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


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


N,Q=map(int,input().split())
S=input()
for i in range(N):
  A.append(S[0:i+1].count("AC"))
for i in range(Q):
  l,r=map(int,input().split())
  print(A[r-1]-A[l-1])

N,Q=map(int,input().split())
S=input()
for i in range(N):
  t=S[0:i+1].count("AC")
  A.append(t)
for i in range(Q):
  l,r=map(int,input().split())
  print(A[r-1]-A[l-1])

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

Verdicts: Wrong Answer

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):
from sys import stdin
N,Q=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
for i in range(Q):
    n1,n2=[int(x) for x in stdin.readline().rstrip().split()]
    print(S[n1-1:n2])

from sys import stdin
N,Q=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
for i in range(Q):
    n1,n2=[int(x) for x in stdin.readline().rstrip().split()]
    print(n1,n2)

from sys import stdin
N,Q=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
acc=[0]*N
cnt=0
flag=0
for index,i in enumerate(list(S)):
    if i == "C" and flag == 1:
        cnt+=1
        flag=0
    if i != "C":
        flag=0
    if i == "A":
        flag=1
    acc[index]=cnt
for j in range(Q):
    n1,n2=[int(x) for x in stdin.readline().rstrip().split()]
    print(acc[n2-1]-acc[n1-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 re

def solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))

    t = [0] * (N)
    for i in range(N):
        t[i+1] = t[i] + (1 if acgt_string[i:i+2] == "AC" else 0)

    for start, end in sub_str_ith:
        print(t[end-1] - t[start-1])

def my_solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))
    # print(sub_str_ith)

    
    a_iths = [m.span() for m in re.finditer('AC', acgt_string)]
    # print(a_iths)

    for start, end in sub_str_ith:
        # print(start, end)
        num = 0
        for ac_start, ac_end in a_iths:
            if ac_start >= start-1 and ac_end <= end:
                num += 1
        print(num)


solve1()
# my_solve1()

import re

def solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))

    t = [0] * (N+1)
    for i in range(N):
        t[i+1] = t[i] + (1 if acgt_string[i:i+2] == "AC" else 0)

    for start, end in sub_str_ith:
        print(t[end-1] - t[start-1])

def my_solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))
    # print(sub_str_ith)

    
    a_iths = [m.span() for m in re.finditer('AC', acgt_string)]
    # print(a_iths)

    for start, end in sub_str_ith:
        # print(start, end)
        num = 0
        for ac_start, ac_end in a_iths:
            if ac_start >= start-1 and ac_end <= end:
                num += 1
        print(num)


solve1()
# my_solve1()

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()

count_sum_list = [0]*(N+1)
start_A_pointa = [0]*(N+1)

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

output_list = []

for _ in range(Q):
    l,r = map(int,input().split(' '))
    if start_A_pointa[r] == 1:
        output_list.append(count_sum_list[r]-count_sum_list[l-1] -1)
    else:
        output_list.append(count_sum_list[r]-count_sum_list[l-1])

for out in output_list:
    print(out)

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

count_sum_list = [0]*(N+1)
start_A_pointa = [0]*(N+1)

for i in range(1,N+1):
    if i != N and S[i-1] == 'A' and S[i] == 'C':
        count_sum_list[i] = count_sum_list[i-1] + 1
        start_A_pointa[i] = 1
    else:
        count_sum_list[i] = count_sum_list[i-1]
#print(count_sum_list)

output_list = []

for _ in range(Q):
    l,r = map(int,input().split(' '))
    if start_A_pointa[r] == 1:
        output_list.append(count_sum_list[r]-count_sum_list[l-1] -1)
    else:
        output_list.append(count_sum_list[r]-count_sum_list[l-1])

for out in output_list:
    print(out)

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] + (1if 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] + (1if 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()
keep = [0]*(n)

for i in range(1, n):
    keep[i] = keep[i-1]
    l, r = i-1, i+1
    if s[l:r] == "AC":
        keep[i] += 1
print(keep)

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


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

for i in range(1, n):
    keep[i] = keep[i-1]
    l, r = i-1, i+1
    if s[l:r] == "AC":
        keep[i] += 1

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

AC_list = [0] * N

for i in range(N-1):
    if(S[i+1]=="C"):
        if(S[i]=="A"):
            AC_list[i+1] = 1

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



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

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

    AC_list[i] = val

for i in range(Q):
    l, r = (int(_) for _ in input().split())
    if(AC_list[r-1]==1 and S[r]=="C"):
        print(val[r-1]-1)
    else:
        print(val[r-1])



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

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

    AC_list[i] = val

for i in range(Q):
    l, r = (int(_) for _ in input().split())
    if(AC_list[r-1]==1 and S[r]=="C"):
        print(val[r-1]-1)
    else:
        print(val[r-1])



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

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

    AC_list[i+1] = val
AC_list[i+2] = val

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



Verdicts: Wrong Answer

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

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

n, q = map(int, input().split())
s = input()
ac = [0]
for i in range(len(s)-1):
  if s[i] == 'A' and s[i+1] == 'C':
    ac.append(ac[i]+1)
  else:
    ac.append(ac[i])
for i in range(q):
  l, r = map(int, input().split())
  print(ac[r-1]-ac[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 os, sys, re, math

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

oc = []
for i in range(len(S) - 1):
    if S[i:i+2] == 'AC':
        oc.append(i)

for i in range(Q):
    (l, r) = [int(n) for n in input().split()]
    print('')

import os, sys, re, math

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

oc = [0]
n = 0
for i in range(len(S) - 1):
    if S[i:i+2] == 'AC':
        n += 1
    oc.append(n)
oc.append(n)

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

t = [0] * len(S)

for index, s in enumerate(S):
  if index+1 > len(S)-1:
    break

  if s == 'A' and S[index+1] == 'C':
    t[index+1] = t[index] + 1
    
  else:
    t[index+1] = t[index]
    
print(t)

for i in li:
  print(t[i[1]-1] - t[i[0] - 1])

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

t = [0] * len(S)

for index, s in enumerate(S):
  if index+1 > len(S)-1:
    break

  if s == 'A' and S[index+1] == 'C':
    t[index+1] = t[index] + 1
    
  else:
    t[index+1] = t[index]

for i in li:
  print(t[i[1]-1] - t[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):
def have_AC(str):
    count=0
    for i in range(len(str)-1):
        if(str[i:i+1]=="AC"):
            count=count+1
    return count

n,q=input().split() 
s=input() 
n=int(n)
q=int(q)
num=[]

for i in range(q):
    a,b=input().split()
    a=int(a) -1
    b=int(b)
    num.append(have_AC(s[a:b]))

for j in range(len(num)):
    print(num[j])

def have_AC(str):
    count=[0]
    for i in range(1,len(str)):
        if(str[i]=='C' and str[i-1]=='A'):
            count.append(count[i-1]+1)
            continue
        count.append(count[i-1])
    return count

n,q=input().split() 
s=input() 
n=int(n)
q=int(q)
num=[]
d=have_AC(s)

for i in range(q):
    a,b=input().split()
    a=int(a)
    b=int(b)
    num.append(d[b-1]-d[a-1])

for j in range(len(num)):
    print(num[j])

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=list(input())
ans_list=[]
length=[]

for i in range(q):
  ans=0
  l,r=map(int,input().split())
  sublist=s[l-1:r]
  print(sublist)
  for j in range(len(sublist)-1):
    if sublist[j]=='A' and sublist[j+1]=='C':
      ans=ans+1
  ans_list.append(ans)
  
for i in range(q):
  print(ans_list[i])

n,q=map(int,input().split())
s=list(input())
value=[0]*n
ans_list=[]
length=[]
     
for i in range(len(s)-1):
  value[i+1]=value[i]+(1 if s[i]=='A' and s[i+1]=='C' else 0)
  
for i in range(q):
  l,r=map(int,input().split())
  print(value[r-1]-value[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):
from itertools import accumulate
n,q=list(map(int,input().split()))
s=list(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=list(map(int,input().split()))
A=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    A.append(1)
  else:
    A.append(0)
check=[0]+A+[0]
check=list(accumulate(check))
for i in range(q):
  print(check[r[i]-1]-check[l[i]])

n,q=list(map(int,input().split()))
s=list(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=list(map(int(input().split())))
A=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    A.append(1)
  else:
    A.append(0)
check=[0]+A
check=list(accumulate(check))
for i in range(q):
  print(check[r[i]]-check[l[i]+1])

    
  

from itertools import accumulate
n,q=list(map(int,input().split()))
s=list(input())
l=[]
r=[]
for i in range(q):
  o,p=list(map(int,input().split()))
  l.append(o)
  r.append(p)
  
ruiseki=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    ruiseki.append(1)
  else:
    ruiseki.append(0)
ruiseki=[0]+list(accumulate(ruiseki))

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



where_ac = [0] * N

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

count = [sum(where_ac[0:i+1]) for i in range(N)]

for lr in lr_list:
    print(count[lr[1]-1] - count[lr[0]-1])

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

where_ac = [0] * N

for i in range(N-1):    
  if S[i] == 'A' and S[i+1] == 'C':
    where_ac[i+1] = where_ac[i] + 1
  else:
    where_ac[i+1] = where_ac[i]
        
for q in range(Q):
  l, r = map(int, input().split())
  print(where_ac[r-1] - where_ac[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()
for i in range(Q):
  l,r=map(int,input().split())
  print(s[l-1:r].count("AC")

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

for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
        S[i], S[i+1] = 2, -1
    else:
        if type(S[i]) != int:
            S[i] = 0

if type(S[-1]) == str:
    S[-1] = 0

print(S)

list_lr = [map(int, input().rstrip().split()) for i in range(Q)]

for i in list_lr:
    l, r = i
    s = S[l-1:r]
    print(s)
    if s[0] == -1 and s[-1] == 2:
        ans = sum(s)-1
    elif s[0] == -1 and (s[-1] == -1 or s[-1] == 0):
        ans = sum(s)+1
    elif s[-1] == 2 and (s[0] == 2 or s[1] == 0):
        ans = sum(s)-2
    else:
        ans = sum(s)

    print(int(ans))


N, Q = map(int, input().split())
S = input()
Sum = [0]*(N+1)
for i in range(N-1):
	if S[i] == 'A' and S[i+1] == 'C':
		Sum[i+1] = Sum[i] + 1
	else:
		Sum[i+1] = Sum[i]
Sum[-1] = Sum[-2]

for i in range(Q):
	l, r = map(int, input().split())
	print(Sum[r-1] - Sum[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):
from itertools import accumulate

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

ac = [0] + ac
acc = list(accumulate(ac))
print(ac)
print(acc)
for i in range(Q):
    l, r = map(int, input().split())
    print(acc[r-1] - acc[l-1])

from itertools import accumulate

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

ac = [0] + ac
acc = list(accumulate(ac))
for i in range(Q):
    l, r = map(int, input().split())
    print(acc[r-1] - acc[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()

lr = []
for _ in range(Q):
    lr.append(list(map(int,input().split(' '))))

index_list = []
#index_list = [0] * N
start = 0
for i in range(N):
    if S[i-1] == 'A' and S[i] == 'C':
        start += 1
        #index_list[i] = index_list[i-1] + 1
    #else:
    index_list.append(start)
        #index_list[i] = index_list[i-1]

print(index_list)
for l,r in lr:
    print(index_list[r-1] - index_list[l-1])

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

lr = []
for _ in range(Q):
    lr.append(list(map(int,input().split(' '))))

index_list = []
#index_list = [0] * N
start = 0
for i in range(N):
    if S[i-1] == 'A' and S[i] == 'C':
        start += 1
        #index_list[i] = index_list[i-1] + 1
    #else:
    index_list.append(start)
        #index_list[i] = index_list[i-1]

for l,r in lr:
    print(index_list[r-1] - index_list[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 = (int(x) for x in input().split())
s = input()
s = [s[i] for i in range(n)]
lr = []
for i in range(q):
    lr.append([int(x) for x in input().split()])
ac = [0 for _ in range(n)]
i, c = 0, 0
while i < n:
    if s[i] == "A":
        ac[i] = c
        i += 1
        if s[i] == "C":
            c += 1
            ac[i] = c
            i += 1
        else:
            ac[i] = c
            i += 1
    else:
        ac[i] = c
        i += 1
print(ac)
for p in lr:
    l, r = p[0] - 1, p[1] - 1
    print(int(ac[r] - ac[l]))


n, q = (int(x) for x in input().split())
s = input()
s = [s[i] for i in range(n)]
lr = []
for i in range(q):
    lr.append([int(x) for x in input().split()])
ac = [0 for _ in range(n)]
i, c = 0, 0
while i < n:
    if s[i] == "A":
        ac[i] = c
        i += 1
        if s[i] == "C":
            c += 1
            ac[i] = c
        else: ac[i] = c
    else:
        ac[i] = c
        i += 1
print(ac)
for p in lr:
    l, r = p[0] - 1, p[1] - 1
    print(int(ac[r] - ac[l]))

n, q = (int(x) for x in input().split())
s = input()
s = [s[i] for i in range(n)]
lr = []
for i in range(q):
    lr.append([int(x) for x in input().split()])
ac = [0 for _ in range(n)]
i, c = 0, 0
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        ac[i+1] = ac[i] + 1
    else:
        ac[i+1] = ac[i]
for p in lr:
    l, r = p[0] - 1, p[1] - 1
    print(int(ac[r] - ac[l]))

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):
from sys import stdin
n, q = stdin.readline().split()
s = stdin.readline().strip()
count = 0
for i in range(q):
  l, r = map(int, stdin.readline().split())
  for j in range(l-1, r-1):
    if s[j] + s[j+1] == 'AC':
      count += 1
      
  print(count)


from sys import stdin

n, q = map(int, stdin.readline().split())
s = stdin.readline().strip()
counts = [0 for i in range(n)]
count = 0
for i in range(1, n):
    if s[i-1:i+1] == 'AC':
        count += 1
    counts[i] = count

for i in range(q):
    l, r = map(int, stdin.readline().split())
    print(counts[r-1] - counts[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):
from bisect import bisect

n,q=map(int,input().split())
s=input()
l=[]
r=[]
for i in range(q):
	L,R=map(int,input().split())
	l.append(L)
	r.append(R)

a=[]
c=[]
for i in range(n-1):
	if s[i:i+2]=='AC':
		a.append(i)
		c.append(i)

for i in range(q):
	print(bisect(c,r[i])-bisect(a,l[i])+1)

from bisect import bisect, bisect_left

n,q=map(int,input().split())
s=input()
l=[]
r=[]
for i in range(q):
	L,R=map(int,input().split())
	l.append(L-1)
	r.append(R-1)

a=[]
c=[]
for i in range(n-1):
	if s[i:i+2]=='AC':
		a.append(i)
		c.append(i+1)

for i in range(q):
	print(bisect(c,r[i])-bisect_left(a,l[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=input()
l=list()
r=list()
for i in range(Q):
  L,R=map(int, input().split())
  S2=S[L-1:R].split("AC")
  print(S[L-1:R])
  print(len(S2)-1)

N, Q = map(int, input().split())
S=list(input())
Snum=list()
Snum.append(0)
Snum.append(0)
for i in range(1,N):
  if S[i]=="C" and S[i-1]=="A":
    Snum.append(Snum[i]+1)
  else:
    Snum.append(Snum[i])
for i in range(Q):
  L,R=map(int, input().split())
  print(Snum[R]-Snum[L])

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())
a=input()

list=[0]*N

for i in range(N):
    list[i+1]=list[i]+1 if a[i:i+2]=="AC" else list[i]
    
for i in range(N):
    l,r = map(int, input().split())
    print(list[r-1]-list[l-1])
    

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

list=[0]*N+1

for i in range(N):
    list[i+1]=list[i]+1 if a[i:i+2]=="AC" else list[i]
    
for i in range(N):
    l,r = map(int, input().split())
    print(list[r-1]-list[l-1])
    

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

l= [input().split() for _ in range(Q)]
v = [a[i:i+2] for i in range(N-1)]

count=0
for v in "AC":
    count+=1

print(count)

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

list=[0]*(N+1)

for i in range(N):
    list[i+1]=list[i]+1 if a[i:i+2]=="AC" else list[i]
    
for i in range(Q):
    l,r = map(int, input().split())
    print(list[r-1]-list[l-1])
    

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted