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:
# coding: utf-8
# Your code here!

S = input()

ACGT = ("A", "G", "C", "T")

max_len = 0
tmp_len = 0
for c in S:
    if c in ACGT:
        tmp_len += 1
    else:
        tmp_len = 0
    
    if tmp_len > max_len:
        max_len = tmp_len

print(max_len)

Submission status: Accepted

Solution code:
S = input()

T = ["A", "C", "G", "T"]
max_length = 0

for start in range(len(S)):
    for end in reversed(range(len(S) + 1)):
        checked = False
        if start > end:
            break
        else:
            sub_str = S[start:end]
            check_str = (
                sub_str.replace("A", "")
                .replace("C", "")
                .replace("G", "")
                .replace("T", "")
            )

            if len(check_str) != 0:
                checked = True
            else:
                if max_length < len(sub_str):
                    max_length = len(sub_str)

print(max_length)

Submission status: Accepted

Solution code:
s=input()
l=list(s)
m=0
for i in range(len(l)):
    if l[i]!="A" and l[i]!="T" and l[i]!="C" and l[i]!="G":
        l[i]="."

ss="".join(l)
ll=ss.split(".")
lll=[0]
for i in ll:
    lll.append(len(i))
print(max(lll))

Submission status: Accepted

Solution code:
S = list(input())

b = 0

ans = [0]

for n, i in enumerate(S, 1):
  if (i == 'A' or i == 'G' or i == 'C' or i == 'T'):
    b += 1
  else:
    b = 0
  ans.append(b)
print(max(ans))

Submission status: Accepted

Solution code:
tmp = input()

char_list = list()
acgt_list = list()
max_acgt = list()
acgt = ["A", "C", "G", "T"]
for char in tmp:
  if char in acgt:
    acgt_list.append(char)
    if len(max_acgt) < len(acgt_list):
      max_acgt = acgt_list
  else:
    if len(max_acgt) < len(acgt_list):
      max_acgt = acgt_list
    acgt_list = list()
print(len(max_acgt))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = str(input())
box = ["A", "G", "C", "T"]
s = str()
ACGTbox = str()
for i in range(0, len(S)):
    for j in range(i, len(S)):
        if S[j] in box:
            s += S[j]
        else:
            break
    if len(s) > len(ACGTbox):
        
        ACGTbox = s 
    s = str()
print(len(ACGTbox))

Submission status: Accepted

Solution code:
s = list(input())
t = [i for i in range(len(s)) if s[i] not in ["A","T","G","C"]]
if len(t) == 0:
	print(len(s))
else:
  t = t + [len(s)]
  u = 0
  w = -1
  for i in range(len(t)):
    if u <= t[i]-w:
      u = t[i]-w
    w = t[i]
  print(u-1)

Submission status: Accepted

Solution code:
s=input()
ans=0
acgt="ACGT"
for i in range(0,len(s)):
  for j in range(i+1,len(s)+1):
    x=s[i:j]
    z=sum([ y in acgt for y in x])
    if z==j-i:
      ans=max(ans,z)
      
print(ans)

Submission status: Accepted

Solution code:
s=raw_input()
longest=0
cur=0
for c in s:
    if c in 'ACGT':
        cur+=1
    else:
        longest=max(longest, cur)
        cur=0
print(max(longest, cur))

Submission status: Accepted

Solution code:
S = input();
answer_max=0;
answer=0;

for i in S:
    if(i=="A" or i=="C" or i=="G" or i=="T"):
        answer+=1;
    else:
        answer=0;
    if(answer_max < answer):
        answer_max = answer;

print(answer_max);

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8-*-
if __name__ == '__main__':
    s = input()
    b = 0
    m = 0
    for i in range(len(s)):
        if not (s[i] in "AGTC"):
            if m < i-b:
                m = i-b
            b = i+1
    if m < len(s)-b:
        m = len(s)-b
    print(m)

Submission status: Accepted

