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:
count = 0
temp_count = 0
for s in str(input().split()):
    if s == 'A' or s == 'G' or s == 'T' or s == 'C':
        temp_count += 1
        if temp_count > count:
            count = temp_count
    else:
        temp_count = 0
print(count)

Submission status: Accepted

Solution code:
N = list(input())
A = set(list("ACGT"))
ans = [0]
for i in range(len(N)):
    cnt = 0
    for n in N[i:]:
        if n in A:
            cnt += 1
        else:
            break
        ans.append(cnt)
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=str(input())
a=""
for i in s:
    if i in ["A","C","G","T"]:
        a+="1"
    else:
        a+="0"
print(len(max(a.split("0"))))

Submission status: Accepted

Solution code:
# B
s = str(input())
max_len = 0
for i in range(len(s)):
    for j in range(i, len(s)+1):
        a = s[i:j]
        a_l = list(a)
        ACGT = True
        for c in a_l:
            if c == 'A' or c == 'C' or c == 'G' or c == 'T':
                continue
            else:
                ACGT = False
                break
        if ACGT:
            if max_len < len(a):
                max_len = len(a)
print(max_len)

Submission status: Accepted

Solution code:
import sys

def main(inp):
    S=list(next(inp))
    
    tmpans=0
    ans=0
    for i in range(len(S)):
        if(S[i]=='A' or S[i]=='T' or S[i]=='C' or S[i]=='G'):
            tmpans += 1
        else: 
            ans=max(ans,tmpans)
            tmpans=0
            
    return max(ans,tmpans)
      
print(main(sys.stdin))

Submission status: Accepted

Solution code:
s=list(input())
counter=0
makkusu=0

for i in range(len(s)):
  if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
    counter +=1
    if counter > makkusu:
      makkusu = counter
  else:
    counter = 0
    
print(makkusu)

Submission status: Accepted

Solution code:
#coding:utf-8
s = input()
tmp = 0
ans = 0
for i in s:
  if i in ('A','G','C','T'):
    tmp += 1
  elif ans < tmp:
    ans = tmp
    tmp = 0
  else:
    tmp = 0
if ans < tmp:
  ans = tmp

print(ans)

Submission status: Accepted

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

n = 0
m = 0
for c in s:
    if c in ('A', 'C', 'G', 'T'):
        n += 1
    else:
        m = max(n, m)
        n = 0

print(max(n, m))

Submission status: Accepted

Solution code:
S = list(input())
length = 0
for start in range(len(S)):
  for end in range(start, len(S)):
    temp = S[start:end + 1]
    if set(temp) <= {"A", "T", "G", "C"} and length < len(temp):
      length = len(temp)
print(length)

Submission status: Accepted

Solution code:
# coding: utf-8

S = input()

isACGT = [s in "ACGT" for s in S]
cnt = 0
length = [0]

for f in isACGT:
    if f:
        cnt += 1
    else:
        length.append(cnt)
        cnt = 0
length.append(cnt)

print(max(length))

Submission status: Accepted

Solution code:
a = input()

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

ret = 0
cur_ret = 0
for i in a:
    if i in acgt:
        cur_ret+=1
    else:
        cur_ret = 0
    if cur_ret > ret:
        ret = cur_ret
print(ret)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

li = ["A","T","G","C"]
max = 0
ct = 0
s = input()
for ch in s:
    if ch in li:
        ct += 1
        if max < ct:
            max = ct
    else:
        ct = 0
print(max)

Submission status: Accepted

Solution code:
S = raw_input()
res = ''
while S:
  cand = S
  while cand:
    if set(cand).issubset(set('ACGT')) and len(cand) > len(res):
      res = cand
    cand = cand[:-1]
  S = S[1:]
print len(res)

Submission status: Accepted

Solution code:
S = input()
N = len(S)

alp = 'BDEFHIJKLMNOPQRSUVWXYZ'

ans = []
cnt = []

for i in range(0, N):
    for j in range(i, N+1):
        tmp = S[i:j]
        flg = 1
        for a in alp:
            if a in tmp:
                flg = 0
        if flg:
            cnt.append(len(tmp))

