TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
a = input()
sum = 0
list = ["A","C","G","T"]
for i in range(len(a)):
  for j in list:
    if j in a[i]:
      sum += 1
    else:
      sum = 0
      
print(sum)

S = input()
m = 0
count = 0
for s in S:
  if "A" in s:
    count += 1
  elif "C" in s:
    count += 1
  elif "G" in s:
    count += 1
  elif "T" in s:
    count += 1
  else:
    count = 0
  m = max(m, count)
print(m)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
s = input()

l = 0
a = 0

for c in s:
    if c in "a↨c↨g↨t↨":
        l += 1
        a = max(a,l)
    else:
        l = 0
        
print(a)

S = input()

l = 0
a = 0
for ch in S:
    if ch in 'ACGT':
        l += 1
        a = max(a, l)
    else:
        l = 0
print(a)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
b = input()
len = len(b)
ACGT = 0
MAX = 0
flag = 0
for i in range(len):
  if b[i]=="A" or b[i]=="C" or b[i]=="G" or b[i]=="T":
    ACGT += 1
  else:
    MAX = ACGT
    ACGT = 0
    flag = 1
if flag ==0:
  MAX=ACGT
print(MAX)

b = input()
len = len(b)
ACGT = 0
MAX = 0
for i in range(b):
  if b[i]=="A" or b[i]=="C" or b[i]=="G" or b[i]=="T":
    ACGT += 1
  else:
    MAX = ACGT
    ACGT = 0
print(MAX)

b = input()
ACGT = 0
for i in range(len(b)):
  if b[i]=="A" or b[i]=="C" or b[i]=="G" or b[i]=="T":
    ACGT += 1
  else:
    MAX = ACGT
    ACGT = 0
print(MAX)

b = input()
len = len(b)
ACGT = 0
MAX = 0
flag = 0
for i in range(len):
  if b[i]=="A" or b[i]=="C" or b[i]=="G" or b[i]=="T":
    ACGT += 1
  else:
    if ACGT > MAX:
      MAX = ACGT
    ACGT = 0
if ACGT > MAX:
  MAX = ACGT
print(MAX)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S=input()
L=['A','C','G','T']
no=0
x=0
for i in S:
  if i in L:
    x+=1
  else:
    x=0
  ans=(x,no)
print(ans)

S=input()
L=['A','C','G','T']
no=0
x=0
for i in S:
  if i in L:
    x+=1
  else:
    x=0
  ans=max(x,no)
print(ans)


S=input()
L=['A','C','G','T']
ans=0
x=0
for i in S:
  if i in L:
    x+=1
  else:
    x=0
  ans=max(x,ans)
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S=str(input())
S2=[]
ans=0
for i in range(len(S)):
  for j in range(len(S)+1):
    S2=S[i:j]
    print(S2)
    que=len(S2)
    S2=S2.replace("A","")
    S2=S2.replace("G","")
    S2=S2.replace("C","")
    S2=S2.replace("T","")
    if S2=="":
      if que>ans:
        ans=que
    S2=[] 
print(ans)

S=str(input())
S2=[]
ans=0
for i in range(len(S)):
  for j in range(len(S)+1):
    S2=S[i:j]
    que=len(S2)
    S2=S2.replace("A","")
    S2=S2.replace("G","")
    S2=S2.replace("C","")
    S2=S2.replace("T","")
    if S2=="":
      if que>ans:
        ans=que
    S2=[] 
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S = input()

subStringList = []
length = len(S)

for i in range(length) :
    for j in range(1,length+1):
        if (i+j <= length) :
            subStringList.append(S[i:i+j])
        else:
            break


for s in subStringList[:]:
    for letter in s:
        if (not(letter in "ATGC")):
            subStringList.remove(s)
            break

print(len(max(subStringList)))


S = input()

subStringList = [S]
length = len(S)

counter = 0
before = 1

