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:
a = input()
ans = 0
for i in range(len(a) + 1):
  str_a = a[(i):]
  for j in range(len(str_a)):
    str_b = str_a[:len(str_a) - j]
    tmp_mess = str_b.replace('A','').replace('C','').replace('G','').replace('T', '')
    if (tmp_mess == ''):
      if (ans <= len(str_b)):
        ans = len(str_b)
print(ans)

Submission status: Accepted

Solution code:
import sys

arg = input()
scavenger=''
warehouse=[]
longest=0
i=0

for tmp in arg[0:]:
  if tmp=='A' or tmp=='T' or tmp=='C' or tmp=='G':
    scavenger=scavenger+tmp
  else:
    warehouse.append(scavenger)
    scavenger=''

warehouse.append(scavenger)

for tmp in warehouse[0:]:
  if len(tmp)>longest:
    longest=len(tmp)

print(longest)

Submission status: Accepted

Solution code:
S = str(input())
max = 0
for i in range(len(S)):
    k = 0
    if not(S[i] in {'A','T','G','C'}):
        continue
    k = 1
    for j in range(i+1,len(S)):
       if S[j] in {'A','T','G','C'}:
           k+=1
       else:
           break

    if k > max:
        max = k

print(max)

Submission status: Accepted

Solution code:
data=[]
for i in input():
  data.append(i)
  
N=0
maxa=0

for j in range(len(data)):
  if data[j]=="A" or data[j]=="C" or data[j]=="G" or data[j]=="T":
    N=N+1
    if N>maxa:
      maxa=N
  else:
    N=0

print(maxa)

Submission status: Accepted

Solution code:
a=input()+"o"
b=["A","T","C","G"]
ans=0
c=0
for i in range(len(a)):
  if a[i] in b:
    c+=1
  else:
    if c>ans:
      ans=c
    c=0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mx, h = [], []
for ch in str(input()):
    if ch in ['A', 'C', 'G', 'T']:
        h += ch
    else:
        mx += [h]
        h = []
else:
    mx += [h]
    print(max([len(l) for l in mx]))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

acgt_set = {'A', 'C', 'G', 'T'}
length = []

count = 0
for i, s in enumerate(S):
    if s in acgt_set:
        count += 1
        if i == len(S) - 1:
            length.append(count)
    else:
        length.append(count)
        count = 0

print(max(length))

Submission status: Accepted

Solution code:
s = input()
maxnum = 0
c = 0
for i in s:
  if i in "ACGT":
    c += 1
  else:
    maxnum = max(maxnum, c)
    c=0
print(max(maxnum,c))

Submission status: Accepted

Solution code:
instr = input()
tmp = 0
ma = 0
for c in instr:
    if c == 'A' or c == 'C' or c == 'G' or c == 'T':
        tmp += 1
        ma = max(ma, tmp)
    else:
        tmp = 0

print(ma)

Submission status: Accepted

Solution code:
S = input()
cnt = 0
maxcnt = 0
for s in S:
    if s in 'ATGC':
        cnt += 1
    else:
        cnt = 0
    maxcnt = max(maxcnt, cnt)

print(maxcnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=str(input())
longest_len = 0
temp_len = 0

for i in range(0,len(s)):
    if (s[i] == "A")|(s[i] == "T")|(s[i] == "C")|(s[i] == "G"):
        temp_len += 1
    else:
        temp_len = 0
        
    if temp_len>longest_len:
        longest_len = temp_len
        
print(longest_len)

Submission status: Accepted

Solution code:
sentence = input()
maximum = 0
num_tmp = 0
for i in range(len(sentence)):
  if sentence[i] in ['A','G','C','T']:
    num_tmp += 1
    if num_tmp == maximum + 1:
      maximum += 1
  else:
    num_tmp = 0
print(maximum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

print(len(max(re.split('[^ACGT]',input()), key=len)))

Submission status: Accepted

Solution code:
string=input()
acgt=["A","C","G","T"]
max=0
num=0
for i in range(len(string)):
    if string[i] in acgt:
        num+=1
        if max<num:
            max=num
    else:
        num=0
print(max)

Submission status: Accepted

Solution code:
def check(c):
    if c == 'A' or c == 'C' or c == 'G' or c == 'T':
        return True
    return False
s = input()
dem  = 0
demmax = 0
for i in range(len(s)):
    if check(s[i]):
        dem+=1
        if dem > demmax: demmax = dem
    else: dem = 0
print (demmax)

Submission status: Accepted

Solution code:
S = input()
ACGT = ['A', 'C', 'G', 'T']
ans = []
if len(S) == 1:
    if S in ACGT:
        print(1)
    else:
        print(0)
else:
    for i in range(len(S)):
        j = 0
        while i + j < len(S):
            if S[i + j] in ACGT:
                j += 1
            else:
                ans.append(S[i : i + j])
                break
        if i + j == len(S):
            ans.append(S[i : len(S)])
    
    print(max([len(x) for x in ans]))

Submission status: Accepted

Solution code:
s = input()

ans = 0
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        flag = True
        for t in s[i:j]:
            if t != 'A' and t != 'C' and t != 'G' and t != 'T':
                flag = False
                break
        if flag:
            ans = max(ans, len(s[i:j]))

print(ans)

Submission status: Accepted

Solution code:
S = str(input())
listS = list(S)

count = 0
max = 0

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

print(max)

Submission status: Accepted

Solution code:
S = input()
smax = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        contFlg = True
        for k in S[i:j + 1]:
            if 'ACGT'.count(k) != 1:
                contFlg = False
                break
        if contFlg:
            smax = max(smax, len(S[i:j + 1]))

print(smax)

Submission status: Accepted

Solution code:
input=input()
count=0
max=0
for c in input:
    if c is 'A' or c is 'C' or c is 'G' or c is 'T':
        count+=1
    else:
        if max < count:
            max = count
        count=0
if max < count:
    max = count
print (max)

Submission status: Accepted

Solution code:
S = input()
longest_acgt = 0

def is_acgt(string):
    a_count = string.count("A")
    c_count = string.count("C")
    g_count = string.count("G")
    t_count = string.count("T")
    acgt_count = a_count + c_count + g_count + t_count
    string_count = len(string)
    if acgt_count == string_count:
        return True
    else:
        return False

for i in range(0, 11):
    # print(str(i) + "回目")

    
    for j in range(i + 1, 11):
        # print(str(i) + " " + str(j))
        # print(S[i:j])
        result = is_acgt(S[i:j])
        if result and len(S[i:j]) > longest_acgt:
            longest_acgt = len(S[i:j])
            pass
print(longest_acgt)

Submission status: Accepted

Solution code:
import re
s = input()
ssp = re.split('[BDEFHIJKLMNOPQRSUVWXYZ]',s)
maxlen = 0
for i in ssp:
	if maxlen < len(i):
		maxlen = len(i)
print(maxlen)

Submission status: Accepted

Solution code:
s=input()
ans=0
ans_list=[]
n=len(s)


for i in range(0,n):
    if s[i] not in {'A','T','C','G',' '}:
        ans_list.append(ans)
        ans=0
#        print(str(ans)+'!')
    else:
        ans+=1
        if i == n-1:
           ans_list.append(ans) 
 #       print(str(ans)+'z')

#print(ans_list)
if max(ans_list)==0:
    print(0)
else:
    print(max(ans_list))

Submission status: Accepted

Solution code:
T = str(input())
counter = 0

for index1, rep1 in enumerate(T):
    if rep1 in "ATGC":
        temp_counter =0
        
        for rep2 in T[index1:]:
            if rep2 in "ATGC":
                temp_counter+=1
            else:
                break

        if temp_counter > counter:
            counter = temp_counter

print(counter)

Submission status: Accepted

Solution code:
# coding: utf-8
str_S = raw_input()

list_S = list(str_S)
list = list(str_S)

list_number = []

while list != []:
    number = 0
    for char in list:
        if char == 'A' or char == 'C' or char == 'G' or char == 'T':
            number += 1
        else:
            break
    list_number.append(number)

    for n in range(number + 1):
        if list != []:
            list.pop(0)

print max(list_number)

Submission status: Accepted

Solution code:
s = list(input())

longest = 0
current = 0
for c in s:
	if c in set("ATCG"):
		current += 1
	else:
		longest = max([current, longest])
		current = 0

print(max([current, longest]))

Submission status: Accepted

Solution code:
hoge=input()
ans=0
for i in range(len(hoge)):
  for j in range(len(hoge)):
    huga=hoge[i:1+j]
    if(len(huga)==huga.count("A")+huga.count("C")+huga.count("T")+huga.count("G")):
      ans=max(ans,len(huga))

print(ans)

Submission status: Accepted

Solution code:
S=input()
SS=S+"X"
ACGT=["A","C","G","T"]
m=0
for i in range(len(S)):
  j=0
  while SS[i+j] in ACGT:
    j+=1   
  m=max(m,j)
print(m)

Submission status: Accepted

Solution code:
S = input()
maxlength = 0
length = 0
for i in S:
  if i in 'ATGC':
    length += 1
  else:
    length =0
  maxlength = max(maxlength, length)
print (maxlength)

Submission status: Accepted

Solution code:
acgt = 'ACGT'
hiscore, score = 0, 0
for char in input():
  if char in acgt:
    score += 1
  else:
    hiscore = max(hiscore, score)
    score = 0

hiscore = max(hiscore, score)
print(hiscore)

Submission status: Accepted

Solution code:
s = input()

max_count = 0
count = 0

for i in s:
    if i not in ['A', 'C', 'G', 'T']:
        count = 0
        continue
    count += 1
    max_count = max(max_count, count)

print(max_count)

Submission status: Accepted

Solution code:
S = input()
length = 0
maxlen = 0
for c in S:
    if c in "ACGT":
        length += 1
    else:
        length = 0
    maxlen = max(maxlen, length)
print(maxlen)

Submission status: Accepted

Solution code:
s = input()


def length(s, i, j):
    for c in s[i:j + 1]:
        if c not in 'ACGT':
            return 0
    return len(s[i:j + 1])


def find(s):
    candidate = 0
    for i in range(len(s)):
        for j in range(len(s)):
            candidate = max(candidate, length(s, i, j))

    return candidate


print(find(s))

Submission status: Accepted

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

#入力
s = raw_input()

l = list(s)

count = 0
cl = []

for x in l:
    if x == "A" or x == "C" or x =="G" or x == "T":
        count += 1
    else:
        cl.append(count)
        count = 0
cl.append(count)

#print(cl)
print(max(cl))

Submission status: Accepted

Solution code:
s = input()
max_count = 0
count = 0
acgt = ['A', 'C', 'G', 'T']
for i, c in enumerate(s) :
    if c in acgt :
        count += 1
        if i == len(s) - 1 and max_count < count :
            max_count = count
    else :
        if count != 0 and max_count < count :
            max_count = count
        count = 0
print(max_count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(S: str):
    res = 0
    ACGT = {"A","C","G","T"}
    for i in range(len(S)):
        sub = 0
        for l in range(len(S) - i):
            if S[i + l] in ACGT:
                sub+=1
            else:
                break
        res = max(res,sub)
    print(res)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

inatcg = False
longest = 0
cur = 0
for c in s:
    if c in {'A', 'T', 'C', 'G'}:
        inatcg = True
        cur += 1
    else:
        if inatcg:
            longest = max(longest, cur)
            cur = 0
            inatcg = False

print(max(cur,longest))

Submission status: Accepted

Solution code:
S = input()

str_map = []
for c in S :
    if (c in ['A','C','G','T']) :
        str_map.append('o')
    else :
        str_map.append('x')

print(len(max(''.join(str_map).split('x'))))

Submission status: Accepted

Solution code:
s = input()
import re
sarr = re.split('[^ACTG]', s)
sarr = sorted(sarr, key=lambda x: len(x))
print(len(sarr[-1]))

Submission status: Accepted

Solution code:
st = str(input())

ans = 0
tmp = 0
for i in range(len(st)):
    if st[i] == 'A' or st[i] == 'T' or st[i] == 'G' or st[i] == 'C':
        tmp += 1
    else:
        if ans < tmp:
            ans = tmp
        tmp = 0

if ans < tmp:
    ans = tmp
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
count = 0


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

Submission status: Accepted

Solution code:
S = str(input()) + 'X'
l = len(S)
x = 0
list = []
for i in range(l):
	if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C' :
		x = x + 1
	else:
		list.append(x)
		x = 0
print(max(list))

Submission status: Accepted

Solution code:
s = input()
ans = 0

for i in range(len(s)):
    for j in range(len(s) - i):
        t = s[i:-j] if j != 0 else s[i:]
        c = 0
        for k in t:
            if k == 'A' or k == 'T' or k == 'C' or k == 'G':
                c += 1
        if c == len(t):
            ans = max(ans, len(s) - i - j)
            #print(len(s) - i - j,i,j,t)
print(ans)

Submission status: Accepted

Solution code:
import re
result = re.findall('[ATCG]+',input(),re.S)
if len(result)>0:
  print(max(list(map(len,result))))
else:
  print(0)

Submission status: Accepted

Solution code:
S = input()
S1 = len(S)
S3 = 0
S4 = 0
while S1 != 0:
    S2 = S[0:1]
    S1 = S1 - 1
    S = S[1:]
    if S2 == "A" or S2 == "C" or S2 == "G" or S2 == "T":
        S3 = S3 + 1
    else:
        if S3 > S4:
            S4 = S3
            S3 = 0
if S3 > S4:
    S4 = S3
    S3 = 0
print(str(S4))

Submission status: Accepted

Solution code:
S = list(input())

num = 0
num_list = [0]
for i in S:
    if i == "A" or i == "T" or i == "G" or i == "C":
        num += 1
        num_list.append(num)
    else:
        num_list.append(num)
        num = 0
print(max(num_list))

Submission status: Accepted

Solution code:

s = ''.join([i if i in 'ACGT' else '-' for i in input()])
s = [[i, len(i)] for i in s.split('-')]

_, maxi = max(s, key=lambda x:x[1])
print(maxi)

Submission status: Accepted

Solution code:
a=''.join([i if i in ['A', 'C', 'G', 'T'] else ' ' for i in input()])
print(len(max(a.split() + [''], key=len)))

Submission status: Accepted

Solution code:
import sys

S = input()
acgt = 'ACGT'
ans = 0

for i in range(len(S)):
    tmp = 0
    for j in range(i, len(S)):
        if S[j] in acgt:
            tmp += 1
        else:
            break
    if tmp > ans:
        ans = tmp

print(ans)

Submission status: Accepted

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

for x in S:
    if x in 'ACGT':
        number += 1
    else:
        number = 0
    answer = max(number,answer)

print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

a = input()

l = ["A","T","G","C"]
count  = 0
max = 0
t = 0
for i in range(len(a)):
    for j in range(i,len(a)):
        if(a[j] not in l):
            count = 0
            break;
        else:
            count += 1
            if(max < count):
                max = count
    count = 0
print(max)

Submission status: Accepted

Solution code:
#!/usr/bin/python

import re

def main():
    print(max([len(x) for x in re.findall(r'[ACGT]*', str(input()))]))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = input()

best = 0
hoge = 0
for i in x:
  if i == 'A' or i == "T" or i == "C" or i == 'G':
    hoge += 1
    if hoge > best:
      best = hoge
  else:
    hoge = 0
print(best)

Submission status: Accepted

Solution code:
import re


s = input()
f = re.findall(r'([ACGT]*)', s)
ans = 0
for i in f:
    if len(i) > ans:
        ans = len(i)
print(ans)

Submission status: Accepted

Solution code:
genom=input()
maxstr=0
bush=0

for i in range(len(genom)):
    if genom[i]=="A" or genom[i]=="G" or genom[i]=="T" or genom[i]=="C":
        bush = bush+1
        maxstr=max(bush, maxstr)
    else:
        bush=0

print(maxstr)

Submission status: Accepted

Solution code:
S = input()

out = [[]]
for s in S:
    if s in ['A', 'T', 'G', 'C']:
        out[-1].append(s)
    else:
        out.append([])

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

Submission status: Accepted

Solution code:
s=input()
ans=""
tmp=""
for i in s:
    if i not in "ATCG":
        if len(ans)<=len(tmp):
            ans=tmp
        tmp=""
        continue
    tmp+=i
if len(tmp)>=len(ans):
    ans=tmp
print(len(ans))

Submission status: Accepted

Solution code:
S = input()
A = S
for i in range(len(S)):
  if (S[i] in ["A","T","C","G"]) != True:
    A = A.replace(S[i],"0")
  else:
    A = A.replace(S[i],"1")
print(max(A.split("0")).count("1"))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(input())
L = ["A", "T", "G", "C"]
m = 0
c = 0
for w in a:
    if w in L:
        c += 1
    else:
        c = 0
    m = max(m, c)
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

ans = 0
ans_tmp = 0

x = {'A', 'G', 'C', 'T'}

for s in S:
  if s in x:
      ans_tmp += 1
  else:
    ans = max(ans_tmp, ans)
    ans_tmp = 0
ans = max(ans_tmp, ans)

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
s = list(raw_input())
s = [1 if (i == 'A') | (i == 'C') | (i == 'G') | (i == 'T') else 0 for i in s]
s = np.array(s)
count = np.zeros(len(s), dtype=np.int)

if s[0] == 1:
	count[0] = 1
	for i in range(1,len(s)):
		if s[i] == 1:
			count[0] += 1
		else:
			break

for i in range(1,len(s)):
	if (s[i-1] == 0) & (s[i] == 1):
		count[i] = 1
		for j in range(i+1,len(s)):
			if s[j] == 1:
				count[i] += 1
			else:
				break

print max(count)

Submission status: Accepted

Solution code:
S = input()

ans = 0
for i in range(len(S)):
    for j in range(i, len(S) + 1):
        s = set(S[i:j])
        if s <= set(["A", "C", "G", "T"]):
            ans = max(len(S[i:j]), ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

base_list = ["A", "T", "G", "C"]
seq_list = []
seq = ""
for s in S:
  if s in base_list:
    seq += s
  else:
    seq_list.append(seq)
    seq = ""
seq_list.append(seq)
seq_len_list = [len(seq) for seq in seq_list]
print(max(seq_len_list))

Submission status: Accepted

Solution code:
import re
s = input()
agct_substr = re.findall(r'[AGCT]+', s)
print(len(sorted(agct_substr, key=lambda x: len(x), reverse=True)[0]) if len(agct_substr) != 0 else 0)

Submission status: Accepted

Solution code:
s = input()
temp="ATCG"

max_cnt = 0
cnt = 0
for _s in s:
    if _s in temp:
        cnt+=1
        if max_cnt < cnt:
            max_cnt=cnt
    else:
        cnt=0

print(max_cnt)

Submission status: Accepted

Solution code:
base_dict = {"A": "T", "T": "A", "G": "C", "C": "G"}

S = input()

max_count = 0
current_count = 0

i = 0
loop = 0
while i < len(S):
    if S[i] in base_dict:
        current_count += 1
        i += 1
    else:
        if max_count < current_count:
            max_count = current_count
        current_count = 0
        loop += 1
        i = loop

if max_count < current_count:
    max_count = current_count

print(max_count)

Submission status: Accepted

Solution code:
longest=0
l=['A','T','G','C']
s=input()
for i in range(len(s)):
  if s[i] in l:
    start=i
    nowlen=0
    while(s[start] in l):
      if start==len(s)-1:
        nowlen+=1
        break
      else:
        start+=1
        nowlen+=1
    if nowlen>longest:
      longest=nowlen
print(longest)

Submission status: Accepted

Solution code:
S=input()
n=len(S)
i=0
count=0
maxcount=0
while(n>0):
    if(S[i]=='A'or S[i]=='T' or S[i]=='G' or S[i]=='C'):
        count=count+1
        if(maxcount<count):
            maxcount=count
    else:
        if(maxcount<count):
            maxcount=count
        count=0
    n=n-1
    i=i+1
print(maxcount)

Submission status: Accepted

Solution code:
import re
print(max([0]+[len(x) for x in re.findall("[ATGC]+",input())]))

Submission status: Accepted

Solution code:
S=input()
list = [-1]
list2 = []

for i in range(len(S)):
    if S[i] != 'A' and S[i] != 'T' and S[i] != 'G' and S[i] != 'C':
        list.append(i)

list.append(len(S))

i=0
while i<len(list)-1:
    list2.append(list[i+1]-list[i]-1)
    i += 1

for i in range(len(list2)):
    for j in range(i,len(list2)):
        if list2[i]<list2[j]:
            temp = list2[i]
            list2[i] = list2[j]
            list2[j] = temp
            
print(list2[0])

Submission status: Accepted

Solution code:
import re

i = input()
r = 0
match_list = re.findall(r'[ATCG]+', i)

if match_list:
    r = max([len(x) for x in match_list])

print(r)

Submission status: Accepted

Solution code:
input = raw_input()

score = 0
scoped = 0

for i in range(len(input)):
    if input[i] in ['A', 'T', 'G', 'C']:
        scoped += 1
        if score < scoped:
            score = scoped
    else:
        scoped = 0

print score

Submission status: Accepted

Solution code:
strings = list(input())
# strings = ['H', 'A', 'T', 'A', 'G', 'A', 'Y', 'A']
success_strings = ["A","G","T","C"]
"""
1文字目から取得していって、一致するものがあればカウントしていく
一致しなくなったらカウントをやめて、次の文字から探索する
"""

cnt = 0
for i in range(0, len(strings)):
    temp_cnt = 0

    for n in range(i, len(strings)):
        if strings[n] in success_strings:
            temp_cnt += 1
        else:
            break

        if temp_cnt > cnt:
            cnt = temp_cnt

print(cnt)

Submission status: Accepted

Solution code:
S = input()

count = [0 for i in range(len(S))]

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

idx = 0
for i in S:
    if i in atgc:
        count[idx] = 1
    idx += 1

list_ct = []
ct = 0
for i in count:
    if i == 1:
        ct += 1
    else:
        if ct > 0:
            list_ct.append(ct)
            ct = 0

if ct:
    list_ct.append(ct)

if list_ct:
    print(max(list_ct))
else:
    print(0)

Submission status: Accepted

Solution code:
s = list(input())
n=len(s)
c = 0
cmax=0
for i in range(n):
    if s[i] == 'A' or s[i] =='G' or s[i] =='C' or s[i] =='T':
        c = c + 1
        if c > cmax:
            cmax=c
    else:
        c=0
print(cmax)

Submission status: Accepted

Solution code:
import re

S=input()
pat = r'[ATCG]+'
parts = re.findall(pat,S)
if len(parts)==0:
  print(0) 
else:
  print(max([len(part) for part in parts]))

Submission status: Accepted

Solution code:
s = input()
ans = 0
cnt = 0
for c in list(s):
    if c in 'ACGT':
        cnt += 1
    else:
        cnt = 0
    ans = max(cnt, ans)

print(ans)

Submission status: Accepted

Solution code:
S = input().strip()

start = False
i = 0
count = 0
max = 0
while i < len(S) and (len(S) - max > i or start):
    if start:
        if S[i] not in ["A", "C", "G", "T"]:
            start = False
            count = 0
    else:
        if S[i] in ["A", "C", "G", "T"]:
            start = True

    if start:
        count += 1
        if count > max:
            max = count
    i += 1
print(max)

Submission status: Accepted

Solution code:
S = input()
list = ["A","C","T","G"]
n = len(S)
box = []

for i in range(n):
    if S[i] in list:
        box.append(1)
    else:
        box.append(0)
        
box.append(0)

cnt = 0
ans = [0]

for i in range(n):
    if box[i] == 1:
        cnt += 1
        if box[i+1] == 0:
            max = cnt
            ans.append(max)
            cnt = 0
X = sorted(ans)
print(X[-1])

Submission status: Accepted

Solution code:
L = list(input())
count, max_ = 0, 0
for i in L:
  if i == 'A' or i == 'T' or i == 'C' or i == 'G':
    count += 1
  else:
    if count > max_:
      max_ = count
    count = 0
if count > max_:
  max_ = count
print(max_)

Submission status: Accepted

Solution code:
S = input()

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

max_count = 0
count = 0
for i in range(len(S)):
    if S[i] in atgc:
        count+=1
    else:
        max_count = max(max_count,count)
        count = 0
max_count = max(max_count,count)
print(max_count)

Submission status: Accepted

Solution code:
import sys

s = sys.stdin.readline()

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

Submission status: Accepted

Solution code:
import sys

s = sys.stdin.readline()

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

Submission status: Accepted

Solution code:
s = input()
acgt = 'ACGT'

count = 0
max = 0
for char in s:
  if char in acgt:
    count += 1
    if count > max:
      max = count
  else:
    count = 0
print(max)

Submission status: Accepted

Solution code:
S=input()+"a"
buf=0
count=0
for c in S:
  if c=="A" or c=="T"or c=="G"or c=="C":
    count+=1
  elif buf<count:
    buf=count
    count=0
print(buf)

Submission status: Accepted

Solution code:
ACGT=["A","C","G","T"]
s=list(input())
s.append("0")
s.append(" ")
i=0
ans=[0]
length=0
while s[i] != " ":
  if s[i] in ACGT:
    length += 1
    i += 1
  else:
    ans.append(int(length))
    length = 0
    i += 1

print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
acgt = 'ACGT'
ans = []
for i in range(len(s)):
  ans.append(0)
  for j in range(i, len(s)):
    if s[j] in acgt:
      ans[-1] += 1
    else:
      break
print(max(ans))

Submission status: Accepted

Solution code:
S =list(input())

ans = [0]
n = 0

for x in S:
    if x in {'A','T','C','G'}:
        n += 1
    else:
        ans.append(n)
        n = 0

ans.append(n)
        
print(max(ans))

Submission status: Accepted

Solution code:
S = input()
L = len(S)
ACGT = ["A","C","T","G"]
ctr = 0
ctrs = [0]
for l in range(L):
  if S[l] in ACGT:
    ctr += 1
    if l==L-1:
      ctrs.append(ctr)
  else:
    ctrs.append(ctr)
    ctr = 0
 
print(max(ctrs))

Submission status: Accepted

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

ans=0
for i in range(len(S)):
  tmp=i
  while S[tmp] in C:
    tmp+=1
    if tmp>=len(S):
      break
  ans=max(ans,tmp-i)
print(ans)

Submission status: Accepted

Solution code:
T = list(map(str,input()))

count = 0
flag1 = 0
list_count = []
for i in T:
    if i == 'A' or i == 'T' or i == 'G' or i == 'C':
        flag1 = 1
        count = count +1
    elif flag1 ==1:
        list_count.append(count)
        flag = 0
        count = 0
list_count.append(count)
print(max(list_count))

Submission status: Accepted

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

      

      

print(ans)

Submission status: Accepted

Solution code:
S = list(input())
max_len = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        bubun = S[i:j+1]
        is_acgt = [s in ("T","A","G","C") for s in bubun]
        if all(is_acgt) and len(bubun)>max_len:
            max_len = len(bubun)
print(max_len)

Submission status: Accepted

Solution code:
s = input()

pattern = "ACGT"

max_cnt = 0
cnt = 0
for part in s:
    if part in pattern:
        cnt += 1
        max_cnt = max(cnt, max_cnt)
    else:
        cnt = 0

print(max_cnt)

Submission status: Accepted

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

def main():
    S = input()
    i = 0
    max_length = 0
    for c in S:
        if c in ['A', 'T', 'G', 'C']:
            i += 1
        else:
            if max_length < i:
                max_length = i
            i = 0
    if max_length < i:
        max_length = i
    print(max_length)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

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