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=input()
n=len(s)
ans=0
for i in range(n):
    for j in range(i,n):
        if all("ACGT".count(c)==1 for c in s[i:j+1]):
            ans = max(ans,j-i+1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
list_s = list(s)
k = 0
ans = []
for i in range(len(list_s)):
    c = list_s[i]
    if c == "A" or c == "C" or c == "G" or c == "T":
        k += 1
    else:
        ans.append(k)
        k = 0
if k != 0:
    ans.append(k)
print(max(ans))

Submission status: Accepted

Solution code:
s = input()

acgt = ["A", "C", "G", "T"]
x = 0
ans = 0
for i in range(len(s)):
    if s[i] in acgt:
        x += 1
    else:
        x = 0
    ans = max(x, ans)
print(ans)

Submission status: Accepted

Solution code:
S = input()
A = list("ACGT")
k = 0
b = 0
for s in S:
    if s in A:
        b+=1
    else:
        b=0
    k = max(k,b)
print(k)

Submission status: Accepted

Solution code:
S = list(input())
def atgc(s):
    if s == "A" or s == "T" or s == "G" or s == "C":
        return True
    else:
        return False
c = 0
nax = 0
for i in range(len(S)):
    if atgc(S[i]):
        c += 1
        if i == len(S)-1:
            nax = max(nax,c)
    else:
        nax = max(nax,c)
        c = 0
print(nax)

Submission status: Accepted

Solution code:
s = input()
m = 0
l = 0
for c in s:
    if not (c == 'A' or c == 'C' or c == 'G' or c == 'T'):
        m = max(m, l)
        l = 0
        continue

    l += 1

m = max(m, l)
print(m)

Submission status: Accepted

Solution code:
x=input()
l=len(x)
maxx =[0]
a=0
for i in range(l):
  if x[i]=='A' or x[i]=='T' or x[i]=='C' or x[i]=='G':
    a+=1
    #print(a)
    maxx.append(a)
  else:
    a=0
print(max(maxx))

Submission status: Accepted

Solution code:
base = set(["A", "C", "G", "T"])
ans = set([0])
cnt = 0

s = list(input())
for i in s:
    if i in base:
        cnt += 1
        ans.add(cnt)
    else:
        cnt = 0

m = max(ans)
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
mx = 0
cnt = 0
for i in range(len(s)):
  if s[i] in ['A', 'G', 'C','T']:
    cnt += 1
    if cnt>mx:
      mx=cnt
  else:
    cnt = 0

print(mx)

Submission status: Accepted

Solution code:
s=input()
ans=0
li=["A","C","G","T"]

for i in range(len(s)):
  for j in range(i,len(s)):
    if all([k in li for k in s[i:j+1]]):
      ans=max(ans,j-i+1)
      
print(ans)

Submission status: Accepted

Solution code:
s=input()
l=[0]*10
i=0
for c in s:
    if c in ['A','C','G','T']:
        l[i]+=1
    else:
        i+=1
print(max(l))

Submission status: Accepted

Solution code:
s = input()
l = []
cnt = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] =="C" or s[i] == "G" or s[i] == "T":
        cnt += 1
        #print(i, cnt)
        if i == len(s) - 1:
            l.append(cnt)
            
        
        
        
    elif i != "A" or i !="C" or i != "G" or i != "T":
        l.append(cnt)
        cnt = 0
        #print("y")
print(max(l))

Submission status: Accepted

Solution code:
S = input()
acgt = {'A', 'C', 'G', 'T'}
length = len(S)
start = 0
ans = 0
while start < length:
  while start < length and S[start] not in acgt:
    start += 1
  right = start
  while right < length and S[right] in acgt:
    right += 1
  ans = max(ans, right - start)
  start = right
print(ans)

Submission status: Accepted

Solution code:
S=input()
N=len(S)
ans=0
d=set(list("AGCT"))

for i in range(N+1):
    for j in range(N+1):
        s=S[i:j]
        if set(list(s))<=d:
            ans=max(ans,len(s))
            
print(ans)

Submission status: Accepted

Solution code:
s=list(input())
ans=0
now=0
for q in s:
    if q in ["A","T","G","C"]:
        now+=1
    else:
        now=0
    ans=max(ans,now)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