print(max(cnt))

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(S)):
    if S[i] in target:
        ans+="1"
    else:
        ans+="0"

ans = ans.split("0")
cnt = 0

for i in range(len(ans)):
    cnt = max(len(ans[i]),cnt)

print(cnt)

Submission status: Accepted

Solution code:
S = input()
s_str = ''

for s in S:
    
    if(s in ('A', 'C', 'G', 'T')):
        s_str += s
    
    else:
        s_str += ' '

if(s_str.split() == []):
    print(0)

else:
    print(len(max(s_str.split(), key = len)))

Submission status: Accepted

Solution code:
# coding: utf-8
s = input()
lenmax = 0
cnt = 0
data = ['A', 'C', 'G', 'T']
for i in range(len(s)):
    if s[i] in data:
        cnt += 1
    else:
        if cnt > lenmax:
            lenmax = cnt
        cnt = 0
print(max(lenmax, cnt))

Submission status: Accepted

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


def solve(S: str):
    tot = 0
    count = 0
    for i, c in enumerate(S):
        if c in "ACGT":
            count += 1
        else:
            tot = max(tot, count)
            count = 0
    tot = max(tot, count)
    print(tot)
    return


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 =list(input())
gene = list(["A","T","G","C"])
count = 0
numl = list()
numl.append(0)
for i in range(0,len(s)):
    if s[i] in gene:
        count += 1
    else:
        numl.append(count)
        count = 0
numl.append(count)
print(max(numl))

Submission status: Accepted

Solution code:
def main():
    s = input()
    res = 0
    for i in range(len(s) + 1):
        for j in range(i + 1, len(s) + 1):
            ss = s[i:j]
            if not all(c in "ACGT" for c in ss):
                continue
            if len(ss) > res:
                res = len(ss)
    print(res)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import exit
# A,B,C = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
S = str(input())
# L = len(S)
cnt = 0
maxs = 0
for s in S:
    if s in ["A","G","C","T"]:
        cnt+=1
    else:
        cnt = 0
    if cnt > maxs:
        maxs = cnt
print(maxs)

Submission status: Accepted

Solution code:
s = input()
anslist = [0]
ans = 0
acgt = ["A", "C", "G", "T"]
for e in s:
  if e in acgt:
    ans += 1
  else:
    anslist.append(ans)
    ans = 0
anslist.append(ans)
print(max(anslist))

Submission status: Accepted

Solution code:
def main():
    S = input()
    ans = 0
    c = 0
    for s in S:
        if s not in ['A', 'T', 'G', 'C']:
            ans = max(ans, c)
            c = 0
            continue
        c += 1
    print(max(ans, c))


main()

Submission status: Accepted

