Problem:


Score : 200 points

Problem Statement

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.

Notes

A substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.

For example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and  (the empty string), but not AC.

Constraints

S is a string of length between 1 and 10 (inclusive).

Each character in S is an uppercase English letter.

Input

Input is given from Standard Input in the following format:

S

Output

Print the length of the longest ACGT string that is a substring of S.

Sample Input 1

ATCODER

Sample Output 1

3

Among the ACGT strings that are substrings of ATCODER, the longest one is ATC.

Sample Input 2

HATAGAYA

Sample Output 2

5

Among the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.

Sample Input 3

SHINJUKU

Sample Output 3

0

Among the ACGT strings that are substrings of SHINJUKU, the longest one is  (the empty string).



Sample input:
ATCODER


Sample output:
3

Submission status: Accepted

Solution code:
S=list(input())
Count=[]
for i in range(len(S)):
    if S[i] in ['A','C','T','G']:
        Count.append(1)
    else:
        Count.append(0)
c=0
m=[]
for i in range(len(S)):
    if Count[i]==1:
        c+=1
        m.append(c)
        continue
    else:
        c*=0
        m.append(c)
        continue


print(max(m))

Submission status: Accepted

Solution code:
s = input()
a=0
b=0
for i in s:
    if i == "A" or i == "G" or i == "C" or i == "T":
        a+=1
    elif b<=a:
        b=a
        a=0
if a < b:
    print(b)
else:
    print(a)

Submission status: Accepted

Solution code:
s=list(input())
cnt = 0
ans = 0
for i in s:
  if i == "A" or i == "G" or i == "C" or i == "T":
    cnt += 1
    ans = max(ans,cnt)
  else:
  	cnt = 0
print(ans)

Submission status: Accepted

Solution code:
S=input()
cnt1=0
for i in range(len(S)):
  cnt2=0
  for j in range(i,len(S)):
    if S[j] in ("A","C","G","T"):
      cnt2+=1
    else:
      break
  cnt1=max(cnt1,cnt2)
print(cnt1)

Submission status: Accepted

Solution code:
S=input()
max=0
for i in range(0,len(S)):
    if S[i] in ('A','C','G','T'):
        i+=1
        cnt=1
        while i<len(S) and S[i] in ('A','C','G','T'):
            i+=1
            cnt+=1
        if cnt > max:
            max=cnt
            cnt=0
print(max)

Submission status: Accepted

Solution code:
S = input()
s_list = list(S)

acgt = list("ACGT")

max_length = 0
max_length_bottom = 0

tmp_length = 0
for i, s in enumerate(s_list):
    if s in acgt:
        tmp_length += 1
    if tmp_length > max_length:
        max_length = tmp_length
#         max_length_bottom =i
    if s not in acgt:
        tmp_length = 0
        
print(max_length)

Submission status: Accepted

Solution code:
import re

S = input()

pattern = '[A|C|G|T]+'
matchall = re.findall(pattern, S)

if matchall:
    print(max(map(len,matchall)))
else:
    print('0')

Submission status: Accepted

Solution code:
S = input()
L = len(S)

ans = 0
counter = 0
for i in range(L):
    if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
        counter += 1
    else:
        if ans < counter:
            ans = counter
        counter = 0

if ans < counter:
    ans = counter
    
print(ans)

Submission status: Accepted

Solution code:
S = input()
m = 0
l = []

for k in range(len(S)):#開始位置
    for i in range(1,len(S)+1-k):#文字数
        moji = ""
        check = True
        for j in range(i):#番目
            #print(S[j+k])
            if not check:
                break
            if S[j+k] == "A" or S[j+k] == "T" or S[j+k] == "C" or S[j+k] == "G":
                moji += S[j+k]
            else:
                check = False
        #print(moji)
        l.append(len(moji))
        #check
        #for str_ in moji:
print(max(l))

Submission status: Accepted

Solution code:
S = input()

length = 0
longest = 0

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