while (not(counter == before)):
    before = counter
    for s in subStringList[:]:
        for letter in s:
            if (not(letter in "ATGC")):
                subStringList += s.split(letter)
                subStringList.remove(s)
                counter = len(subStringList)
                break

print(len(max(subStringList,key=len)))


Verdicts: Runtime Error

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
s=input()
ans=0
cur=0
ACGT=set("A","C","G","T")
for ss in s:
  if ss in ACGT:
    cur+=1
  else:
    ans=max(cur,ans)
    cur=0
print(max(ans,cur))



S=input()
ACGT=["A","C","G","T"]
m=0
for i in range(len(S)):
  n=0
  while S[i] in ACGT:
    n+=1
  m=max(m,n)
print(m)

s=input()
ans=0
cur=0
ACGT=["A","C","G","T"]
for ss in s:
  if ss in ACGT:
    cur+=1
  else:
    ans=max(cur,ans)
    cur=0
print(max(ans,cur))



Verdicts: Runtime Error

Time Limit Exceeded

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S = input()
cnt = 0
max = 0
for str in S:
  if str in {'A', 'C', 'G', 'T'}:
    cnt += 1
  else:
    if max < cnt:
      max = cnt
    cnt = 0
if max < cnt:
  max = cnt
print(cnt)

S = input()

cnt = 0
max = 0
for str in S:
  if str in {'A', 'C', 'G', 'T'}:
    cnt += 1
  else:
    if cnt < max:
      max = cnt
    cnt = 0

print(cnt)

S = input()
cnt = 0
max = 0
for str in S:
  if str in {'A', 'C', 'G', 'T'}:
    cnt += 1
  else:
    if max < cnt:
      max = cnt
    cnt = 0
print(cnt)

    S = input()
     
    cnt = 0
    max = 0
    for str in S:
      if str in {'A', 'C', 'G', 'T'}:
        cnt += 1
      else:
        if max < cnt:
          max = cnt
        cnt = 0
     
    print(cnt)

S = input()
cnt = 0
max = 0

for str in S:
  if str in {'A', 'C', 'G', 'T'}:
    cnt += 1
  else:
    if max < cnt:
      max = cnt
    cnt = 0
    
if max < cnt:
  max = cnt
  
print(max)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
s = input()
ans = 0
for S in s:
  if S == "A":
    ans += 1
  elif S == "G":
    ans += 1
  elif S == "T":
    ans += 1
  elif S == "C":
    ans += 1
  else:
    ans = 0
    
print(ans)
s = input()
ans = 0
for S in s:
  if S == "A":
    ans += 1
  elif S == "G":
    ans += 1
  elif S == "T":
    ans += 1
  elif S == "C":
    ans += 1
  else:
    ans = 0
    
print(ans)


s = input()
ans = 0
for s in S:
  if s == "A":
    ans += 1
  elif s == "G":
    ans += 1
  elif s == "T":
    ans += 1
  elif s == "C":
    ans += 1
  else:
    ans = 0
    
print(ans)

s = input()
ans = 0
m = 0
for S in s:
  if S in "A":
    ans += 1
  elif S in "G":
    ans += 1
  elif S in "T":
    ans += 1
  elif S in "C":
    ans += 1
  else:
    ans = 0
  m = max(m,ans)
print(m)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
pat = ["A", "C", "G", "T"]

s = input()

left = right=0
ans = 0

while left<len(s):
  right = left
  while s[right] in pat:
    right+=1
  
  ans = min(ans, right - left)
  
  left = right+1
  
print(ans)

pattern = ["A", "T", "G", "C"]

s = input()

max_count = 0
count = 0
for c in s:
    if s in pattern:
        count += 1
    else:
        max_count = max(count, max_count)
        count = 0
max_count = max(count, max_count)
print(max_count)


pat = ["A", "C", "G", "T"]

s = input()

left = right = 0
ans = 0

while left < len(s):
    right = left
    while right < len(s) and s[right] in pat:
        right += 1

    ans = max(ans, right - left)

    left = right + 1

