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

Submission attempts (in order):
n,q=map(int,input().split())
S=input()
L=[0]
c=0
for i in range(n-1):
    if S[i:i+2]=='AC':
        c+=1    
    L.append(c)
print(L)
for j in range(q):
    s,e=map(int,input().split())
    print(L[e-1]-L[s-1])

n,q=map(int,input().split())
S=input()
L=[0]
c=0
for i in range(n-1):
    if S[i:i+2]=='AC':
        c+=1    
    L.append(c)
for j in range(q):
    s,e=map(int,input().split())
    print(L[e-1]-L[s-1])

Verdicts: Wrong Answer

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

Submission attempts (in order):
n,q=map(int,input().split())
s=input()+" "
A=[0]*(n+1)
cnt=0
for i in range(1,n+1):
    if s[i-1]+s[i]=="AC":
        cnt +=1
    A[i+1]=cnt

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

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

for i in range(q):
    l,r=map(int,input().split())
    print(A[r]-A[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):
import bisect
n,q=map(int,input().split())
s=input()
ac=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    ac.append(i+1)
for i in range(q):
  a,b=map(int,input().split())
  print(bisect.bisect_right(b-1)-bisect.bisect_left(a))

import sys
import bisect
input=sys.stdin.readline
n,q=map(int,input().split())
s=input()
ac=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    ac.append(i+1)
for i in range(q):
  a,b=map(int,input().split())
  print(bisect.bisect_right(ac,b-1)-bisect.bisect_left(ac,a))

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 = 0

for i in range(Q):
  l, r = map(int,input().split())
  Si = S[l-1:r]
  
  len_Si = len(Si)
  for i in range(len_Si-1):
    if Si[i:i+2] == 'AC'
      count += 1
  print(count)
  count = 0


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

for i in range(Q):
  l, r = map(int,input().split())
  Si = S[l-1:r]
  
  len_Si = len(Si)
  for i in range(len_Si-1):
    if Si[i] == 'A' and Si[i+1] == 'C':
      count += 1
  print(count)

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

for i in range(Q):
  l, r = map(int,input().split())
  Si = S[l-1:r]
  
  len_Si = len(Si)
  for i in range(len_Si-1):
    if Si[i] == 'A' and Si[i+1] == 'C':
      count += 1
  print(count)

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

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):
nq = list(map(int, input().split()))
n = nq[0]
q = nq[1]
s = input()
ac = []
for i in range(n - 1):
    if s[i] == "A" and s[i + 1] == "C":
        ac.append(i)
print(ac)
for i in range(q):
    lr = list(map(int, input().split()))
    l = lr[0]
    r = lr[1]
    ans = 0
    for j in ac:
        if l - 1 <= j < r - 1:
            ans += 1
        elif j >= r - 1:
            break
    print(ans)


nq = list(map(int, input().split()))
n = nq[0]
q = nq[1]
s = input()
ac_list = []
ac_number = 0
for i in range(n - 1):
    if s[i : i+2] == "AC":
        ac_number += 1
    ac_list.append(ac_number)
ac_list.append(0)
for i in range(q):
    lr = list(map(int, input().split()))
    l = lr[0]
    r = lr[1]
    print(ac_list[r - 2] - ac_list[l - 2])


Verdicts: Wrong Answer

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

Submission attempts (in order):
n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if (S[i-1:i+1] == "AC"):
    cnt += 1
    counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])

n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if S[i-1:i+1] == "AC":
    cnt += 1
    counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])

S = input()
import re
def appear(i, j)
 T = S[i:j+1]
 T.count('AC')

n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if (S[i-1:i+1] == "AC":)
    cnt += 1
    counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])

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

counts = [0 for i in range(N)]
cnt = 0

for i in range(n):
  if S[i-1:i+1] == "AC":
    cnt += 1
    counts[i] = cnt
    
for i in range(q):
  l, r = map(int, input().split())
  print (counts[r-1] - counts[l-1])

n, q = map(int, input().split())
S = input()
 
counts = [0 for i in range(n)]
cnt = 0
 
for i in range(n):
  if S[i-1:i+1] == "AC":
    cnt += 1
  counts[i] = cnt
    
for i in range(q):
    l, r = map(int, input().split())
    print(counts[r-1] - counts[l-1])

Verdicts: Wrong Answer

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


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


import bisect
N,Q=list(map(int,input().split()))
S=input()
place=[]
for i in range(0,len(S)-1):
    print(S[i:i+2])
    if S[i:i+2]=='AC':
        place.append(i+2)