for i in range(len(S)):
    if S[i] in agct:
        length += 1
        if length > longest:
            longest = length
    else:
        length = 0

print(longest)

Submission status: Accepted

Solution code:
s = [i for i in input()]
ans = 0
tmp = 0
acgt = ['A', 'C', 'G', 'T']
while s:
  if s.pop(0) in acgt:
    tmp += 1
  else:
    ans = max([ans, tmp])
    tmp = 0

ans = max([ans, tmp])
print(ans)

Submission status: Accepted

Solution code:
#coding-utf-8

def main():
    s = str(input())
    slist = list(s)
#   print(slist)
    stk = []
    c = []
    lenmax = 0
    for i in range(len(slist)):
        if slist[i] == 'A' or slist[i] =='C' or slist[i] =='G' or slist[i] =='T':
            stk.append(slist[i])
            if i == len(slist) - 1:
                c.append(stk)
        else:
            c.append(stk)
            if len(stk) > 0:
                stk = []
                c.append(stk)
            stk = []

#   print(c)

    for j in range(len(c)):
        if len(c[j]) > lenmax:
            lenmax = len(c[j])

    print(lenmax)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
m = 0
count = 0
for i in s:
  if i in ["A","C","G","T"]: count+=1
  else: count=0
  m = max(m,count)
print(m)

Submission status: Accepted

Solution code:
import re

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

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

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

Submission status: Accepted

Solution code:
S = input()

cnt = 0
maxcnt = 0
for i in range(len(S)):
    if S[i]=="A" or S[i]=="T" or S[i]=="G" or S[i]=="C":
        cnt += 1
    else:
        if cnt>maxcnt:
            maxcnt = cnt
            cnt = 0
        else:
            cnt = 0
print(max(cnt, maxcnt))

Submission status: Accepted

Solution code:
s = input()

count = 0
m = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import re

def main():
    s = input()
    substrs = re.split('[^ACGT]', s)
    print(max(list(map(len, substrs))))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
  S = input()
  acgts = ['']
  for b in range(len(S)):
    for e in range(b + 1, len(S) + 1):
      span = S[b:e]
      if not span.replace('A', '').replace('G', '').replace('C', '').replace('T', ''):
        acgts.append(span)
  print(max([len(x) for x in acgts]))


if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
s = input()
V = [s[j] for j in range(0,len(s))]
countG = 0
countL = 0
for j in range(0,len(s)):
	if s[j] != 'A' and s[j] != 'T' and s[j] != 'C' and s[j] != 'G':
		countL = 0
	else:
		countL = countL + 1
	countG = max([countG,countL]) 
print(countG)

Submission status: Accepted

Solution code:
ex = input()
a = ex.replace('A','*')
b = a.replace('T','*')
c = b.replace('G','*')
d = c.replace('C','*')
ans = 0
for i in range(10):
    if '*'*(i+1) in d:
        ans = i+1
print(ans)

Submission status: Accepted

Solution code:
S = input()

counter = 0
pib = 0
for i in S:
    if i in 'AGCT':
        counter += 1
    else:
        counter = 0
    if pib < counter:
        pib = counter
print(pib)

Submission status: Accepted

Solution code:

S = input()
ARR = ['A', 'C', 'G', 'T']

results = []
count = 0
for i in range(len(S)):
    if S[i] in ARR:
        count+=1
        results.append(count)
    else:
        results.append(count)
        count = 0

print(max(results))

Submission status: Accepted

Solution code:
import re
s=input()
s1=re.sub(r'[BD-FH-SU-Z]','*',s)
s2=s1.split('*')
l1=[len(s2[i]) for i in range(len(s2))]
print(max(l1))

Submission status: Accepted

Solution code:
S = input()


def is_acgt(c):
    return c == 'A' or c == 'C' or c == 'G' or c == 'T'


succession = 0
max_succession = 0
for c in S:
    if is_acgt(c):
        succession += 1
    else:
        max_succession = max(succession, max_succession)
        succession = 0