S = input().rstrip('\r\n')
ans = 0
count = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        count += 1
    else:
        ans = max(ans, count)
        count = 0
ans = max(ans, count)
print(ans)

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    n = len(s)
    acgt = ["A", "C", "G", "T"]
    ans = 0
    for i in range(n):
        for j in range(i+1, n+1):
            flag = True
            for k in s[i:j]:
                if k not in acgt:
                    flag = False
                    break
            if flag:
                ans = max(len(s[i:j]), ans)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=input()

ans=[]
count=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
    else:
        ans.append(count)
        count=0

ans.append(count)

print(max(ans))

Submission status: Accepted

Solution code:
S = input()
count = 0
count_max = 0
for i in range(len(S)):
    if S[i] in 'ACGT':
        count += 1
    else:
        count_max = max(count_max,count)
        count = 0
count_max = max(count_max,count)
print(count_max)

Submission status: Accepted

Solution code:
s=input()
count,ans=0,0
for i in range(len(s)):
  if s[i] in 'ACGT':
    count+=1
  else:
    ans=max(ans,count)
    count=0
ans=max(ans,count)
print(ans)

Submission status: Accepted

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

for i in range(len(S)):
  if S[i] in "ACGT":
    cnt+=1
    l.append(cnt)
  else:
    cnt = 0
    l.append(0)
print(max(l))

Submission status: Accepted

Solution code:
s = str(input())
cnt = 0
cnt_list = []

for i in range(len(s)):
    if s[i] in 'ACGT':
        cnt += 1
        cnt_list.append(cnt)
    else:
        cnt = 0
        cnt_list.append(0)
print(max(cnt_list))

Submission status: Accepted

Solution code:
S=input()

max_bubun_length=0
tmp_bubun_length = 0
for i in range(len(S)):
    # print(S[i])
    # print(tmp_bubun_length)
    # print(max_bubun_length)
    if S[i] in "ACGT":
        tmp_bubun_length += 1
    else:
        if tmp_bubun_length > max_bubun_length:
            max_bubun_length = tmp_bubun_length
            # print(S[(i-tmp_bubun_length):i])
        tmp_bubun_length = 0
if tmp_bubun_length > max_bubun_length:
    max_bubun_length = tmp_bubun_length
print(max_bubun_length)

Submission status: Accepted

Solution code:
S = input()
mode = 0
now = 0
k = []
for i in range(len(S)):
    if str(S[i]) == "A" or str(S[i]) == "T" or str(S[i]) == "G" or str(S[i]) == "C":
        if mode == 0:
            mode = 1
            now += 1
        else:
            now += 1
    else:
        k.append(now)
        now = 0
        mode = 0
k.append(now)
if len(k) == 0:
    print(0)
else:
    print(max(k))

Submission status: Accepted

Solution code:
s=input()
n=len(s)
List="ACGT"
count=0
ans=0
flag=0
for i in range(n):
    if (List.count(s[i])>0):
        count+=1
        ans=max(ans,count)
    else:
        count=0
print(ans)

Submission status: Accepted

Solution code:
*s, = input()

s.append(" ")

current = 0
ans = 0
for i in range(len(s)):
    if s[i] not in ["A", "C", "G", "T"]:
        ans = max(ans, i - current)
        current = i+1

print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(len(S)):
    tmp = 0
    for j in range(len(S)):
        if 'ACGT'.count(S[j]) == 1:
            tmp += 1
            ans = max(ans, tmp)
        else:
            tmp = 0

print(ans)

Submission status: Accepted

Solution code:
s=input()
ans=0
tmp=0
l=['A','C','G','T']

for i in range(len(s)):
    if l.count(s[i]) != 0:
        tmp+=1
    else:
        ans=max(tmp,ans)
        tmp=0
    ans=max(tmp,ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

s = input()

cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans, cnt)
print(ans)

Submission status: Accepted

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

if cnt > ans:
    ans = cnt

print(ans)

Submission status: Accepted