print(ans)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
s = str(input())
ACGT = {"A", "C", "G", "T"}

ans = 0
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        k = s[i: j]
        for l in k:
            if l not in ACGT:
                break
        else:
            ans = max(ans, len(t))
print(ans)


s = str(input())
ACGT = {"A", "C", "G", "T"}

ans = 0
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        t = s[i: j]
        for k in t:
            if k not in ACGT:
                break
        else:
            ans = max(ans, len(t))
print(ans)


Verdicts: Runtime Error

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S = str(input())
listS = list(S)

count = 0
max = 0

for i in range(len(listS)):
    if listS[i] == 'A' or listS[i] == 'T' or listS[i] == 'G' or listS[i] == 'C':
        count += 1
    else:
        max = count
        count = 0

print(max)     

S = str(input())
listS = list(S)

count = 0
max = 0

for i in range(len(listS)):
    if listS[i] == 'A' or listS[i] == 'T' or listS[i] == 'G' or listS[i] == 'C':
        print(listS[i])
        count += 1
        max = count
    else:
        count = 0

print(max)


S = str(input())
listS = list(S)

count = 0
max = 0

for i in range(len(listS)):
    if listS[i] == 'A' or listS[i] == 'T' or listS[i] == 'G' or listS[i] == 'C':
        print(listS[i])
        count += 1
        if count > max:
            max = count
    else:
        count = 0

print(max)

S = str(input())
listS = list(S)

count = 0
max = 0

for i in range(len(listS)):
    if listS[i] == 'A' or listS[i] == 'T' or listS[i] == 'G' or listS[i] == 'C':
        count += 1
        if count > max:
            max = count
    else:
        count = 0

print(max)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
s = input()
def check(a):
    ALLOWED = "ACGT"
    for c in a:
        if not c in ALLOWED:
            return False
    return True

ans = 0
for i in range(len(s)):
    for j in range(1, len(s) - i + 1):
        tmp = s[i: i + j]
        print(tmp)
        if check(tmp):
            ans = max(ans, len(tmp))
print(ans)


s = input()
def check(a):
    ALLOWED = "ACGT"
    for c in a:
        if not c in ALLOWED:
            return False
    return True

ans = 0
for i in range(len(s) - 1):
    for j in range(1, len(s) - i + 1):
        tmp = s[i: i + j]
        print(tmp)
        if check(tmp):
            ans = max(ans, len(tmp))
print(ans)


s = input()
def check(a):
    ALLOWED = "ACGT"
    for c in a:
        if not c in ALLOWED:
            return False
    return True

ans = 0
for i in range(len(s)):
    for j in range(1, len(s) - i + 1):
        tmp = s[i: i + j]
        if check(tmp):
            ans = max(ans, len(tmp))
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
s = input()
tgt = ['A', 'C', 'G', 'T']

lst = []
cnt = 0

for x in s:
  if x in tgt:
    cnt = cnt +1
  else:
    lst.append(cnt)
    cnt = 0