Solution code:
def longest_acgt(t):
    helix = ["A","C","G","T"]
    length = 0
    max_length = 0
    for c in t:
        if c in helix:
            length += 1
        else:
            if max_length < length:
                max_length = length
                length = 0
    if max_length < length:
        max_length = length
    return max_length


t = input()
print(longest_acgt(t))

Submission status: Accepted

Solution code:
#ATCoder

s= input()
slist= list(s)
alist= []

def fun1(i):
    target= slist[i]
    if i==len(s)-1:
        if slist[i]=='A' or slist[i]=='C' or slist[i]=='G' or slist[i]=='T':
            return 1
        else:
            return 0
    elif slist[i]=='A' or slist[i]=='C' or slist[i]=='G' or slist[i]=='T':
        return fun1(i+1)+1
    else:
        return 0

for i in range(len(slist)):
    alist.append(fun1(i))

print(max(alist))

Submission status: Accepted

Solution code:
""" AtCoder """

S = input()

ans = 0
ans_max = 0
l = ['A', 'C', 'G', 'T']
check = 1

for i in S:
    if i in l:
        ans += 1
    else:
        ans_max = max(ans_max, ans)
        ans = 0
        check = 0

ans_max = max(ans_max, ans)

if check == 1:
    ans_max = len(S)

print(ans_max)

Submission status: Accepted

Solution code:
cnt = 0 
memory = 0
s=input()
for x in s: #文字列Sから1文字ずつ取り出してXに代入
  if x in ['A','G','C','T']: #取り出した文字xが[]内の文字いずれかの場合
    cnt += 1
  else:
    memory = max(memory,cnt) #退避先memoryとcntを比較し大きい方を更新
    cnt = 0
print(max(memory,cnt))  #ACGT以外の文字が現れなかった時(全てACGTいずれか又はXAAAA等)

Submission status: Accepted

Solution code:
S = list(input())
ACGT = []
tmp = ""
for i, s in enumerate(S):
    if s == "A" or s == "C" or s == "G" or s == "T":
        tmp += s
        if i == len(S)-1:
            ACGT.append(tmp)
            break
    else:
        ACGT.append(tmp)
        tmp = ""

print(len(sorted(ACGT, key=lambda x: len(x))[len(ACGT)-1]))

Submission status: Accepted

Solution code:
S = input()
max_len = 0
for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        s = S[i:j]
        s = s.replace('A', '.')
        s = s.replace('T', '.')
        s = s.replace('G', '.')
        s = s.replace('C', '.')
        flag = True
        for ss in s:
            if ss != '.':
                flag = False
        if flag:
            if max_len < len(s):
                max_len = len(s)
print(max_len)

Submission status: Accepted

Solution code:
S = input()
L=len(S)
longest=0
for i in range(L):
  for j in range(i+1):
    DUP=S[j:i+1]
    DUP=DUP.replace("A","#")
    DUP=DUP.replace("T","#")
    DUP=DUP.replace("G","#")
    DUP=DUP.replace("C","#")
    count=0
    for a in range(len(DUP)):
      if DUP[a]=="#":
        count+=1
      else:
        break
    else:
      longest=max(longest,count)
print(longest)

Submission status: Accepted

Solution code:
import re
S = input()
H = re.findall("[ACGT]+", S)
max_length = 0
for h in H:
	if max_length < len(h):
		max_length = len(h)
print(max_length)

Submission status: Accepted

Solution code:
def is_ATCG(str):
    for i in range(len(str)):
        chr=str[i]
        if(not(chr=='A' or chr=='T' or chr == 'C' or chr=='G')):
            return 0
    return 1

i_str=input()
max_len=0
len_str=len(i_str)

for i in range(len_str): #０行目から最後の行まで
    for j in range(i,len_str): #それぞれの文字数目から行末までのそれぞれの部分単語を取り出す
        strA=i_str[i:j+1:1]
        if max_len < len(strA) and is_ATCG(strA):
            max_len = len(strA)
