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:
S = input()
ans = []
for n in range(len(S)):
    counter = 0
    for i in range(n,len(S)):
        if (S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] =='T'):
            counter+=1
        else:
            break
    ans.append(counter)
print(max(ans))

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

def pne(n):
    print(n,end='')

rem = pow(10,9)+7

#n = ip()                                     #入力整数1つ
#x,y= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
b = ["A","C","T","G"]
s = [0]
c = 0
for i in range(len(a)):
    if a[i] in b:
        c+=1
    else:
        s.append(c)
        c=0
s.append(c)
print(max(s))

Submission status: Accepted

Solution code:
S = list(raw_input())

mx_cnt = 0
cnt=0

for c in S:
#    print c,cnt,mx_cnt
    if (c == 'A') or (c == 'T') or (c == 'G') or (c == 'C') :
        cnt += 1
#        print c,cnt,mx_cnt,"CTAG"
    else:
#        print c,cnt,mx_cnt,"not CTAG"
        if cnt > mx_cnt:
            mx_cnt = cnt
#            print c,cnt,mx_cnt,"update"
        cnt = 0

if cnt > mx_cnt:
    mx_cnt = cnt

print mx_cnt

Submission status: Accepted

Solution code:
S = input()

acgt = set(['A', 'C', 'G', 'T'])

max_count = 0
count = 0
for s in S:
    if s in acgt:
        count += 1
    else:
        count = 0
    if max_count < count:
        max_count = count

