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()
counter = 0
max_ = 0
for s in S:
  if s == "A" or s == "G" or s == "C" or s == "T":
    counter += 1
  else:
    if max_ < counter:
      max_ = counter
    counter = 0
if max_ < counter:
  max_ = counter
print(max_)

Solution (Python):
s=input()
ok = "ATGC"
ans = 0
cnt = 0
isok = False

for i in range(len(s)):
    for j in range(4):
        if s[i] == ok[j]:
            isok = True
    if isok == False:
        cnt = 0
        continue
    cnt += 1
    ans = max(ans,cnt)
    isok = False
print(ans)

Solution (Python):

S = str(input())
T = 'ATCG'

ans = 0
now = 0

for i in range(len(S)):
    isATCG = False
    for j in range(len(T)):
        if S[i] == T[j]:  
            isATCG = True
    
    if not isATCG:
        
        now = 0
    else:
        
        now += 1
        ans = max(now, ans)  

print(ans)

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

part_len = 0
max_len = 0

for s in s_list:
	if s in acgt:
		part_len += 1
		if part_len > max_len:
			max_len = part_len
	else:
		part_len = 0

print(max_len)

Solution (Python):
import re

s = input()
l = re.findall('[ACGT]*', s)
print(len(max(l,key=len)))

Solution (Python):
s = input()

acgt = "ACGT"
s_list = list(s)

cur_len = 0
max_len = 0

for c in s_list:
    if c in acgt:
        cur_len += 1
        if max_len < cur_len:
            max_len = cur_len
    else:
        cur_len = 0

print(max_len)

Solution (Python):
s = input()

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

n_max = 0
n_acgt = 0
for c in s:
  if c in lis:
    n_acgt += 1
  else:
    if n_acgt > n_max:
      n_max = n_acgt
    n_acgt = 0

if n_acgt > n_max:
      n_max = n_acgt
    
print(n_max)

Solution (Python):



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

    for i in range(1, n + 1):
        for j in range(n - i + 1):
            t = s[j:j + i]

            if len(t.replace('A', '').replace('C', '').replace('G', '').replace('T', '')) == 0:
                ans = max(ans, i)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
wordList = 'ACGT'
t = []
tmp = []
lead = 0
ans = 0
slist = list(s)
for i in range(len(slist)):
    if not slist[i] in wordList:
        ans = max(ans, (i - lead))
        lead = i + 1
ans = max(ans, (len(slist) - lead))
print(ans)

Solution (Python):
s = input()

S = []
for i in range(len(s)):
    S.append(s[i:])
    for j in range(len(s) - i - 1):
        S.append(s[i:-(j+1)])

ans = []
for i in range(len(S)):
    if (('A' in set(S[i])) + 
        ('C' in set(S[i])) + 
        ('G' in set(S[i])) + 
        ('T' in set(S[i])) == len(set(S[i]))):
        ans.append(len(S[i]))
    else:
        ans.append(0)

print(max(ans))

Solution (Python):
s = list(input())
c = 0
li = ["A","C","G","T"]
li2 = []
for i in range(len(s)):
    if s[i] in li:
        c += 1
        
    else:
        li2.append(c)
        c = 0
li2.append(c)
print(max(li2))

Solution (Python):
s = input()
acgt = []
cnt = 0
for a in s:
    if a == 'A' or a == 'C' or a == 'T' or a == 'G':
        cnt += 1
    else:
        acgt.append(cnt)
        cnt = 0
acgt.append(cnt)
print(max(acgt))

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


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

print(max(Ans))

Solution (Python):
N = input()
answer_list = []
answer = 0

for i in range(len(N)):
  if N[i] == "A" or N[i] == "T" or N[i] == "C" or N[i] == "G":
    answer += 1
  else:
    answer_list.append(answer)
    answer = 0
  if i+1 == len(N):
    answer_list.append(answer)
print(max(answer_list))

Solution (Python):
def main():
    s = input()
    ans = [0]
    count = 0
    for char in s:
        if char in ["A", "C", "G", "T"]:
            count += 1
        else:
            ans.append(count)
            count = 0
    ans.append(count)
    print(max(ans))