Solution code:
s = input()
s += " "
ans = 0
acgt = ""
for i in range(len(s)):
    # print(s[i], s[i] == "A" or s[i] == "B" or s[i] == "C" or s[i] == "D")
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        acgt += s[i]
    else:
        if ans < len(acgt):
            ans = len(acgt)
        acgt = ""
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = 0
tmp = 0
for i in s:
    if i in 'AGCT':
        tmp +=1
        ans = max(ans, tmp)
    else:
        tmp = 0
print(ans)

Submission status: Accepted

Solution code:
s = input()

count = 0
max_count = 0
for c in s:
    if c in ['A', 'C', 'G', 'T']:
        count += 1
    else:
        if count > max_count:
            max_count = count
        count = 0

if count > max_count:
    max_count = count
    
print(max_count)

Submission status: Accepted

Solution code:
S = raw_input()

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

ans = 0
candi = 0
for item in S:
    if item in AGCT:
        candi = candi + 1
    else:
        ans = max(ans, candi)
        candi = 0

print max(ans, candi)

Submission status: Accepted

Solution code:
x=input()
x=list(x)
a=len(x)
ans=0
count=0
for i in range(a):
	if x[i]=='A' or x[i]=='C' or x[i]=='G' or x[i]=='T':
		count=count+1
	else:
		if ans<count:
			ans=count
		count=0
if count!=0 and ans<count:
	print(count)
else:
	print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    n = len(s)
    ans = 0
    r = 0
    for l in range(n):
        while r < n and s[r] in "ACGT":
            r += 1
        k = r-l
        if ans < k:
            ans = k
        if r <= l:
            r = l+1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans = 0
tmp = 0

for c in s:
    if c in "ACGT":
        tmp += 1
        ans = max(ans, tmp)
    else:
        tmp = 0

print(ans)

Submission status: Accepted

Solution code:
s=input()+"X"
t=["A","G","T","C"]
ans=0
c=0
f=False
for i in s:
  if i in t:
    if f:
      c+=1
    else:
      f=True
      c=1
  else:
    f=False
    ans=max(ans,c)
print(ans)

Submission status: Accepted

Solution code:
S = input()
max_S = 0
ACGT = ['A', 'C', 'G', 'T']
S2 = [1 if x in ACGT else 0 for x in S]
for i in range(len(S2)):
  for j in range(i+1, len(S)+1):
    if len(S[i:j])==sum(S2[i:j]):
      if len(S[i:j])>max_S:
        max_S = len(S[i:j])
print(max_S)

Submission status: Accepted

Solution code:
from itertools import groupby as gb
res = 0

s = [i in 'ATGC' for i in list(input())]
g = gb(s)
for k, v in g:
    if k == False:
        continue
    res = max(res, len(list(v)))
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B
s = list(input())

count = 0
l = []
for i in range(len(s)):
    if s[i] == 'A':
        count += 1
        continue
    elif s[i] == 'C':
        count += 1
        continue
    elif s[i] == 'G':
        count += 1
        continue
    elif s[i] == 'T':
        count += 1
        continue
    else:
        l.append(count)
        count = 0
l.append(count)

print(max(l))

Submission status: Accepted

Solution code:
s = input()
n = len(s)

ans = 0
for i in range(n+1):
    for j in range(i+1):
        if all([a in 'ATGC' for a in s[j:i]]):
            ans = max(ans, len(s[j:i]))
print(ans)

Submission status: Accepted

Solution code:
S = str(input())

ans=0
for i in range(len(S)+1):
    for j in range(i,len(S)+1):
        s=S[i:j]
        if s.count("A")+s.count("G")+s.count("C")+s.count("T")==len(s):
            ans=max(len(s),ans)

print(ans)

Submission status: Accepted

Solution code:
s=input()
ans=0
for i in range(len(s)):
    count=0
    for j in range(i,len(s)):
        if s[j] in ('A','T','G','C'):
            count+=1
        else:
            break

    ans=max(ans,count)

print(ans)

Submission status: Accepted

Solution code:
a=[i for  i in input()]
st=['A','C','G','T'] ; ct=0 ; maxx=0
for i in a:
    if i in st:
        ct+=1
    else:
        maxx=max(maxx,ct)
        ct=0
maxx=max(maxx,ct)
print(maxx)

Submission status: Accepted

Solution code:
import re

split = re.split('[^ACGT]', input())

print(max(map(len, split)))