Solution code:
S = [ _ for _ in input()]
ACGT = ["A", "C", "G", "T"]
ans = 0
for i, data in enumerate(S):
    if data not in ACGT:
        continue
    if i >= len(S):
        break

    cnt = 1
    for j in range(i + 1, len(S)):
        if S[j] not in ACGT:
            ans = max(ans, cnt)
            break

        cnt += 1

    ans = max(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
#N,Q =map(int,input().strip().split())
#=int(input().strip())
#=list(map(int,input().strip().split()))
S = input()

#for i in range(0,Q):


subs = []
tmp = []
for s in S:
    if "A" == s or "C" == s or "G"== s or "T" == s:
        tmp.append(s)
    else:
        subs.append(tmp)
        tmp = []

subs.append(tmp)
if len(subs) == 0:
    print("0")
    exit()

rs = sorted(subs,key=lambda x: len(x),reverse=True)
print(len(rs[0]))

Submission status: Accepted

Solution code:
S = input()

items = ['A', 'G', 'C', 'T']
ans = 0
length = 0
for i in range(len(S)):
    if S[i] in items:
        length += 1
    else:
        ans = max(ans, length)
        length = 0
else:
    ans = max(ans, length)

print(ans)

Submission status: Accepted

Solution code:
A = str(input())
S = []
for s in A:
    S.append(s)
ACGT = ["A","C","G","T"]
X = []
cnt = 0
ans = []
for i in range(len(S)):
    if S[i] in ACGT:
        cnt += 1
        continue
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
print(max(ans))

Submission status: Accepted

Solution code:
S = list(str(input()))
agct = {'A', 'C', 'G', 'T'}

ans = 0
tmp_ans = 0
flg = 0
for s in S:
    # contain acgt
    if s in agct:
        if flg == 0:
            flg = 1
        tmp_ans += 1
    else:
        if flg == 1:
            flg = 0
            if ans < tmp_ans:
                ans = tmp_ans
            tmp_ans = 0
else:
    if flg == 1:
        if ans < tmp_ans:
            ans = tmp_ans
        tmp_ans = 0

print(ans)

Submission status: Accepted

Solution code:
a = list(input())
max = 0
n = 0
while len(a) != 0:
  if a[0] == 'A' or a[0] == 'T' or a[0] == 'G' or a[0] == 'C':
    n += 1
    a.pop(0)
  else:
    n = 0
    a.pop(0)
  if n >= max:
    max = n
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
mx=0
a=len(S)
for i in range(0,a):
  for j in range(1,a+1):
    x=S[i:j]
    f=False
    for y in x:
      if y not in 'ACGT':
        f=True
    if not f:
      mx=max(mx,len(x))
print(mx)

Submission status: Accepted

Solution code:
x=input()
m=0
for i in range(len(x)):
    for j in range(i,len(x)):
        #print(x[i])
        if x[j] not in ["A","G","C","T"]:
            #print(j)
            break
        else:
            m=max(m,j-i+1)
print(m)

Submission status: Accepted

Solution code:
str = input()
cnt = 0
max = 0

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

if max < cnt:
   max = cnt
   cnt = 0

print(max)

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


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

def solve(s):
  ret = ""
  for i in range(len(s)):
    for j in range(i+1,len(s)+1):
      if chk(s[i:j]) and len(ret) < len(s[i:j]):
        ret = s[i:j]
  return ret

S = str(input())
print(len(solve(S)))

Submission status: Accepted

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

print(Mlen)

Submission status: Accepted

Solution code:
import re

str=input()

arr = re.split(r'[^AGCT]', str)

m=0
for part in arr:
    m = max(m, len(part))

print (m)

Submission status: Accepted

Solution code:
s=list(input())
count = 0
Max = 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:
        Max = max(Max, count)
        count = 0
print(max(Max, count))

Submission status: Accepted

Solution code:
a=input()
maxvalue=0
for i in range(1,len(a)+1):
    for j in range(0,len(a)+1-i):
        tmp=a[j:j+i]
        flag=True
        for k in range(0,len(tmp)):
            if (not(tmp[k]=='A' or tmp[k]=='T' or tmp[k]=='G' or tmp[k]=='C')):
                flag=False
        if flag==True:
            maxvalue=max(maxvalue,i)
print(maxvalue)

Submission status: Accepted

Solution code:
st = list(input())

cnt = 0
ret = 0
for s in st:
  if s in ['A','C','G','T']:
  	cnt += 1
  else:
    if ret < cnt:
      ret = cnt
    cnt = 0
if ret < cnt:
	ret = cnt

print(ret)

Submission status: Accepted

Solution code:
S=input()
l=int(len(S))
k=0
p=[0]*10
for i in range(l):
    if S[i]=="A" or S[i]=="G" or S[i]=="C" or S[i]=="T" :
        k+=1
        p[i]=k
    else:
        k=0
        p[i]=k
ans=max(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9])
print(ans)

Submission status: Accepted

Solution code:
s = input()
s = s.replace("A","0").replace("T","0").replace("G","0").replace("C","0")
for i in range(len(s)+1,0,-1):
  if "0"*i in s:
    print(i)
    break
if "0" not in s:
  print("0")

Submission status: Accepted

Solution code:
s = input()
acgt = ['A','T','C','G']
streak = 0
mcnt = 0
for i in s: 
    if i in acgt: streak += 1
    else: 
        if streak > mcnt: mcnt = streak
        streak = 0
if streak > mcnt: mcnt = streak
print(mcnt)