if __name__ == '__main__':
   main()

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

OK = ["A", "C", "G", "T"]
s = input()[:-1]
l = 0
r = 0
ans = 0
N = len(s)
while l < N and r < N:
    if s[r] in OK:
        ans = max(ans, r-l+1)
        r += 1
    else:
        l = r+1
        r += 1
print(ans)

Solution (Python):
from itertools import groupby
import random

s = input()


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


def ans_2():
    def check(c):
        return c in "AGCT"

    ans = 0
    for k, grp in groupby(s, check):
        temp = len(list(grp))
        if k:
            ans = max(ans, temp)

    print(ans)


def ans_3():
    temp, ans = 0, 0
    for c in s:
        if c in "AGCT":
            temp += 1
            ans = max(ans, temp)
        else:
            temp = 0
    print(ans)


method = random.randrange(3)
if method == 0:
    ans_1()
elif method == 1:
    ans_2()
else:
    ans_3()

Solution (Python):
import sys

def sub(a):
    return [a[i : j + 1] for i in range(len(a)) for j in range(i,len(a))]


s = input()
l = sub(s)
maks = 0

for i in l:
    sum = 0
    for x in i:
        if x == 'A' or x == 'C' or x == 'T' or x == 'G':
           sum += 1
    if sum == len(i):
        maks = max(maks, len(i)) 

print(maks)

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

s=[]

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

Solution (Python):
S = input()
len_now = 0
len_max = 0
list_s = ["A","C","G","T"]

for i in range(len(S)):
    if S[i] in list_s:
        len_now += 1
        if len_now > len_max:
            len_max = len_now
    else:
        len_now = 0
print(len_max)

Solution (Python):
s = input()

ans = 0
tmp = ''
for i in range(len(s)):
  if s[i] in 'ACGT':
    tmp += s[i]
  else:
    tmp = ''
  if ans <= len(tmp):
    ans = len(tmp)
print(ans)

Solution (Python):
S = input()
count=0
max=0
for s in S:
  if s in ["A","C","G","T"]:
    count=1+count
  else:
    if max < count:
      max=count
    count=0
if max < count:
	max=count

print(max)

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

max_count = 0
length = len(S)
for idx in xrange(length):
    count = 0
    for i in range(idx, length):
        if 'ACGT'.find(S[i]) >= 0: count += 1
        else: break
    if count > max_count: max_count = count
print max_count

Solution (Python):

import sys


def solve(S: str):
    def is_valid(s):
        for c in s:
            if not c in 'AGTC':
                return False
        return True
    n = len(S)
    ret = ''
    for i in range(n):
        for j in range(i, n):
            if is_valid(S[i:j + 1]) and j - i + 1 > len(ret):
                ret = S[i:j + 1]
    print(len(ret))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):
S = input()

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

Solution (Python):
l=list(input())
c=0
cl=[]
for i in l:
  if i=="A" or i=="T" or i=="G" or i=="C":
    c+=1
  else:
    cl.append(c)
    c=0
cl.append(c)
print(max(cl))

Solution (Python):
S = input()

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

max_count = 0
count = 0
for c in S:
    if c in atgc:
        count += 1
        if count > max_count:
            max_count = count
    else:
        count = 0

print(max_count)

Solution (Python):
in_str = input()
length_str = len(in_str)
inner_count = 0
inner_length = 0
for i in range(len(in_str)):
    if (in_str[i] == "A") or (in_str[i] == "C") or (in_str[i] == "G") or (in_str[i] == "T"):
        inner_count +=1

    else :
        if inner_length <= inner_count:
            inner_length = inner_count
        inner_count = 0

if inner_length <= inner_count:
            inner_length = inner_count
print(inner_length)

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

S = str(input())

ans = 0
answers = []

for i in range(len(S)):
    if S[i] in words:
        ans += 1
    else:
        answers.append(ans)
        ans = 0

answers.append(ans)

print(max(answers))

Solution (Python):







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

S = str(input())

ans = 0
answers = []

for i in range(len(S)):
    if S[i] in words:
        ans += 1
    else:
        answers.append(ans)
        ans = 0

