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

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

Solution (Python):
import sys


def readlines(n):
    for _ in range(n):
        yield map(int, input().split())


def main():
    s = input()

    subst = 0
    for i in range(len(s)):
        if s[i] in "ACGT":
            subst += 1
        else:
            yield subst
            subst = 0
    
    yield subst
    

print(max(main()))

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

print(ans)

Solution (Python):
S = str(input())
count = 0
Answer = 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
        for j in range(len(S)-1-i):
            if S[i+1+j] == "A" or S[i+1+j] == "C" or S[i+1+j] == "G" or S[i+1+j] == "T":
                count+=1
            else:
                break
        if Answer < count:
            Answer = count
            count = 0
        else:
            count = 0

print(Answer)

Solution (Python):
s = input()
items = ['A', 'T', 'G', 'C']
length = 0
maxLen = 0

for i in s:
    if i in items:
        length += 1
    else:
        if length >= maxLen:
            maxLen = length

        length = 0


    if length >= maxLen:
        maxLen = length

print(maxLen)

Solution (Python):
import re

s = input()
s = s.translate(str.maketrans({'A': 'x', 'C': 'x', 'G': 'x', 'T': 'x'}))
s = re.sub(r'[^x]', ' ', s)
s_ls = list(map(len, (s.split())))
if len(s_ls) == 0:
    print(0)
else:
    s_ls.sort()
    print(s_ls[-1])

Solution (Python):
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)

Solution (Python):
S = input()

mx = 0
cnt = 0
for s in S:
    if s not in ['A', 'T', 'C', 'G']:
        mx = max(mx, cnt)
        cnt = -1
    cnt += 1
mx = max(mx, cnt)
print(mx)

Solution (Python):
S = input()

A = 0
B = 0
for i in S:
  if "AGTC".count(i) == 1:
    B += 1
  else:
    A = max(A,B)
    B = 0
A = max(A,B)
print(A)

Solution (Python):
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)

Solution (Python):
S = input()

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

Solution (Python):
ACGT_filter = ['A', 'C', 'G', 'T']

ans = 0
now = 0
for s in input():
    if s in ACGT_filter:
        now += 1
    else:
        now = 0
    ans = max(now, ans)

print(ans)

Solution (Python):
s = input()
for i in s:
    if i not in 'ACGT':
        s = s.replace(i, '0')
print(len(max(s.split('0'), key = len)))

Solution (Python):

s = input()
ans = 0
for i in range(len(s)):
    count = 0
    for j in range(i,len(s)):
        if s[j] in "ACGT":
            count += 1
        else:
            break
    if count >= ans:
        ans = count
print(ans)

Solution (Python):
from sys import stdin

def main():
    word = stdin.readline()
    max = 0
    count = 0
    for i in range(len(word)):
        if word[i] == "A" or word[i] == "C" or word[i] == "G" or word[i] == "T":
            count += 1
        elif max < count:
            max = count
            count = 0
    print(max)

if __name__ == '__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
s1 = []
s2 = [0]

for n in S:
	if n == "A" or n == "C" or n == "G" or n == "T":
		s1.append(1)
	else:
		s1.append(0)

for i in range(len(S)):
	if s1[i] == 0:
		s2.append(0)
	else:
		s2.append(s2[i] + s1[i])

print(max(s2))

Solution (Python):
s = input()
possible_answers = [0]
possible_answer = 0
acgt = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    if s[i] in acgt:
        possible_answer += 1
    else:
        possible_answers.append(possible_answer)
        possible_answer = 0

possible_answers.append(possible_answer)
print(max(possible_answers))

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

Solution (Python):
s = input()
n = len(s)
dp = [0 for i in range(n+1)]
for i in range(n):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'T' or s[i] == 'G':
        dp[i+1] = dp[i] + 1
print(max(dp))

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

S2 = ''
for i in range(len(S)):
    if S[i] in l:
        S2 += S[i]
    else:
        S2 += '-'
S2 = S2.split('-')
ans = 0
for s in S2:
    if ans < len(s):
        ans = len(s)
print(ans)

Solution (Python):
S = input()

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

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

Solution (Python):
s = input()
n = len(s)
res = 0
for i in range(n):
    cnt = 0
    for j in range(i, n):
        if s[j] in "ACGT":
            cnt += 1
        else:
            break
    if cnt >= res:
        res = cnt
print(res)

Solution (Python):
S = input()
llist = [0 for i in range(10)]

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

print(max(llist))

Solution (Python):
S = input()
max = 0
ans = 0

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

print(max)

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    L = len(S)
    ans = 0
    ACGT = ['A', 'C', 'G', 'T']
    tmp = 0
    for i in range(L):
        if S[i] in ACGT:
            tmp += 1
            ans = max(ans, tmp)
        else:
            tmp = 0
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
S=str(input())
max_count = 0
count = 0
for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
    count = count + 1
    if count > max_count:
      max_count = count
  else:
    count = 0
print(max_count)

Solution (Python):
s=input()
c=0
m=0
for e in s:
  if e in "ACGT":
    c+=1
  else:
    if c>m:
      m=c
    c=0
if c>m:
  m=c
print(m)

Solution (Python):
s = input()

compare = ['A', 'C', 'G', 'T']
max_str = ''
tmp = ''
for si in s:
    if si in compare:
        tmp += si
        if len(tmp) > len(max_str):
            max_str = tmp
    else:
        tmp = ''

print(len(max_str))

Solution (Python):
def check_ACGT(S):
    length = len(S)
    for i in range(length):
        if not(S[i] == "A" or  S[i] == "G" or S[i] == "C" or S[i] == "T"):
            return 0
    
    return length

S = input()

tmp = 0
length = len(S)
for i in range(length):
    for j in range(i+1, length):
        
        tmp = max(tmp, check_ACGT(S[i:j+1]))
tmp = max(tmp, check_ACGT(S[-1]))

print(tmp)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque

from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]



s=input().rstrip()
mx=0
for i in range(len(s)):
    l=0
    for j in range(i,len(s)):
        if s[j]=="A" or s[j]=="T" or s[j]=="G" or s[j]=="C":
            l+=1
        else:
            break
    if l>mx:
        mx=l
print(mx)

Solution (Python):
S = input()
cnt = 0
tmp = 0

for i in S:
    if  i in ['A', 'C', 'G', 'T']:
        tmp+=1
    elif cnt < tmp:
        cnt = tmp
        tmp = 0
if cnt < tmp:
    print(tmp)
else:
    print(cnt)

Solution (Python):
S = list(input())

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

Solution (Python):
s = input().rstrip()

ans = 0
current = 0

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

ans = max(ans, current)
print(ans)

Solution (Python):
s = input() + 'n'
ans = 0
fans = 0
for i in range(len(s)):
    if s[i] in 'ACGT':
        ans += 1
    elif fans < ans:
        fans = ans
        ans = 0
print(fans)

Solution (Python):
s = input() + 'n'
ans = 0
fans = 0
for i in range(len(s)):
    if s[i] =='A' or s[i] =='C' or s[i] =='G' or s[i] =='T':
        ans += 1
    elif fans < ans:
        fans = ans
        ans = 0
print(fans)

Solution (Python):
S = input()

answer = ''
number_of_consecutive_times = 0
maxium_number_of_consecutive_times = 0
for char in S:
    is_included = char in ['A', 'C', 'G', 'T']

    if is_included:
        number_of_consecutive_times += 1
        maxium_number_of_consecutive_times = max(
            number_of_consecutive_times,
            maxium_number_of_consecutive_times,)
    else:
        number_of_consecutive_times = 0

print(maxium_number_of_consecutive_times)

Solution (Python):
S = input()