Submission status: Accepted

Solution code:
s=input()
l=['A','C','G','T']
ans=[];ct=0
for i in range(len(s)):
  if s[i] in l:
    ct+=1
  else:
    ans.append(ct)
    ct=0
ans.append(ct)
print(max(ans))

Submission status: Accepted

Solution code:
import numpy as np
import sys

S = input()

p = -1
length = 0
for i in range(len(S)):
    if S[i] in ["A","T","G","C"]:

        if i-p > length:
            length = i-p
    else:
        p = i
print(length)

Submission status: Accepted

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

Submission status: Accepted

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


def solve(S: str):
    sl = {'A', 'C', 'G', 'T'}

    T = list(S)
    c = 0
    ans = 0
    for i in range(len(T)):
        if(T[i] in sl):
            c += 1
            continue
        else:
            ans = max(ans,c)
            c = 0
    print(max(ans,c))
    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()
l=0
k=0
c=["A","T","G","C"]
a=0
for i in range(len(s)):
    if s[i] in c:
        k+=1
    else:
        a=max(a,k-l)
        k=i
        l=i
print(max(a,k-l))

Submission status: Accepted

Solution code:
S = input()
SSub = []
maxl = 0
for h in range(len(S)):
  for t in range(1,len(S)-h+1):
    if(h+t >= len(S)):
      SSub = S[h:]
    else:
      SSub = S[h:h+t]
    if len(SSub) == SSub.count("A") + SSub.count("T") + SSub.count("G") + SSub.count("C"): 
      if maxl < len(SSub):
        maxl = len(SSub) 
print(maxl)

Submission status: Accepted

Solution code:
s = input()
letters = ["A","G","C","T"]
counter = 0
record = 0

for letter in s:
    if letter in letters:
        counter += 1
    else:
        record = max(record,counter)
        counter = 0

record = max(record,counter)

print(record)

Submission status: Accepted

Solution code:
s = str(input())
a = 0
b = ["A", "T", "G", "C"]
c = 0
for s_ in s:    
    if s_ in b:
        c += 1
    else:
        a = max(c, a)
        c = 0
a = max(c,a)        
print(a)

Submission status: Accepted

Solution code:
s = list(input())
a = ['A', 'C', 'G', 'T']
ans = 0

for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        f = True
        for ss in s[i:j]:
            if ss not in a:
                f = False

        if f:
            ans = max(ans, len(s[i:j]))

print(ans)

Submission status: Accepted

Solution code:
S = input()

f_s = [s in ["A", "C", "G", "T"] for s in S]

c = 0
max_c = 0
for f in f_s:
    if f:
        c += 1
        max_c = max(max_c, c)
    else:
        c = 0

print(max_c)

Submission status: Accepted

Solution code:
S = input()+'Z'
X = 'ATCG'
res = [0]
count = 0
for i in S:
    if i in X:
        count += 1
    else:
        res.append(count)
        count = 0
print(max(res))

Submission status: Accepted

Solution code:
ss = input()
ans = 0
cnt = 0
for s in ss:
    if s == "A" or s == "T" or s == "C" or s == "G":
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt
        cnt = 0
    
if ans < cnt:
    ans = cnt

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = list(str(input()))
n.append(0)
c = 0
t = [0]

for i in range(len(n)-1):
        if n[i] == "A" or n[i] == "T" or n[i] == "G" or n[i] == "C":
                c += 1
                if n[i+1] == "A" or n[i+1] == "T" or n[i+1] == "G" or n[i+1] == "C":
                        continue
                else:
                        t.append(c)
                        c = 0

print(max(t))

Submission status: Accepted

Solution code:
S = input()

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

length = 0

head = 0

while head < len(S):
    tail = head
    while S[tail] in TARGET:
        tail += 1
        if tail >= len(S):
            break
    length = max(length, tail - head)
    head = tail + 1
print(length)

Submission status: Accepted

Solution code:
S = list(input())

seikai=["A", "C", "G", "T"]
ansList=[]
for i in range(len(S)):
  if S[i] in seikai:
    ansList.append(1)
  else:
    ansList.append(0)