answers.append(ans)

print(max(answers))

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

Solution (Python):





def solveProblem(inputString):
	stringLength = len(inputString)
	answerStringList = list()
	maxStringLength = 0
	for i in range(0,stringLength,+1):
		for j in range(i,stringLength,+1):
			AllATGCList = list()
			for c in inputString[i:j+1]:
				x = 'AGTC'.count(c) == 1
				AllATGCList.append(x)
			if all(AllATGCList) :
				strATGCLength = len(inputString[i:j+1])
				if maxStringLength < strATGCLength :
					maxStringLength = strATGCLength
	answer = maxStringLength
	return answer

if __name__ == '__main__':
	S = str(input().strip())
	solution = solveProblem(S)
	print("{}".format(solution))

Solution (Python):
S = input()
m = k = 0
for c in S:
  if c in 'ACGT':
    k += 1
  else:
    m = max(m, k)
    k = 0
m = max(m, k)
print(m)

Solution (Python):

import re
import bisect
from datetime import datetime as dt

S = raw_input()
i = 0
max = 0
tmp = 0
while i < len(S):
    if S[i] in 'ACGT':
        tmp += 1
    else:
        if max < tmp:
            max = tmp
        tmp = 0
    i += 1
if max < tmp:
    max = tmp
print max

Solution (Python):
S = input()
counter = 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':
        counter+=1
    else:
        if ans<counter:
            ans = counter
            counter = 0

if ans < counter:
    ans = counter

print(ans)

Solution (Python):
s = input()
s = s.translate(str.maketrans({'T': 'A', 'G': 'A', 'C': 'A'}))
s = list(s)+['END']

if s[0] == 'A':
    counter = 1
else:
    counter = 0

ans = 0

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

Solution (Python):
s = input()

s_list = ['T', 'C', 'G']

out = 0

for i in s_list:
  s = s.replace(i, 'A')

count = 0
for i in s:
  if i == 'A':
    count += 1
    if out < count:
      out = count
  else:
    count = 0

print(out)

Solution (Python):
S = input()
ACGT = ['A', 'C', 'G', 'T']
length = 0
max_length = 0

for s in range(len(S)):
    
    match = 0
    for acgt in ACGT:
        if S[s] == acgt:
            length += 1
            if max_length < length:
                max_length = length
            match = 1

    if match == 0:
        length = 0

print(max_length)

Solution (Python):
ans=0
tmp=0
for i in input():
    if i=='A' or i=='C' or i=='G' or i=='T':
        tmp += 1
    else:
        tmp = 0
    if ans<tmp:
        ans = tmp
print(ans)

Solution (Python):
def main():

    s = input()
    count = [0] * len(s)

    for i in range(len(s)):
        if s[i] in ['A', 'C', 'T', 'G']:
            count[i] = count[i-1] + 1

    print(max(count))


main()

Solution (Python):
S=input()

i=0
ans,temp=0,0
while(i<len(S)):
    if(S[i]=='A' or S[i]=='T' or S[i]=='G' or S[i]=='C'):
        temp+=1
        ans=max(ans,temp)
    else:
        temp=0
    i+=1

print(ans)

Solution (Python):

s = input();
charList=list(s);
result=0;
tmp=0;
for c in charList:
 if c=='A' or c=='T' or c=='G' or c=='C':
   tmp=tmp+1;
 else:
  if tmp>result:
   result=tmp;
  tmp=0;
if tmp>result:
 result=tmp;
print(result);

Solution (Python):
S = input()
ans = 0
l = 0
for i in range(len(S)):
    if S[i] in 'ATGC':
        l += 1
    else:
        l = 0
    if l > ans:
        ans = l
print(ans)

Solution (Python):
s = list(input())
remove = ["A","T","C","G"]
mxm = 0
i = 0
counter = 0
while i < len(s):
    if s[i] in remove:
        counter += 1
        i += 1
    else:
        if counter > mxm:
            mxm = counter
        counter = 0
        i += 1
if counter > mxm:
    mxm = counter
print(mxm)