print(max_len)

Submission status: Accepted

Solution code:
import re

pattern = "[ATCG]+"
S = input()
result = re.findall(pattern, S)
S_len = map(len, result)
try:
  print(max(S_len))
except:
  print(0)

Submission status: Accepted

Solution code:
S=str(input())  #文字列の入力
S=S.replace("A","x")
S=S.replace("T","x")
S=S.replace("G","x")
S=S.replace("C","x")
for i in range(0,2,1):
  if S.count("xxxxxxxxxx")!=0:
    print(10)
    break
  elif S.count("xxxxxxxxx")!=0:
    print(9)
    break
  elif S.count("xxxxxxxx")!=0:
    print(8)
    break
  elif S.count("xxxxxxx")!=0:
    print(7)
    break
  elif S.count("xxxxxx")!=0:
    print(6)
    break
  elif S.count("xxxxx")!=0:
    print(5)
    break
  elif S.count("xxxx")!=0:
    print(4)
    break
  elif S.count("xxx")!=0:
    print(3)
    break
  elif S.count("xx")!=0:
    print(2)
    break
  elif S.count("x")!=0:
    print(1)
    break
  else:
    print(0)
    break

Submission status: Accepted

Solution code:
from sys import stdin

str = stdin.readline().rstrip()


cnt = 0
rslt = 0




for a in str:
    flg = 0
    for b in "ATGC":
        if a == b:
            cnt = cnt + 1
            flg = 1
            break
            
    
    if rslt <= cnt:
        rslt = cnt
        
    if flg == 0:
        cnt = 0


print(rslt)

Submission status: Accepted

Solution code:
S = input()
acgt = ["A","C","G","T"]
S_tf = [any([sss == aaa for aaa in acgt]) for sss in S]
maxlen = 0
curlen = 0
for i in S_tf:
    if i:
        curlen += 1
        if maxlen < curlen:
            maxlen = curlen
    else:
        curlen = 0
print(maxlen)

Submission status: Accepted

Solution code:
s = input().strip()
agct = ['A', 'G', 'C', 'T']
counter = 0
counts = [0]

for c in s:
    if c in agct:
        counter += 1
    else:
        if max(counts) < counter:
            counts.append(counter)
        counter = 0


counts.append(counter)

print(max(counts))

Submission status: Accepted

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

for i in range(l):
    for j in range(l-i+1):
        seq = S[i:i+j]
        seq2 = seq.replace("A","").replace("G","").replace("T","").replace("C","")
        if seq2 == "":
            ans = max(ans, len(seq))
print(ans)

Submission status: Accepted

Solution code:
def tasu(i):
    global bubun
    if i >= len(string):
        return
    elif string[i] == "A" or string[i] == "C" or string[i] == "G" or string[i] == "T":
        bubun += string[i]
        tasu(i + 1)

string = input()

lst = [""]

for i in range(len(string)):
    if string[i] == "A" or string[i] == "C" or string[i] == "G" or string[i] == "T":
        bubun = ""
        tasu(i)
        lst.append(bubun)

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

Submission status: Accepted

Solution code:
s = input()
max = 0
oldmax = 0
for e in s:
    if(oldmax < max):
        oldmax = max
    if (e == "A" or e == "T" or e == "G" or e == "C"):
        max += 1
        if(oldmax < max):
            oldmax = max
    else:
        max = 0
print(oldmax)

Submission status: Accepted

Solution code:
s = input()
s2 = ''
for c in s:
    if c in ('A','T','C','G'):
        s2 += '1'
    else:
        s2 += '0'


tmp = 0
ret = 0
for c in s2:
    if c == '1':
        tmp += 1
    else:
        ret = max(ret, tmp)
        tmp = 0
ret = max(ret, tmp)
print(ret)

Submission status: Accepted