answer = ''
number_of_consecutive_times = 0
maxium_number_of_consecutive_times = 0
for char in S:
    is_included = char in ['A', 'C', 'G', 'T']

    if is_included:
        number_of_consecutive_times += 1
    else:
        maxium_number_of_consecutive_times = max(
            number_of_consecutive_times,
            maxium_number_of_consecutive_times,)
        number_of_consecutive_times = 0
maxium_number_of_consecutive_times = max(
            number_of_consecutive_times,
            maxium_number_of_consecutive_times,)

print(maxium_number_of_consecutive_times)

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

def main():
    s = input()
    print(cntLetter(s))
main()

Solution (Python):
def is_acgt(s):
    for c in list(s):
        if c not in ["A", "C", "G", "T"]:
            return False
    return True


S = input()
N = len(S)
ans = 0
for l in range(N):
    for r in range(N, l, -1):
        ss = S[l:r]
        if is_acgt(ss):
            ans = max(ans, len(ss))
print(ans)

Solution (Python):

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

Solution (Python):

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

se = {'A', 'C', 'G', 'T'}
S = sr()
cand = []
answer = []
for s in S:
    if s in se:
        cand.append(s)
    else:
        if len(cand) > len(answer):
            answer = cand
        cand = []

if len(cand) > len(answer):
    answer = cand
print(len(answer))

Solution (Python):
icase=0
if icase==0:
    s=list(input())
    acgt={"A","C","G","T"}
    sc=[0]*len(s)
    if s[0] in acgt:
        sc[0]=1
    for i in range(1,len(s)):
        if s[i] in acgt:
            sc[i]=sc[i-1]+1
    print(max(sc))

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

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

Solution (Python):
s = input()
counts = []
count = 0
for i in range(len(s)):
    c = s[i:len(s)+1]
    for j in c:
        if "A" in j or "C" in j or "G" in j or "T" in j:
            count += 1
        else:
            break
    counts.append(count)
    count = 0
max_count = max(counts)
print(max_count)

Solution (Python):
s = list(input())
Max = 0
cnt = 0
D = ["A","C","G","T"]
for i in s:
    if i in D:
        cnt += 1
    else:
        if Max < cnt:
            Max = cnt
        cnt = 0
print(max(Max,cnt))

Solution (Python):
def ACGT(s):
    A = s.count('A')
    C = s.count('C')
    G = s.count('G')
    T = s.count('T')
    return len(s) == A+C+G+T

S = input()

ans = 0
for i in range(len(S)+1):
    for k in range(i+1, len(S)+1):
        sub = S[i:k]
        if ACGT(sub):
            if ans < len(sub):
                ans = len(sub)

print(ans)

Solution (Python):
s = input()
l = list(s)
count = 0
ans = 0
for i in range(len(l)):
    if l[i] == "A" or l[i] == "T" or l[i] == "G" or l[i] == "C":
        count += 1
        continue
    ans = max(ans,count)
    count = 0
ans = max(ans,count)
print(ans)

Solution (Python):
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)

Solution (Python):
def main():
    S = input()
    maxlen = 0
    for i in range(len(S)):
        for j in reversed(range(len(S))):
            if i <= j:
                c = 0
                for k in range(i, j+1):
                    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
                        c += 1
                    else:
                        break
                if c > maxlen:
                    maxlen = c
    print(maxlen)
main()

Solution (Python):
N=input()
alp="BDRFHIJKLMNOPQRSUVWXYZ"
cnt=[]

for i in range(0,len(N)):
    for j in range(i,len(N)+1):
        tmp=N[i:j]
        flg=1
        for a in alp:
            if a in tmp:
                flg = 0
        if flg:
            cnt.append(len(tmp))
print(max(cnt))

Solution (Python):
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)

