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()
L = [s in "ACGT" for s in S]
ans, cnt = 0, 0
for l in L:
  if l == True:
    cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
ans = max(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:

s = list(input())

max_len = 0
tmp_len = 0

acgt = ['A','C','G','T']
s.append('B')

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

print(max_len)

Submission status: Accepted

Solution code:
def main():
    S = input()

    s = set()
    s.add('A')
    s.add('C')
    s.add('G')
    s.add('T')

    max_count = 0

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

    max_count = max(max_count, count)
    print(max_count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

cnt = 0
maxcnt = 0
for i in range(len(S)):
    if S[i] in L:
        cnt += 1
    else:
        if maxcnt < cnt:
            maxcnt = cnt
        cnt = 0
if maxcnt < cnt:
    maxcnt = cnt
print(maxcnt)

Submission status: Accepted

Solution code:
s=input()
ans=0
c=0
d={"A","C","G","T"}
for i in range(len(s)):
    if not s[i] in d:
        ans=max(ans,c)
        c=0
    else:
        c+=1
ans=max(ans,c)

print(ans)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
S += "?"

s = 0
t = 0
ans = 0
while t < N:
    while t < N:
        if S[t] in "ATGC":
            t += 1
        else:
            break
    ans = max(ans, t - s)
    s = t + 1
    t = s

print(ans)

Submission status: Accepted

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


s = input()

max = 0

for i in range(len(s)):
    if judacgt(s[i]):
        if max==0:
            max=1
        for j in range(i+1,len(s)):
            # print(s[i:j])
            if judacgt(s[j])==False:
                break
            elif j-i+1 > max:
                max=j-i+1
print(max)

Submission status: Accepted

Solution code:
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    s = input()
    n = len(s)

    cnt = 0
    cf = False
    cnts = list()

    for i in range(n):
        if s[i] in ['A', 'C', 'G', 'T']:
            cf = True
            cnt += 1
        
        elif cf:
            cf = False
            cnts.append(cnt)
            cnt = 0
        
        if cf and i == n-1:
            cnts.append(cnt)

    if cnts:
        print(max(cnts))
    else:
        print(0)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = list(input())

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

print(m)

Submission status: Accepted

Solution code:
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


s = input()
ans = 0
cnt = 0

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

Submission status: Accepted

Solution code:
s = input()
ma = 0
#ma_s = ''
for i in range(len(s)+1):
    for j in range(i,len(s)+1):
        part = s[i:j]
        flag = 1
        for k in range(len(part)):
            if not part[k] in 'ATGC':
                flag = 0
        if flag:
            if ma < len(part):
                ma = len(part)
                #ma_s = part
#print(ma_s)
print(ma)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ACGT = []
others = 'BDEFHIJKLMNOPQRSUVWXYZ'
for i in range(N):
    fl = True
    for j in range(i+1,N+1):
        tmp_S = S[i:j]
        M = len(tmp_S)
        for k in range(M):
            if tmp_S[k] in others:
                fl = False
        if fl==False:
            break
        ACGT.append(tmp_S)
len_ACGT = [len(x) for x in ACGT]
print(max(len_ACGT)) if len(len_ACGT)>0 else print(0)

Submission status: Accepted

Solution code:
s = input()

count = 0
for i in range(len(s)):
    c=0
    if s[i]!='A' and s[i]!='C' and s[i]!='G' and s[i]!='T':
        continue
    c=1
    for j in range(i+1,len(s)):
        if s[j]!='A' and s[j]!='C' and s[j]!='G' and s[j]!='T':
            break
        else:
            c+=1
    count = c if count<=c else count
print(count)

Submission status: Accepted

Solution code:
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


def main():

    s = input()
    ans = 0
    now = 0
    isATCG = False
    for i in range(len(s)):
        if s[i] in ["A", "G", "C", "T"]:
           isATCG = True

        if isATCG == False:
            now = 0
        else:
            now += 1
            ans = max(now,ans)

        isATCG = False

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())

maxlen=0
for i in range(len(S)):
    for j in range(i,len(S)):
        for k in range(i,j+1):
            #cnt=0
            if S[k]!='A' and S[k]!='C' and S[k]!='G' and S[k]!='T':
                break
            if k==j and j-i+1>maxlen:
                maxlen=j-i+1
print(maxlen)

Submission status: Accepted

Solution code:
S = input()
result = 0
for i in range(len(S)):
    head = S[i:]
    for j in range(len(head)):
        tail = head[:j + 1]
        if len(list(filter(lambda x: x not in "ACGT", tail))) == 0:
            result = len(tail) if len(tail) > result else result
print(result)

Submission status: Accepted

Solution code:
str = input()

ans=0
temp=0
for i in range(len(str)):
  if str[i] in 'ACGT':
    temp += 1
  else:
    if ans < temp:
      ans = temp
    temp = 0

if ans < temp:
  ans = temp

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
L = ['A','C','G','T']
S = input()
N = len(S)
cnt = -1
cnt1 = 0
for i in range(N):
    if S[i] in L:
        cnt1 += 1
    else:
        cnt = max(cnt,cnt1)
        cnt1 = 0

ans = max(cnt,cnt1)

print(ans)

Submission status: Accepted

Solution code:
S = input()

len_ACGT = 0
canCount = False
max_len = 0
for s in S:
  if (s in "ACGT"):
    if(canCount == False):
      canCount = True
    len_ACGT += 1
  else:
    if(canCount == True):
      canCount = False
      len_ACGT = 0

  if(len_ACGT > max_len):
    max_len = len_ACGT

print(max_len)

Submission status: Accepted

Solution code:
S = input()
lst = ['A', 'G', 'C' ,'T']
max_num = 0
for i in range(len(S)):
    cnt = 0
    if S[i] in lst:
        cnt += 1
        for j in range(i+1, len(S)):
            if S[j] in lst:
                cnt += 1
            else:
                break
    if cnt > max_num:
        max_num = cnt

print(max_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import math
#import bisect
#import numpy as np
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    s = input()
    p =['A', 'C', 'G', 'T']
    ans = 0
    cnt = 0

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

ans = 0
ans_li= []

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

Submission status: Accepted

Solution code:
S = input()
T = set({'A', 'T', 'C', 'G'})

ans = 0
for l in range(len(S)):
    for r in range(l + 1, len(S) + 1):
        if set(S[l:r]) <= T:
            ans = max(ans, r - l)
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = set(list('AGCT'))

ans = 0
for l in range(len(S)):
    for r in range(l + 1, len(S) + 1):
        if set(S[l: r]) <= T:
            ans = max(ans, r - l)

print(ans)

Submission status: Accepted

Solution code:
s = input()

substring = set(['A', 'C', 'G', 'T'])

MAX = 0
i = 0
while i < len(s):
    t = 0
    for j in range(i, len(s)):
        if s[j] in substring:
            t += 1
        else:
            break
    i += 1
    MAX = max(MAX, t)
print(MAX)

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(cnt,ans)
        cnt=0
    ans=max(cnt,ans)
print(ans)

Submission status: Accepted

Solution code:
import sys

def solve():
    S = input()
    ans = 0
    OK = set(["A", "G", "C", "T"])
    for i in range(len(S)):
        for j in range(i + 1, len(S) + 1):
            temp = 0
            for k in range(i, j):
                if S[k] in OK: temp += 1
                else: break
            else:
                ans = max(ans, temp)
    print(ans)
            
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
S = input()
i = 0
ans = 0
while i < len(S):
    c = 0
    while i < len(S) and S[i] in 'ACGT':
        c += 1
        i += 1
    ans = max(ans, c)
    i += 1
print(ans)

Submission status: Accepted

Solution code:
*s, = input()

s.append(" ")

c = 0
ans = 0
for i in range(len(s)):
    if s[i] not in "ACGT":
        ans = max(ans, i - c)
        c = i+1

print(ans)

Submission status: Accepted

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

res = 0
max_res = 0
for i in range(len(S)):
  flag = 0
  for j in range(len(ACGT_str)):
    if S[i] == ACGT_str[j]:
      flag = 1
  
  if flag == 1:
    res += 1
  else:
    if res > max_res:
      max_res = res
    res = 0

if res > max_res:
  max_res = res

print(max_res)

Submission status: Accepted

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

S = input().strip()

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

max_cnt = max(max_cnt,cnt)
print(max_cnt)

Submission status: Accepted

Solution code:
#python3
def main():
    s = input()
    ans = 0
    cnt = 0
    for i in range(len(s)):
        if (s[i] == "A") | (s[i] == "T") | (s[i] == "C") | (s[i] == "G"):
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, cnt)
    print(ans)
main()

Submission status: Accepted

Solution code:
#python3
from collections import Counter
def main():
    s = input()
    ans = 0
    cnt = 0
    for i in range(len(s)):
        if (s[i] == "A") | (s[i] == "T") | (s[i] == "C") | (s[i] == "G"):
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, cnt)
    print(ans)