Solution code:
# coding: utf-8
moji = list(input())
n = len(moji)
kaunto = 0
risuto = []
for i in range(n):
    if (moji[i] == "A") or (moji[i] == "G") or (moji[i] == "C") or (moji[i] == "T"):
        risuto.append("X")
    else:
        risuto.append(" ")

s = 0
kotae = []
for i in risuto:
    if i == "X":
        s += 1
        kotae.append(s)
    else:
        s = 0
if kotae != []:
    print(int(max(kotae)))
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
b, = map(str, input().split())

alpha = [chr(ord('A') + i) for i in range(26)]
acgt = ["A","C","G","T"]
for i in acgt:
    alpha.remove(i)

for i in alpha:
    b = b.replace(i," ")
    words = b.split(" ")
    
const = 0
length = 0

for word in words:
    const = len(word)
    if const>length:
        length = const

print(length)

Submission status: Accepted

Solution code:
s = input()
def check(substr):
    ret = 0
    for i in range(len(substr)):
        if substr[i] !='A' and substr[i] !='C' and substr[i] != 'G' and substr[i] !='T':
            return 0
        else:
            ret +=1
    return ret
ans = 0
for i in range(len(s)):
    for j in range(i,len(s)+1):
        sub = s[i:j]
        ans = max(ans, check(sub))
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    S = lines.pop(0)
    c = 0
    res = 0
    for i in S:
        if i in 'AGCT':
            c += 1
        else:
            c = 0
        res = max(res, c)
    print(res)

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Accepted

Solution code:
import re

s = input()
table = str.maketrans({'A': 'a', 'T': 't', 'G': 'g', 'C': 'c'})
result = s.translate(table)
# print(result)
#s.replace("A", "a").replace("T", "t").replace("G", "g").replace("C", "c")
result = re.sub(r'[A-Z]', " ", result)
s_list = result.split()
m = 0
for ss in s_list:
    m = max(m, len(ss))
    # print(ss)

print(m)

Submission status: Accepted

Solution code:
s = str(input())


s1 = s.replace("A","1")
s2 = s1.replace("G","1")
s3 = s2.replace("T","1")
s4 = s3.replace("C","1")

if s4.count("1111111111") >= 1:
 print(10)
elif s4.count("111111111") >= 1:
 print(9)
elif s4.count("11111111") >= 1:
 print(8)
elif s4.count("1111111") >= 1:
 print(7)
elif s4.count("111111") >= 1:
 print(6)
elif s4.count("11111") >= 1:
 print(5)
elif s4.count("1111") >= 1:
 print(4)
elif s4.count("111") >= 1:
 print(3)
elif s4.count("11") >= 1:
 print(2)
elif s4.count("1") >= 1:
 print(1)
else:
 print(0)

Submission status: Accepted

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

input_len = len(input)
cnt = 0
max_cnt = 0
for i,s in enumerate(input):
    if s in acgt:
        cnt += 1
    elif cnt > max_cnt:
        max_cnt = cnt
        cnt = 0
    else:
        cnt = 0

    if i == input_len - 1 and cnt > max_cnt:
        max_cnt = cnt

print(max_cnt)

Submission status: Accepted

Solution code:
S = input()
countermax = 0
counter = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        counter += 1
    else:
        if countermax < counter:
            countermax = counter
            counter = 0
if countermax < counter:
    countermax = counter

print(countermax)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

subStringList = [S]
length = len(S)

counter = 0
before = 1

while (not(counter == before)):
    before = counter
    for s in subStringList[:]:
        for letter in s:
            if (not(letter in "ATGC")):
                subStringList += s.split(letter)
                subStringList.remove(s)
                counter = len(subStringList)
                break

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

Submission status: Accepted

Solution code:
s=list(input())
counts=0
lists=[]
a=len(s)
for i in range (1,a+1):
    if s[i-1]=='A':
        counts=counts+1
        lists.append(counts)
    elif s[i-1]=='G':
        counts=counts+1
        lists.append(counts)
    elif s[i-1]=='T':
        counts=counts+1
        lists.append(counts)
    elif s[i-1]=='C':
        counts=counts+1
        lists.append(counts)
    else:
        counts=0
lists.sort()
k=len(lists)
if k==0:
    print(0)
else:
    print(lists[k-1])

Submission status: Accepted

Solution code:
def main():
    s = input()
    n = len(s)
    output = 0

    ss = s.replace("A", "1").replace("T", "1").replace("G", "1").replace("C", "1")

    for i in range(n + 1):
        if "1" * i in ss:
            output = i

    print(output)
    return 0


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
count,ans = 0,0

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

Submission status: Accepted

Solution code:
S = list(input())
m = 0
count = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        count = 0
        #switch = False
        for s in list(S[i:j+1]):
            #print(s, list(S[i:j+1]), count)
            if s in ['A', 'G', 'T', 'C']:
                count += 1
            else:
                if m <= count:
                    m = count
                count = 0
                switch = True
            if m <= count:
                m = count


print(m)

Submission status: Accepted

Solution code:
S = input()
S = S +'R'
#ATCG = 'ATCG'                   
count = 0
j=0
num=[]
for i in range(len(S)):
    # for j in range(4):
    #     if S[i]==ATCG[j]:
    # if (S[i] == 'A' or S[i]=='T' or S[i]=='C' or S[i]== 'G') and (i==(len(S)-1)):
    #     count =count+1
    #     print(S[i])
    #     num.append(count)

    if S[i] == 'A' or S[i]=='T' or S[i]=='C' or S[i]== 'G':
        count=count+1
        #print(S[i])
       
    else:
        num.append(count)
        j=j+1
        count=0


#print(num)
max_num=max(num)
print(max_num)

Submission status: Accepted

Solution code:
sss = str(input())
ss_list = []

for i in range(len(sss)):
    for j in range(i,len(sss)+1):
        ss_list.append(sss[i:j])
ss_list = list(set(ss_list))


#文字列を渡して、AGTCから構成されていればその長さを返す
def bh(ss):
    flag = 0
    for s in ss:
        if s not in ["A","G","T","C"]:
            flag = 1
    if flag == 0:
        return len(ss)
    else:
        return 0

max_len = 0
for ss in ss_list:
    l = bh(ss)
    if l>max_len:
        max_len = l

print(max_len)

Submission status: Accepted

Solution code:
b = input()
let = 'ATGC'
prev = b[0]
high = 0
leng = 0
stop = False

if prev in let:
    leng = 1
    high = 1
    
for i in range(1,len(b)):
    if leng == 0 and b[i] in let:
        leng = 1
    if b[i] in let and prev in let:
        leng += 1
        stop = False
    else:
        stop = True
        if leng > high:
            high = leng
            leng = 0
    prev = b[i]
    
if not stop:
    if leng > high:
        high = leng
    
print(high)

Submission status: Accepted

Solution code:
S = list(input())
lst=[]
for i in range(len(S)):
    if S[i]!="A" and S[i]!="C" and S[i]!="T" and S[i]!="G":
        lst.append(i)
lst.insert(0,-1)
lst.append(len(S))
dif=[]
for j in range(len(lst) - 1):
    dif.append(lst[j+1] - lst[j])

ans = max(dif) - 1
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
   
ans = []
pre = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        pre += 1
    else:
        ans.append(pre)
        pre = 0

ans.append(pre)
print(max(ans))

Submission status: Accepted

Solution code:
S = input()

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

res = 0

for i in range(len(S)+1):
    for j in range(1,len(S)+1):
        flag = True
        if -j+1 == 0:
            #print(S[i:])
            for k in S[i:]:
                if k not in st:
                    flag = False
                    break
        
            if flag:
                res = max(res,len(S[i:]))
        
        else:
            for k in S[i:-j+1]:
                if k not in st:
                    flag = False
                    break
            
            if flag:
                res = max(res,len(S[i:-j+1]))

print(res)

Submission status: Accepted

Solution code:
retu = input()
res = list(map(str,retu))
sum = [0]*len(retu)


for i in range(len(retu)):
  if res[i] == "A" or res[i]=="C" or res[i] =="T" or res[i]=="G":
    res[i] = 1
  else:
    res[i] = 0

    
for i in range(len(retu)):
  for j in range(len(retu)-i):
    if res[i+j] == 1:
      sum[i] += 1
    else:
      break
      
print(max(sum))

Submission status: Accepted

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

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

count = 0
count_list = []
count_list.append(0)
list_S = list(S)
length = len(list_S)

for i in range(0, length):
  if list_S[i] in acgt_list:
    for j in range(i, length):
      if list_S[j] in acgt_list:
        count += 1
      else:
        count_list.append(count)
        count = 0
        break
      if j == length -1:
        count_list.append(count)
        count = 0
print(max(count_list))

Submission status: Accepted

Solution code:
S = input()
count = 0

while S != "":
	while S[0] != "A" and S[0] != "C" and S[0] !="G" and S[0] !="T":
#		print(S)
		S = S[1:]
		if S == "":
			break
	
	if S == "":
		break
	c = 0
	while S[0] == "A" or S[0] == "C" or S[0] =="G" or S[0] =="T":
		c +=1
		if count < c:
			count = c
	
#		print("count = " + str(count) + ", S = " + S)
		S = S[1:]
#		print(S)
		if S == "":
			break
	
	if S == "":
		break

print(count)

Submission status: Accepted

Solution code:
from re import sub

word = input()
word_length = []

word = sub('[^ATGC]', ' ', word).split()
for i in word:
    word_length.append(len(i))

if len(word_length) == 0:
    print(0)
else:
    print(max(word_length))

Submission status: Accepted

Solution code:
a = input()
answer = 0

a = a.replace("B", "-")
a = a.replace("D", "-")
a = a.replace("E", "-")
a = a.replace("F", "-")
a = a.replace("H", "-")
a = a.replace("I", "-")
a = a.replace("J", "-")
a = a.replace("K", "-")
a = a.replace("L", "-")
a = a.replace("M", "-")
a = a.replace("N", "-")
a = a.replace("O", "-")
a = a.replace("P", "-")
a = a.replace("Q", "-")
a = a.replace("R", "-")
a = a.replace("S", "-")
a = a.replace("U", "-")
a = a.replace("V", "-")
a = a.replace("W", "-")
a = a.replace("X", "-")
a = a.replace("Y", "-")
a = a.replace("Z", "-")

strs = int(a.count("-")) + 1
a = a.split("-")

for i in range(strs):
    if len(a[i]) > answer:
        answer = len(a[i])

print(answer)

Submission status: Accepted

Solution code:
S = list(input())
k=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':
		k+=1
	else:
		if k>ans:
			ans=k
		k=0
if k>ans:
	ans=k
print(ans)

Submission status: Accepted

Solution code:
s=list(input())
lst=['A','T','G','C']
l=len(s)
ans=[[]]

for i  in range(l):
  for j in range(i+1,l+1):
    a=True
    L=s[i:j]
    
    for k in L:
      if k not in lst:
        a=False
        break
    if a:
      ans.append(L)
num=0

for i in ans:
  num=max(num,len(i))
print(num)

Submission status: Accepted

Solution code:
def checkACGT(s):
    for i in range(len(s)):
        if s[i] == "A" or s[i] == "G" or s[i] == "C" or s[i] == "T":
            continue
        else:
            return False
    return True

s=input()
n = len(s)
check = []
check.append(s)
while True:
    if not check:
        print(0)
        break
    if checkACGT(check[0]):
        print(len(check[0]))
        break
    else:
        if len(check[0]) == 1:
            check.pop(0)
            continue
        check.append(check[0][1:])
        check.append(check[0][:len(check[0])-1])
        check.pop(0)

