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:
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n):
        for j in range(i + 1, n + 1):
            if set(s[i:j]) - {"A", "C", "G", "T"} == set():
                ans = max(ans, len(s[i:j]))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

S = input()

cnt = 0
ans = 0
for char in S:
    if char == 'A' or char == 'C' or char == 'G' or char == 'T':
        cnt += 1
    else:
        ans = max(cnt, ans)
        cnt = 0

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

Submission status: Accepted

Solution code:
S = input()

ma = 0
tmp = 0
acgt = ('A','C','G','T')

for s in S:
    if s in acgt:
        tmp += 1
        ma = max(ma,tmp)
    else:
        tmp = 0
print(ma)

Submission status: Accepted

Solution code:
s=input()
l=["A","C","G","T"]
ans=0
for i in range(len(s)):
    for j in range(len(s)):
        part=s[i:len(s)-j]
        if all((part[k] in l) for k in range(len(part))) and len(part)>ans:
            ans=len(part)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = list(input())
    ans = 0
    for i in range(len(s)):
        count = 0
        for j in range(i, len(s)):
            if s[j] in ['A', 'C', 'G', 'T']:
                count += 1
            else:
                break
        ans = max(ans, count)
    print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#n=int(input())
#n,m=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
s=list(input())
n=len(s)
mx=0
temp=0
l=['A','C','G','T']

for i in range(n):
    for j in range(i,n):
        st=s[i:j+1]
        if all([c in l for c in st]):
            mx=max(mx,j-i+1)
print(mx)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import re
S = input()
if not ( 1 <= len(S) <= 10 ): sys.exit()
if not S.isupper: sys.exit()

result = 0
max = max(re.findall('[A|T|G|C]+', S),key=len) if re.findall('[A|T|G|C]+', S) else ''
if len(max) > 0:result = len(max)
print(result)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

s = input()
n = len(s)
ans = 0
acgt = set(['A', 'C', 'G', 'T'])
for i in range(n):
    for j in range(i + 1, n + 1):
        t = s[i:j]
        flag = 1
        for k in t:
            if k not in acgt:
                flag = 0
                break
        if flag:
            ans = max(ans, len(t))
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

S = input()

res = 0
now_mojisu = 0
agct = ["A", "C", "G", "T"]

for i in S:
    if i in agct:
        now_mojisu += 1
    else:
        now_mojisu = 0
    res = max(res, now_mojisu)

print(res)

Submission status: Accepted

Solution code:
S = input()

ACGT = 'A C G T'.split()
result = 0
tmp = 0
for i in S:
    if i in ACGT:
        tmp += 1
    else:
        tmp = 0
    if tmp > result:
        result = tmp

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

s = input()

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

ACGT = ['A', 'C', 'G', 'T']
cntList = []
cnt = 0
cntList.append(cnt)
for s in S:
    if s in ACGT:
        cnt += 1
        cntList.append(cnt)
    else:
        cnt = 0
print(max(cntList))

Submission status: Accepted

Solution code:
s=input()
ans=0
for i in range(len(s)):
  for j in range(len(s)):
    s2=s[i:len(s)-j]
    if len(s2)==s2.count("A")+s2.count("T")+s2.count("C")+s2.count("G"):
      if len(s2)>ans:
        ans=len(s2)
print(ans)

Submission status: Accepted

Solution code:
S = input()

ACGT = 'ACGT'

count = []
tmp_num = 0
for i in S:
    if i in ACGT:
        tmp_num += 1
    elif i not in ACGT:
        count.append(tmp_num)
        tmp_num = 0
count.append(tmp_num)

print(max(count))

Submission status: Accepted

Solution code:
def main():
    S = list(input().rstrip())
    for l in reversed(range(1, len(S)+1)):
        for d in range(len(S) - l + 1):
            if set(S[d:d+l]).issubset(set(["A", "C", "G", "T"])):
                print(l)
                exit()
    print(0)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
string = input()
ans = 0
score = 0
ok = set('ACGT')
for c in string:
    if c in ok:
        score += 1
    else:
        ans = max(ans, score)
        score = 0
ans = max(ans,score)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
mx = 0
count = 0
for x in S :
    if x in "ATGC" :
        count += 1
    else :
        mx = max(mx, count)
        count = 0
mx = max(mx, count)
print(mx)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

s = input()

l = 0
ans = 0
for c in s:
    if c in ('A', 'C', 'G', 'T'):
        l += 1
        ans = max(ans, l)
    else:
        l = 0
print(ans)

Submission status: Accepted

Solution code:
s = input()

ans = 0