print(max(lst)


s = input()
tgt = ['A', 'C', 'G', 'T']

lst = []
cnt = 0

for x in s:
  if x in tgt:
    cnt = cnt +1
  else:
    lst.append(cnt)
    cnt = 0
    
lst.append(cnt)

print(max(lst))


Verdicts: Runtime Error

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S = str(input())
counter = 0
max = 0

for i in S:
    if i == 'A' or i == 'T' or i == 'C' or i == 'G':
        counter += 1
        if counter >= max:
            max = counter
    else:
        counter = 0

print(counter)

S = str(input())
counter = 0
max = 0

for i in S:
    if i == 'A' or i == 'T' or i == 'C' or i == 'G':
        counter += 1
        if counter >= max:
            max = counter
    else:
        counter = 0

print(max)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
s = input()
n = len(s)
a = [B,D,E,F,H,I,J,K,L,M,N,O,P,Q,R,S,U,V,W,X,Y,Z]
cnt = []
for i in range(n):
    for j in range(i,n+1):
    	fr = s[i;j]
    	value = 1
    	for k in a:
    		if k in fr:
    			value = 0
    	if value:
    		cnt.append(len(fr))
print(max(cnt))

s = input()
n = len(s)
a = "BDEFHIJKLMNOPQRSUVWXYZ"
cnt = []
for i in range(n):
    for j in range(i,n+1):
    	fr = s[i;j]
    	value = 1
    	for k in a:
    		if k in fr:
    			value = 0
    	if value:
    		cnt.append(len(fr))
    		
print(max(cnt))

s = input()
n = len(s)
a = [B,D,E,F,H,I,J,K,L,M,N,O,P,Q,R,S,U,V,W,X,Y,Z]
cnt = []
for i in range(n):
    for j in range(i,n+1):
    	fr = s[i;j]
    	value = 1
    	for k in a:
    		if k in fr:
    			value = 0
    	if value:
    		cnt.append(len(fr))
    		
print(max(cnt))

s = input()
n = len(s)
a = "BDEFHIJKLMNOPQRSUVWXYZ"
cnt = []
for i in range(0, n):
    for j in range(i,n+1):
    	fr = s[i:j]
    	value = 1
    	for k in a:
    		if k in fr:
    			value = 0
    	if value:
    		cnt.append(len(fr))
    		
print(max(cnt))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S = input()
F = "ATGC"
cnt = 0
n = len(S)
for i in range(n-1):
  for j in range(i+1, n):
    flg = True
    for k in range(i, j):
      flg *= (S[i] in F)
    if flg:
      cnt = max(cnt, j - i)
print(cnt)

S = input()
F = "ATGC"
cnt = 0
n = len(S)
for i in range(n):
  for j in range(i+1, n+1):
    flg = True
    for k in range(i, j):
      flg *= (S[k] in F)
    if flg:
      cnt = max(cnt, j - i)
print(cnt)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S = input()
ret = 0
for x in range(len(S)):
    for y in range(x + 1, len(S) + 1):
        s = S[x:y]
        print(s)
        if all([x in 'ACGT' for x in s]):
            ret = max(ret, len(s))
print(ret)

S = input()
ret = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        f = True
        for k in S[i:j + 1]:
            if k not in ("ACGT"):
                f = False
                break
        if f:
            ret = max(ret, (j + 1) - i)
print(ret)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
s = input()
chrlis = []
for i in range(len(s)):
  if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
    start = i
    for j in range(i,len(s)):
      if s[j]=="A" or s[j]=="C" or s[j]=="G" or s[j]=="T":
        end = j
      else:
        break
  else:
    continue
  chrlis.append(s[start:end+1])

ans = 0
for i in range(len(chrlis)):
  tmp = len(chrlis[i])
  if tmp>ans:
    ans = tmp
print(chrlis,ans)

s = input()
chrlis = []
for i in range(len(s)):
  if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
    start = i
    for j in range(i,len(s)):
      if s[j]=="A" or s[j]=="C" or s[j]=="G" or s[j]=="T":
        end = j
      else:
        break
  else:
    continue
  chrlis.append(s[start:end+1])

ans = 0
for i in range(len(chrlis)):
  tmp = len(chrlis[i])
  if tmp>ans:
    ans = tmp
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
print(max([sum(1 for _ in s[1]) if [0] == 'A' else 0 for s in __import__('itertools').groupby(input().replace('T', 'A').replace('G', 'A').replace('C', 'A'))]))

print(max([sum(1 for _ in s[1]) if s[0] == 'A' else 0 for s in __import__('itertools').groupby(input().replace('T', 'A').replace('G', 'A').replace('C', 'A'))]))

Verdicts: Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S = input()

partial = ""

conditions = ["A","T","G","C"]

conlist = []

con = 0

for i in range(0,len(S)):
	if S[i] in conditions:
		for j in range(0,i+1):
			print(S[j])
			if S[j] in conditions:
				con +=1
			if (S[j] not in conditions) or j == i:
				conlist.append(con)
				con = 0
				

if len(conlist) > 0:
	print(max(conlist))
else:print(0)



S = input()

partial = ""

conditions = ["A","T","G","C"]

conlist = []

con = 0

for i in range(0,len(S)):
	if S[i] in conditions:
		for j in range(0,i):
			if S[j] in conditions:
				con +=1
			if (S[j] not in conditions) or j == i:
				conlist.append(con)
				con = 0
				

print(max(conlist))

S = input()
M = 0
con = 0

L = ["A","C","G","T"]

for i,s in enumerate(S):
  if S[i] in L:
    con += 1
    M = max(M,con)
  elif S[i] not in L:
    con = 0
    M = max(M,con)

print(M)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
import re

S = input()
pattern = "[ATGC]*"

matched_list = sorted(re.findall(pattern, S),
                      key=lambda s: len(s),
                      reverse=True)
print(matched_list)
print(len(matched_list[0]))


import re

S = input()
pattern = "[ATGC]*"

matched_list = sorted(re.findall(pattern, S), key=len, reverse=True)
print(len(matched_list[0]))


Verdicts: Wrong Answer

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
S = input()
T = "ACGT"
ans = 0
for s in S:
    if s in T:
        cnt += 1
    else:
        if cnt > ans:
            ans = cnt
        cnt = 0
print(ans)

S = input()
T = "ACGT"
ans = 0
cnt = 0
for s in S:
    if s in T:
        cnt += 1
    else:
        if cnt > ans:
            ans = cnt
        cnt = 0
if cnt>ans:
    ans = cnt
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given a string S consisting of uppercase English letters. Find the length of the longest _ACGT string_ that is a substring (see Notes) of S.  Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Submission attempts (in order):
l=input()

if "A" or "G" or "C" or "T" not in l:
  print(0)
  exit()

ans=0
num=0
for i in l:
  print(i)
  if i=="A" or i=="G" or i=="C" or i=="T":
    num+=1
  else:
    ans=max(num,ans)
    num=0
    
print(ans)
    

l=input()

if "A" or "G" or "C" or "T" not in l:
  print(0)
  exit()

ans=0
num=0
for i in l:
  if i=="A" or i=="G" or i=="C" or i=="T":
    num+=1
  else:
    ans=max(num,ans)
    num=0
    
print(ans)
    


l=input()

ans=0
num=0

for i in l:
  if i=="A" or i=="G" or i=="C" or i=="T":
    num+=1
  else:
    ans=max(num,ans)
    num=0
ans=max(ans,num)
    
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()
al = [0] * N
al[0] = 0
for i in range(1,N):
    if s[i-1:i+1] == 'AC':al[i] = al[i-1]+1
    else:al[i]=al[i-1]
for _ in range(Q):
    l,r = map(int,input().split())
    print(l,r,':',al[r-1]-al[l-1])

N,Q = map(int,input().split())
s = input()
al = [0] * N
al[0] = 0
for i in range(1,N):
    if s[i-1:i+1] == 'AC':al[i] = al[i-1]+1
    else:al[i]=al[i-1]
for _ in range(Q):
    l,r = map(int,input().split())
    print(al[r-1]-al[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())
8 3
s = input()
ACACTACG
lr = list(list(map(int,input().split())) for i in range(q))
3 7
2 3
1 8

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

for i in range(q):
    print(sum(x[(lr[i][0]-1):(lr[i][1]-1)]))


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

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

for i in range(q):
    print(x[lr[i][1]-1]-x[lr[i][0]-1])


Verdicts: Runtime Error

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

Submission attempts (in order):
#N,Q=8,3
#S="ACACTACG"
#L = [3,2,1]
#R = [7,3,8]

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


sh=[0]
n=0
for i in range(1,N):
    if S[i-1] == "A" and S[i] == "C":
        n+=1
    sh.append(n)
for (l,r) in zip(L, R):
    print(sh[r-1]-sh[l-1])


#N,Q=8,3
#S="ACACTACG"
#L = [3,2,1]
#R = [7,3,8]

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

sh = [0]
n = 0
for i in range(1, N):
    if S[i - 1] == "A" and S[i] == "C":
        n += 1
    sh.append(n)
for (l, r) in zip(L, R):
    print(sh[r - 1] - sh[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()
Sum=[0]
sum=0
for i in range(1,n+1):
  sum=s[:i].count("AC")
  Sum.append(sum)
for i in range(q):
  l.r=map(int,input().split())
  print(Sum[r]-Sum[l])

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


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

Verdicts: Runtime Error

Wrong Answer

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
p = 'ACGT'
s = input()
l = len(s)
r = 0
i = -1
while i < l:
 j = next((i for i in range(i + 1, l) if s[i] in p), l)
 i = next((i for i in range(j + 1, l) if s[i] not in p), l)
 r = max(r, i - j)
print(r)


R = lambda: map(int, input().split())
n, q = R()
s = input()
a = [0] * n
c = 0
for i in range(1, n):
    if s[i-1: i+1] == 'AC': c += 1
    a[i] = c
for _ in range(q):
    l, r = R()
    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):
def main():
    N, Q = map(int, input().split(" "))
    S = input()
    result = [0] * (N + 1)
    for i in range(1, Q + 1):
        if S[i-1:i+1] == "AC":
            result[i] = result[i - 1] + 1
        else:
            result[i] = result[i - 1]
    for _ in range(Q):
        l, r = map(int, input().split(" "))
        print(result[l] - result[r - 1])


if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()

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,m=map(int,input().split())
s=input()
for i in m:
  a,b=map(int,input().split())
  lan=s[a-1:b]
  print(lan.count("AC"))

n,m=map(int,iput().split())
s=input()
ACsuu=[0 for i in range(n)]
for i in range(1,n):
  Acsuu[i]=ACsuu[i-1]+(1 if s[i-1:i+1]=="AC" else 0)
for i in range(m):
  a,b=map(int,input().split())
  print(ACsuu[b-1]-ACsuu[a-1])

n,m=map(int,input().split())
s=input()
ACsuu=[0 for i in range(n)]
for i in range(1,n):
  ACsuu[i]=ACsuu[i-1]+(1 if s[i-1:i+1]=="AC" else 0)
for i in range(m):
  a,b=map(int,input().split())
  print(ACsuu[b-1]-ACsuu[a-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()
place = []
for s in range(N - 1):
	if S[s] == 'A':
		if S[s + 1] == 'C':
			place.append(s)
PlaceCount = len(place)
for q in range(Q):
    num = 0
	l,r = map(int,input().split())
	l -= 1
	r -= 2
	for i in range(PlaceCount):
		if l <= place[i] <= r:
			num += 1
	print(num)

n,q = map(int,input().split())
s = input()
num = []
for Q in range(q):
	l,r = map(int,input().split())
	num.append(int(s[l - 1:r].count('AC')))
print('/n'.join(num))

N,Q = map(int,input().split())
S = input()
r = [0 for n in range(N)]
l = [0 for n in range(N)]
cnt = 0
for s in range(N - 1):
	if S[s] == 'A':
		if S[s + 1] == 'C':
			cnt += 1
	l[s + 1] = cnt
cnt = 0
for s in range(1,N):
	if S[-s] == 'C':
		if S[-s - 1] == 'A':
			cnt += 1
	r[-s - 1] = cnt
for q in range(Q):
	L,R = map(int,input().split())
	print(cnt - l[L - 1] - r[R - 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 = [int(x) for x in input().split()]

s = input()

arr = [0 for _ in range(len(s)+1)]

for i in range(len(s)-1):
	if s[i] == 'A' and s[i+1] == 'C':
		arr[i+2] += 1

for i in range(1, len(arr)):
	arr[i] = arr[i-1] + arr[i]

for i in range(1, len(arr)):
	print(arr[i], end=" ")
for _ in range(q):
	a, b = [int(x) for x in input().split()]
	print(str(arr[b]-arr[a]))

n, q = [int(x) for x in input().split()]

s = input()

arr = [0 for _ in range(len(s)+1)]

for i in range(len(s)-1):
	if s[i] == 'A' and s[i+1] == 'C':
		arr[i+2] += 1

for i in range(1, len(arr)):
	arr[i] = arr[i-1] + arr[i]

for _ in range(q):
	a, b = [int(x) for x in input().split()]
	print(str(arr[b]-arr[a]))

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)]
count=0
l=[0]*n
for i in range(1,n):
  if s[i-1]=="A" and s[i]=="C":
    count+=1
  l[i]=count
print(l)
for i in range(q):
  print(l[lr[i][1]-1]-l[lr[i][0]-1])

n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]
count=0
l=[0]*n
for i in range(1,n):
  if s[i-1]=="A" and s[i]=="C":
    count+=1
  l[i]=count
for i in range(q):
  print(l[lr[i][1]-1]-l[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 = map(int, input().split())
s = input()
ac = [0] * n
c = 1
for i in range(n - 1):
    if s[i] == 'A' and s[i + 1] == 'C':
        ac[i] = c
        c += 1
for i in range(q):
    l, r = map(int, input().split())
    s, f = 0, 0
    for j in range(l - 1, r - 1):
        if ac[j] != 0:
            s = ac[j]
            break
    j = r - 2
    while j >= l:
        if ac[j] != 0:
            f = ac[j]
            break
        j -= 1
    print(f - s + 1)

n, q = map(int, input().split())
s = input()
ac = [0] * n
c = 0
for i in range(1, n):
    if s[i - 1] == 'A' and s[i] == 'C':
        c += 1
    ac[i] = c
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):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s):
 if n>100:

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break


n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s):
 if n>=10000:

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break

n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s)-1:
 #if n<10000:

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-2]-a[l-1]
    print(s)
  except:
      break

n,q=map(int,input().split())
s=list(input())
#print(s)
i=1
a=[0]
x=0
while i!=n:
    if s[i-1]=="A":
        if s[i]=="C":
            x=x+1
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break

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

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


Verdicts: Wrong Answer

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

Submission attempts (in order):
N,Q=map(int,input().split())

S=input()

ACDP=[0]*N
Aflag=0
ACcount=0
for i in range(len(S)):
  if S[i]=='A':
    Aflag=1
  else:
    Aflag=0
  if S[i]=='C' and Aflag==1:
    ACcount+=1
  ACDP[i]=ACcount
print(ACDP)

for _ in range(Q):
  start,end=map(int,input().split())
  print(ACDP[end-1]-ACDP[start-1]

N,Q=map(int,input().split())
 
S=input()
 
ACDP=[0]*N
Aflag=0
ACcount=0
for i in range(len(S)):
  if S[i]=='C' and Aflag==1:
    ACcount+=1
  if S[i]=='A':
    Aflag=1
  else:
    Aflag=0
  ACDP[i]=ACcount
#print(ACDP)
 
for _ in range(Q):
  start,end=map(int,input().split())
  print(ACDP[end-1]-ACDP[start-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 = [list(map(int, input().split())) for _ in range(Q)]
dp = [0] * (N)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        dp[i+1] = dp[i] + 1
    else:
        dp[i+1] = dp[i]

for l, r in LR:
    print(dp[r-1] - dp[l-1])
print(dp)


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

for l, r in LR:
    print(dp[r-1] - dp[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 = str(input())
N,Q = 8,3
S = "ACACTACG"
L = [0] * len(S) 
i = 0
while i < len(S)-1:
    if S[i] == "A":
        if S[i+1] == "C":
            L[i] = 1
            i += 1
        elif S[i+1] == "A":
            i += 1
        else:
            i += 2
    else:
        i += 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(sum(L[l-1:r-1]))


N,Q = map(int, input().split())
S = str(input())
# N,Q=8,3
# S = "ACACTACG"
L = [0] * len(S) 
i = 0
sum_i = 0
while i < len(S)-1:
    if S[i] == "A":
        if S[i+1] == "C":
            L[i] = sum_i
            sum_i += 1
            L[i+1] = sum_i
            i += 2
        elif S[i+1] == "A":
            L[i] = sum_i
            i += 1
        else:
            L[i] = sum_i
            L[i+1] = sum_i
            i += 2
    else:
        L[i] = sum_i
        i += 1
L[len(S)-1] = sum_i
for _ in range(Q):
    l, r = map(int, input().split())
    print(L[r-1] - L[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]
for i in range(1,N):
    if S[i-1]+S[i]=='AC':
        a.append(1)
    else:
        a.append(0)
print(a)
b=[]
sum=0
b.append(sum)
for x in a:
    sum+=x
    b.append(sum)
print(b)
for i in range(Q):
    l,r=map(int,input().split())
    print(b[r]-b[l])

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

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

print(lc)

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


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

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

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


Verdicts: Wrong Answer

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

Submission attempts (in order):
n, q = list(map(int, input().split()))
s = input()

acs = [0] * (n - 1)

for i in range(n - 1):
  if i == 0:
    if s[0 : 2] == "AC":
      acs[0] += 1
  else:
    if s[i : i + 2] == "AC":
      acs[i] = acs[i - 1] + 1
    else:
      acs[i] = acs[i - 1]
      
print(acs)

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

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

acs = [0] * (n)

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

print(acs)

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

n, q = list(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[i] + 1
  else:
    ac[i + 1] = ac[i]

for _ in range(q):
  l, r = list(map(int, input().split()))
  print(ac[r - 1] - ac[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 = [int(item) for item in input().split()]
s = input()
lr = [[int(item) for item in input().split()] for _ in range(q)]

is_ac = [0] * n
count = 0
for i in range(n-1):
  if s[i] == "A":
    if s[i+1] == "C":
      count += 1
  is_ac[i+1] = count
is_ac[-1] = count
print(is_ac)
for item in lr:
  ans = is_ac[item[1]-1] - is_ac[item[0]-1]
  print(ans)

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

is_ac = [0] * n
count = 0
for i in range(n-1):
  if s[i] == "A":
    if s[i+1] == "C":
      count += 1
  is_ac[i+1] = count
is_ac[-1] = count
for item in lr:
  ans = is_ac[item[1]-1] - is_ac[item[0]-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 = list(input())
x = []

ans = 0
for i in range(n):
	if s[i] == "A" and s[i+1] == "C":
		ans += 1
		x.append(ans)
	else:
		x.append(ans)
x.append(ans)

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

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

import math
n=int(input())
a=[int(i) for i in input().split()]

L=[0]*(n+1)
R=[0]*(n+1)
ans=0
for i in range(n):
    L[i]=math.gcd(L[i-1],a[i])
for i in reversed(range(n)):
    R[i]=math.gcd(R[i-1],a[i])
for i in range(n):
    if math.gcd(L[i-1],R[i+1]) > ans:
        ans=math.gcd(L[i-1],R[i-1])

print(ans)


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

ans = 0
for i in range(n):
	if s[i] == "A" and s[i+1] == "C":
		ans += 1
		x.append(ans)
	else:
		x.append(ans)

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

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

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

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

ans = 0
for i in range(len(s)-1):
	if s[i] == "A" and s[i+1] == "C":
		ans += 1
		x.append(ans)
	else:
		x.append(ans)
x.append(ans)

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

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

for i in range(q):
    ans=0
    l,r=map(int,input().split())
    x=s[l-1:r]
    for h in range(len(x)+1):
        if s[i:i+1]==["A","C"]:
            ans+=1
print(ans)

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

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted