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:
import numpy as np
S = input()
spl = list(S)
alpha_set = ['A', 'T', 'G', 'C']
x = np.zeros(len(S))
for i in range(len(S)):
  if len(set(alpha_set)-set(spl[i]))==4:
    x[i] = 0
  else:
    x[i] = 1
count = 0
answer = 0
for i in range(len(x)):
  if x[i]==1:
    count += 1
    if answer<count:
      answer = count
  else:
    count = 0
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

for mae in range(len(s)):
    for ato in range(len(s)):
        tmp = s[mae:ato+1]
        kosu = 0
        for cnt in range(len(tmp)):
            if tmp[cnt] in atgc:
                kosu += 1
            if kosu == len(tmp) and len(tmp) > ans:
                ans = len(tmp)

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
 
S = input()
count = 0
count_max = 0
 
for i in S : 
    if (i == "A" or i == "T" or i == "G" or i == "C") :
        count += 1
        count_max = max(count_max, count)
    else : 
        count = 0
        
print(count_max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def length(strings):
  N = len(strings)
  dp = [0 for _ in range(N)]
  max_l = [0 for _ in range(N)]
  i = 0
  if strings[i] in ["A", "C", "G", "T"]:
    dp[i] = 1
  else:
    dp[i] = 0 
  max_l[i] = dp[i]
  for i in range(1, N, 1):
    if strings[i] in ["A", "C", "G", "T"]:
      dp[i] = dp[i-1] + 1
    else:
      dp[i] = 0
    max_l[i] = max(max_l[i-1], dp[i])
    
  return max_l[N-1]

if __name__ == "__main__":
  string = input()
  print(length(string))

Submission status: Accepted

Solution code:
s = input()
p = []

ans = 0
ansp = []

for i in s:
    if i == "A" or i == "C" or i == "G" or i == "T":
        p.append(1)
    else:
        p.append(0)
lenp = len(p)

for ii in range(20):
    for j in range(len(p)):
        if p[j] == 1:
            ans = ans + 1
        else:
            break
    ansp.append(ans)
    ans = 0

    if len(ansp) == lenp:
        break

    del p[0]

print(max(ansp))

Submission status: Accepted

Solution code:
import re

pattern = '[^ACGT]'
S = input()
ans = max(map(len, re.split(pattern, S)))
print(ans)

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    S = [str(c) for c in input().strip()]

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=str(input())
import re
n=len(list(S))
result=re.findall('[A,C,G,T]{1,10}',S)
try:
    # print(result)
    result=max(result,key=len)
    print(len(result))
except:
    print(0)

Submission status: Accepted

Solution code:
# coding: utf-8

str = input()
x = len(str)
count = 0
tmp_c = 0

for i in range(x):
    if str[i:i+1] == 'A' or str[i:i+1] == 'T' or str[i:i+1] =='C' or str[i:i+1] == 'G':
        tmp_c = tmp_c + 1
    else:
        if count < tmp_c:
            count = tmp_c
        tmp_c = 0

    if i+1 == x:
        if count < tmp_c:
            count = tmp_c
        break

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
list = ["A","C","G","T"]
result = 0
count = 0
for i in range(len(S)):
    if S[i:i+1] in list:
        count += 1
    elif count > result:
        result = count
        count = 0
if count > result:
    result = count
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
string_list = list(input())
string_len = len(string_list)
renzoku_list = []

def find_letter():
  renzoku = 0
  for i in range(string_len):
    if string_list[i]=='A':
      renzoku += 1
    elif string_list[i]=='C':
      renzoku += 1
    elif string_list[i]=='G':
      renzoku += 1
    elif string_list[i]=='T':
      renzoku += 1
    else:
      renzoku_list.append(renzoku)
      renzoku = 0
  renzoku_list.append(renzoku)

find_letter()
  
if renzoku_list:
  max_len = max(renzoku_list)
  print(max_len)
else:
  print(0)

Submission status: Accepted

Solution code:
s = input()
s = list(s)
cnt = []
for i in range(len(s)):
  c = 0
  j = i
  while s[j] == 'A' or s[j] == 'T' or s[j] == 'C' or s[j] == 'G':
    c +=1
    j += 1
    cnt.append(c)
    if j == len(s):
      break
if not cnt:
  print(0)
else:
  print(max(cnt))

Submission status: Accepted

Solution code:
b=list(input())
N=len(b)
enki=["A","T","G","C"]
curmax=0
for i in range(N):
    for j in range(i,N):
        if all((k in enki) for k in b[i:j+1]):
            curmax=max(curmax,j-i+1)
print(curmax)

Submission status: Accepted

Solution code:
s = input()

N = len(s)
i = 0
a = ""
while i<N:
	#print( s[i] )
	if s[i]=="A" or s[i]=="T" or s[i]=="C" or s[i]=="G":
		a = a + "A"
	else:
		a = a + ","
	i += 1

#print(a)
l=a.split(",")

#print(l)

ans=0
for b in l:
	ans = max(len(b),ans)

print(ans)

Submission status: Accepted

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

if counter > ans:
    ans = counter
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
judge=''
L=len(S)
for index in range(L):
    moji=S[index]
    if (moji=='A') or (moji=='G') or (moji=='T') or (moji=='C'):
        judge+='X'
    else:
        judge+='W'
#print(judge)
num_keeper=[]
num=0
for index in range(L):
    J=judge[index]
    if (index==0) and (J=='X'):
        num=1
    elif J=='W':
        num_keeper.append(num)
        num=0
    elif (index==L-1) and (J=='X'):
        num+=1
        num_keeper.append(num)
    else:
        num+=1
if len(num_keeper)==0:
    num_keeper.append(L)
print(max(num_keeper))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = input()

n = 0
best_n = 0
length = len(S)

for i in range(length):
    if (S[i] in ['A', 'C', 'G', 'T']):
        n += 1
        if (i == length - 1) and (n > best_n):
            best_n = n
    else:
        if (n > best_n):
            best_n = n
            n = 0
print(best_n)

Submission status: Accepted

Solution code:
def main():
    a = ['A', 'T', 'G', 'C']
    S = input()
    l = 0
    L = 0
    for s in S:
        if s in a:
            l += 1
        else:
            if l > L:
                L = l
            l = 0
    if l > L:
        L = l
    print(L)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = input()
a = a.replace("A","*")
a = a.replace("C","*")
a = a.replace("G","*")
a = a.replace("T","*")
if (a.find("**********")!=-1):
    print("10")
elif(a.find("*********")!=-1):
    print("9")
elif(a.find("********")!=-1):
    print("8")
elif(a.find("*******")!=-1):
    print("7")
elif(a.find("******")!=-1):
    print("6")
elif(a.find("*****")!=-1):
    print("5")
elif(a.find("****")!=-1):
    print("4")
elif(a.find("***")!=-1):
    print("3")
elif(a.find("**")!=-1):
    print("2")
elif(a.find("*")!=-1):
    print("1")
else:
    print("0")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
  str = input()
  l = list(str)
  counter = 0
  max = 0
  for s in l:
    if s == 'A' or s == 'G' or s == 'C' or s == 'T':
      counter += 1
      if max <= counter:
        max = counter
    else:
      counter = 0
  print(max)

Submission status: Accepted

Solution code:
S = input()
max = 0
import re
for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        if re.search("[^ATCG]", S[i:j]):
            pass
        else:
            if max < len(S[i:j]):
                max = len(S[i:j])
print(max)

Submission status: Accepted

Solution code:
s = input()

maxLength = 0

tempLength = 0

for letter in s:
  if letter in "AGCT":
    tempLength += 1
    if tempLength > maxLength:
      maxLength = tempLength
  else:
    tempLength = 0

print(maxLength)

Submission status: Accepted

Solution code:
S = input()
li = [-1]
ans = 0
for index,i in enumerate(S):
    if(i!='A' and i!='C' and i!='G' and i!='T'):
        li.append(index)
li.append(len(S))
if(len(li)==1):
    print(len(S))
else:
    for index,i in enumerate(li):
        if(not index==0):
            ans = max(ans,li[index]-li[index-1]-1)

    print(ans)

Submission status: Accepted

Solution code:
S = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

S = str(input())

max_len = 0

for i in range(len(S)):
    for j in range(i, len(S)):
        compared_str = compared_str = S[i : j+1]
        compared_str = compared_str.replace('A', '')
        compared_str = compared_str.replace('C', '')
        compared_str = compared_str.replace('G', '')
        compared_str = compared_str.replace('T', '')
        
        if compared_str == '':
            max_len = max([max_len, len(S[i : j+1])])
        
print(max_len)

Submission status: Accepted

Solution code:

S = list(input())
ACGT = []
lentemp = 0
while len(S)>0:
    s = S.pop(0)

    if s == "A" or s == "C" or s == "G" or s == "T":
        lentemp += 1

    else:
        ACGT.append(lentemp)
        lentemp = 0
ACGT.append(lentemp)

print(max(ACGT))

Submission status: Accepted

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

    ans = 0
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            ok = True
            ss = s[i:j]
            for k in ss:
                if k not in {"A", "C", "G", "T"}:
                    ok = False

            if ok:
                ans = max(ans, j-i)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
y = input()
ans = 0
count = 0
c = 0
for i in y:
    c += 1
    if i == 'A' or i == 'C' or i == 'T' or i == 'G':
        count += 1
        if c == len(y):
            if ans < count:
                ans = count
    else:
        if ans < count:
            ans = count
        count = 0

print(ans)

Submission status: Accepted

Solution code:
n=input()
ans=0
anss=[]
for i in range(len(n)):
    
    if n[i] == "A" or n[i] == "T" or n[i] == "G" or n[i] == "C":
        ans += 1
        anss.append(ans)
    else:
        anss.append(ans)
        ans=0

import numpy as np
anss=np.array(anss)
print(anss.max())

Submission status: Accepted

Solution code:
a = input()
lis = []
li = ["A","C","G","T"]
l = []
for i in range(len(a)):
    if a[i] in li:
        lis.append(a[i])
        if i == len(a)-1:
            l.append(lis)
    else:
        l.append(lis)
        lis = []
ans = 0
for n in l:
    if ans < len(n):
        ans = len(n)
print(ans)

Submission status: Accepted

Solution code:
import re

istr=input()

print(max([len(e) for e in re.split('[BDEFHIJKLMNOPQRSUVWXYZ]',istr)]))

Submission status: Accepted

Solution code:
s = list(input())
acgt = ['A', 'C', 'G','T']
lst = []
for c in s:
    if c in acgt:
        lst.append(c)
    else:
        lst.append(" ")
ans = "".join(lst).split()
ln = list(map(len, ans))
if len(ln) > 0:
    print(max(ln))
else:
    print(0)

Submission status: Accepted

Solution code:
S = input()

cntMax = 0
cnt = 0

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

cntMax = max(cntMax, cnt)

print(cntMax)

Submission status: Accepted

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

ans = 0
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        s = S[i:j]
        flag = 0
        for ss in s:
            if not (ss in ch):
                flag = 1
                break
        if flag == 0:
            ans = max(ans, len(s))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
b=input()
ACGT=["A","C","G","T"]
ans=[0 for i in range(len(b))]
a=0
for i in b:
	if i in ACGT:
		ans[a]=ans[a]+1
	else:
		a=a+1
ans.sort(reverse=True)
print(ans[0])

Submission status: Accepted

Solution code:
import re

S = input()
ans = re.split(r'[^ATGC]', S)

maxlen = -1
maxarg = 0
for a in ans:
    maxlen = len(a) if len(a) > maxlen else maxlen

print(maxlen)

Submission status: Accepted

Solution code:
inp = input()

max_len = 0
list_match = []

for i in inp:
  if i in ('A','T','G','C'):
    list_match.append(1)
  else:
    list_match.append(0)



for i in range(len(list_match)):
  cnt_char = 0
  if list_match[i] == 1:
    cnt_char += 1
    
    for _j in range(len(list_match)):
      if i + 1 == len(list_match):
        break
      elif list_match[i+1] == 1:
        cnt_char += 1
        i += 1
      else:
        break      
    
    if max_len < cnt_char:
      max_len = cnt_char
      
print(max_len)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import collections

def main():
	S = input()
	S = list(S)
	
	ans = 0
	for i, vol in enumerate(S):
		tmp = 0
		if vol == "A" or vol == "C" or vol == "G" or vol == "T":
			tmp += 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":
					tmp += 1
				else:
					break
			if ans < tmp:
				ans = tmp
			
		
	
	print(ans)
			
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
S = input()
count = 0
x = [0]

for i in S:
  if i in ('A','C','G','T'):
    count += 1
  else:
    x.append(count)
    count = 0
x.append(count)

print(max(x))

Submission status: Accepted

Solution code:

string = input()
pattern = ["A","C","G","T"]

c = 0
result = []
for i in string:
    if i in pattern:
        c += 1
        if string[len(string)-1] == i:
            result.append(c)
    else:
        result.append(c)
        c = 0

if len(result) == 0:
    print(len(string))
else:
    print(max(result))

Submission status: Accepted

Solution code:
S = input()

S = list(S)

for i in range(len(S)):	
	if not (S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G'):
		S[i] = ","
		
S = ("".join(S)).split(",")
print(max([len(s) for s in S]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
answer = 0

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

Submission status: Accepted

Solution code:
S = input()
S = list(S)
cnt = 0
maxcount = 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
        if cnt > maxcount:
            maxcount = cnt
    else:
        cnt = 0
print(maxcount)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
# 1文字ずつ格納
a = [str(i) for i in input()] 
max=0
ans=0


for i in range(len(a)):

    if a[i] == "A" or a[i] == "C" or a[i] == "G" or a[i] == "T":
        max=max+1
    else:
        if(ans <= max):
            ans=max
            max=0
        
        
if(ans <= max):
    ans=max

if ans >= 11:
    ans=10
    
print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

S = read_str()

def solve():
    res = [0 for _ in range(10)]
    index = 0
    for i in range(len(S)):
        if S[i] in ['A','T','G','C']:
            res[index] += 1
        else:
            index += 1
    print(max(res))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = input()
S = list(h)

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

flag = False
count = 0
maxt = 0
for i in range(len(S)):
    for s in range(len(S)):
        s = s + i
        if len(S) <= s:
            if maxt <= count:
                maxt = count
            break
        if flag == False and (S[s] in atc):
            flag = True
            count += 1
        elif flag == True and (S[s] in atc):
            count += 1
        elif flag == True:
            break
        if maxt < count:
            maxt = count
    count = 0
    flag = False
print(maxt)

Submission status: Accepted

Solution code:

S=input()


c=0
m=0
for i in range(len(S)):
	if(S[i]=="A" or S[i]=="T" or S[i]=="G" or S[i]=="C"):
		c+=1
	else:
		if(m<=c):
			m=c
		c=0
if(m<=c):
	m=c
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

s = input()
print(max((len(m.group(0)) for m in re.finditer("[ACGT]+", s)), default=0))

Submission status: Accepted

Solution code:
S = input()

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

print(max(C))

Submission status: Accepted

Solution code:
S = list(input())


for i in range (len(S)):
    if S[i] == "A":
        S[i] = "1"
    elif S[i] == "G":
        S[i] = "1"
    elif S[i] == "C":
        S[i] = "1"
    elif S[i] == "T":
        S[i] = "1"

S2 = "".join(S)

for i in range (len(S)+1)[::-1]:
    A = "".join("1" * i)
    if A in S2:
        print(i)
        break

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[30]:


S = str(input())


# In[31]:


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


# In[32]:


count = 0
ans = 0


# In[33]:


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

print(ans)


# In[ ]:

Submission status: Accepted

Solution code:
s=input()
l=len(s)
max=0
Max=0
i=0
while i < l:
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        i+=1
        max+=1
    else:
        i+=1
        if max>Max:
            Max=max
        max=0
if max>Max:
    Max=max
print(Max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l=input()
a='AGCT'
cnt=0;max=0
for i in l:
    if i in a:
        cnt+=1
        if max < cnt:
            max=cnt
    else:
        cnt=0
print(max)

Submission status: Accepted

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

n = len(S)
st = 0
ans = 0
for i in range(n):
    if S[i] in base:
        ans = max(ans, i - st + 1)
        continue
    ans = max(ans, i - st)
    st = i + 1

print(ans)

Submission status: Accepted

Solution code:
b = input()

count = 0
max_count = 0
for s in b:
  if s == "A" or s == "C" or s == "G" or s == "T":
    count += 1
  else:
    if max_count < count:
      max_count = count
    count = 0
if max_count == 0 or max_count < count:
  	max_count = count
print(max_count)

Submission status: Accepted

Solution code:
n = input()

ls = []
cnt = 0
for i in range(len(n)):
  if n[i] == 'A' or n[i] == 'G' or n[i] == 'C' or n[i] == 'T':
    cnt += 1
    ls.append(cnt)
  else:
    cnt = 0
    ls.append(cnt)
    
print(max(ls))

Submission status: Accepted

Solution code:
import re
from functools import reduce

print(reduce(lambda x, y: max(x, y), map(lambda x: len(x), re.split('[^ATGC]', input()))))

Submission status: Accepted

Solution code:
n=input()
n=list(n)
#print(n)
n1=[0 for i in range(len(n))]
for i in range(len(n)):
    if n[i]=='A' or n[i]=='C' or n[i]=='G' or n[i]=='T':
        n1[i]=1
#print(n1)

cnt=0
maxcnt=0
for i in n1:
    if i==1:
        cnt+=1
        maxcnt=max(maxcnt,cnt)
    else:
        cnt=0
        
print(maxcnt)

Submission status: Accepted

Solution code:
s = input()
cs = [c in {'A', 'T', 'C', 'G'} for c in s]

q = 0
for i, c in enumerate(cs):
    p = 0
    if c:
        for j in range(i, len(cs)):
            if not cs[j]:
                break
            p += 1
        if q == 0 or q < p:
            q = p

print(q)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
num = 0
maxi = 0
for i in s:
  if i=="A" or i=="T" or i=="G" or i=="C":
    num += 1
  else : num = 0
  if num > maxi:
    maxi = num
print(maxi)

Submission status: Accepted

Solution code:
s = list(input())
renzoku = 0
count = 0
hu_renzoku = 0
renli = []
for i in s:
    count += 1
    if i == "A" or i == "T" or i == "C" or i == "G":
        renzoku += 1
        renli.append(renzoku)
    else:
        renzoku = 0
        hu_renzoku += 1
if count == hu_renzoku:
    print(0)
else:
    print(max(renli))

Submission status: Accepted

Solution code:
s = input()

count = 0
ans = 0

for i in s:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count += 1
    else:
        if ans < count:
            ans = count
        count = 0
        
if ans < count:
    ans = count

print(ans)

Submission status: Accepted

Solution code:
a = ['A', 'C', 'G', 'T']
s = list(input())
result = 0
count = 0
for c in s:
    if c in a:
        count += 1
    else:
        if result < count:
            result = count
        count = 0
if result < count:
    result = count
print(result)

Submission status: Accepted

Solution code:
a = input()

part = ""
s = ["A","C","G","T"]
ans = [""]

for i in a:
    
    if  i  in s:
        part += i
    else:
        part = ""
    ans.append(part)
ans = [len(i) for i in ans]
print(max(ans))

Submission status: Accepted

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

            break
print(tmp)

Submission status: Accepted

Solution code:
s = input()
li = ["A","T","C","G"]

cnt = 0
cntli = []
for i in range(len(s)):
    if s[i] in li:
        cnt += 1
    else:
        cntli.append(cnt)
        cnt = 0
else:
    cntli.append(cnt)

print(max(cntli))

Submission status: Accepted

Solution code:
S = str(input())
n = len(S)
L = ["A","C","G","T"]
w = [0]
for i in range(n):
    if S[i] in L:
        cnt = 0
        for j in range(i,n):
            if S[j] not in L:
                cnt += 1
                w.append(len(S[i:j]))
                break
        if cnt == 0:
            w.append(len(S[i::]))
print(max(w))

Submission status: Accepted

Solution code:
S = input()
ans = 0

def check(s):
    for i in s:
        if not i in ['A', 'G', 'T', 'C']:
            return False
    return True

for l in range(len(S)):
    for i in range(len(S)-l+1):
        sub = S[i:i+l+1]
        
        if not check(sub):
            continue
        ans = max(len(sub), ans)
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/24
@author: shinjisu
"""


# ABC 122
# import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)
def getIntLines(n): return [int(input()) for i in range(n)]
def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    T = input()
    d.dmp((T), 'T')
    AGCT = ('A', 'T', 'C', 'G', )
    mx = 0
    for i in range(len(T)):
        for j in range(i, len(T)):
            count = 0
            for k in range(i, j+1):
                if T[k] in AGCT:
                    count += 1
                else:
                    break
            mx = max(mx, count)
            #d.dmp((mx, count),'mx, count')
    return mx

ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Submission status: Accepted

Solution code:
s = list(input())
l = ['A', 'T', 'C', 'G']
max_cnt = 0
cnt = 0
for i in range(len(s)):
    if s[i] in l:
        cnt += 1
    elif s[i] not in l:
        cnt = 0
    if max_cnt <= cnt:
        max_cnt = cnt
print(max_cnt)

Submission status: Accepted

Solution code:
s = input()
count = 0
maxi = 0
for i in s:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count += 1
    else:
        if maxi < count:
            maxi = count
        count = 0
if maxi < count:
    maxi = count
print(maxi)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
ans_lis = [0]
for x in S:
    if x == 'A' or x == 'C' or x == 'G' or x == 'T':
        ans += 1
    else:
        ans_lis.append(ans)
        ans = 0
ans_lis.append(ans)
print(max(ans_lis))

Submission status: Accepted

Solution code:
t=input()
ans=0
for i in range(len(t)):
  s=[i for i in t]
  for j in range(i):
    s.pop()
  for j in range(len(s)):
    q=''.join(s)
    q=q.lstrip('ACGT')
    ans=max(ans,len(s)-len(q))
    s.pop(0)
print(ans)

Submission status: Accepted

Solution code:
#b
s = input()

def judge(seq):
    flag = True
    group = ['A', 'T', 'G', 'C']
    for s in seq:
        if s not in group:
            flag = False
    return flag

max_len = 0
for x in range(len(s)):
    for y in range(x+1, len(s)+1):
        sub_seq = s[x:y]
        # print(sub_seq)
        if judge(s[x:y]):
            max_len = max(max_len, len(s[x:y]))

print(max_len)

Submission status: Accepted

Solution code:
s = str(input())
cnt = []
l = 0
pos = 0

for i in range(len(s)):
    l = 0
    pos = i
    while s[pos] == 'A' or s[pos] == 'C' or s[pos] == 'G' or s[pos] == 'T':
        l += 1
        pos += 1
        if pos >= len(s):
            break

    cnt.append(l)

print(max(cnt))