print(max_count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
moji = input()

cnt = 0
li = [0]

last = 1000

for i in range(len(moji)):
    if moji[i] == "A" or moji[i] == "G" or moji[i] == "C" or moji[i] == "T":
        cnt += 1
        last = i
        if i == len(moji)-1:
            li.append(cnt)
    elif last == i-1:
        li.append(cnt)
        cnt = 0

print(max(li))

Submission status: Accepted

Solution code:
S=input()
B=[]
ACGT=['A','C','G','T']
for s in S:
    if s in ACGT: B.append(True)
    else: B.append(False)
B.append(False)
ans=0
for start in range(len(B)):
    if not B[start]: continue
    count=0
    for end in range(start,len(B)):
        if not B[end]:
            ans=max(ans,count)
            break
        count+=1
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

print(str(count))

Submission status: Accepted

Solution code:
s = input()
pattern = "[A|C|G|T]+"

import re

result = [len(r) for r in re.findall(pattern, s)]
if len(result) == 0:
    print(0)
else:
    print(max(result))

Submission status: Accepted

Solution code:
test = input()

ans = 0

for i in range(len(test)+1):
    bubun = test[i:]
    if set(list(bubun)) <= {'A','C','G','T'}:
        ans = max(ans,len(bubun))

for i in range(len(test)+1):
    for j in range(len(test)+1):
        bubun = test[i:-j+1]
        if set(list(bubun)) <= {'A','C','G','T'}:
            ans = max(ans,len(bubun))



print(ans)

Submission status: Accepted

Solution code:
def B():
    S = input()
    helyx_str = 'ATGC'
    cnt = 0
    max_cnt = 0
    for a in S:
        h = helyx_str.find(a) 
        if h != -1:
            cnt += 1
            if max_cnt < cnt:
               max_cnt = cnt
        else:
            if max_cnt < cnt:
               max_cnt = cnt
            cnt = 0

    print(max_cnt)

if __name__ == '__main__':
    B()

Submission status: Accepted

Solution code:
import sys
import io
import math
import re

datalist = input().split()
datalist_a = list(datalist[0])

flag = 0
flag_max = 0
for data in datalist_a:
    if data == 'A' or data == 'T' or data == 'C' or data == 'G':
        flag += 1
    else:
        flag = 0
    if flag > flag_max:
        flag_max = flag
print(flag_max)

Submission status: Accepted

Solution code:
S = input()
max_len = 0

def f(S):
    for s in S:
        if s not in ('A', 'G', 'C', 'T'):
            return False
    return True

for i in range(len(S)+1):
    for j in range(i+1, len(S)+1):
        sbstr = S[i:j]
        if f(sbstr):
            if(max_len <= j-i):
                max_len = j-i
print(max_len)

Submission status: Accepted

Solution code:
s = input()

max_score = 0
score = 0
for i in range(len(s)):
  if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
    score += 1
    if max_score <= score:
      max_score = score
  else:
    if max_score <= score:
      max_score = score
    score = 0
  
 
      
print(max_score)

Submission status: Accepted

Solution code:
A = list(input())
c = 0 #見分け
d = 0 #temp
m = 0 #max
i = 0
while i<len(A):
    if c == 0:
            if A[i] =="A" or A[i] == "C" or A[i] == "G" or A[i] == "T":
                c = 1
                d = 1
                #print(i,c)
    elif c == 1 and A[i] =="A" or A[i] == "C" or A[i] == "G" or A[i] == "T":
        d +=1
    elif c == 1:
        m = max(m,d)
        d = 0
    i += 1
m = max(m,d)
print(m)

Submission status: Accepted

Solution code:
s=input()
ls=["A",'C','G','T']
ans=0
u=0
i=0
while i < len(s):
  if s[i] in ls:
    cnt=1
    i+=1
    while i<len(s) and s[i] in ls:
      i+=1
      cnt+=1
    ans=max(cnt,ans)
  i+=1
print(ans)

Submission status: Accepted

Solution code:


total = 0
temp = 0
S = input()

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

if temp > total:
    total = temp

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
list_original=input()
box=list(list_original)
MAX = 0
count = 0
flag = 0
for figure in box:
  if figure == 'A' or figure =='T' or figure =='C' or figure == 'G':
    flag = 1
  else:
    flag = 0
    count = 0
  if flag == 1:
    count += 1
  if count > MAX:
    MAX = count
print(MAX)

Submission status: Accepted

Solution code:
str=input()
char_list = list(str)
N=len(char_list)

tmp=0
max=0
for i in range(N):
    if char_list[i] in ['A' , 'T' , 'G' , 'C']:
        tmp+=1
        if tmp>max:
            max=tmp
    else: tmp=0

print(max)

Submission status: Accepted

Solution code:
def solve(b):
    u = []
    lenu = []
    p = ''
    for i in range(len(b)):
        if (b[i]=='A')or(b[i]=='T')or(b[i]=='G')or(b[i]=='C'):
            p += b[i]
        else:
            u.append(p)
            lenu.append(len(p))
            p=p.replace(p,'')
    u.append(p)
    lenu.append(len(p))
    
    
    
    # print(u,lenu)

    print(max(lenu))


 
 
def main():
    b = input()
    solve(b)
 
 
if __name__ == '__main__':
    main()

Submission status: Accepted

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

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

S = raw_input()
cnt = ans = 0
for c in S:
    if not c in 'ATCG':
        ans = max(cnt, ans)
        cnt = 0
    else:
        cnt += 1
print max(ans, cnt)

Submission status: Accepted

Solution code:
n=input()
l=["A","T","C","G"]
res=0
cnt=0

for i in range(len(n)):
  if n[i] in l:
    cnt+=1
    if cnt>res:
      res=cnt
  else:
    cnt=0
    if cnt>res:
      res=cnt
      
print(res)

Submission status: Accepted

Solution code:
s = input()
m = 0
c = 0
S = {"A", "C", "G", "T"}
for i in range(len(s)):
    if s[i] in S:
        c += 1
    else:
        if c != 0:
            if c > m:
                m = c
            c = 0

if c > m:
    m = c

print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

acgt = 'ACGT'

max_len = 0
for i in range(len(s)):
    j = 0
    while True:
        if i + j >= len(s) or s[i + j] not in acgt:
            if max_len < j:
                max_len = j
            break
        j += 1

print(max_len)

Submission status: Accepted

Solution code:
import re
cstr = input()
result = re.findall("[ACGT]+", cstr)
nums = [len(s) for s in result]
if not nums:
    nums = [0]
print(max(nums))

Submission status: Accepted

Solution code:

s = input()

max_acgt = ''
candidate = ''
for bs in s:
    if 'A' == bs or 'T' == bs or 'G' == bs or 'C' == bs:
        candidate += bs
    else:
        if len(max_acgt) < len(candidate):
            max_acgt = candidate
            candidate = ''
else:
    if len(max_acgt) < len(candidate):
            max_acgt = candidate
    print(len(max_acgt))

Submission status: Accepted

Solution code:
S=list(input())
li = ['A','T','G','C']
ans=0
leng=0
for i in range(len(S)):
    if S[i] in li:
        leng+=1
    else:
        leng=0
    if leng>ans:
        ans=leng
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
l = [0] * 5
ind = 0
f = True

for i in range(len(S)):
    if (S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T') and f:
        l[ind] += 1
    elif (S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T') and f == False:
        l[ind] += 1
    else:
        f = False
        ind += 1
print(max(l))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for i in range(n):
    for j in range(i, n + 1):
        flag = 1
        for k in s[i:j]:
            if k not in ["A", "C", "G", "T"]:
                flag = 0
                break
        if flag:
            ans = max(ans, len(s[i:j]))
print(ans)

Submission status: Accepted

Solution code:
S = input()
t = []
u = []
for i in range(len(S)):
    if S[i] in 'AGTC':
        u.append(S[i])
    else:
        w = u.copy()
        t.append(w)
        u = []
t.append(u)
v = [len(i) for i in t]
print(max(v))

Submission status: Accepted

Solution code:
s = input()
count = 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":
        count += 1
    else:
        ans = max(count,ans)
        count = 0

ans = max(count,ans)
count = 0

print(ans)

Submission status: Accepted

Solution code:
S=list(input())
max=0
for i in range(len(S)):
  leng=0
  if S[i]=="A" or S[i]=="G" or S[i]=="C" or S[i]=="T":
    leng+=1
    for j in range(i+1,len(S)):
      if S[j]=="A" or S[j]=="G" or S[j]=="C" or S[j]=="T":
        leng+=1
      else:
        break
  if max<leng:
    max=leng
print(max)

Submission status: Accepted

Solution code:
S=input()
n=0
for i in range(len(S)):
    for j in range(i, len(S)+1):
        s=S[i:j]
        if len([c for c in s if c in "ACGT"]) == len(s):
            n=max(n, len(s))
print(n)

Submission status: Accepted

Solution code:
s = input()

max_len = 0
len = 0
for e in s:
    if e == 'A' or e == 'C' or e == 'G' or e == 'T':
        len += 1
    else:
        if max_len < len:
            max_len = len
        len = 0

if max_len < len:
    max_len = len
print(max_len)

Submission status: Accepted

Solution code:
import re
S = input()
ans = ['']
for i in range(len(S)):
    for k in range(i, len(S)):
        ans.append(S[i:k+1])
ans = sorted(ans,key=lambda x:len(x),reverse=True)
for i in ans:
    if len(re.sub("[ACGTacgt]", "", i)) == 0:
        print(len(i))
        break

Submission status: Accepted

Solution code:
def main():
    S = input()
    S_list = [str(c) for c in S]

    max_count = 0
    for i, c in enumerate(S_list):
        counter = 0
        for j in range(i, len(S_list)):
            if S_list[j] == "A" or S_list[j] == "C" or S_list[j] == "G" or S_list[j] == "T":
                counter += 1
            else:
                break
        if max_count < counter:
            max_count = counter

    print(max_count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
cdt = []
before_invalid = False


def is_acgt(char):
    if char == 'A':
        return True
    if char == 'C':
        return True
    if char == 'G':
        return True
    if char == 'T':
        return True
    return False


for i in S:
    if is_acgt(i):
        if not before_invalid:
            cdt.append(1)
        else:
            current = len(cdt) - 1
            cdt[current] = cdt[current] + 1
        before_invalid = True
    else:
        before_invalid = False

ans = 0
if len(cdt) > 0:
    ans = max(cdt)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(len(S)):
    for q in range(i,len(S)+1):
        if {"A","C","G","T"} >= set(S[i:q]):
            ans = max(ans,len(S[i:q]))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

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

print(max(list))

Submission status: Accepted

Solution code:
wlist = list(input())
wlength = 0
tmp = 0
for w in wlist:
    if not w in ["A","T","G","C"]:
        tmp = 0
        continue

    else:
        tmp += 1
        if tmp >= wlength:
            wlength = tmp
print(wlength)

Submission status: Accepted

Solution code:
S = input()
acgt = ["A", "C", "G", "T"]
ans = 0

for i in range(len(S)):
    if S[i] in acgt:
        j = i
        while True:
            if j < len(S) - 1 and S[j + 1] in acgt:
                j += 1
            else:
                break
        ans = max(j - i + 1, ans)

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

s=input()
isContinue=0
part=[0]

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

print(max(part))

Submission status: Accepted

Solution code:
s=str(input())
s=list(s)
l=[]

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

count=0
a=[]
for i in range(len(s)):
    if (l[i]!=0):
        #if l[i]==1:
        count+=1
    a.append(count)
    if l[i]==0:
        count=0
#    count=0
print(max(a))
"""     
        print()
    while l[i]==1:
        count+=1
        print(count)
 """    
    #if l[i]==0:

Submission status: Accepted

Solution code:
import re
S = input()

s = re.sub(r"[ACGT]", "#", S)
s = re.sub(r"[^#]", "X", s)

l = s.split("X")

l_len = [len(l_i) for l_i in l]
print(max(l_len))

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    S = input()

    ans, cnt = 0, 0
    for s in S:
        if s in {'A', 'C', 'G', 'T'}:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    print(max(ans, cnt))

input = lambda: stdin.readline().rstrip()
main()

Submission status: Accepted

Solution code:

AGCT = "AGCT"

S = input()

longest = ""
tmpCounter = 0
for i in range(len(S)):
	# print(i, tmpCounter, longest)
	if S[i] in AGCT:
		if tmpCounter >= len(longest):
			longest = S[i - tmpCounter: i  + 1]
		tmpCounter += 1
	else:
		if tmpCounter > len(longest):
			longest = S[i - tmpCounter: i]
		tmpCounter = 0


print(len(longest))

Submission status: Accepted

Solution code:
s = input()
s = s.translate(str.maketrans({"T":"A", "G":"A", "C":"A"}))
for i in [10,9,8,7,6,5,4,3,2,1,0]:
  if "A"*i in s:
    print(i)
    break

Submission status: Accepted

Solution code:
S = str(input())
ans = count = 0
for i in range(len(S)):
    for j in range(i,len(S),1):
        if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
            count += 1
        else:
            break
    if count > ans:
        ans = count
    count = 0
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
S=(stdin.readline().rstrip())
ans=0
for i in range(0,len(list(S))+1):
    for j in range(0,len(list(S))+1):
        if set(list(S)[i:j]) <= {"A","T","C","G"}:
            if len(list(S)[i:j]) > ans:
                ans=len(list(S)[i:j])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

ma = 0
for i in range(len(s)):
    for j in range(1,len(s)-i+1):
        tmp = s[i:i+j]
        # print(i,j,tmp)
        is_good = True
        for c in tmp:
            if c not in "AGCT":
                is_good = False
                break
        if is_good:
            if (len(tmp)) > ma :
                ma = len(tmp)

print(ma)

Submission status: Accepted

Solution code:
s = input()
l = []
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        l.append(1)
    else:
        l.append(0)
tmp = 0
counter = []
for i in range(len(l)):
    if l[i] == 0:
        counter.append(tmp)
        tmp = 0
    else:
        if i == len(l) - 1:
            tmp += 1
            counter.append(tmp)
        else:
            tmp += 1

print(max(counter))

Submission status: Accepted

Solution code:
s = str(input())
S = []
for c in s:
    S.append(c)
    
count = 0
maxcount = 0
for i in range(len(S)):
    if (S[i] == "A")or(S[i] == "T")or(S[i] == "G")or(S[i] == "C"):
        count += 1
    else:
        count = 0
    if (maxcount < count):
        maxcount = count



print(maxcount)

Submission status: Accepted

Solution code:
s= input()

c=0
max= 0
for i in s:
  if (i == 'A') or (i == 'T') or (i == 'G') or (i == 'C'):
    c+= 1
  else:
    if(c> max):
      max= c
    c=0

if c>max:
  print(c)
else:
  print(max)

Submission status: Accepted

Solution code:
import re
import numpy as np
s = input()
atgcs = re.split(r'[^ATGC]', s)
lens = np.array(list(map(len, atgcs))).max()
print(lens)

Submission status: Accepted

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

# In[21]:


S=input()
t=list()
ct=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='T' or S[i]=='G':
        i+=1
        ct+=1
    else:
        t.append(ct)
        ct=0
        i+=1
t.append(ct)
print(max(t))


# In[ ]:

Submission status: Accepted

Solution code:
S = input()

max_length = 0

for i in range(0, len(S)):
    for j in range(i + 1, len(S) + 1):
        sub = S[i:j]
        #print(sub.replace('ACGT', ''))
        if len(sub.translate(str.maketrans({'A':'','C':'','G':'','T':''}))) == 0:
            max_length = max(len(sub), max_length)


print(max_length)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=raw_input()
C="ACGT"

len_S=len(S)

ans=float("-inf")
for i in range(len_S+1):
	for j in range(i,len_S+1):
		s=S[i:j]
		for x in s:
			if x not in C:
				break
		else:
			ans=max(ans,len(s))

print ans

Submission status: Accepted

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


print(max(ansarr))

Submission status: Accepted

Solution code:
import re
S = input()

splited = re.split('[^ATGC]+', S)

max_len = 0
for item in splited:
  if len(item) >= max_len:
    max_len = len(item)

print(max_len)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
i = input()
print(max(len(s) for s in re.findall(r'[ATGC]*', i)))

Submission status: Accepted

Solution code:
S=str(input())

acgt=False
length=0
maxlen=0
for i in S:
  if acgt:
    if i=="A" or i=="G" or i=="C" or i=="T":
      length += 1
    else:
      maxlen = max(maxlen, length)
      acgt = False
  else:
    if i=="A" or i=="G" or i=="C" or i=="T":
      length = 1
      acgt = True
    else:
      continue
if acgt:
  maxlen = max(maxlen, length)

print(maxlen)

Submission status: Accepted

Solution code:
s=list(str(input()))
l=[]
for i in range(len(s)):
    if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
        l.append(1)
    else:
        l.append(0)
tl=[]
for k in range(len(l)):
    ctr=0
    for i in range(k,len(l)):
        if l[i]==1:
            ctr+=1
        else:
            break
    tl.append(ctr)
print(max(tl))

Submission status: Accepted

Solution code:
import numpy as np

def main():
	S=input()
	array=[]
	pack=['A','T','G','C']
	for i in range(len(S)):
		temp=False
		for j in range(len(pack)):
			if(S[i]==pack[j]):
				temp=True
		if(temp):
			array.append(1)
		else:
			array.append(0)
	
	result=[]
	for i in range(len(array)):
		temp=0
		for j in range(i,len(array)):
			if(array[j]==1):
				temp+=1
			else:
				break
		result.append(temp)
	
	print(max(result))


def inputList():
	a=list(map(int,input().split()))
	return a

def multisort(li,index):
	return sorted(li,key=lambda x: x[index])

if(__name__=='__main__'):
	main()

Submission status: Accepted

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

s  = input()

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

    if max < a:
        max = a

print(max)

Submission status: Accepted

Solution code:
s = input() #文字列

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

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

ans = max(ans, now)
print(ans)

Submission status: Accepted

Solution code:
acgt = ['A','C','G','T']
S = list(input())
cnt = 0
mcnt = 0
for i in S:
    if i in acgt:
        cnt += 1
    else:
        mcnt = max(mcnt, cnt)
        cnt = 0
mcnt = max(mcnt, cnt)
print(mcnt)

Submission status: Accepted

Solution code:
s=list(input().replace('',' ').split())
cnt=0
ans=[0]*len(s)
for i in range(len(s)):
  if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
    cnt+=1
    ans[i]=cnt
  else:
    cnt=0
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

import re

if __name__ == '__main__':

    s = input()

    s = re.sub(r'[^ACGT]+', '_', s)


    maxlen = 0

    for ss in s.split('_'):
        if len(ss) > maxlen:
            maxlen = len(ss)

    print(maxlen)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
l = len(a)
ans = 0
for i in range(l):
	tmp = 0
	for j in range(l-i):
		if a[i+j] != "A" and a[i+j] != "G" and a[i+j] != "C" and a[i+j] != "T":
			break
		tmp += 1
	if ans < tmp:
		ans = tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
s = list(stdin.readline().rstrip())
counts=[]
count=0
for i in s:
    if i in ['A','G','C','T']:
        count+=1
        counts.append(count)
    else:
        count=0
        counts.append(count)
print(max(counts))

Submission status: Accepted

Solution code:
from sys import stdin

S = stdin.readline().rstrip()
countlist = []

count = 0
for s in S:
    if s == "A" or s == "C" or s == "G" or s == "T":
        count += 1
    else:
        countlist.append(count)
        count = 0
countlist.append(count)
print(max(countlist))

Submission status: Accepted

Solution code:
s_list = list(input())
str_list = ['A','C','G','T']
now_max = 0
for i,s in enumerate(s_list):
    if s in str_list:
        l = 1
        for next in s_list[i+1:]:
            if next in str_list:
                l += 1
            else:
                break
        now_max = max(l,now_max)
print(now_max)

Submission status: Accepted

Solution code:
A = input()
a = [str(c) for c in A]
ans = 0
c = 0
for i in a:
	if i == "A" or i =="C" or i == "G" or i =="T":
		c = c + 1
	else:
		if c > ans:
			ans = c
		c = 0
if c > ans:
	ans = c
print(ans)

Submission status: Accepted

Solution code:
char = input()

max_num = 0
max_seq = ''

def include(char):
    for c in char:
        if c not in ['A', 'T', 'G', 'C']:
            return False
    return True

for i in range(len(char)):
    for j in range(i, len(char)):
        sub = char[i:j+1]
        if include(sub):
            if max_num < len(sub):
                max_num = len(sub)
                max_seq = sub

print(max_num)

Submission status: Accepted

Solution code:
s = input()
res = 0
for i in range(len(s)):
  words = s[i:]
  m = 0
  for word in words:
    if word in 'ACGT':
      m += 1
    else:
      break
  res = max(res, m)
print(res)

Submission status: Accepted

Solution code:
S = list(input())
ans = 0
chain = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "G" or S[i] == "T" or S[i] == "C":
        if i == 0:
            chain += 1
        elif S[i-1] == "A" or S[i-1] == "G" or S[i-1] == "T" or S[i-1] == "C":
            chain += 1
        elif not S[i-1] == "A" or not S[i-1] == "G" or not S[i-1] == "T" or not S[i-1] == "C":
            chain = 1
        ans = max(ans, chain)
print(ans)

Submission status: Accepted

Solution code:
#coding: utf-8
import re

s = raw_input()
s = re.split("[^ATGC]", s)
print(max(map(len, s)))

Submission status: Accepted

Solution code:
import re

S=input()

ss = re.sub('[^A, T, C, G]', ',', S)
sss = ss.split(',')
ans = ""
for i in sss:
  if len(ans) < len(i):
    ans = i
print(len(ans))

Submission status: Accepted

Solution code:
s = input()
acgt = 'ACGT'
ans = 0
tmp = 0

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
a = 0
for c in S:
  if c == 'A' or c == 'T' or c == 'C' or c == 'G':
    a += 1
  else:
    a = 0
  ans = max(ans,a)
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
count = 0
max_long = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "T" or S[i] == "C" or S[i] == "G":
        count += 1
        if max_long < count:
            max_long = count
    else:
        count = 0

print(max_long)

Submission status: Accepted

Solution code:
S = str(input())
cont = 0
ans = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        cont += 1
        if ans < cont:
            ans = cont
    else:
        if ans < cont:
            ans = cont
        cont = 0
print(ans)