Solution (Python):
S = list(input())
answer = 0
index = len(S)
i = 0
s = 0
while(i < index):
    str = S[i]
    if(str == "A" or str == "C" or str == "G" or str == "T"):
        s += 1
    else:
        s = 0
    if(answer < s):
        answer = s
    i += 1
print(answer)

Solution (Python):
text = input()
rule = 'ATCG'

max_len = 0
text_len = 0
for char in text:
    if char in rule:
        text_len += 1
    else:
        if text_len > max_len:
            max_len = text_len
        text_len = 0
if text_len > max_len:
    max_len = text_len
print(max_len)

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

i = 0
while i<=l-1 :
    
    if s[i] in ls :
        
        j = i + 0
        while (j<=l-1) and (s[j] in ls) :
            j += 1
        
        if j-i > ans :
            ans = j-i
        
        i = j + 0

    else :
        i += 1

print(ans)

Solution (Python):
ans,count,inp=0,0,input()+" "
for c in inp:
  if c in ["A","T","G","C"]:
    count+=1
  else:
    if count>ans:
      ans=count
    count=0
print(ans)

Solution (Python):
a = str(input())

cnt = 0
cnt_max = 0



for i in range(len(a)):
    if((a[i]=="A") or(a[i]=="C") or (a[i]=="G") or (a[i]=="T")):
        cnt += 1
    else:
        cnt = 0
    
    if(cnt >= cnt_max):
        cnt_max = cnt
        

print(cnt_max)

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

for i in S:
    if i == "A" or i == "T" or i == "G" or i == "C":
        counter += 1
    else:
        if counter > ans:
            ans = counter
        counter = 0

if counter > ans:
    ans = counter
        
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) == 1 for c in S[i:j + 2]):
            ans = max(ans, len(S[i:j + 2]))

print(ans)

Solution (Python):
s = input()

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

Solution (Python):


import re

S = input()
S = re.sub("[ACGT]", "-", S)

for i in range(1, 12):
    if not ("-" * i) in S:
        print(i - 1)
        exit()

Solution (Python):
"""
s = input()
output = []
comp_str = ['A','T','G','C']

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

max = 0
for i in output:
    if (i >= max):
        max = i

print(max)

"""

s = input()
count = 0

for i in range(len(s)):
    count_tmp = 0
    for j in range(i,len(s)):
        if(s[j] == 'A'):
            count_tmp += 1
        elif(s[j] == 'T'):
            count_tmp += 1
        elif(s[j] == 'G'):
            count_tmp += 1
        elif(s[j] == 'C'):
            count_tmp += 1
        else:
            break
    if(count_tmp > count):
        count = count_tmp

print(count)

Solution (Python):
s = input()

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

print(ans)

Solution (Python):
def search_atcg(data):
    atcg = ['A', 'T', 'C', 'G']
    co = 0
    max_co = 0
    for s in data:
        if s in atcg:
            co += 1
            if co > max_co:
                max_co = co
        else:
            co = 0
    return max_co


if __name__ == "__main__":
    data = input()
    print(search_atcg(data))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    t = 'ACGT'
    r = 0
    u = 0
    for c in s:
        if c in t:
            u += 1
        else:
            if r < u:
                r = u
            u = 0
    if r < u:
        r = u

    return r


print(main())

Solution (Python):
import re

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

def solve(s):
    r = 0
    for x in re.findall(r'[ACGT]+', s):
        r = max(r, len(x))
    return r

main()

Solution (Python):
S = input()
temp = ""
ans = 0
for n in range(len(S)):
  if S[n]=="A" or S[n]=="C" or S[n]=="G" or S[n]=="T":
    temp += S[n]
  else:
    if ans < len(temp):
      ans = len(temp)
    temp = ""
if ans < len(temp):
  ans = len(temp)
print(ans)

Solution (Python):
S = list(input())
temp = ""
list = []
ans = 0
for n in range(len(S)):
  if S[n]=="A" or S[n]=="C" or S[n]=="G" or S[n]=="T":
    temp += S[n]
  else:
    list.append(temp)
    temp = ""
list.append(temp)
temp = 0
for n in range(len(list)):
  if temp < len(list[n]):
    temp = len(list[n])
print(temp)