Submission status: Accepted

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

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 (i == len(s)-1) and (max < count):
          max = count
    else:
        if max < count:
            max = count
        count = 0
print(max)

Submission status: Accepted

Solution code:
string = input()

elements = set(string)

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

for i in ATCGs:
    elements.discard(i)

for i in elements:
    string = string.replace(i, ".")
    
subs = string.split(".")
print(max(map(len, subs)))

Submission status: Accepted

Solution code:
S = input()
s_list=[]
string= ""
AGCT = ["A", "G", "C", "T"]
for s in S:
    if s in AGCT:
        #string = string + s
        string += s
    else:
        s_list.append(string)
        string=""
s_list.append(string)
print(max(map(len, s_list)))

Submission status: Accepted

Solution code:
S = input()
s = len(S)
L = []
temp = 0
for i in range(s):
    if S[i]=='A' or S[i]=='T' or S[i]=='G' or S[i]=='C':
        if temp ==0:
            temp=1
            L.append(temp)
        else:
            temp*=10
            L.append(temp)
    else:
        temp = 0
L.append(-1)        
if len(L)==2 and L[0]==0:
    P=0
elif len(L)==1:
    P=0
else:
    P = len(str(max(L)))
print(P)

Submission status: Accepted

Solution code:
S=input()
U={"A","T","G","C"}
N=len(S)
L=[0]
for i in range(N):
    if S[i] in U:
        L[-1]+=1
    else:
        L.append(0)
print(max(L))

Submission status: Accepted

Solution code:
import sys
from operator import itemgetter
import collections


def r(s):
    m = 0
    cnt = 0
    for n in s:
        if n in ['A', 'C', 'G', 'T']:
            cnt = cnt + 1
            m = max(m, cnt)
        else:
            cnt = 0
    return m


def main():
    input = sys.stdin.readline
    s = str(input()).strip()

    print(r(s))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
seq = input()
index = []
for char in list(seq):
    if char == "A" or char == "T" or char == "C" or char == "G":
        index.append("1")
    else:
        index.append("0")
index2 = ''.join(index)
print(len(max(index2.split("0"))))

Submission status: Accepted

Solution code:
s = input()
t = ['A', 'T', 'G', 'C']

ans = []
for i in range(len(s)):
  c = 0
  for j in range(i, len(s)):
    if s[j] in t:
      c += 1
    else:
      break
  ans.append(c)

print(max(ans))

Submission status: Accepted

Solution code:
S = input()
ACGT = ['A', 'C', 'G', 'T']
nagasatachi = []
nagasa = 0
for i in S:
	if i in ACGT:
		nagasa += 1
	else:
		nagasatachi.append(nagasa)
		nagasa = 0
nagasatachi.append(nagasa)
print(max(nagasatachi))

Submission status: Accepted

Solution code:
S=input()
all=[]
for i in range(len(S)):
    if S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
        all.append(i)
max=0
test=0
try:
    mae=all[0]
except:
    print("0")
    quit()
del all[0]
for j in all:
    if (j-1)==mae:
        test+=1;
    else:
        max=test
        test=0
    mae=j
else:
    if max<test:
        max=test;
    else:
        pass
print(str(max+1))

Submission status: Accepted

Solution code:
s = list(input())
list = {"A", "T", "G", "C"}
tmp = 0
count = 0
for i in s:
    count += 1
    if i not in list:
        if count -1 > tmp:
            tmp = count-1
        count = 0
if count > tmp:
    tmp = count
print(tmp)

Submission status: Accepted

Solution code:
S = input()

not_agct = "BDEFHIJKLMNOPQRSUVWXYZ"

head = 0
tail = 0
length = len(S)

candi = []

for head in range(length):
    for tail in range(length,head,-1):
        candi.append(S[head:tail])        

#candi_sort = sorted(candi)

ans = 0
for txt in candi:
    for judge in txt:
        if judge in not_agct:
            break
    else:
        if ans < len(txt):
            ans = len(txt) 

