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()

ans = 0
for i in range(len(s)):
    for j in range(i,len(s)):
        tmp = s[i:j+1]
        if set(list(tmp)) <= set(["A","C","G","T"]):
            ans = max(ans,len(tmp))
print(ans)

Submission status: Accepted

Solution code:
import re
S = input()
string = re.findall(r'([ACGT]+)', S)

if len(string) != 0:
  lenst = [len(x) for x in string]
  print(max(lenst))
  
else:
  print(0)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    N = len(S)

    ans = 0

    for i in range(N):
        for j in range(i, N):
            for k in range(i, j + 1):
                if S[k] not in ("A", "C", "G", "T"):
                    break
            else:
                ans = max(ans, j - i + 1)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
count = 0
lens = []

for i, _ in enumerate(s):
  for c in s[i:]:
    if c in ['A', 'G', 'C', 'T']:
      count += 1
    else:
      break
  lens.append(count)
  count = 0
  
print(max(lens))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
s = {"A", "C", "G", "T"}
ans = 0
tmp = 0
for i in S:
  if i in s:
    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 = 0
Max = 0
if len(S) == 1:
    if  S[0] in ACGT:
        print(1)
    else:
        print(0)
else:
    for s in S:
        if s in ACGT:
            count += 1
            if count > Max:
                Max = count
        else:
            if count > Max:
                Max = count
            count = 0
    print(Max)

Submission status: Accepted

Solution code:
S=input()
ans = 0
for i in range(1,len(S)+1):
    for j in range(0,len(S)-i+1):
        if all([c in ["A","T","G","C"] for c in S[j:j+i]]):
            ans = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
l=0
ans=0
for i in s:
  if i in "ATGC":
    l+=1
  else:
    l=0
  ans=max(ans,l)

print(ans)

Submission status: Accepted

Solution code:
s = input()
l = 0
ans = 0
for i in s:
    if i in "ATGC":
        l += 1
    else:
        l = 0
    ans = max(ans, l)
print(ans)

Submission status: Accepted

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

start = False
counts = [0]

for i, c in enumerate(S):
	if c in l:
		if start == False:
			start = True
			count = 1
		else:
			count += 1
			
		if i == len(S) - 1:
			counts.append(count)
	else:
		if start == False:
			continue
		else:
			start = False
			counts.append(count)
			count = 0

print(max(counts))

Submission status: Accepted

Solution code:
a=input()
total=0
total2=0
i=0
while True:
    if i==len(a):
        break
    elif a[i]=="A" or a[i]=="T" or a[i]=="C" or a[i]=="G":
        total+=1
        i+=1
    else:
        i+=1
        if total2<total:
            total2=total
        total=0
if total2<total:
    print(total)
else:
    print(total2)

Submission status: Accepted

Solution code:
s = input()
length = 0
max_length = 0

for i in range(len(s)):
    if s[i] in 'ACGT':
        length += 1
    else:
        length = 0
    if length > max_length:
        max_length = length
print(max_length)

Submission status: Accepted

Solution code:
def is_ACGT(c):
    return c == "A" or c == "C" or c == "G" or c == "T"

S = input()

ans = 0
for i in range(len(S)):
    j = 0
    while i+j < len(S) and is_ACGT(S[i+j]):
        j += 1
    ans = max(ans, j)

print(ans)

Submission status: Accepted

Solution code:
#b
S=input()

l = len(S)
ans=0
for i in range(l):
    for j in range(i,l):
        ss = S[i:j+1]
        if all(sss in ["A","G","C","T"] for sss in ss):
            cand = len(ss)
            ans=max(ans,cand)
print(ans)

Submission status: Accepted

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

ans = 0
tmp = 0
ACGT = {"A", "C", "G", "T"}
i = 0
while i < N:
  if S[i] in ACGT:
    tmp += 1
  else:
    ans = max(ans, tmp)
    tmp = 0
  i += 1
    