for l in range (len(s)):

  for r in range(l+1, len(s)+1):

    cnt = 0

    for str in s[l:r]:

      if str not in ['A','C','G','T']:

        cnt = 0 

        break

      else:

        cnt += 1

    ans = max(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
#18
S = input()
N = len(S)
mozi = ["A","C","G","T"]
cou = 0
Max = 0
n = 0
for i in range(N):
    for j in mozi:
        if S[i] == j:
            cou += 1
            n += 1
        if j == "T" and n == 0:
            if cou > Max:
                Max = cou
            cou = 0
        elif j == "T":
            n = 0
        
if cou > Max:
    Max = cou
print(Max)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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:
import sys
sys.setrecursionlimit(10**6)

s = input()

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

ans = 0
tmp = 0

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

Submission status: Accepted

Solution code:
S = input()
T = ['A', 'C', 'G', 'T']
ans, cnt = 0, 0

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

Submission status: Accepted

Solution code:
S = input()
N = int(len(S))

ans = 0
for i in range(N):
    for j in range(i, N):
        if all("ACTG".count(s) == 1 for s in S[i:j+1]):
            ans = max(ans, j - i + 1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(ans)

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

s = S()

temp = 0
ans = 0

for char in s:
    if char in 'ACGT':
        temp += 1
    else:
        temp = 0
    ans = max(ans,temp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

len_S = len(S)
ans = 0
for i in range(len_S):
    tmp = 0
    tmp_ans = 0
    for j in range(i, len_S):
        if S[j] == 'A' or S[j] == 'C' or S[j] == 'G' or S[j] == 'T':
            tmp += 1
        else:
            tmp_ans = max(tmp_ans, tmp)
            tmp = 0
    ans = max(tmp_ans, tmp, ans)
print(ans)

Submission status: Accepted

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

for i in range(n):
  for j in range(n):
    p = s[i : j + 1]
    if all(c in l for c in p):
        ans.append(len(p)) 
print(max(ans))

Submission status: Accepted

Solution code:
S=input()
acgt=['A','C','G','T']
ans,count=0,0

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        c = True
        for k in range(i, j+1):
            if S[k]!='A' and S[k]!='C' and S[k]!='G' and S[k]!='T':
                c = False
        if c and ans < j-i+1:
            ans = j-i+1
print(ans)

Submission status: Accepted

Solution code:
S = input()

s = []

for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        s.append(i)

ans = 0
if len(s) == 1:
    ans = 1

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

Submission status: Accepted

Solution code:
s = input()

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

print(max(max_cnt, cnt))

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
cnt,ans=0,0
for i in S:
    #print(i)
    if i in "ACGT":
        cnt += 1
        #print(cnt)
    else:
        #print(cnt,c)
        ans = max(ans,cnt)
        #print(ans)
        cnt = 0
ans = max(ans,cnt)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
counter = 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"):
        counter += 1
    else:
        max_ = max(max_,counter) 
        counter = 0
max_ = max(max_,counter) 
print(max_)

Submission status: Accepted

Solution code:
s=input()
n=len(s)
a=[0]*n
for i in range(n):
  if s[i] in 'ATCG':a[i]=a[i-1]+1
  else:a[i]=0
print(max(a))

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:
def resolve():
    S = str(input().split())
    ans = 0

    for pos in range(len(S)):
        for ln in range(pos, len(S)):
            if all('ACGT'.count(c) == 1 for c in S[pos:ln+1]):
                ans = max(ans, ln - pos + 1)

    print(ans)
    return

resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
ACGT = ['A', 'C', 'G', 'T']

count_list = []
for i in range(len(S)):
    count = 0
    for j in range(i, len(S)):
        if S[j] in ACGT:
            count += 1
        else:
            break
    count_list.append(count)

print(max(count_list))

Submission status: Accepted

Solution code:
S = input()
MAX = 0
ATGC = ['A','T','G','C']
for T in range(0,len(S)):
    if S[T] in ATGC:
        Count = 1
        for TT in range(T+1,len(S)):
            if S[TT] in ATGC:
                Count += 1
            else: break
        if Count>MAX: MAX = Count
print(MAX)

Submission status: Accepted

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

if (count <= w_count): count = w_count
print(count)

Submission status: Accepted

Solution code:
s = input()

acgt = ("A","C","G","T")
max_len = 0

for i in range(len(s)):
  t_max = 0
  for c in s[i:]:
    if c not in acgt:
      break
    t_max += 1
  max_len = max(t_max,max_len)

print(max_len)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
c = 0
a = 0
for i in s:
    if i in ["A", "C", "T", "G"]:
        c += 1
        a = max(a, c)
    else:
        c = 0
print(a)

Submission status: Accepted

Solution code:
S = input()
counts = []
count = 0
for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'G' or S[i] == 'C' or S[i] == 'T':
    count += 1
  else:
    counts.append(count)
    count = 0
counts.append(count)
if len(S) ==1:
  print(counts[0])
else:
  print(max(counts))

Submission status: Accepted

Solution code:
S=input()

l=len(S)

ans=0
ans_list=[]

for i in range(l):
    if S[i] in ("A","G","C","T"):
        ans+=1
    else:
        ans_list.append(ans)
        ans=0
ans_list.append(ans)
print(max(ans_list))

Submission status: Accepted

Solution code:
s = input()
ans = 0
for i in range(len(s)):
  for j in range(i, len(s)):
    if all(x in "ACGT" for x in s[i:j+1]):
      ans = max(ans, len(s[i:j+1]))
print(ans)

Submission status: Accepted

Solution code:
S=list(input())
m = 0
ans = 0
for n in S:
    if n in ("A","C","G","T"):
        m += 1
        ans = max(ans,m)
    else:
        m = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
print(len(max("".join(re.sub(r"[^ATCG]", " ", input())).split(" "), key=lambda x: len(x))))

Submission status: Accepted

Solution code:
import re
S = re.sub(r"[^ATCG]", " ", input())
S = "".join(S).split(" ")
print(len(max(S, key=lambda x: len(x))))

Submission status: Accepted

Solution code:
S = list(input())
for i in range(len(S)):
    if S[i] not in "ATCG":
        S[i] = " "
S = "".join(S).split(" ")
print(len(max(S, key=lambda x: len(x))))

Submission status: Accepted

Solution code:
s = list(input())
a = ""
ans = 0
for c in s:
    if c in ("A", "C", "G", "T"):
        a += c
    else:
        ans = max(ans, len(a))
        a = ""
print(max(ans, len(a)))

Submission status: Accepted

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

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()
m=0
count=0
for s in S:
    if s in "A":count+=1
    elif s in "C":count+=1
    elif s in "G":count+=1
    elif s in "T":count+=1
    else:count=0
    m=max(m,count)
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
checklist=['A','C','G','T']
sn = list(input())

answer = 0
count = 0
for s in sn :
  if s in checklist:
    count += 1
  else :
    count = 0
  answer = max(answer,count)

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    S = input()
    res = 0
    max_res = 0
    for i in range(len(S)):
        if S[i] in ['A', 'C', 'G', 'T']:
            res += 1
        else:
            res = 0
        max_res = max(max_res, res)
    print(max_res)
if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
ma = 0
ma_ = 0
for c in S:
    if c == 'A' or c == 'C' or c == 'G' or c == 'T':
        ma_ += 1
    else:
        ma = max(ma, ma_)
        ma_ = 0
ma = max(ma, ma_)
print(ma)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans = 0
for i in range(len(s)):
  for j in range(i,len(s)):
    if all("ATGC".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()
left = 0
ans = 0
for right in range(0,len(s)):
  if s[right] in ("A","C","G","T"):
    pass
  else:
    left=right+1
  ans = max(ans,right-left+1)
print(ans)

Submission status: Accepted

Solution code:
s = input()
left = 0
ans = 0
for right in range(0,len(s)):
  if s[right] == "A" or s[right]== "C"or s[right]== "T"or s[right]=="G":
    pass
  else:
    left=right+1
  ans = max(ans,right-left+1)
print(ans)

Submission status: Accepted

Solution code:
S = input()

AGCT = ['A','G','C','T']
AGCT_list = []

i = 0
while i < len(S):
    #print('i=',i)
    if S[i] in AGCT:
        k = 1
        agct_tmp = S[i]
        if i+k < len(S):
            while S[i+k] in AGCT:
                #print('k=', k)
                #print('i+k=',i+k)
                agct_tmp += S[i+k]
                if i+k+1 < len(S):
                    k +=1
                else:
                    break
    
        AGCT_list.append(agct_tmp)
        i = i + k + 1
    else:
        i += 1
if AGCT_list:
    print(max([len(string) for string in AGCT_list]))
else:
    print('0')

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

S = X()
a = [0]
b = ["A","G","C","T"]

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

print(max(a))

Submission status: Accepted

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

ans = 0
for i in range(N+1):
    for j in range(i+1, N+1):
        if set(S[i:j]) <= set('ACGT'):
            ans = max(ans, j-i)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
x = ['A', 'C', 'T', 'G']

i = 0
count = 0
ans = 0
while i < len(S):
    if S[i] in x:
        count += 1
        ans = max(ans, count)
    else:
        count = 0
    i += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""abc122_b"""
S = input()

CNT = 0

ANS = [0]
for s in S:
    if s in "ACTG":
        CNT += 1
    elif CNT != 0:
        ANS.append(CNT)
        CNT = 0
ANS.append(CNT)

print(max(ANS))

Submission status: Accepted

Solution code:
from math import gcd
import re
s=input()
match=re.findall("[ACGT]*",s)
length=0
for i in match:
    length=max(length,len(i))
print(length)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
acgt = {'A','C','G','T'}
m = 0
c = 0
for s in S:
  if s in acgt:
    c+=1
    m = max(m,c)
  else:
    m = max(m,c)
    c = 0
print(m)

Submission status: Accepted

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

    i = j
    ans = max(ans, count)
    count = 0
print(ans)

Submission status: Accepted

Solution code:
import sys
import re

rr = lambda: sys.stdin.readline().rstrip()
txt = rr()
box = re.findall(r'[ATCG]+', txt)
ans = 0
for i in box:
    ans = max(len(i), ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = ('A', 'T', 'C', 'G')
S = input()

ans = [0]
res = 0
for i in range(len(S)):
    if S[i] in l:
        res += 1
    elif res != 0:
        ans.append(res)
        res = 0
ans.append(res)

print(max(ans))

Submission status: Accepted

Solution code:
l = ('A', 'T', 'C', 'G')
S = input()

ans, res = 0, 0
for i in range(len(S)):
    if S[i] in l:
        res += 1
    else:
        ans = max(ans, res)
        res = 0
ans = max(ans, res)

print(ans)

Submission status: Accepted

Solution code:
s=input()
Flag=True
cnt=0
ans=0
for i in range(len(s)):
    if s[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())
T = ['1' if s in ['A', 'C', 'G', 'T'] else '0' for s in S]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
print(max(map(len,re.split("[BDEFHIJKLMNOPQRSUVWXYZ]",input()))))

Submission status: Accepted

Solution code:
S = input()
T = ["A","C","G","T"]
A = []
c = 0

for s in S:
  if s in T:
    c+=1
  else:
    c=0
  A+=[c]
  
print(max(A))

Submission status: Accepted

Solution code:
s = input()

ans = 0
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
        ans = max(ans, count)
    else:
        count = 0

print(ans)

Submission status: Accepted

Solution code:
s = input()
dic = {"A", "T", "C", "G"}

k = [1 if s[i] in dic else 0 for i in range(len(s))]

result = []
for i in range(len(k)):
    cnt = 0
    if k[i] == 1:
        cnt = 1
        j = i-1
        while j >= 0:
            if k[j] == 1:
                cnt += 1
                j -= 1
            else:
                break
    result.append(cnt)

print(max(result))

Submission status: Accepted

Solution code:
s = input()

ans = 0
tmp = 0
for i in s:
    if i in ["A", "C", "G", "T"]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
else:
    ans = max(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
s = input()
l = []
cnt = 0
for c in s:
    if c == 'A' or c =='C' or c == 'G' or c == 'T':
        cnt += 1
    else:
        l.append(cnt)
        cnt = 0

l.append(cnt)
print(max(l))

Submission status: Accepted

Solution code:
""" tutorial03
    https://atcoder.jp/contests/abc122/tasks/abc122_b
"""
import sys
import math

def main(s):
    """ main
    """
    result = 0
    count = 0

    for c in s:
        if c in ["A", "T", "C", "G"]:
            count += 1
        else:
            if result < count:
                result = count
            count = 0

    if result < count:
        result = count

    return result

if __name__ == "__main__":
    S = sys.stdin.readline()

    print(main(S))

Submission status: Accepted

Solution code:
S="x"+input()

T=[0]*(len(S)+1)
U={"A","C","G","T"}

for i in range(len(S)):
    if S[i] in U:
        T[i]=T[i-1]+1
    else:
        T[i]=0
print(max(T))

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

s = S()
cnt = 0
max_reg = 0
for x in s:
    if 'A' in x or 'C' in x or 'G' in x or 'T' in x:
        cnt += 1
    else:
        max_reg = max(max_reg,cnt)
        cnt = 0
max_reg = max(max_reg,cnt)
print(max_reg)

Submission status: Accepted

Solution code:
s = input()

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

ans = 0
cnt = 0

for i in range(len(s)):
    if s[i] not in x:
        ans = max(ans,cnt)
        if i != (len(s)-1):
            cnt = 0
    else:
        cnt += 1
            
ans = max(ans,cnt)
        
print(ans)