maxans=0
ans=0
for i in range(len(ansList)):
  if ansList[i] ==1:
    ans+=1
    if maxans<ans:
      maxans=ans
  else:
    ans=0
print(maxans)

Submission status: Accepted

Solution code:
n=input()
#n=int(input())
#li=input().split()
#li=list(map(int,input().split()))
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import math
#import numpy as np
ans=0
tmp=0
dict={"A","C","G","T"}
for i in range(len(n)):
    if n[i] in dict:
        tmp+=1
    else:
        if ans<tmp:
            ans=tmp
        tmp=0
if ans<tmp:
    ans=tmp


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().rstrip()

allow = set(('A', 'T', 'G', 'C'))
maximum = 0

for i in range(len(s)):
    for j in range(len(s)-i):
        tmp = s[i:j+i+1]
        count = tmp.count('A') + tmp.count('G') + tmp.count('T') + tmp.count('C')
        if count == len(tmp):
            if maximum < count:
                maximum = count

print(maximum)

Submission status: Accepted

Solution code:
s = input()
ans = 0;ls = ['A','T','G','C'];o = 0
for i in range(len(s)):
    check = False
    for j in range(4):
        if ls[j] == s[i]:check = True
    if check:ans += 1
    else:
        ans = 0
    o = max(ans,o)
print(o)

Submission status: Accepted

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

ans=""
m=""
for i in range(len(a)):
  if b[i]==0:
    continue
  for j in range(i,len(a)):
    if b[j]==0:
      break
    m+=a[j]
  if len(ans)<len(m):
    ans=m
  m=""
  
print(len(ans))

Submission status: Accepted

Solution code:
S = list(input())  # 一文字ずつ格納
ans = 0
tmp = 0
for s in S:
    if s != "A" and s != "T" and s != "G" and s != "C":
        ans = max(ans, tmp)
        tmp = 0
    else:
        tmp += 1

ans = max(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
S = input()
ACGT = ["A", "C", "G", "T"]
max = 0
cnt = 0
for i in S:
    if i in ACGT:
        cnt += 1
    else:
        cnt = 0
    if cnt >= max:
        max = cnt
print(max)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]
    max_count = 0
    for i in range(len(S)):
        for j in range(i, len(S)):
            new_S = S[i:j+1]
            not_agct = False
            for news in new_S:
                if news != "A" and news != "G" and news!="C" and news !="T":
                    not_agct = True
                    break
            if not_agct == False:
                max_count = max(max_count , len(new_S))
    print max_count



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

a = ['A', 'C', 'G', 'T']
count = 0
ans = 0

f = False
for i in S:
  if f:
    if i in a:
      count += 1
      ans = max(count, ans)
    else:
      count = 0
      f = False
  else:
    if i in a:
      count += 1
      ans = max(count, ans)
      f = True

print(ans)

Submission status: Accepted

Solution code:
S = input()
tmp = 0
check = False
for i in range(len(S)):
    for j in range(i, len(S)):
        for k in list(str(S[i:j + 1])):
            if k != "A" and k != "C" and k != "G" and k != "T":
                check = False
                #print(i, j, 100)
                break
            else:
                check = True
        if check:
            if j - i + 1 > tmp:
                #print(i, j)
                tmp = j - i + 1

print(tmp)

Submission status: Accepted

Solution code:
S = input()

result = 0
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        for ti in S[i:j]:
            if ti not in ['A', 'C', 'G', 'T']:
                break
        else:
            result = max(result, len(S[i:j]))
print(result)

Submission status: Accepted

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

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

print(max(cnt, ans))

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


# inputs
S = ""


def set_inputs():
    global S
    S = get_str()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    ans = 0
    tmp = 0
    for c in S:
        if c in "ACGT":
            tmp += 1
            ans = max(ans, tmp)
        else:
            tmp = 0
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

count = 0
max_count = count
for s in S:
    if s in 'ATCG':
        count += 1
    else:
        count = 0
    if count > max_count:
	    max_count = count

print(max_count)

Submission status: Accepted