Solution (Python):
def main():
    S = input()
    ACGT = {'A', 'C', 'G', 'T'}
    ans, s_l = 0, 0
    for c in S:
        if c in ACGT:
            s_l += 1
        else:
            ans = max(ans, s_l)
            s_l = 0
    ans = max(ans, s_l)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
S = str(input())
count = 0
ans = 0
for i in range(len(S)):
  if S[i] in "ACGT":
    count += 1
    ans =  max(ans,count)
  else:
    count = 0
print(ans)

Solution (Python):
import re
s = input()

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

Solution (Python):
s = input()
answer = 0
for left in range(len(s)):
    for right in range(left, len(s)): 
        if set(s[left:right+1]) <= set("ACGT"):
            answer = max(answer, right - left +1)
print(answer)

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

Solution (Python):

S=input()
N=len(S)

ans=0
'''
for i in range(N):
    if S[i] in "ACGT":
        ans=1

for l in range(N-1):
    for r in range(l+1,N):
        for s in S[l:r]:
            if not s in "ACGT":
                break
        else:
            ans=max(ans,len(S[l:r])) 
'''

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)

Solution (Python):


S=input()
N=len(S)

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

print(ans)

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

res = 0
for i in range(n):
    c = 0
    for j in range(i,n):
        if s[j] not in ("A","G","C","T"):
            break
        c += 1
    res = max(res, c)
print(res)

Solution (Python):
"""
問題文
英大文字からなる文字列Sが与えられます。
Sの部分文字列 (注記を参照) であるような最も長い ACGT 文字列 の長さを求めてください。

ここで、ACGT 文字列とは A, C, G, T 以外の文字を含まない文字列です。

注記
文字列 Tの部分文字列とは、Tの先頭と末尾から0文字以上を取り去って得られる文字列です。
例えば、ATCODER の部分文字列には TCO, AT, CODER, ATCODER,  (空文字列) が含まれ、AC は含まれません。

制約Sは長さ1以上10以下の文字列である。Sの各文字は英大文字である。
"""

import re

S = input()


S = re.sub('[ACGT]', '1', S)
S = re.sub('[A-Z]', '0', S)

S = S.split('0')

print(len(max(S, key = len)))

Solution (Python):
def S(): return input()
S = S()
dp = [0]*(len(S)+1)
for i,x in enumerate(S,1):
    if x in 'ACGT':
        dp[i] = dp[i-1]+1
print(max(dp))

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

Solution (Python):
s = input()
ans = 0
ans_l = [0]*len(s)


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

Solution (Python):
def S(): return input()
S = S()
dp = [0]*(len(S)+1)
for i,x in enumerate(S,1):
    if x in 'ACGT':
        dp[i] = dp[i-1]+1
    else:
        dp[i] = 0
print(max(dp))

Solution (Python):
def ATCoder(S):
    count = 0
    res = 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 count > res:
                res = count
        else:
            count = 0
    return res



if __name__ == "__main__":
    S = str(input())
    print(ATCoder(S))

Solution (Python):
x = list(input())

y = 0
z = 0
for i in range(len(x)):
    if x[i] in ['A', 'C', 'G', 'T']:
        y += 1
    else:
        z = max(z,y)
        y = 0
else:
    z = max(z,y)

print(z)

Solution (Python):


from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    s = input()
    anslist = []
    for i in s:
        if i == 'A' or i == 'T' or i == 'C' or i == 'G':
            anslist.append(1)
        else:
            anslist.append(0)
    anslist.append(0)
    ans = 0
    tmp = 0
    for i in anslist:
        tmp+=i
        if not i:
            ans = max(ans,tmp)
            tmp = 0
    print(ans)


main()

Solution (Python):
s = list(input())
key = ['A','T','G','C']

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

Solution (Python):
S = input()
lst = []
for s in S:
    if s in 'ACGT':
        lst.append(True)
    else:
        lst.append(False)

max_true = -1
k = 0
for b in lst:
    if b:
        k+=1
    else:
        if k > max_true:
            max_true = k
        k = 0