main()

Submission status: Accepted

Solution code:
S = str(input())
sam = ['A','C','G','T']
box = []
count = 0
for i in range(len(S)):
    if i == 0 and S[i] in sam:
        count+=1
    elif i > 0:
        if count == 0 and S[i] in sam:
            count+=1
        elif S[i] in sam and S[i-1] in sam:
            count+=1
        else:
            box.append(count)
            count=0
box.append(count)
        
print(max(box))

Submission status: Accepted

Solution code:
S = input()
acgt = ('A', 'C', 'G', 'T')
right = 0
res = -1
for left in range(len(S)):
    while right < len(S) and S[right] in acgt:
        right += 1
    res = max(res, right - left)
    if left == right:
        right += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().rstrip()
N = len(S)
ans = 0
from collections import Counter
for i in range(N):
    for j in range(i + 1, N + 1):
        flag = 1
        s = S[i:j]
        c = Counter(s)
        for k in c.keys():
            if k != "A" and k != "C" and k != "G" and k != "T":
                flag = 0
                break
        if flag:
            ans = max(ans, len(s))       

print(ans)

Submission status: Accepted

Solution code:
S =input()
output_length = 0
for i,s in enumerate(S):
    if s not in ["A","C","G","T"]:
        continue
    partial_str = s
    if i+1 > len(S):
        break

    for s2 in S[i+1:]:
        if s2 not in ["A","C","G","T"]:
            break
        partial_str +=s2
    if len(partial_str) >  output_length:
        output_length =len(partial_str)