ans = max(ans, tmp)  

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
n=len(s)
res=0
for i in range(n):
  if s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T':
    ans=1
    j=i+1
    while j<n:
      if s[j]=='A' or s[j]=='C' or s[j]=='G' or s[j]=='T':
        ans+=1
        j+=1
      else:
        break
  else:
    continue
  res=max(res,ans)
print(res)

Submission status: Accepted

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

s = input().strip()

ans = 0
tmp = 0
for v in s:
    if v in ('A', 'C', 'G', 'T'):
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
# 最後がACGT文字だった場合
ans = max(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
def main():
    s = input()
    acgt_flag = [0 for i in range(len(s))]

    for i in range(len(s)):
        if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
            acgt_flag[i] = 1

    counter = 0
    counter_max = 0
    for i in range(len(acgt_flag)):
        if acgt_flag[i] == 1:
            counter += 1
            if counter_max < counter:
                counter_max = counter
        else:
            counter = 0

    print(counter_max)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input().split())
S = list(s)

ans = 0
alist = []

for i in range(len(s)):
  if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
    ans += 1
  else:
    alist.append(ans)
    ans = 0
    
print(max(alist))

Submission status: Accepted

Solution code:
S = input()
S += '0'
max = 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 
    else :
        if count > max :
            max = count
            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
    if max < count:
      max = count
  else:
    count = 0
print(max)

Submission status: Accepted

Solution code:
N =list(str(input()))
l=['A','C','G','T']

ans=0
for i in range(len(N)):
    num=0
    for u in range(len(N)-i):
        #print(N[i+u])
        if N[i+u] in l:
            num+=1
        else:
            break
    ans=max(ans,num)        
print(ans)

Submission status: Accepted

Solution code:
target = 'ACGT'
S = input()

answer = 0
for start in range(len(S)):
    if S[start] not in target:
        continue
    count = 0
    for end in range(start, len(S)):
        if S[end] not in target:
            break
        count += 1
    
    answer = max(answer, count)

print(answer)

Submission status: Accepted

Solution code:
target = 'ACGT'
S = input()

answer = 0
for start in range(len(S)):
    if S[start] not in target:
        continue
    count = 0
    for end in range(start, len(S)):
        if S[end] in target:
            count += 1
        else:
            break
    
    answer = max(answer, count)

print(answer)

Submission status: Accepted

Solution code:
s = input()
tmp = 0
max = 0
def check(i):
  if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
    return True
  else:
    return False
for i in range(len(s)):
  if check(i):
    tmp += 1
  else:
    tmp = 0
  if tmp > max:
    max = tmp
print(max)

Submission status: Accepted

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

resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    S = input()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
#import numpy as np
import math
#sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    key = {"A","C","G","T"}
    mx = 0
    count = 0
    for item in s:
        if item in key:
            count += 1
        else:
            mx = max(mx,count)
            count = 0
    mx = max(mx,count)
    print(mx)
    return

if __name__=='__main__':
    s = S()
    solve()

Submission status: Accepted

Solution code:
s = list(input())
count = 0
list1 = []
for x in s:
  if x == 'A' or x == 'G' or x == 'T' or x == 'C':
    count = count + 1
  list1.append(count)
  if x != 'A' and x != 'G' and x != 'T' and x != 'C':
    count = 0
    

print(max(list1))

Submission status: Accepted

Solution code:
s = input()
x = list()
cnt = 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
        if i == len(s) - 1:
            x.append(cnt)
    else:
        x.append(cnt)
        cnt = 0
print(max(x))

Submission status: Accepted

Solution code:
s=input()
count=0
ans=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:
        ans=max(ans,count)
        count=0
print(max(ans,count))

Submission status: Accepted

Solution code:
max_len = 0
tmp = 0

S = input()
acgt = {'A': 0, 'C': 0, 'G': 0, 'T': 0}

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

max_len = max(max_len, tmp)
print(max_len)

Submission status: Accepted

Solution code:
b=list(str(input()))
E={"A","C","G","T"}
count=0
ans=0
for moji in b:
	if moji in E:
		count+=1
	else:
		ans=max(ans,count)
		count=0