print(max(max_true, k))

Solution (Python):
s = input()
n = len(s)
ans = 0
for i in range(n):
    for j in range(i, n):
        ok = True
        for k in range(i, j + 1):
            if s[k] not in ['A', 'T', 'G', 'C']:
                ok = False
        if ok:
            ans = max(ans, j - i + 1)
print(ans)

Solution (Python):
s=input()
l=len(s)
count=0
ans=0
for i in range(l):
  if s[i]=='A' or s[i]=='G' or s[i]=='C' or s[i]=='T':
    count+=1
  else:
    if count>ans:
      ans=count
    count=0
if count>ans:
  ans=count
print(ans)

Solution (Python):
s = input()
chrlis = []
for i in range(len(s)):
  if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
    start = i
    for j in range(i,len(s)):
      if s[j]=="A" or s[j]=="C" or s[j]=="G" or s[j]=="T":
        end = j
      else:
        break
  else:
    continue
  chrlis.append(s[start:end+1])

ans = 0
for i in range(len(chrlis)):
  tmp = len(chrlis[i])
  if tmp>ans:
    ans = tmp
print(ans)

Solution (Python):
S = input()

li = []
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:
        li.append(cnt)
        cnt = 0
li.append(cnt)

print(max(li))

Solution (Python):
import re
import io
    
data = input()
pattern = "[ATGC]*"
    
matched_list = sorted(re.findall(pattern, data), key=len, reverse=True)
print(len(matched_list[0]))

Solution (Python):
s=list(input())+["Z"]
cnt = 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:
                if cnt < t:
                    cnt = t
                break
print(cnt)

Solution (Python):
if __name__ == "__main__":
    s = input()
    dna = ['A', 'C', 'G', 'T']

    ans = 0
    tmp = 0
    for i in range(len(s)):
        if s[i] in dna:
            tmp += 1
        else:
            if tmp > ans:
                ans = tmp
                tmp = 0
            else:
                tmp = 0
    if tmp > ans:
        ans = tmp

    print(ans)

Solution (Python):
s = input()
count = 0
maxcount = 0

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

maxcount = max(maxcount, count)
print(maxcount)

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

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

Solution (Python):
S = list(input())
M = 0
count = 0
for x in S:
  if x =="A" or x =="C" or x =="T" or x =="G":
    count += 1
  else:
    count = 0
  M = max(M,count)
print(M)

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

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

Solution (Python):
s=input()

ans=[]

count=0
max=0

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

print(max)

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip() 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

def main():
    s = ns()
    ACGT = "AGCT"
    ans = 0
    tmp = 0
    for i in s:
        if i in ACGT:
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0
    ans = max(ans, tmp)
    print(ans)
    return

if __name__ == '__main__':
    main()

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

ans = 0
for i in range(1,n+1):
    for j in range(n-i+1):
        target = S[j:j+i]
        flag = True
        for t in target:
            if t not in ['A', 'C', 'G', 'T']:
                flag = False
                break
            
        if flag:
            ans = max(ans, len(target))

print(ans)

Solution (Python):
s =  list(input())
nucleotide = ['A', 'C', 'G', 'T']
paircount, maxpair = 0, 0
for i in s:
  if (i in nucleotide) == True:
    paircount += 1
  else:
    paircount = 0
  if maxpair <= paircount:
    maxpair = paircount
print(maxpair)

Solution (Python):
s = input()


def checkSpell(c):
    return c=="A" or c =="C" or c =="G" or c =="T"

cnt = 0
res = 0
for i in s:
    if checkSpell(i) == True:
        cnt += 1
        res = max(res,cnt)
    else:
        cnt = 0
        
print(res)

Solution (Python):
s=input()
left,ans=0,0
word=["A","C","G","T"]
for i in range(len(s)):
    point=i
    while point!=len(s):
        if s[point] in word:
            point +=1
        else:break
    ans=max(ans,point-left)
    left +=1