Submission status: Accepted

Solution code:
import re
S=input()
S2=(re.sub('[^{ACGT}]', ' ', S))
S3=S2.split()
L=0
for i in range(len(S3)):
    if len(S3[i])>L:
        L=len(S3[i])
print(L)

Submission status: Accepted

Solution code:
A = list(input())
max_nu = 0 
nu = 0
for i in range(len(A)):
    if A[i] == "A" or A[i] == "C" or A[i] == "G" or A[i] == "T":
        nu += 1
        if max_nu < nu:
            max_nu = nu
    else:
        nu = 0
print(max_nu)

Submission status: Accepted

Solution code:
def main(s):
    res = 0
    val = 0
    lst = ["A","C","G","T"]
    for i in range(len(s)):
        if s[i] in lst:
            val += 1
        else:
            res = max(res, val)
            val = 0
    return max(res,val)

s = input()
print(main(s))

Submission status: Accepted

Solution code:
S=input()
start=1
end=0
ans=[]
for _ in range(len(S)):
    for i in range(len(S))[end:]:
        if S[i] in {"A","C","G","T"}:
            start=i
            break
    for j in range(len(S))[start:len(S)]:
        end=len(S)
        if S[j] not in {"A","C","G","T"}:
            end=j
            break
    ans.append(end-start)
if max(ans)<0:print(0)
else:print(max(ans))

Submission status: Accepted

Solution code:
S = input()
ACGT = ""
ans = 0
for i in range(len(S)):
    for j in range(len(S)-i):
        if(S[i+j] != "A" and S[i+j] != "C" and S[i+j] != "G" and S[i+j] != "T"):
            break
        ACGT = ACGT + S[i+j]
    ans = max(ans,len(ACGT))
    ACGT = ""
print(ans)

Submission status: Accepted

Solution code:
def all_part_string(s):
    r = range(len(s))
    return [s[i:j+1] for i in r for j in r if s[i:j+1] != '']

def contains_only(s, l):
    return False if [a for a in [e for e in s if e not in l] if a != ''] else True

if __name__ == '__main__':
    s = input()
    ss = all_part_string(s)
    o = [e for e in ss if contains_only(e, "ACGT")]
    print(0 if len(sorted(o, key=len, reverse=True)) == 0 else len(sorted(o, key=len, reverse=True)[0]))

Submission status: Accepted

Solution code:
#ABC122

s = input()

d = ["A","T","G","C"]
l = []
count = 0
for i in range(len(s)):
    if s[i] not in d:
        l.append(count)
        count = 0
    else:
        count += 1
    #print(count)
l.append(count)
print(max(l))

Submission status: Accepted

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

count = 0
arr = []
for i in range(len(s)):
    if s[i] in ['A', 'C', 'G', 'T']:
        count += 1
    else:
        arr.append(count)
        count = 0

        
arr.append(count)
print(max(arr))

Submission status: Accepted

Solution code:
S=input()
ans=0
for i in range(len(S)):
    cnt=0
    while True:
        if  i>=len(S):
            break
        elif S[i] not in ["A","C","G","T"]:
            break
        else:
            cnt+=1
            i+=1    
    if cnt>ans:
        ans=cnt
print(ans)

Submission status: Accepted

Solution code:
#import sys
#import math
#import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
N=input()
ans=ju=0
li=[]
li=list(N)

for i in range(len(li)):
  ans=0
  if str(li[i])=='T' or str(li[i])=='A' or str(li[i])=='G'or str(li[i])=='C':
    ans+=1
    for j in range(1,len(li)-i):
      if str(li[i+j])!='T' and str(li[i+j])!='A' and str(li[i+j])!='G' and str(li[i+j])!='C':
        break
      ans+=1
    ju=max(ju,ans)
print(ju)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def check(In):
    return In != "A" and In != "C" and In != "G" and In != "T"

def main():
    s = ns()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = str(input())

len = 0
ans = 0

for c in S:
    if c in "ACGT":
        len += 1
        ans = max(len, ans)
    else:
        len = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

length = len(s)
acgt = set("ACGT")

ans = 0
for i in range(length):
    for j in range(length):
        moji = s[i:][::-1]
        moji = moji[j:][::-1]
        if set(moji) <= acgt:
            ans = max(ans,len(moji))