ans=max(ans,count)
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):
        t = s[i:j]
        if (all(map(lambda x:x in ['A','C','G','T'],t))):
            ans = max(len(t),ans)
print(ans)

Submission status: Accepted

Solution code:
S=input()
ans=0
length=0
for c in S:
    if (c == 'A' or c == 'G' or c == 'C' or c == 'T'):
        length += 1
        if length > ans:
            ans = length
    else:
        length = 0

print(ans)

Submission status: Accepted

Solution code:
s = input()
# print(s)

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

S = input()

ans = 0
cnt = 0
for s in S:
    if s 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()
 
S = list(S)
 
ls = len(S)
count = 0
ans = 0
 #一番最後がATGCでなくとも対応可にしておく
for i in range(ls):
      if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
          count += 1
          if count >= ans:
              ans = count
      else:
          count = 0
 
print(ans)

Submission status: Accepted

Solution code:
S = input()

S = list(S)

ls = len(S)
count = 0
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
S=input()
cnt=0
lis=[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
        lis.append(cnt)
    else:
        cnt=0
print(max(lis))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

print(m)

Submission status: Accepted

Solution code:
s=input()
ans=[0]
atgc=["A","T","G","C"]
for i in range(len(s)):
    for k in range(i,len(s)):
        check=s[i:k+1]
        complete=0
        for i in range(len(check)):
            if check[i] in atgc:
                complete+=1
        if complete==len(check):
            ans.append(len(check))
print(max(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,tmp=0,0
for s in S:
  if s in ['A','T','G','C']:
    tmp+=1
  else:
    ans=max(tmp,ans)
    tmp=0
print(max(ans,tmp))

Submission status: Accepted

Solution code:
S=list(input())

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

max_length = 0
length = 0
for word in S:
    if word in acgt:
        length+=1
    else:
        if length!=0:
            if max_length<length:
                max_length=length
            length=0
if length!=0:
    if max_length<length:
        max_length=length
print(max_length)

Submission status: Accepted

Solution code:
import re
S = input()

strings = re.findall('[ACGT]*',S)

print(max(map(len,strings)))

Submission status: Accepted

Solution code:
import sys
import numpy as np
import numba
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@jit
def main(s):
  ans = 0
  for j, i in enumerate(s):
    if i=='A' or i=='C' or i=='G' or i=='T':
      cnt = 1
      j += 1
      while s[j]=='A' or s[j]=='C' or s[j]=='G' or s[j]=='T':
        j += 1
        cnt += 1
      ans = max(ans, cnt)
  return ans
        
s = str(readline().split())
print(main(s))

Submission status: Accepted

Solution code:
s = input()
l = [0]
c = 0
for i in s:
  if i in "ACGT":
    c += 1
  else:
    l.append(c)
    c = 0
l.append(c)
print(max(l))

Submission status: Accepted

Solution code:
l=input()

ans=0
num=0

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

Submission status: Accepted

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

for i in range(len(S)):
    if S[i] in ACGT:
        cnt = 1
        for j in range(len(S) - i - 1):
            if S[i+j+1] in ACGT:
                cnt += 1
            else:
                ans[i] = cnt
                break
        ans[i] = cnt

print(max(ans))

Submission status: Accepted

Solution code:
import re;print(max(len(i)for i in re.split('[^ACTG]',input())))

Submission status: Accepted

Solution code:
S = str(input())

ans = 0
cnt = 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
for i in range(len(s)):
  if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
    cnt+=1
  else:
    ans=max(ans,cnt)
    cnt=0
ans=max(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
ans=0
rans=0
c=0
check=True
S = input().rstrip()
def countans(s,rans,check):
  if (s=='A' or s=='C' ) or (s=='G'or s=='T'):
    rans+=1
  else:
    check=False
  return rans,check

for s in range(len(S)):
  rans=0
  check = True
  while True:
    if check:
      rans, check = countans(S[s],rans,check)
      if s>=len(S)-1:
        break
      s+=1
    else:
      break
  if ans<rans:
    ans =rans

print(ans)

Submission status: Accepted

Solution code:
#from functools import lru_cache
import sys
from itertools import product,combinations,accumulate
from functools import reduce,lru_cache
import heapq

def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def list_t(l): return vfunc(lambda *args:args)(*l)

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

s = reader()[0][0]
score = [0]
for i in s:
    if i in 'ACGT':score.append(score[-1]+1)
    else:score.append(0)
print(max(score))

Submission status: Accepted

Solution code:
#
# abc122 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """ATCODER"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """HATAGAYA"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """SHINJUKU"""
        output = """0"""
        self.assertIO(input, output)


def resolve():
    S = input()

    ans = 0
#    for i in range(len(S)):
#        t = 0
#        if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
#            t += 1
#            for j in range(i+1, len(S)):
#                if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
#                    t += 1
#                else:
#                    break
#        ans = max(ans, t)

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


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
#
# abc122 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """ATCODER"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """HATAGAYA"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """SHINJUKU"""
        output = """0"""
        self.assertIO(input, output)


def resolve():
    S = input()

    ans = 0
    for i in range(len(S)):
        t = 0
        if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
            t += 1
            for j in range(i+1, len(S)):
                if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
                    t += 1
                else:
                    break
        ans = max(ans, t)

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
S = list(input())[: -1]
res = 0
for l in range(len(S)):
  for r in range(l + 1, len(S) + 1):
    for i in range(l, r):
      if not S[i] in ["A", "T", "C", "G"]: break
    else: res = max(res, r - l)
print(res)

Submission status: Accepted

Solution code:
S = input()

max_num = 0

count = 0
for x in S:
    if x in 'ACGT':
        count += 1
    else:
        max_num = max(max_num, count)
        count = 0

print(max(max_num, count))

Submission status: Accepted

Solution code:
s=input()
n=len(s)
c,m=0,0
l='ACTG'
for i in range(n):
    if(s[i] in l):
        c+=1
        m=max(c,m)
    else:
        c=0
m=max(c,m)
print(m)

Submission status: Accepted

Solution code:
import itertools

S = list(input())
Idxs = list(itertools.combinations(range(len(S)), 2)) 

def ACGT(Word):
    for w in Word:
        if w not in ["A", "C", "G", "T"]:
            return 0
    return len(Word)

ans = 0

for s in S:
    if s in ["A", "C", "G", "T"]:
        ans = 1
        break

for idx in Idxs:
    tmp = S[idx[0]:idx[1]+1]
    ans = max(ans, ACGT(tmp))
    
print(ans)

Submission status: Accepted

Solution code:
S = list(input())

ans = [0]
ans_ = 0
for s in S:
    if s == "A" or s == "C" or s == "G" or s == "T":
        ans_ += 1
    else:
        ans.append(ans_)
        ans_ = 0
ans.append(ans_)
print(max(ans))

Submission status: Accepted

Solution code:
S = input()
Answer = 0
for i in range(len(S)):
    counter = 0
    for j in range(len(S)-i):
        if S[j] in ['A','C', 'G','T']:
            counter += 1
            if Answer < counter:
                Answer = counter
            j = i + 1
        else:
            counter = 0
print(Answer)

Submission status: Accepted

Solution code:
ans = 0
c = 1
li = ["A","C","G","T"]
s = input()
lens = len(s)
for i in range(lens):
    for j in range(lens-(i)):
        a = s[j:j+i+1]
        for k in range(i+1):
            if a[k] not in li:
                c = 1
                break
            else:
                c = 0
                continue
        if c == 0:
            ans = i+1
        else:
            c = 1
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
n = len(S)
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+1-i)
print(ans)

Submission status: Accepted

Solution code:
S = input().rstrip()
P = {"A", "C", "G", "T"}
cnt = 0
res = 0
for s in S:
    if s in P:
        cnt += 1
        res = max(cnt, res)
    else:
        cnt = 0
print(res)

Submission status: Accepted

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

res = 0
for i in range(n):
    for j in range(i, n):
        sub = s[i: j+1]

        flg = True
        for c in sub:
            if(c not in ['A', 'G', 'C', 'T']): flg = False

        if(flg): res = max(res, len(sub))

print(res)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
target = ['A', 'C', 'G', 'T']
ans = []
for i in range(N):
    ret = 0
    for j in S[i:N]:
      if not j in target:
        break
      ret += 1
    ans.append(ret)
    i = j
print(max(ans))

Submission status: Accepted

Solution code:
S = input()

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


max_l = 0

for i in range(len(S)):
    l = 0
    for j in range(i, len(S)):
        if S[j] in acgt:
            l+=1
        else:
            break
    if l > max_l:
        max_l = l
print (max_l)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    ACGT = 'ACGT'

    ans = 0
    for i in range(len(S)):
        for j in range(i + 1, len(S) + 1):
            if j - i < ans:
                continue
            ok = True
            for c in S[i:j]:
                if c not in ACGT:
                    ok = False
                    break
            if ok and ans < j - i:
                ans = j - i

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
S = input()
maxer = 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
        if maxer < count:
            maxer = count
    else:
        count = 0
print( maxer )

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = "BDEFHIJKLMNOPQRSUVWXYZ"
res = ""
for x in s:
    if x in t:
        res += "0"
    else:
        res += x
ans = 0
for a in res.split("0"):
    ans = max(ans, len(a))
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = 0
start = 0
end = 1

def acgt(s):
    count = 0
    for i in ["A","T","G","C"]:
        count += s.count(i)
    return count

while start < len(s):
    check = s[start:end]
    while len(check) == acgt(check) and end <= len(s):
        end += 1
        check = s[start:end]
    lenth = end - start -1
    ans = max(ans, lenth)
    start = end
print(ans)

Submission status: Accepted

Solution code:
#n = int(input())
#n, k = map(int, input().split())
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(h)]
s = list(input())


def isACGT(s):
    A = s.count('A')
    C = s.count('C')
    G = s.count('G')
    T = s.count('T')
    if A+C+G+T == len(s):
        return True
    else:
        return False


ans = 0
n = len(s)
for i in range(n):
    for j in range(i, n):
        tempstring = s[i:j+1]
        if isACGT(tempstring):
            ans = max(ans, len(tempstring))
print(ans)

Submission status: Accepted

Solution code:
S=input()
agct='AGCT'
ans=0
for i in range(len(S)):
  cnt=0
  j=i
  while j<len(S) and S[j] in agct :
    cnt+=1
    j+=1
  ans=max(ans,cnt)
print(ans)

Submission status: Accepted

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

for i in range(L):
    for j in range(i, L):
        sub_S = S[i:j+1]
        if all([s in ACGT for s in sub_S]):
            if len(sub_S) > ans:
                ans = len(sub_S)

print(ans)

Submission status: Accepted

Solution code:
S = input()

max_cnt = 0
for i in range(len(S)):
    cnt = 0
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        cnt += 1
        for j in range(len(S)-(1+i)):
            if S[j+i+1] == "A" or S[j+i+1] == "C" or S[j+i+1] == "G" or S[j+i+1] == "T":
                cnt += 1
            else:
                break
    if cnt >= max_cnt:
        max_cnt = cnt
print(max_cnt)

Submission status: Accepted

Solution code:
s = str(input())
w = ""
l = []
for i in s:
    if i=='A' or i=='C' or i=='G' or i=='T':
        w += i
    else:
        l.append(len(w))
        w = ""
l.append(len(w))
print(max(l))

Submission status: Accepted

Solution code:
def main():
    S = input()
    ans = 0
    cnt = 0
    flag = False

    for i in range(len(S)):
        if S[i] in "ACGT":
            flag = True
            cnt += 1

        if S[i] not in "ACGT" or i == len(S) - 1:
            flag = False

        if flag == False and cnt > ans:
            ans = cnt
            cnt = 0

    print(ans)


if __name__ == "__main__":
    main()