print(output_length)

Submission status: Accepted

Solution code:
S = input()

N = len(S)
ans = 0

for i in range(N):
    for j in range(i, N):
        #cは調べる文字列の一部分
        #ACGTの中にその文字があるかどうか調べる
        #すべてあればそれはACGT文字
        if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
            #j-i+1はその文字列の長さ
            ans = max(ans, j - i + 1)
print(ans)

Submission status: Accepted

Solution code:
S = input()
n = len(S)
ans = 0
flag = True

for i in range(n):
  for j in range(i):
    for k in range(i,n+1):
      S_part = S[j:k]
      for s in S_part:
        if not s in "ACGT":
          flag = False
      if flag:
        ans = max(ans,len(S_part))
      flag = True

if n == 1:
  if S[0] in "ACGT": ans = 1
print(ans)

Submission status: Accepted

Solution code:
X = list(input())
list_1 = ["A","T","G","C"]
ans =[]
num = 0
for i in X:
    if i in list_1:
        num += 1
        ans.append(num)
    else:
        num = 0
        ans.append(num)

print(max(ans))

Submission status: Accepted

Solution code:
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
ans=max(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
S = input()

src = ["A","T","C","G"]
ok = True
ans = 0
tmp = 0
for s in S:
    if not ok:
        tmp = 0
    ok = s in src
    if ok:
        tmp += 1
    ans = max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())

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

Submission status: Accepted

Solution code:
N=[a for a in input()]+["Z"]
count=0
lis=["A","G","C","T"]
ans=[]

for i in N:
  if i in lis:
    count+=1
  else:
    ans.append(count)
    count=0

print(max(ans))

Submission status: Accepted

Solution code:
def main():
    s = input()
    acgt = set("ACGT")
    max_len = 0
    for i in range(len(s)+1):
        for j in range(i+1, len(s)+1):
            p = s[i:j]
            if set(p) <= acgt:
                max_len = max(len(p), max_len)
    print(max_len)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

ans = 0
ACGT = set("ACGT")

for i in range(len(S)) :
    for j in range(len(S)+1) :
        if i < j :
            if set(S[i:j]) <= ACGT :
                ans = max(ans, len(S[i:j]))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#122_B
S=input()
Ans=0
cnt=0
for s in S:
    if s in 'ATCG':
        cnt+=1
    else:
        Ans=max(Ans,cnt)
        cnt=0
Ans=max(Ans,cnt)
print(Ans)

Submission status: Accepted

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

######
# URL: https://atcoder.jp/contests/abc122/tasks/abc122_b
######

def main():
    S = input()
    ans = 0
    for begin in range(len(S)):
        for end in range(begin, len(S)):
            if sum([ "ACGT".count(s) for s in S[begin:end+1]]) == len(S[begin:end+1]):
                ans = max(ans, len(S[begin:end+1]))
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = read().decode().rstrip()
ans = 0

for l in range(0, len(S)):
    for r in range(l + 1, len(S) + 1):
        flag = True
        for c in [
                "B", "D", "E", "F", "H", "I", "J", "K", "L", "M", "N", "O", "P",
                "Q", "R", "S", "U", "V", "W", "X", "Y", "Z"
        ]:
            if c in S[l:r]:
                flag = False
        if flag:
            ans = max(ans, r - l)

print(ans)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# Code for B - ATCoder
# Use input() to fetch data from STDIN
s = input()

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