print(ans)

Submission status: Accepted

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

def solve(S: str):
    return max(map(len, map(lambda x: tuple(x[1]), filter(lambda x: x[0], groupby(S, lambda x: x in 'ATGC')))), default=0)

                          


# Generated by 1.1.6 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
    print(solve(S))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = [1 if i in ["A", "C", "G", "T"] else 0 for i in input()]
r = [0]
c = 0
for i, si in enumerate(s):
    if si == 1:
        c += 1
    if si == 0 or i == len(s) - 1:
        if c != 0:
            r.append(c)
            c = 0
print(max(r))

Submission status: Accepted

Solution code:
s=input()
acgt = ['A','C','G','T']
l=[0]

for i in range(len(s)):
    if s[i] in acgt:
        moji=s[i]
        cnt=1
        l.append(len(moji))
        while i+cnt < len(s):
            if s[i+cnt] in acgt:
                moji=s[i:i+cnt+1]
                # print(moji)
                cnt+=1
                l.append(len(moji))
            else:
                break
print(max(l))

Submission status: Accepted

Solution code:
s=input()

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

ans=-1
cnt=0
for i in range(len(s)):
        if s[i] in acgt:
                cnt+=1
        else:
                if ans < cnt:
                        ans=cnt
                cnt=0
if ans < cnt:
        ans=cnt
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(i, N):
         if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
            ans = max(ans, j-i+1)
print(ans)

Submission status: Accepted

Solution code:
s = input()

ans = 0

for i in range(len(s)):
  if not s[i] in 'ACGT':
    continue
  count = 1
  for j in range(i + 1, len(s)):
    if s[j] in 'ACGT':
      count += 1
    else:
      break
  ans = max(ans, count)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

targets = ("A", "C", "G", "T")
max_length = 0
current_length = 0
for s in S:
    if s in targets:
        current_length += 1
    else:
        current_length = 0
    if max_length <= current_length:
        max_length = current_length
print(max_length)

Submission status: Accepted

Solution code:
S=list(input())

ACGT=['A','C','G','T']
tmp=''
MAX1=0
MAX2=0

for moji in S:
    if((moji in ACGT)==True):
        tmp+=moji
        MAX2=len(tmp)
    else:
        if(MAX1 < MAX2):
            MAX1=MAX2
        MAX2=0
        tmp=''

if(MAX1==0 or MAX1 < MAX2):
    MAX1=MAX2

print(MAX1)

Submission status: Accepted

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

S = str(input())
# print(S)

def is_ATGC(char):
    if char == "A" or char == "C" or char == "G" or char == "T":
        return True
    return False

def is_ATGC_str(s):
    is_ATGC_str = True
    for char in s:
        if not is_ATGC(char):
            is_ATGC_str = False
    return is_ATGC_str

len_max = 0
for start in range(len(S)):
    for end in range(start+1, len(S)+1):
        # print(start, end)
        # print(S[start:end])
        s = S[start:end]
        if is_ATGC_str(s) and len(s) > len_max:
            len_max = len(s)

print(len_max)

Submission status: Accepted

Solution code:
S = input()

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

max_cnt = 0
cnt = 0
for i in range(len(S)):
    if S[i] in acgt:
        cnt += 1
        max_cnt = max(cnt, max_cnt)
    else:
        cnt = 0
print(max_cnt)

Submission status: Accepted

Solution code:
def main():
    S = input()
    N = len(S)
    s = {"A", "G", "C", "T"}
    ans = 0
    for i in range(N):
        for j in range(i, N):
            T = S[i:i+(j-i+1)]
            if all(t in s for t in T):
                ans = max(ans, len(T))
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())

chrs = ('A', 'C', 'G', 'T')
max_len = 0
this_len = 0
for s in S:
  if s in chrs:
    this_len += 1
  else:
    this_len = 0

  max_len = max(this_len, max_len)

print(max_len)

Submission status: Accepted

Solution code:
S = input()
L = ["A","T","C","G"]
ans = 0
t = 0
for e in S:
    if e in L:
        t += 1
        ans = max(ans,t)
    else:
        t = 0
print(ans)

Submission status: Accepted