Solution code:
def main():
    S = input()
    cnt = 0
    max_cnt = 0
    for s in S:
        if s == 'A' or s=='T' or s=='G' or s=='C':
            cnt += 1
        else:
            cnt = 0
        if max_cnt <= cnt:
            max_cnt = cnt
    print(max_cnt)
    return 0

main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import re


def main():
    S = input('')
    S = re.split('[^ACGT]', S)
    max_len = 0
    for string in S:
        if len(string) > max_len:
            max_len = len(string)
    print(max_len)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
res = 0
for i in range(len(s)):
    for j in range(i + 1, len(s)+1):
        tmp = s[i:j]
        flag = True
        for k in range(len(tmp)):
            if not (tmp[k] == 'A' or tmp[k] == 'G' or tmp[k] == 'C' or tmp[k] == 'T'):
                flag = False
                break
        if flag:
            res = max(res, len(tmp))
print(res)

Submission status: Accepted

Solution code:
S = input()
ans = []
for i in S:
    if(i in ['A','C','G','T']):
        ans.append(1)
    else:
        ans.append(0)
num = 0
max_num = 0
for i in ans:
    if(i==1):
        num += 1
        if(max_num < num):
            max_num = num
            
    else:
        num = 0
print(max_num)

Submission status: Accepted

Solution code:
#!/usr/bin/python3

S = input()
m = 0
for i in range(0, len(S)):
    for j in range(i, len(S)+1):
        sub = S[i:j]
        #print(i, j, sub)
        if all(x in 'ATCG' for x in sub):
            m = max(len(sub), m)
print(m)

Submission status: Accepted

Solution code:
S = list(input())
tmp = ''
line = ''
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp += s
    else:
        if len(tmp) > len(line): line = tmp
        tmp = ''
print(max(len(tmp), len(line)))

Submission status: Accepted

Solution code:
n = list(input())

qtd = 0
ma = 0
let = ['A','C','G','T']

for i in range(len(n)):
    if(n[i] in let):
        qtd+=1
    else:
        ma = max(ma,qtd)
        qtd = 0
ma = max(qtd,ma)
print(ma)

Submission status: Accepted

Solution code:
b = input()
max_len = 0
cnt = 0
for it in b:
    if it == 'A' or it=='T' or it=='C' or it=='G':
        cnt+=1
    else:
        if cnt != 0 and max_len < cnt:
            max_len = cnt
        cnt = 0
    
if cnt != 0 and max_len < cnt:
    max_len = cnt
    
print(max_len)

Submission status: Accepted

Solution code:
S = input()

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

    count = max(count, temp)
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())

maxlen=0
tmplen=0

for c in S:
	if c in ("A","C","G","T"):
		tmplen+=1
	else:
		tmplen=0
	maxlen=max(tmplen,maxlen)

print(maxlen)

Submission status: Accepted

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    ml = l = 0
    ACTG = set('ACTG')
    for x in input():
        if x in ACTG:
            l += 1
            ml = max(ml, l)
        else:
            l = 0
    print(ml)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
s = list(input())
answer = 0
on = 0
for i in s:
    if i=='A' or i=='C' or i=='G' or i=='T':
        on += 1
        answer = max(answer, on)
    else:
        on = 0

print(answer)

Submission status: Accepted

Solution code:
S=input()
ls=[]
tmp=0
aaa=['A', 'T', 'G', 'C']
for i in range(len(S)):
	if S[i] not in aaa:
		ls.append(tmp)
		tmp=0
		continue
	else:
		tmp+=1
ls.append(tmp)
print(max(ls))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
acgt=["A","T","G","C"]
st=""
for i in s:
    if i in acgt:
        st+=i
    else:
        st+=","
a=st.split(",")
print(max([len(i) for i in a]))

Submission status: Accepted

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


def is_acgt(s):
    if s=='A' or s=='C' or s=='G' or s=='T':
        return 1
    else: return 0


x = raw_input()


count = []
c = 0
for s in x:
    a = is_acgt(s)
    if a == 0:
        count.append(c)
        c = 0
        continue
    else:
        c += 1

    count.append(c)

if len(count)==0:
    print 0
    exit()
print max(count)

Submission status: Accepted

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