print(ans)

Submission status: Accepted

Solution code:
import re

T = input()
max_ = 0
s = re.match('[ACGT]+', T)
if s:
    max_ = len(s.group(0))

s = re.search('[^ACGT][ACGT]+$', T)
if s:
    max_ = max(max_, len(s.group(0)) - 1)


ss = re.findall('[^ACGT][ACGT]+[^ACGT]', T)
if ss:
    for s in ss:
        if s:
            max_ = max(max_, len(s) - 2)
print(max_)

Submission status: Accepted

Solution code:
a = input()
sum = 0
max = 0
for i in a:
    if i is "A":
        sum += 1
    elif i is "T":
        sum += 1
    elif i is "C":
        sum += 1
    elif i is "G":
        sum += 1
    else:
        if sum > max:
            max = sum
        sum = 0
if max == 0 and sum > 0:
    max = sum
if sum > max:
    max = sum
print(max)

Submission status: Accepted

Solution code:
def f(x):
    length=0
    array=[]
    for b in x:
        if b==True:
            length+=1
        else:
            array.append(length)
            length=0

    array.append(length)
    return array

s=input()
sb = ['A','C','G','T']
boola=list()
length=0

for x in s:
    boola.append(x in sb)

print(max(f(boola)))

Submission status: Accepted

Solution code:
b = input()
l = len(b)
ans = []
kotae = 1
c = []
for i in range(l):
  if b[i]=="A" or b[i]=="T" or b[i]=="G" or b[i]=="C":
    ans.append(i)
l2 = len(ans)
if l2==1:
  c.append(1)
for i in range(l2-1):
  if (ans[i+1]-ans[i])==1 and i==l2-2:
    kotae+=1
    c.append(kotae)
  elif (ans[i+1]-ans[i])==1:
    kotae+=1
  else:
    c.append(kotae)
    kotae=1
if ans==[]:
  print(0)
else:print(max(c))

Submission status: Accepted

Solution code:
from sys import stdin
s = input()
a = []
a.append(s.find('A'))
a.append(s.find('T'))
a.append(s.find('G'))
a.append(s.find('C'))
for i in range(len(a)):
    if a[i] == -1:
        a[i] = 100
start = min(a)
#print(a)
pos = 0
sol = 0
for i in range(start, len(s)):
    #print(start)
    if s[i] != 'A' and s[i]!='T' and s[i]!='G' and s[i]!='C':
        pos = i
        if pos - start > sol:
            sol = pos - start
        #start = i+1
        a.clear()
        a.append(s.find('A', i))
        a.append(s.find('T', i))
        a.append(s.find('G', i))
        a.append(s.find('C', i))
        for i in range(len(a)):
            if a[i] == -1:
                a[i] = 100
        start = min(a)
if len(s)- start > sol:
    sol = len(s)-start
print(sol)

Submission status: Accepted

Solution code:
s=-1
S=raw_input()+"!"
ans=0
for i in range(len(S)):
  if S[i]in "ATCG":
    if s==-1:
      s=i
  elif s!=-1:
    ans=max(ans, i-s)
    s=-1
print ans

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())

def sea(s):
    if s==[]:
        return 0
    max_agct=0
    tem_agct=0
    for i in range(len(s)):
        for j in range(len(s)-i):
            if s[i+j]=="A" or s[i+j]=="G" or s[i+j]=="C" or s[i+j]=="T":
                tem_agct+=1
          
                        
            else:
                if tem_agct>max_agct:
                    max_agct=tem_agct
                tem_agct=0
                break
                
        if i+j==len(s)-1:
            if tem_agct>max_agct:
                max_agct=tem_agct
            break
                    
    return max_agct

print(sea(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
S_list = list(S)
S_ex = ''.join((['1' if (k == 'A' or k == 'C' or k == 'G' or k == 'T') else '0' for k in S_list]))
S_ans = [len(k) for k in S_ex.split('0')]
print(max(S_ans))