print(max(succession, max_succession))

Submission status: Accepted

Solution code:
import re
s=input()
s1=re.sub(r'[BD-FH-SU-Z]','*',s)
s2=s1.split('*')
l1=[len(s2[i]) for i in range(len(s2))]
print(max(l1))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

s = list(input().strip())
l = []

b = ""
for v in s:
    if v in ["A", "G", "C", "T"]:
        b += v
    else:
        l.append(b)
        b = ""
l.append(b)

print(max([len(v) for v in l]))

Submission status: Accepted

Solution code:
import re

print(max(map(len, re.split("[^ACGT]", input()))))

Submission status: Accepted

Solution code:
S = input()
n = len(S)
li = list(S)

ans = 0
lians = []
for i in range(n):
  if li[i] == "A" or li[i] =="G" or li[i] =="C" or li[i] =="T":
    ans += 1
  else:
    lians.append(ans)
    ans = 0
lians.append(ans)
print(max(lians))

Submission status: Accepted

Solution code:
s = input()
set = {'A', 'T', 'G', 'C'}
l, ans = 0, 0
for i in range(len(s)):
  if s[i] in set:
    l += 1
  else:
    ans = max(l, ans)
    l = 0
ans = max(l, ans)
print(ans)

Submission status: Accepted

Solution code:
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return map(int, input_tuple)


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    s = input()
    acgt = ['A', 'C', 'G', 'T']

    count = 0
    max_count = 0
    for i in s:
        if i in acgt:
            count += 1
            max_count = max(count, max_count)
        else:
            count = 0

    print(max_count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#ATCGを小文字へ置き換え、小文字を抽出する作戦
S=input().replace("A","a").replace("T","t").replace("C","c").replace("G","g")

#小文字の列を取得
import re
list=re.findall(r"[a-z]+",S)

#各列の文字列の長さをリストに
list2=[]
for i in range(len(list)):
  list2.append(len(list[i]))
  
#リストが空の場合との場合分け
if list2 ==[]:
  print(0)
else:
  print(max(list2))

Submission status: Accepted

Solution code:
# coding: utf-8
s = input()
s += 'X'
here = 0
res = -100

for c in s:
    counter = 0
    char = c
    while char == 'A' or char == 'C' or char == 'G' or char == 'T':
        counter += 1
        char = s[here + counter]
    if counter > res:
        res = counter
    here += 1

print(res)

Submission status: Accepted

Solution code:
S = str(input())+"_"
cnt, ans = 0, 0
acgt = set(["A","T","G","C"])
for i in range(len(S)):
    if S[i] not in acgt:
        ans=max(ans, cnt)
        cnt=0
    else:
        cnt+=1
print(ans)

Submission status: Accepted

Solution code:
item=list(input())
result=0
sign=0
search=['A','C','G','T']
for i in range(len(item)):
    if item[i] in search:
        sign=sign+1
        continue
    if sign>result:
        result=sign
        sign=0
if sign>result:
    result=sign
print(result)

Submission status: Accepted

Solution code:
S=list(input())
AGCT=["A","G","C","T"]
count=0
Max=0
for i in range(len(S)):
    if S[i] in AGCT:
        count+=1
        if Max<count:
            Max=count
    else:
        count=0
print(Max)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = 0
for l in range(N):
    for r in range(l+1, N+1):
        T = S[l:r]
        ok = True
        for c in T:
            if c not in 'ACGT':
                ok = False
                break
        if ok:
            ans = max(ans, r-l)
print(ans)

Submission status: Accepted

Solution code:
S = input()
count = 0
max = 0
atcg = ('A', 'T', 'C', 'G')

for i in range(len(S)):
  if S[i] in atcg:
    count += 1
    if max < count:
        max = count
  else:
    count = 0
    
print(max)

Submission status: Accepted

Solution code:
s = input()
count = 0
_max = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        count += 1
        _max = max(_max, count)
    else:
        count = 0
print(_max)

Submission status: Accepted

Solution code:
s = input()
max = 0
l = 0
L = ["A","T","C","G"]
for i in range(len(s)):
  if s[i] in L:
    l += 1
  else:
    if max <= l:
      max = l
    l = 0
if max <= l:
  max = l
print(max)

Submission status: Accepted

Solution code:
S = input()
listS = []
for i in range(len(S)):
  listS.append(S[i])
  

def check_ACGT(array):
  cnt = 0
  for i, elm in enumerate(array):
    if elm not in ["A", "C", "G", "T"]:
      cnt += 1
  return True if cnt == 0 else False

ans = 0
for i in range(len(listS)):
  for j in range(len(listS)):
    if i<j+1:
      sublistS = listS[i:(j+1)]
      if check_ACGT(sublistS) and ans < len(sublistS):
        ans = len(sublistS)

print(ans)

Submission status: Accepted

Solution code:
s = input()
flag = 0
cnt = 0
ans = 0
for i in range(len(s)):
  if flag == 1:
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
      cnt += 1
    else:
      flag = 0
      if cnt > ans:
        ans = cnt
  else:
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
      flag = 1
      cnt = 1
if cnt > ans:
  ans = cnt
print(ans)

Submission status: Accepted

Solution code:
a = input()

b = 'ACGT'
ans =0
for i in a:
    now = 0
    for j in a:
        if j in b:
            now += 1
            ans = max(ans,now)
        else:
            now=0
print(ans)

Submission status: Accepted

Solution code:
s = input()
l = 'ACGT'
ans = 0
most = 0
for i in s:
    if i in l:ans+=1
    else:ans=0
    if ans > most:most=ans
print(most)

Submission status: Accepted

Solution code:
S = str(input())
S = list(S)

count = 0
list_count = []
for s in S:
    if s == 'A' or s == 'T' or s == 'C' or s == 'G':
        count += 1
        list_count.append(count)
    else:
        count = 0

if len(list_count) == 0:
    print('0')
else:
    print(max(list_count))

Submission status: Accepted

Solution code:
import re;s=input();m=[len(p.group(0))for p in re.finditer('[ACGT]+',s)];print(max(m+[0]))

Submission status: Accepted

Solution code:
S=input()
n=len(S)
l='ACTG'
ans=0
for i in range(0,n+1):
  for j in range(i,n+1):
    a=S[i:j]
    if set(l)>=set(a):
      ans=max(ans,len(a))
print(ans)

Submission status: Accepted

Solution code:
S=input()
n=len(S)
l='ACTG'
ans=0
for i in range(0,n):
  for j in range(i,n+1):
    a=S[i:j]
    if set(l)>=set(a):
      ans=max(ans,len(a))
print(ans)

Submission status: Accepted

Solution code:
b=str(input())
setb=['A','T','C','G']
lenmax=0
lenmaxlist=[]
for i in range(len(b)):
    if b[i] in setb:
        lenmax=lenmax+1;
    else:
        lenmaxlist.append(lenmax)
        lenmax=0
if lenmax>0:
    lenmaxlist.append(lenmax)
if lenmaxlist:
    print(max(lenmaxlist))
else:
    print(0)

Submission status: Accepted

Solution code:
s = input()
chars = ['A', 'T', 'C', 'G']
count = 0
ans = 0
for c in s:
  if (c in chars):
    count += 1
    ans = max(ans, count)
  else:
    count = 0

print(ans)

Submission status: Accepted

Solution code:
b = input()
ans = []
cnt = 0

for i in b:
    if i in "ACTG":
        cnt+=1
    else:
        ans.append(cnt)
        cnt = 0

ans.append(cnt)

print(max(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(S: str):
    longest = 0
    count = 0
    for s in S:
        if s in ['A','T','G','C']:
            count += 1
        else:
            count = 0
        if count > longest:
            longest = count
    print(longest)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
ls = list(S)
ans = 0
for i in range(len(ls)):
    cnt = 0
    for j in range(i,len(ls)):
        if S[j] in ['A','T','C','G']:
            cnt += 1
            if j == len(ls) - 1:
                ans = max(ans,cnt)
        else:
            ans = max(ans,cnt)
            break
print(ans)

Submission status: Accepted

Solution code:
import copy
ls=list(input())
ans=0
#ans1=0
ans_ls=[]
#print(ls)
for i in range(len(ls)):
    if ls[i]=='A' or ls[i] == 'C' or ls[i] == 'G' or ls[i] == 'T':
        ans=ans+1
        #print(ans)
    else:
        #print(ans)
        ans1=ans
        #print(ans1)
        ans_ls.append(ans1)
        ans=0
ans_ls.append(ans)
#print(ans_ls)
print(max(ans_ls))

Submission status: Accepted

Solution code:
j = 0
i = 0
count = 0
max_count = 0
b = input()

b = b.replace('A','*')
b = b.replace('T','*')
b = b.replace('G','*')
b = b.replace('C','*')

while i < len(b):
    if b[i] == "*":
        while i + j < len(b):
            if b[i+j] == "*":
                count += 1
                j += 1
            else:
                i = i + j
                j = 0
                break
        if count >= max_count:
            max_count = count
            count = 0
    i += 1
    
print(max_count)

Submission status: Accepted

Solution code:
S = input()
acgt = ["A", "C", "G", "T"]
cnts = []
cnt = 0
for i in range(len(S)):
	if S[i] in acgt:
		cnt += 1
		cnts.append(cnt)
	else:
		cnts.append(cnt)
		cnt = 0
print(max(cnts))

Submission status: Accepted

Solution code:
s = input()

s_len = len(s)
acgt_len = 0
chg_flag = 0
cnt_buf = 0
cnt = 0
for i in range(len(s)):
    if s[i] in ["A", "C", "G", "T"]:
        cnt += 1
    elif cnt_buf <= cnt:
        cnt_buf = cnt
        cnt = 0
    else:
        cnt = 0

if cnt_buf <= cnt:
    acgt_len = cnt
else:
    acgt_len = cnt_buf

print(acgt_len)

Submission status: Accepted

Solution code:
S=input()
max=0
cnt=0
key=False
li=['A','C','G','T']
for i in S:
    for j in li:
        if i==j:
            key=True
            cnt+=1
            if max<cnt:
                max=cnt
            break
        else:
            key=False
    if key==False:
        cnt=0
print(max)

Submission status: Accepted

Solution code:
import re
s=input()
r=[0]
for i in re.finditer("[ACGT]+", s):
    r.append(len(i.group()))
print(max(r))

Submission status: Accepted

Solution code:
s=input()
len=0
ans=0
for c in s:
    if c in "AGCT":
        len+=1
        ans=max(ans,len)
    else:
        len=0
print(ans)

Submission status: Accepted

Solution code:
c=p=0
a=input()
for i in range (len(a)):
	if a[i]=='A' or a[i]=='C' or a[i]=='G' or a[i]=='T':
		p+=1
	else:
		p=0
	if p>c:
		c=p
print(c)

Submission status: Accepted

Solution code:
s=input()
res=[]
for i in range(len(s)):
    for j in range(i,len(s)+1):
        t=s[i:j]
        if all([k in ["A","T","G","C"] for k in list(t)]):
            res.append(len(t))
print(max(res))

Submission status: Accepted

Solution code:
S = input()
n = 0
atgc = [0] * len(S)

for i in S:
    if ('A' in i) or ('C' in i) or ('G' in i) or ('T' in i):
        atgc[n] += 1
    else:
        n += 1
        
ans = max(atgc)
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
cnt = 0
num_list = [0]
for i in S:
    if i == "A" or i == "T" or i == "G" or i == "C":
        cnt += 1
        num_list.append(cnt)
    else:
        cnt = 0
print(max(num_list))

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

def solve():
    S = input()

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
S=input()
ct=0
max=0
for s in S:
  if s=='A' or s=='T' or s=='G' or s=='C':
    ct+=1
    if ct > max:
      max=ct
  else:
    ct=0
print(max)

Submission status: Accepted

Solution code:
s=input()
s_2=[1 if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T" else 0 for i in range(len(s))]
s_3=0
for j in range(len(s)):
    s_3+=s_2[j]*(10**j)
s_3=str(s_3)
ans=0
for k in range(len(s)+1):
    if "1"*k in s_3:
        ans=k
print(ans)

Submission status: Accepted

Solution code:
import re
print(max(map(len,re.split('[^ACTG]',input()))))

Submission status: Accepted

Solution code:
import re
regex=(r'[A|C|G|T]+')
s=input()
mo=re.findall(regex,s)
print(len(max(mo,key=len)) if mo!=[] else 0)

Submission status: Accepted

Solution code:
import sys
import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

s = input()

i = 0
j = 0
ret = 0
while i < len(s):
    while j < len(s) and s[j] in "ACGT":
        j += 1
    ret = max(ret, j - i)
    j += 1
    i = j
print(ret)

Submission status: Accepted

Solution code:
S = str(input())
A = 'ACGT'
L = len(S)

cnt = 0
max_cnt = 0
for x in S:
    if x in A:
        cnt += 1
    else:
        if max_cnt < cnt:
            max_cnt = cnt
        cnt = 0
if max_cnt < cnt:
    max_cnt = cnt

print(max_cnt)

Submission status: Accepted

Solution code:
x=input()
N=len(x)
maxl=0
for i in range(N):
  if (x[i]=="A")or(x[i]=="T")or(x[i]=="G")or(x[i]=="C"):
    j=1
    while (i+j<N):
      if ((x[i+j]=="A")or(x[i+j]=="T")or(x[i+j]=="G")or(x[i+j]=="C")):
        j=j+1
      else:
        break
    if maxl<j:
      maxl=j
      maxi=i
    
print(maxl)

Submission status: Accepted

Solution code:
s = input().strip()

ok_list = ['A', 'T', 'C', 'G']

max_len, i = 0, 0

while i < len(s):
    if s[i] in ok_list:
        l = 0
        while i < len(s) and s[i] in ok_list:
            i += 1
            l += 1

        if l > max_len:
            max_len = l

    else:
         i += 1

print(max_len)

Submission status: Accepted

Solution code:
c = list(input())
ans = 0
for i in range(len(c)):
    j = i
    count = 0
    judge = True
    while judge and j <= len(c)-1:
        # print("a")
        if ((c[j] == "A") or (c[j] == "C") or (c[j] == "G") or (c[j] == "T")):
            judge = True
            count += 1
            j += 1
        else:
            judge = False
    ans = max(ans,count)
print(ans)

Submission status: Accepted

Solution code:
S = input()
L = ["A","C","G","T"]
ans = 0
for i in range(len(S)):
  for j in range(i+1,len(S)+1):
    s = S[i:j]
    ok = True
    for c in s:
      if not c in L:
        ok = False
    if ok:
      ans = max(ans,j-i)
print(ans)

Submission status: Accepted

Solution code:
S = input()
acgt_tmp = 0
acgt_max = 0

for s in S+'$':
  if s in ['A','C','G','T']:
    acgt_tmp += 1
  else:
    if acgt_tmp>acgt_max:
      acgt_max = acgt_tmp
    acgt_tmp = 0

print(acgt_max)

Submission status: Accepted

Solution code:
s=0
n=0
for i in list(input()):
  if i in {'A','T','C','G'}:
    n+=1
  else:
    n=0
  s=max(s,n)
print(s)

Submission status: Accepted

Solution code:
a=input()
b="ACGT"
c=d=0
for i in range((len(a))):
    if a[i] in b:
        c+=1
    else:
        c=0
    d=max(c,d)
print(d)

Submission status: Accepted

Solution code:
S = input()
cnt = 0
ans = 0
for s in S:
    if s in "ATCG":
        cnt += 1
    else:
        cnt = 0
    ans = max(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
A = 'ATGC'
 
S = input()
leng = 0
k = 0
 
for s in S:
  if s in A:
    k += 1
  else:
    if k > leng:
      leng = k
      k = 0
      
print(max(k, leng))

Submission status: Accepted

Solution code:
s = input()
ans = 0

for i in range(len(s)):
  for j in range(len(s) - i):
    s1 = s[i:len(s) - j]
    flag = 1
    for k in range(len(s1)):
      if s1[k] != "A" and s1[k] != "C" and s1[k] != "G" and s1[k] != "T":
        flag = 0
        break
    if flag == 1 and len(s1) > ans:
      ans = len(s1)
print(ans)

Submission status: Accepted

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = list(input())
clst=[]
count = 0
for s in S:
    if s == 'A' or s == 'T' or s =='C' or s == 'G':
        count += 1
        clst.append(count)
    else:
        
        count = 0
        clst.append(count)
print(max(clst))

Submission status: Accepted

Solution code:
s = list(input())
len = 0
max_len = 0
for str in s:
    if str in ["A", "C", "G", "T"]:
        len += 1
    else:
        if len > max_len:
            max_len = len
        len = 0
else:
    if len > max_len:
        max_len = len
print(max_len)

Submission status: Accepted

Solution code:
def judge(ch):
    if ch in "ACGT":
        return True
    else:
        return False


s = input()
ans, tmp = 0, 0
for ch in s:
    if judge(ch):
        tmp += 1
    else:
        tmp = 0
    ans = max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
import re
a = re.sub('[^ACGT]+',' ',input()).split()
len_list = [len(x) for x in a]
if not len_list:
  print('0')
else:
  print(max(len_list))

Submission status: Accepted

Solution code:
S=set(["A","C","G","T"])
L=list(input())
A=[]
M=0
for i in L :
  if i in S :
    M+=1
  else :
    A.append(M)
    M=0
A.append(M)
print(max(A))

Submission status: Accepted

Solution code:
s=list(input())
l=len(s)
ma=0
pr=0
for i in range(l):
  if s[i]=='A' or s[i]=='G' or s[i]=='T' or s[i]=='C':
    ma +=1
    pr=max(pr,ma)
  else:
    ma=0
print(pr)

Submission status: Accepted

Solution code:
# B - ATCoder
s = input()
agct = ["A", "G", "C", "T"]
r = re = 0
for i in s:
	if i in agct:
		r += 1
	else:
		re = max(re, r)
		r =0
print(max(re, r))

Submission status: Accepted

Solution code:
S = str(input())
m =0
maxi = 0
for i in range(0,len(S)):
    if S[i] == 'A' or S[i] == 'G'or S[i] == 'C'or S[i] == 'T' :
        m = m + 1 
        maxi = max(maxi,m)
    else:
        m = 0
        maxi = maxi
print(maxi)

Submission status: Accepted

Solution code:
S = str(input())
lists = []
result = []
max = 0
for i in range(len(S)):
    for j in range(len(S)):
        result.append(S[i:len(S) - j])
for i in range(len(result)):
    cnt = 0
    for j in range(len(result[i])):
        m = list(result[i])
        if m[j] == "A" or m[j] == "C" or m[j] == "G" or m[j] == "T":
            cnt += 1
    if cnt == len(result[i]):
        lists.append(result[i])
        if max < len(result[i]):
            max = len(result[i])
print(max)

Submission status: Accepted

Solution code:
S = input()

slist = []
s = ''
for i in range(len(S)):
    if S[i] in 'ATGC':
        s += S[i]
    else:
        slist.append(s)
        s = ''
if S[-1] in 'ATGC':
    slist.append(s)

lenlist = [len(slist[i]) for i in range(len(slist))]
print(max(lenlist))

Submission status: Accepted

Solution code:
import re

# B
s = input()
print(max(map(len,re.sub(r'[^ATCG]', ' ',s).split(' '))))

Submission status: Accepted

Solution code:
s = input()
ss = ""
for i in range(len(s)):
    if s[i] not in ["A", "T", "G", "C"]:
        ss += " "
    else:
        ss += s[i]
l = ss.split()
# print(l)
m = 0
for ll in l:
    if (len(ll)) > m:
        m = len(ll)
print(m)

Submission status: Accepted

Solution code:
S = input()

ACGT = "ACGT"

i = 0

result = 0

while i < len(S):
    while i < len(S) and S[i] not in ACGT:
        i += 1
    st = i
    while i < len(S) and S[i] in ACGT:
        i += 1
    result = max(result, i - st)

print(result)

Submission status: Accepted

Solution code:
b = input()

tmp = 0
total = 0
for i in b :
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        tmp += 1
        total = max(total,tmp)
    else:
        total = max(total,tmp)
        tmp = 0

print(total)

Submission status: Accepted

Solution code:
s= input()

chars = list(s)

s1 = ''
s2 = ''

for c in chars:

  if c in 'ACGT':
    s2 += c
  else:
    if len(s2) >= len(s1):
      s1 = s2
      s2 = ''

if len(s2) >= len(s1):
  print(len(s2))
else:
  print(len(s1))

Submission status: Accepted

Solution code:
a = input()
count = 0
ans = 0
for i in a:
    if i != "A" and i != "G" and i != "C" and i != "T":
        count = 0
    else:
        count += 1
        if ans <= count:
            ans = count
print(ans)

Submission status: Accepted

Solution code:
S = input()
count = 0
ans = 0
for i in S:
	if i == "A" or i == "C" or i == "G" or i == "T":
		count+=1
		if ans < count:
			ans = count
	else:
		count = 0
print(ans)

Submission status: Accepted

Solution code:
S = input()
A = ['A', 'C', 'G', 'T']
ans = 0
cnt = 0
for s in S:
    if s in A:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
src = input()
length = len(src)
acgt = set("ACGT")
ans = 0
for i in range(length):
    n = length - i
    for ngram in [src[k:k+n] for k in range(length - n + 1)]:
        subtract = len(set(ngram) - acgt)
        if subtract == 0:
            ans = n
            break
    if ans != 0:
        break
print(ans)

Submission status: Accepted

Solution code:
s =input()

c = 0
m = 0
for i in range (len(s)):
  if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
      c += 1
      if c >= m:
        m = c
  else:
    c = 0
print(m)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
S = str(input())
ans = 0
count =0
i = 0
j = 1
#print ('len(S)', len(S))
while i <= len(S):
    j = i + 1
    while j <= (len(S)+1):
#        print ('(i, j-1, j)=', i, j-1, j)
        s = S[j-1:j]
#        print ('S:', S)
#        print ('s:', s)
        if j == len(S) + 1:
            if s == 'A' or s == 'C' or s == 'G' or s == 'T':
                count += 1
                ans = max(ans, count)
#                print (ans)
                count = 0
#                print ('V')
            else:
                ans = max(ans, count)
#                print (ans)
                count = 0
#                print ('W')
        else:
            if s == 'A' or s == 'C' or s == 'G' or s == 'T':
                count += 1
#                print (count)
#                print ('X')
            else:
                ans = max(ans, count)
                count = 0
                j = len(S) + 2
#                print ('Y')
                
        j += 1
    i += 1
print (ans)

Submission status: Accepted

Solution code:
S = input()
cnt = 0
t_cnt = 0
for x in S:
    if x in ['A', 'C', 'G', 'T']:
        t_cnt += 1
        if t_cnt > cnt:
            cnt = t_cnt
    else:
        t_cnt = 0
print(cnt)

Submission status: Accepted

Solution code:
sentence = input()

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