print(ans)

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

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

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

Solution (Python):
s = input()

count = 0
count_list = [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_list.append(count)
        count = 0
count_list.append(count)
print(max(count_list))

Solution (Python):



word = input()
chl = ['A','C','G','T']
lmax = 0
temp = 0
for ch in word:
    if ch in chl:
        temp += 1
    else:
        temp = 0
    if temp >= lmax:
            lmax = temp
print(lmax)

Solution (Python):
S = list(input())

ans = 0
acgt = ['A', 'C', 'G', 'T']
conti = 0

for i in S:
    if i in acgt:
        conti += 1
        if ans < conti:
            ans = conti
    else:
        conti = 0

print(ans)

Solution (Python):
S=input()
acgt=['A','C','G','T']

c=0
ans=0

for i in S:
    if i in acgt:
        c+=1
        ans=max(ans,c)
    else:
        c=0
print(ans)

Solution (Python):
S = input()
acgt = ['A', 'C', 'G', 'T']

c = 0
ans = 0

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

print(ans)

Solution (Python):
import re
S = input()
S = re.sub("[ACGT]", "*", S)
cnt = 0
for i in range(len(S)):
    for j in range(i, len(S) + 1):
        if S[i:j] == "*" * (j - i):
            cnt = max(j - i, cnt)
print(cnt)

Solution (Python):
s = input()
size = len(s)
d = ('A','C','G','T')
ans = 0
for i in range(size):
    for j in range(i+1, size+1):
        for k in s[i:j]:
            if k not in d:
                break
        else: ans = max(ans, j-i)

print(ans)

Solution (Python):
S = input()
cnt = 0
MAX = 0
base = set(['A', 'C', 'G', 'T'])
for char in S:
    if char in base:
        cnt += 1
    else:
        MAX = max(MAX, cnt)
        cnt = 0
MAX = max(MAX, cnt)
print(MAX)

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

Solution (Python):
s=input()
n=len(s)
ans=0
for i in range(n):
  for j in range(i,n):
    if all("ACGT".count(c) for c in s[i:j+1]):
      ans=max(ans,j-i+1)
print(ans)

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

Solution (Python):
print(max([len(s) for s in "".join(["1" if s in ["A","C","G","T"] else "0" for s in input()]).split("0")]))

Solution (Python):
a="".join(["1" if s in ["A","C","G","T"] else "0" for s in input()])
ans=[len(s) for s in a.split("0")]
print(max(ans))

Solution (Python):
S = input()
l = []
ans = ("A", "C", "G", "T")
A = 0
flag = False

for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        l.append(S[i:j])
    
for i in range(len(l)):
    for c in l[i]:
        if c not in ans:
            flag = True
            break
    if flag:
        flag = False
        continue
    A = max(A, len(l[i]))

print(A)

Solution (Python):
S = input()

l = len(S)
maxv = 0

for i in range(l):
    count = 0
    if 'A' == S[i] or 'C' == S[i] or 'G' == S[i] or 'T' == S[i]:
        count = 1
        for j in range(i+1, l):
            if 'A' == S[j] or 'C' == S[j] or 'G' == S[j] or 'T' == S[j]:
                count += 1
            else:
                break

    if maxv < count:
        maxv = count

print(maxv)

Solution (Python):

s = input()
ans = 0
cnt = 0
for i in s:
    if i == "A" or i=="T" or i=="G" or i=="C" :
        cnt+=1
    else:
        if ans<cnt:
            ans=cnt
            cnt=0
if ans<cnt:
    ans=cnt

print(ans)

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

Solution (Python):
S = input()
n = len(S)
ans = 0
k = 0
agct = ['A','G','C','T']
for i in range(n):
    if S[i] in agct:
        k+=1
        continue
    ans = max(k,ans)
    k = 0

ans = max(ans,k)
print(ans)