Solution (Python):
s = input()
ans = []
counter = 0
for i in s:
    if i in 'ATGC':
        counter += 1
    else:
        counter = 0
    ans.append(counter)
print(max(ans))

Solution (Python):
s=input()
i=1
n=0
ans=[0]
sta=0

 
while i<=len(s):
  if s[i-1]=='A'or s[i-1]=='C' or s[i-1]=='G' or s[i-1]=='T':
    n=n+1
    sta=1
  elif sta==1:
    ans.append(n)
    n=0

  if i<=len(s)&n==len(s):
    ans.append(n)
  elif n!=0:
      ans.append(n)
    
  i=i+1
  
print(max(ans))

Solution (Python):
import re

S = input()
num_list = [len(s) for s in re.split(r'[^ATCG]', S)]

print(max(num_list))

Solution (Python):

import sys
import re

input_line = sys.stdin.readline()

result = re.sub(r'[^ACGT]+', ' ', input_line).split(' ')

result_list = []
for i in result :
  result_list.append(len(i))

print(max(result_list))

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

c=0
ans=0
for word in S:
    c = c+1 if word in acgt else 0
    ans = max(ans, c)
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) == 1 for c in S[i:j + 1]):
            ans = max(ans, j - i + 1)

print(ans)

Solution (Python):


text = input()

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

exist = False
for i in targets:
    if i in list(text):
        exist = True
        break

max_len_answer = ''

if exist:
    answer = ''
    for i in range(len(text)):
        if text[i] in targets:
            answer += text[i]
        else:
            if len(answer) >= len(max_len_answer):
                max_len_answer = answer
            answer = ''
        if i == len(text) - 1:
            if len(answer) >= len(max_len_answer):
                max_len_answer = answer


print(len(max_len_answer))

Solution (Python):
S = input()
max_l = 0
temp_l = 0

for s in S:
    if s == 'A' or s=='G' or s=='C' or s=='T':
        temp_l += 1
        max_l = max(max_l, temp_l)
    else:
        temp_l = 0

print(max_l)

Solution (Python):
s = input().strip()
st = "ACGT"
i, c,start = 0,0,0
while i < len(s):
    if s[i] not in st:
        c = max(i - start, c)
        start = i + 1
    i += 1
print(max(c,i - start))

Solution (Python):


s = input()

max_c = 0
count = 0
for i in s:
    if "ATCG".count(i):
        count += 1
        max_c = max(max_c, count)
    else:
        count = 0

print(max_c)

Solution (Python):
def calc(S,T):
    ans = 0
    for i in range(N):
        count = 0
        for j in range(i,N):
            flag = False
            for k in range(M):
                if S[j] == T[k]:
                    flag = True
            if flag:
                count = count + 1
                ans = max(count,ans)
            else:
                break
    print(ans)

if __name__ == "__main__":
    S = input()
    N = len(S)
    Target = "ATGC"
    M = len(Target)
    calc(S,Target)

Solution (Python):
def measure_ACGT(str):
  elements = ['A','C','G','T']
  length = 0
  for s in str:
    if not(s in elements):
      break
    else:
      length += 1    
  return length

def start_positions():
  return [0,1,2,3,4,5,6,7,8,9]

def find_longest_block(str):
  length = 0
  positions = start_positions()
  for pos in positions:
    s2 = str[pos:]
    ln = measure_ACGT(s2)
    if ln > length:
      length = ln
  return length

S = input()
print(find_longest_block(S))

Solution (Python):
s = input()
res = 0
for i in range(len(s)):
    cnt = 0
    while s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        cnt += 1
        i += 1
        if i==len(s):
          break
    res = max(res,cnt)
print(res)

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

Solution (Python):
ACGT = 'ACGT'
S = input()
for i in S:
    if i not in ACGT:
        S = S.replace(i, '-')
LIST = S.split('-')
LIST.sort(key = lambda n:len(n), reverse=True)
print(len(LIST[0]))

Solution (Python):
cnt = 0
max = 0
for s in input():
    if 'ATCG'.count(s):
        cnt +=1
        if cnt > max:
            max = cnt
    else:
        cnt = 0 