Solution code:
S = input()
st = set(['A', 'G', 'C', 'T'])
ans = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        string = S[i:j+1]
        if not string:
            continue
        flag = True
        for char in string:
            if char not in st:
                flag = False
        if flag:
            ans = max(ans, len(string))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

ans = 0
tmp = 0
for i in s:
    if i in 'ACGT':
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0

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

Submission status: Accepted

Solution code:
s = input()
acgt = ["A","C","G","T"]
c = ""
for i in s:
  if i in acgt:
    c+=i
  else:
    c+= " "
l = c.split()
if l:
	print(len(max(l, key=lambda x:len(x))))
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

S = input()

ans = 0

for s in range(len(S)):
    for e in range(s + 1, len(S) + 1):
        if set(S[s:e]) <= set({'A', 'T', 'C', 'G'}):
            ans = max(ans, e - s)
        # print(s, e, S[s:e], set(S[s:e]), set(S[s:e]) <= set({'A', 'T', 'C', 'G'}))
print(ans)

Submission status: Accepted

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

length = 0

for s in range(n):
    for e in range(s, n):
        if all("ACGT".count(c)==1 for c in S[s:e+1]):
            length = max(length, e-s+1)

print(length)

Submission status: Accepted

Solution code:
s = input()
ans = [0] * 10 ** 3
cnt = 0

for i in range(len(s)):
    for j in range(1, len(s) + 1):
        memo = s[i:j]
        for k in range(len(memo)):
            if memo[k] == 'A' or memo[k] == 'C' or memo[k] == 'T' or memo[k] == 'G':
                cnt += 1
            else:
                break

        ans.append(cnt)
        cnt = 0

print(max(ans))

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    ans = 0
    cnt = 0
    agct = ['A', 'G', 'C', 'T']
    for s in S:
        if s in agct:
            cnt += 1
            ans = max(ans, cnt)
        else:
            cnt = 0
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
seq = 0
ans = 0
for c in s:
    if c in 'ACGT':
        seq += 1
        ans = max(ans, seq)
    else:
        seq = 0
print(ans)

Submission status: Accepted

Solution code:
s=input()
cnt=0
ans=0
for i in s:
    if i in 'ACGT':
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
ans=max(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
ans = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        # print(s[i:j+1])
        if all(x == 'A' or x == 'C' or x == 'G' or x == 'T' for x in s[i:j+1]):
            # print('Yes')
            if ans < len(s[i:j+1]):
                ans = len(s[i:j+1])
        # if expression:
        #     pass
    # print(s[:i], len(s[:i]))

print(ans)

Submission status: Accepted

Solution code:
s = input()

ans = 0
cnt = 0
for i in s:
    if i in 'ACGT':
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft

def main():
    s = input()
    ans = 0
    n = len(s)
    for i in range(n):
        for j in range(i+1, n+1):
            if len([k for k in s[i:j] if k not in 'ACGT']) == 0:
                ans = max(ans, j - i)
    print(ans)


main()

Submission status: Accepted

Solution code:
s=input()

ans=0
count=0
for i in s:
    if i in 'ACGT':count+=1
    else:
        ans=max(ans,count)
        count=0

else:
    ans=max(ans,count)
print(ans)

Submission status: Accepted

Solution code:
s = input()
acgt = set({'A','C','G','T'})
s = s + 'Z' #dummy
ans = [-1]*(len(s))
def dfs(i):
    if ans[i] != -1:
        return ans[i]
    elif s[i] not in acgt:
        ans[i] = 0
        return 0
    else:
        ans[i] = dfs(i+1) + 1
        return ans[i]
for i in range(len(s)):
    dfs(i)
print(max(ans))

Submission status: Accepted

Solution code:
S = input()

cnt = 0
max_cnt = 0

for i in S:
  if i in "ACGT":
    cnt += 1
    if cnt > max_cnt:
      max_cnt = cnt
  else:
    cnt = 0
    
print(max_cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ACGT = 'ACGT'
ans = 0
temp = 0
for x in S:
    if x in ACGT:
        temp += 1
    else:
        ans = max(ans, temp)
        temp = 0
ans = max(ans, temp)
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
s = input()
SENT = ('A','T','G','C')

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