for i in range(Q):
    frm,to=list(map(int,input().split()))
    if to-frm<=1:
        print(0)
    else:
        f=bisect.bisect_left(place,frm-1)
        t=bisect.bisect_left(place,to)
        print(t-f)

#print(place)


N,Q=list(map(int,input().split()))
S=input()
place=[0]*(N+1)
for i in range(0,len(S)-1):
    if S[i:i+2]=='AC':
        place[i+2]+=1
        
for i in range(N):
    place[i+1]=place[i]+place[i+1]
for i in range(Q):
    frm,to=list(map(int,input().split()))
    print(place[to]-place[frm])
#print(place)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N,Q = map(int,input().rstrip().split())
S = input().rstrip()
a = [0]*N
for i in range(N):
    if i > 1:
        a[i] = a[i-1]
    if i != 0 and S[i-1]=='A' and S[i] == 'C':
        a[i] += 1
for _ in range(Q):
    l, r = map(int,input().rstrip().split())

N,Q = map(int,input().rstrip().split())
S = input().rstrip()
a = [0]*N
for i in range(N):
    if i > 1:
        a[i] = a[i-1]
    if i != 0 and S[i-1]=='A' and S[i] == 'C':
        a[i] += 1
for _ in range(Q):
    l, r = map(int,input().rstrip().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 = (int(i) for i in input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

accum = [0] * N

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



countAC()

for i in range(Q):
    print(accum[LR[i][1]-1] - accum[LR[i][0]-1])

print(accum)



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

accum = [0] * N

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



countAC()

for i in range(Q):
    print(accum[LR[i][1]-1] - accum[LR[i][0]-1])


Verdicts: Wrong Answer

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

Submission attempts (in order):
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    print(s[li-1:ri].count("AC"))


N, Q = input().split(" ")
N, Q = int(N), int(Q)
S = input()
s = S.replace("AC", "__")
counts = []
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    counts[i] = s[li-1, ri].count("__")

print(max(counts))

N, Q = input().split(" ")
N, Q = int(N), int(Q)
S = input()
s = S.replace("AC", "__")
counts = range(Q)
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    print(s[li, ri].count("__"))


N, Q = input().split(" ")
N, Q = int(N), int(Q)
S = input()
s = S.replace("AC", "__")
counts = range(Q)
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    counts[i] = s[li-1, ri].count("__")

print(max(counts))


N, Q = [int(nq) for nq in input().split(" ")]
S = input()
s = S.replace("AC", "NM")
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    print(li, ri, S[li-1:ri])
    print(s[li-1:ri].count("NM"))


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

Verdicts: 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):
n,q = map(int,input().split())
s = input()
t = [0] * (n + 1)
for i in range(q):
  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 = str(input())
for _ in range(q):
  l,r = map(int,input().split())
  print(s[l-1:r].count("AC")

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


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


Verdicts: Runtime Error

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

def get(n):
    ans = 0
    for i in range(n):
        if S[i] =="A" and S[i+1] =="C":
            ans += 1
    return ans

for i in range(len(S)):
    l.append(get(i))
print(l)
for i in range(Q):
    print(l[X[i][1]-1]-l[X[i][0]-1])

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

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

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
N,Q = map(int,input().split(" "))
S = input()
a = [0] *  N
acc = [0] * N
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        a[i] = 1
        acc[i] += a[i]
    acc[i+1] = acc[i]

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

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

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



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



C=[0]*(N+1)
for i in range(N):
    C[i+1]=C[i]+(1 if S[i:i+2]=='AC' else 0)
#print(C)
#exit()

#print()
#print("#"*20)
for q in range(Q):
    l,r=map(int,input().split())
    #print(S[l-1:r].count("AC"))
    #print(sum(C[l-1:r-1]))
    print(C[r-1]-C[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()
S += 'J'
L = []
for i in range(Q):
  L.append(list(map(int,input().split())))
cnt = [0]*(N+1)
for i in range(N):
  if S[i] == 'A' and S[i+1] == 'C':
    cnt[i+1] = 1
for i in range(1,N+1):
  cnt[i] += cnt[i-1]
for j in range(Q):
  print(cnt[L[j][1]-1]-cnt[L[j][0]-1])
print(cnt)

N,Q = map(int,input().split())
S = input()
S += 'J'
L = []
for i in range(Q):
  L.append(list(map(int,input().split())))
cnt = [0]*(N+1)
for i in range(N):
  if S[i] == 'A' and S[i+1] == 'C':
    cnt[i+1] = 1
for i in range(1,N+1):
  cnt[i] += cnt[i-1]
for j in range(Q):
  print(cnt[L[j][1]-1]-cnt[L[j][0]-1])

Verdicts: Wrong Answer

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

Submission attempts (in order):
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(s[i]+1)
  else:
    list.append(s[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r]-list[l-1])

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

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

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

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

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

n,q = map(int, input().split())
s = input()
for i in range(q):
  l,r = map(int,input().split())
  print(s[l-1:r]).cound("AC")

n,q = map(int, input().split())
s = input()
for i in range(q):
  l,r = map(int,input().split())
  count = 0
  pre = s[l-1]
  for j in range(l, r):
    if pre == 'A' and s[j] == 'C':
      count += 1
    pre = s[j]
  print(cound)

n,q = map(int, input().split())
s = input()
c = []
for i in range(n+1):
  c.append(s[:i].count("AC"))
  
for i in range(q):
  l,r = map(int,input().split())
  print(c[r]-c[l-1])

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

Verdicts: Runtime Error

Runtime Error

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()
l_r = []
for _ in range(q):
    l_r.append(tuple(map(int, input().split(' '))))
    
for (l, r) in l_r:
    substr = s[l-1:r]
    print(substr)
    count = 0
    for i in range(len(substr) - 1):
        print(substr[i:i+2])
        if substr[i:i+2] == 'AC':
            count += 1
    print(count)

n, q = map(int, input().split(' '))
s = input()
l_r = []
for _ in range(q):
    l_r.append(tuple(map(int, input().split(' '))))

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

for (l, r) in l_r:
    print(n[r - 1] - n[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):
b = "ACACTACG"
n, q = map(int, input().split())
b = input()
a = [[int(x) for x in input().split()] for _ in range(q)]
for j in range(len(b)-1):
        if b[j] == "A" and b[j+1] == "C":
            ans.append(1)
        else:
            ans.append(0)
for i in a:
    print(sum(ans[i[0]:i[1]]))


n, q = map(int, input().split())
s = input()
t = [[int(x) for x in input().split()] for _ in range(q)]
add_list = [0]
for i in range(len(s)-1):
    if s[i:i+2] == "AC":
        add_list.append(add_list[i]+1)
    else:
        add_list.append(add_list[i])
for i in t:
    ans = add_list[i[1]-1] - add_list[i[0]-1]
    print(ans)

Verdicts: Runtime Error

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

Submission attempts (in order):
import bisect
N, Q = [int(x) for x in input().split()]
S = str(input())

ac_list = []
for (idx, (s1, s2)) in enumerate(zip(S[:-1], S[1:])):
  if s1 == 'A' and s2 == 'C':
    ac_list.append(idx+1)

print(ac_list)
for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  index_l = bisect.bisect_left(ac_list, l)
  index_r = bisect.bisect_left(ac_list, r)
  print(index_r - index_l)



import bisect
N, Q = [int(x) for x in input().split()]
S = str(input())

ac_list = []
for (idx, (s1, s2)) in enumerate(zip(S[:-1], S[1:])):
  if s1 == 'A' and s2 == 'C':
    ac_list.append(idx+1)

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  index_l = bisect.bisect_left(ac_list, l)
  index_r = bisect.bisect_left(ac_list, r)
  print(index_r - index_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()
lr = [list(map(lambda x: int(x)-1, input().split())) for _ in range(q)]

ac = [0]*n
for i in range(n-1):
    print(s[i:i+2])
    if s[i:i+2] == 'AC':
        ac[i+1]= ac[i]+1
    else:
        ac[i+1] = ac[i]
print(ac)
for x in lr:
    print(ac[x[1]] - ac[x[0]])

n,q = map(int, input().split())
s = input()
lr = [list(map(lambda x: int(x)-1, input().split())) for _ in range(q)]

ac = [0]*n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        ac[i+1]= ac[i]+1
    else:
        ac[i+1] = ac[i]
for x in lr:
    print(ac[x[1]] - ac[x[0]])

Verdicts: Wrong Answer

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

Submission attempts (in order):
n, q = map(int, input().split())
s = str(input())
lr = []
for i in range(q):
    lr.append(list(input().split()))

n = len(s)
ary = [0 for i in range(lne(s)+1)]

for i in range(1, N):
    if s[i-1] == 'A' and s[i] == 'C':
        ary[i+1] = ary[i] + 1
    else:
        ary[i+1] = ary[i]

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


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

n = len(s)
ary = [0 for i in range(len(s)+1)]

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

for i in range(q):
    ans = ary[int(lr[i][1])] - ary[int(lr[i][0])]
    print(ans)


Verdicts: Runtime Error

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

Submission attempts (in order):
N,Q=map(int,input().split())
S=input()
C=[0]*N

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

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



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

num=[0]*N

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

sums=[0]*(N+1)
for i in range(1,N+1):
    sums[i]=sums[i-1]+num[i-1]

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

sum_list = [0]

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

print(sum_list)

for l, r in lr_list:
    print(sum_list[r] - sum_list[l-1])


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

sum_list = [0]


#     if S[i] == 'C' and S[i-1] == 'A' and i:
#         sum_list.append(sum_list[-1]+1)
#     else:
#         sum_list.append(sum_list[-1])

[sum_list.append(sum_list[-1]+1) if s == 'C' and S[i-1] == 'A' else sum_list.append(sum_list[-1]) for i, s in enumerate(S)]

for l, r in lr_list:
    print(sum_list[r] - sum_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):
# -*- coding: utf-8 -*-
import sys
import collections
import re
import copy

def main():
	N, Q = map(int, input().split(" "))
	S = input()
	S = list(S)
	pattern = r"AC"
	
	Qs = []
	for _ in range(Q):
		l, r = map(int, input().split(" "))
		Qs.append((l, r))
	
	ans = []
	for i, val in enumerate(Qs):
		l, r = val
		#tmp = S[l-1:r]
		matchedList = re.findall(pattern, "".join(S))
		
		ans.append(len(matchedList))
	
	
	for i in ans:
		print(i)
	
if __name__ == "__main__":
	main()
	

# -*- coding: utf-8 -*-
import sys
import collections
import re
import copy

def main():
	N, Q = map(int, input().split(" "))
	S = input()
	S = list(S)
	pattern = r"AC"
	
	Qs = []
	for _ in range(Q):
		l, r = map(int, input().split(" "))
		Qs.append((l, r))
	
	ans = []
	for i, val in enumerate(Qs):
		l, r = val
		tmp = S[l-1:r]
		#matchedList = re.findall(pattern, "".join(tmp))
		
		ans.append(tmp)
	
	
	for i in ans:
		print(i)
	
if __name__ == "__main__":
	main()
	

# -*- coding: utf-8 -*-
import sys

def main():
	N, Q = map(int, input().split(" "))
	S = input()
	S = list(S)
	
	Qs = []
	for _ in range(Q):
		l, r = map(int, input().split(" "))
		Qs.append((l, r))
	
	ptn = []
	hit = 0
	flg = False
	for i, val in enumerate(S):
		if val == "A":
			ptn.append(hit)
			if i+1 < len(S) and S[i+1] == "C":
				hit += 1
				ptn.append(hit)
				flg = True
		else:
			if flg == False:
				ptn.append(hit)
			else:
				flg = False
		
	ans = []
	for i, val in enumerate(Qs):
		l, r = val
		if l == r:
			ans.append(0)
			break
			
		tmp = ptn[r-1] - ptn[l-1]
		ans.append(tmp)
	
	
	for i in ans:
		print(i)
	
if __name__ == "__main__":
	main()
	

Verdicts: Wrong Answer

Wrong Answer

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

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

import re
N, Q = map(int, input().split())
S = input()
query = [list(map(int, input().split())) for _ in range(Q)]
s = re.sub(r"AC", "0", S)
accum = [0 for _ in range(N)]
for i in range(1, N):
    accum[i] = accum[i-1]
    if S[i-1]=="A" and S[i]=="C":
        accum[i] += + 1

for l,r in query:
    print(accum[r-1]-accum[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 for i in range(n)]
count = 0
for i in range(1,n):
    if S[i] == 'C' and S[i-1] == 'A':
        count += 1
    a[i] = count
for i in range(q):
    l,r = map(int,input().split())
    print(a[r-1]-a[l-1])
print(a)

n,q = map(int,input().split())
S = input()
a = [0 for i in range(n)]
count = 0
for i in range(1,n):
    if S[i] == 'C' and S[i-1] == 'A':
        count += 1
    a[i] = count
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()
lr = [list(map(int, input().split())) for i in range(q)]

idx = [s[i:i+2] == "AC" for i in range(n-1)]


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


idx = [s[i:i+2] == "AC" for i in range(n-1)]
idx2 = [sum(idx[:i]) for i in range(n)]

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



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


idx = [0] * n


for i in range(1,n):
    idx[i] = idx[i-1] + (s[i-1:i+1] == "AC")


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


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: 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()
cnt_list = [0]

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





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

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

for j in range(Q):
    x,y = map(int, input().split())
    print(A[y-1]-A[x-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()
c=[0 for _ in range(n)]
p=''
d=0
for i in range(n):
  x=s[i]
  if p=='A' and x=='C':
    d+=1
  p=x
  c[i]=d
print(c)
for i in range(q):
  ans=0
  l,r=map(int,input().split())
  ans=c[r-1]-c[l-1]

  print(ans)


n,q=map(int,input().split())
s=input()
c=[0 for _ in range(n)]
p=''
for i in range(1,n):
  x=s[i]
  if p=='A' and x=='C':
    c[i-1]=1
  p=x
for i in range(q):
  ans=0
  l,r=map(int,input().split())
  ans=sum(c[l-1:r-1])
 # if s[]
  print(ans)


n,q=map(int,input().split())
s=input()
c=[0 for _ in range(n)]
p=''
for i in range(1,n):
  x=s[i]
  if p=='A' and x='C':
    c[i-1]=1
  p=x
for i in range(q):
  ans=0
  l,r=map(int,input().split())
  ans=sum(c[l-1:r-1])
 # if s[]
  print(ans)


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

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

n,q=map(int,input().split())
s=input()
c=[0 for _ in range(n)]
p=''
d=0
for i in range(n):
  x=s[i]
  if p=='A' and x=='C':
    d+=1
  p=x
  c[i]=d
for i in range(q):
  ans=0
  l,r=map(int,input().split())
  ans=c[r-1]-c[l-1]

  print(ans)


Verdicts: Wrong Answer

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

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


Verdicts: Runtime Error

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

Submission attempts (in order):
N,Q=map(int,(input()).split())
S=input()
l_list=[]
r_list=[]
for i in range(Q):
  l,r=input().split()
  l_list.append(int(l))
  r_list.append(int(r))
count=0
AC_count=[0]
for i in range(1,N+1):
  if S[i-1:i+1]=="AC":
    count+=1
  AC_count.append(count)
AC_count.append(count)
k=0
for j in range(Q):
  k=AC_count[r_list[j]+1]-AC_count[l_list[j]-1]
  print(k)


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


N,Q=int(input()).split()
S=input()
l_list=[]
r_list=[]
for i in range(Q):
  l,r=int(input()).split()
  l_list.append(l)
  r_list.append(r)
for i in range(Q):
  S_i=S[l_list[i]-1,r_list[i]]
  n=0
  while "AC" in S_i:
    n+=1
  print(n)

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


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


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

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

Verdicts: Wrong Answer

Wrong Answer

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

for i in range(N):
    if S[i : i + 2] == '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-1] - t[l-1])

n,q=map(int,input().split())
s=input()
c=[0]*n
for i in range(1,n):
  t=s[i-1:i+1]
  if t=="AC":c[i]+=1
from itertools import accumulate
s=list(accumulate(c))
for i in range(q):
  l,r=map(int,input().split())
  l-=1
  r-=1
  print(s[r]-s[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()
cumulative = [0] * (N+1)
for i in range(N-1):
  if S[i:i+2] == "AC":
    cumulative[i+2] = cumulative[i+1] + 1
  else:
    cumulative[i+2] = cumulative[i+1]

print(cumulative)    
    
for _ in range(Q):
  start, end = map(int, input().split())
  ans = cumulative[end] - cumulative[start-1]
  if start > 1 and S[start-2:start] == "AC":
    ans -= 1
  print(ans)

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

for _ in range(Q):
  start, end = map(int, input().split())
  ans = cumulative[end] - cumulative[start-1]
  if start > 1 and S[start-2:start] == "AC":
    ans -= 1
  print(ans)

N, Q = map(int, input().split())
S = input()
cumulative = [0] * (N+1)
for i in range(N-1):
  if S[i:i+2] == "AC":
    cumulative[i+2] = cumulative[i+1] + 1
  else:
    cumulative[i+2] = cumulative[i+1]
    
for _ in range(Q):
  start, end = map(int, input().split())
  ans = cumulative[end] - cumulative[start-1]
  if start > 1 and S[start-2:start] == "AC":
    ans -= 1
  print(ans)

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n,q=map(int,input().split())
s=input()
c=[0]
t=0
for i in range(1:N):
    t+=1 if (s[i-1]=='A' and s[i]=='C') else 0
    c.append(t)
for i in range(q):
    l,r=map(int,input().split())
    print(c[r]-c[l])

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

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

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


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

for i in range(Q):
    print(ans[i])

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


Verdicts: Runtime Error

Accepted