print(max)

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

AGCT = ['A','G','C','T']
Ans = [0]
for i in range(len(S)):
    for j in range(len(S)):
        if all(AGCT.count(c) == 1 for c in (S[i:j+1])) == True:
            Ans.append(len(S[i:j+1]))

print(max(Ans))

Solution (Python):
S = input()

ok_list = ["A", "C", "G", "T"]
count = 0
ans = 0

for c in S:
  if c in ok_list:
    count += 1
    if ans < count:
      ans = count
  else:
    count = 0

print(ans)

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

def count(s):
	max = 0
	cnt = 0
	for i in range(0, len(s)):
		if s[i] in acgt:
			cnt += 1
		else:
			cnt = 0
		if cnt > max:
			max = cnt
	return max

print count(raw_input())

Solution (Python):
S = input()
N = len(S)
max = 0
for i in range(N):
    if N-i<=max:
        break
    flag = 0
    for j in range(N-i):
        for k in range(j+1):
            if S[i+k]!='A' and S[i+k]!='T' and S[i+k]!='G' and S[i+k]!='C':
                flag = 1
                break
        if flag==0:
            if max < j+1:
                max = j+1
print(max)

Solution (Python):
def is_ACGT(c):
    if (c == "A") or (c == "C") or (c == "G") or (c == "T"):
        return True
    else:
        return False

def get_ACGT_length(s):
    if len(s) == 0:
        return 0

    if not is_ACGT(s[0]):
        return 0

    return 1 + (get_ACGT_length(s[1:]))


s = str(input())

result = 0
for i, c in enumerate(s):
    if is_ACGT(c):
        result = max(get_ACGT_length(s[i:]), result)

print(result)

Solution (Python):


import sys, re

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=input()
N=len(S)

ans=0

pattern = re.compile(r'^[ACGT]*$')
for i in range(N):
    for j in range(i+1, N+1):
        if pattern.match(S[i:j]):
            ans=max(ans, j-i)
print(ans)

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

max_length_str = ''
tmp_str = ''
for n in string:
  if n in acgt:
    tmp_str += n
  else:
    if len(tmp_str) > len(max_length_str):
      max_length_str = tmp_str
      tmp_str = ''

if len(tmp_str) > len(max_length_str):
  max_length_str = tmp_str
  tmp_str = ''

print(len(max_length_str))

Solution (Python):
S=input()
max=0
l=0
for s in S:
  if (s=="A" or s=="T" or s=="C" or s=="G"):
    l+=1
  else:
    if max<l:
      max=l
    l=0
if max<l:
  max=l
print(max)

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

Solution (Python):
s=input()
mm=0
cc=0
for i in s:
	if i in ["A","C","T","G"]:
		cc+=1
	else:
		mm=max(mm,cc)
		cc=0
mm=max(mm,cc)
print(mm)

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

maxlen = 0
templen = 0
for i in range(len(S)):
    if S[i] in li:
        templen += 1
    else:
        maxlen = max(maxlen, templen)
        templen = 0
maxlen = max(maxlen, templen)
print(maxlen)

Solution (Python):
s=input()
cnt=0
mx=0
for i in range(len(s)):
    if s[i] in "ACGT":
        cnt+=1
    else:
        cnt=0
    mx=max(mx,cnt)
print(mx)

Solution (Python):
S=list(input())
Check_list=['A','T','G','C']
 
out_num=0
for i in range(len(S)):
  for l in range(i,len(S)): 
    
    c=[x for x in S[i:l+1] if x not in Check_list]
    
    if (len(c) == 0) & (len(S[i:l+1]) >= out_num):
      out_num=len(S[i:l+1])
       
print(out_num)

Solution (Python):
def function(S):
    ACGT = ['A', 'C', 'G', 'T']
    ret = 0
    N = len(S)
    for i in range(0, N):
        for j in range(i+1, N+1):
            temp = 0
            l = S[i:j]
            const = 0
            for x in l:
                if x not in ACGT:
                    const = 1
                    break
            if const == 1:
                break
            temp = len(l)
            if temp >= ret:
                ret = temp
    return ret