m = []
c = 0
for x in s:
    if not x in acgt:
        m.append(c)
        c = 0
    else:
        c += 1
m.append(c)

print(max(m))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

cnt = 0
max = 0

for i in s:
    if i in word_list:
        cnt += 1
        if cnt > max:
            max = cnt
    else:
        cnt = 0

print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC122B - ATCoder
s = str(input())
size = len(s)
ans = 0
for i in range (0,size):
    for j in range (i,size+1):
        hantei = s[i:j]
        countA = hantei.count('A')
        countC = hantei.count('C')
        countG = hantei.count('G')
        countT = hantei.count('T')
        if (len(hantei) == countA + countC + countG + countT):
            if(ans < len(hantei)):
                ans = len(hantei)
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
s=input()
c=0
count=0
hantei=0
d=["A","C","T","G"]
for i in s:
  if i=="A" or i=="C" or i=="T" or i=="G":
    count+=1
  else:
    if hantei<count:
      hantei=count
      count=0
if hantei<count:
  hantei=count
print(hantei)

Submission status: Accepted

Solution code:
def is_acgt(str):
    return all(c in ['A', 'C', 'G', 'T'] for c in list(str))


s = input()
rslt = 0

for i in range(len(s)):
    for j in range(i, len(s)):
        str = s[i:j + 1]
        if is_acgt(str) and rslt < len(str):
            rslt = len(str)

print(rslt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
c=0
r=0
for s in S:
    if s in 'ATCG':
        c+=1
        r=max(r,c)
    else:
        c=0
print(r)

Submission status: Accepted

Solution code:
s=input()
s_len=len(s)
acgt=["A","C","G","T"]
ans=0
for i in range(s_len):
    if s[i] in acgt:
        buf=0
        for j in range(s_len-i):
            if s[i+j] in acgt:
                buf+=1
            else:
                break
        ans=max(ans,buf)
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

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

Submission status: Accepted

Solution code:
def solve():
    L = list(input())
    l = ['A', 'C', 'G', 'T']
    m = 0
    tmp = 0
    for i in L:
        if i in l:
            tmp += 1
            m = max(m, tmp)
        else:
            tmp = 0
    
    return m

print(solve())

Submission status: Accepted

Solution code:
import sys

S = sys.stdin.readline()
ans = 0
valid = {"A", "C", "G", "T"}

l = 0
for s_i in S:
    if s_i in valid:
        l += 1
    else:
        ans = max(ans, l)
        l = 0
print(max(ans, l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations
A = ["A","C","G","T"]
S = input().strip()
lmax = 0
for x in combinations(range(len(S)+1),2):
    l,r = x
    flag = 0
    for i in range(l,r):
        if S[i] not in A:
            flag = 1
            break
    if flag==0:
        lmax = max(lmax,r-l)
print(lmax)

Submission status: Accepted

Solution code:
def ABC106():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        # divisors.sort()
        return divisors
    N = I()
    ans = 0
    for i in range((N+1)//2):
        cur = i*2+1
        if len(make_divisors(cur))==8:
            ans += 1
    print(ans)
    return

def ABC122():
    S = SI()
    ans = 0
    cur = 0
    d = {"A","C","G","T"}
    for s in S:
        if s in d:
            cur += 1
        else:
            ans = max(ans,cur)
            cur = 0
    ans = max(ans,cur)
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    ABC122()

"""

"""

Submission status: Accepted

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

Submission status: Accepted

Solution code:
target = set(["A", "C", "G", "T"])

S = list(input())

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

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

Submission status: Accepted

Solution code:
# 尺取り
S = input()
start = 0
ans = 0

while start < len(S):
    while start < len(S) and S[start] not in "ACGT":
        start += 1
    end = start
    while end < len(S) and S[end] in "ACGT":
        end += 1
    ans = max(ans, end - start)
    start = end

print(ans)

Submission status: Accepted

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

for start in range(n):
    for end in range(start + 1, n + 1):
        T = S[start:end]
        flag = True
        for i in range(len(T)):
            if T[i] not in "ACGT":
                flag = False
                break
        if flag: ans = max(ans, end - start)

print(ans)

Submission status: Accepted

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

ret = 0
for i in range(n):
    for j in range(i + 1, n + 1):
        # [i,j)
        t = s[i:j]
        if all(c in 'ACGT' for c in t):
            ret = max(ret, j - i)

print(ret)

Submission status: Accepted

Solution code:
s = input()
l = 0
max_num = 0

for str in s:
    if str in 'ATCG':
        l += 1
    else:
        max_num = max(max_num, l)
        l = 0
max_num = max(max_num, l)
print(max_num)

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
print(max(ans,tmp))