S = input()
print(function(S))

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

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

print(len(ans))

Solution (Python):
s = input()
ans = 0
possible = set(["A", "C", "G", "T"])

for i in range(len(s), -1, -1):
  for j in range(len(s)):
    if j + i > len(s):
      break
    else:
      sub = s[j:i+j]
      if set(sub).issubset(possible):
        ans = max(ans, len(sub))

print(ans)

Solution (Python):
Ss = input() + '

ans = 0
num = 0
for S in Ss:
    if S in 'ACGT':
        num += 1
    else:
        ans = max(ans, num)
        num = 0

print(ans)

Solution (Python):
ACGT = "ACGT"

s= input()
nums = []
num = 0
for _s in s:
    if _s not in ACGT:
        nums.append(num)
        num = 0
        continue
    num += 1
nums.append(num)
print(max(nums))

Solution (Python):
st = input()
lis = ['A', 'T', 'C', 'G']
cnt = 0
max_cnt = 0
for s in st:
    if s in lis:
        cnt += 1
    else:
        max_cnt = max(cnt, max_cnt)
        cnt = 0
print(max(cnt, max_cnt))

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

ans = 0
lis = ['A', 'C', 'G', 'T']

for i in range(l):
  count = 0
  for j in range(l-i):
    if S[i+j] in lis:
      count += 1
    else:
      break
  ans = max(ans, count)
print(ans)

Solution (Python):
s = input()
dic_ = str.maketrans({'T':'1','A':'1','C':'1','G':'1'})
s = s.translate(dic_)
count = 0
result = 0
pre_i = ''

for i in s:
  if pre_i == '1' and i == '1':
    count += 1
    
  elif pre_i =='1':
    if count > result:
      result = count
    count = 0
    pre_i = ''
  
  elif i == '1':
    count += 1
    pre_i = '1'
if result < count:
  result = count
print(result)

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

for i in S:
  if i == 'A' or i == 'C' or i == 'G' or i == 'T':
    tmp += 1
    if max_l < tmp:
      max_l = tmp
  else:
    tmp = 0
print(max_l)

Solution (Python):
n=input()
dic = {'A': True, 'C': True, 'G': True, 'T': True}
lens = []

for i in range(0, len(n)):
    length = 0
    s = n[i]

    if s not in dic:
        lens.append(length)
        continue

    length += 1
    for j in range(i+1, len(n)):
        t = n[j]
        if t not in dic:
            break

        length += 1

    lens.append(length)
print(max(lens))

Solution (Python):
str = input()
ans = []
allow = ["A","C","G","T"]
count = 0
for s in str:
  if s in allow:
    count = count + 1
    ans.append(count)
  else:
    count = 0
    
if len(ans) == 0:
  print(0)
else:
  print(sorted(ans)[-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()
max_len = 0
temp = 0

for s in S:
	if (s == 'A') | (s == 'C') | (s == 'G') | (s == 'T'):
		temp += 1
	else:
		if temp > max_len:
			max_len = temp
		temp = 0
if temp > max_len:
    max_len = temp
print(max_len)

Solution (Python):
s = list(input())
ans = 0
acgt = ["A","C","G","T"]
for i in range(len(s)):
    if s[i] in acgt:
        temp = 1
        j = 1
        while len(s) > i + j and s[i + j] in acgt:
            temp += 1
            j += 1
        ans = max(temp, ans)

print(ans)

Solution (Python):
S = input()

S = ''.join(list(map(lambda s: 'x' if s in 'ACGT' else 'y', S)))
S = S.split('y')
S = [len(s) for s in S]

print(max(S))

Solution (Python):
mojiretu=input()
b="ACGT"
length=0
temp=[]
for i in range(len(mojiretu)):
    if mojiretu[i] in b:
        length += 1
    else:
        temp.append(length)
        length=0

temp.append(length)

print(max(temp))

Solution (Python):
mojiretu = input()
length = 0
dict = ["A","G","C","T"]
answers =[]
for i in range(len(mojiretu)):
  if mojiretu[i] in dict:
    length += 1
  else:
    answers.append(length)
    length = 0

answers.append(length)

print(max(answers))