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:
def ACGT(s):
    A = s.count('A')
    C = s.count('C')
    G = s.count('G')
    T = s.count('T')
    return len(s) == A+C+G+T

S = input()

ans = 0
for i in range(len(S)+1):
    for k in range(i+1, len(S)+1):
        sub = S[i:k]
        if ACGT(sub):
            if ans < len(sub):
                ans = len(sub)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    maxlen = 0
    for i in range(len(S)):
        for j in reversed(range(len(S))):
            if i <= j:
                c = 0
                for k in range(i, j+1):
                    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
                        c += 1
                    else:
                        break
                if c > maxlen:
                    maxlen = c
    print(maxlen)
main()

Submission status: Accepted

Solution code:
N=input()
alp="BDRFHIJKLMNOPQRSUVWXYZ"
cnt=[]

for i in range(0,len(N)):
    for j in range(i,len(N)+1):
        tmp=N[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:
def main():
    S = input()
    ACGT = {'A', 'C', 'G', 'T'}
    ans, s_l = 0, 0
    for c in S:
        if c in ACGT:
            s_l += 1
        else:
            ans = max(ans, s_l)
            s_l = 0
    ans = max(ans, s_l)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = str(input())
count = 0
ans = 0
for i in range(len(S)):
  if S[i] in "ACGT":
    count += 1
    ans =  max(ans,count)
  else:
    count = 0
print(ans)

Submission status: Accepted

Solution code:
import re
s = input()

m = re.findall(r'[A|T|G|C]+',s)
if len(m)==0:
    print(0)
else:    
    print(len(max(m,key=len)))

Submission status: Accepted

Solution code:
s = input()
answer = 0
for left in range(len(s)):
    for right in range(left, len(s)): #一文字だけの場合があるので、始端はleft+1ではない
        if set(s[left:right+1]) <= set("ACGT"):
            answer = max(answer, right - left +1)
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC122B パターン１　部分文字列全探索
S=input()
N=len(S)

ans=0
'''
for i in range(N):
    if S[i] in "ACGT":
        ans=1

for l in range(N-1):
    for r in range(l+1,N):
        for s in S[l:r]:
            if not s in "ACGT":
                break
        else:
            ans=max(ans,len(S[l:r])) 
'''

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:
#ABC122B パターン2　カウントアップMAX方式

S=input()
N=len(S)

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

print(ans)

Submission status: Accepted

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

res = 0
for i in range(n):
    c = 0
    for j in range(i,n):
        if s[j] not in ("A","G","C","T"):
            break
        c += 1
    res = max(res, c)
print(res)

Submission status: Accepted

Solution code:
"""
問題文
英大文字からなる文字列Sが与えられます。
Sの部分文字列 (注記を参照) であるような最も長い ACGT 文字列 の長さを求めてください。

ここで、ACGT 文字列とは A, C, G, T 以外の文字を含まない文字列です。

注記
文字列 Tの部分文字列とは、Tの先頭と末尾から0文字以上を取り去って得られる文字列です。
例えば、ATCODER の部分文字列には TCO, AT, CODER, ATCODER,  (空文字列) が含まれ、AC は含まれません。

制約Sは長さ1以上10以下の文字列である。Sの各文字は英大文字である。
"""

import re

S = input()
#S = 'HATAGAYA'

S = re.sub('[ACGT]', '1', S)
S = re.sub('[A-Z]', '0', S)

S = S.split('0')

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

Submission status: Accepted

Solution code:
def S(): return input()
S = S()
dp = [0]*(len(S)+1)
for i,x in enumerate(S,1):
    if x in 'ACGT':
        dp[i] = dp[i-1]+1
print(max(dp))

Submission status: Accepted

Solution code:
def S(): return input()
S = S()
ans = 0
temp = 0
for x in S:
    if x in 'ACGT':
        temp += 1
    else:
        temp = 0
    ans = max(temp,ans)
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = 0
ans_l = [0]*len(s)


for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        ans_l[ans] += 1
    else:
        ans += 1
print(max(ans_l))

Submission status: Accepted

Solution code:
def S(): return input()
S = S()
dp = [0]*(len(S)+1)
for i,x in enumerate(S,1):
    if x in 'ACGT':
        dp[i] = dp[i-1]+1
    else:
        dp[i] = 0
print(max(dp))

Submission status: Accepted

Solution code:
def ATCoder(S):
    count = 0
    res = 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
            if count > res:
                res = count
        else:
            count = 0
    return res



if __name__ == "__main__":
    S = str(input())
    print(ATCoder(S))

Submission status: Accepted

Solution code:
x = list(input())

y = 0
z = 0
for i in range(len(x)):
    if x[i] in ['A', 'C', 'G', 'T']:
        y += 1
    else:
        z = max(z,y)
        y = 0
else:
    z = max(z,y)

print(z)

Submission status: Accepted

Solution code:
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    s = input()
    anslist = []
    for i in s:
        if i == 'A' or i == 'T' or i == 'C' or i == 'G':
            anslist.append(1)
        else:
            anslist.append(0)
    anslist.append(0)
    ans = 0
    tmp = 0
    for i in anslist:
        tmp+=i
        if not i:
            ans = max(ans,tmp)
            tmp = 0
    print(ans)


main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
lst = []
for s in S:
    if s in 'ACGT':
        lst.append(True)
    else:
        lst.append(False)

max_true = -1
k = 0
for b in lst:
    if b:
        k+=1
    else:
        if k > max_true:
            max_true = k
        k = 0
print(max(max_true, k))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for i in range(n):
    for j in range(i, n):
        ok = True
        for k in range(i, j + 1):
            if s[k] not in ['A', 'T', 'G', 'C']:
                ok = False
        if ok:
            ans = max(ans, j - i + 1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
chrlis = []
for i in range(len(s)):
  if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
    start = i
    for j in range(i,len(s)):
      if s[j]=="A" or s[j]=="C" or s[j]=="G" or s[j]=="T":
        end = j
      else:
        break
  else:
    continue
  chrlis.append(s[start:end+1])

ans = 0
for i in range(len(chrlis)):
  tmp = len(chrlis[i])
  if tmp>ans:
    ans = tmp
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

print(max(li))

Submission status: Accepted

Solution code:
import re
import io
    
data = input()
pattern = "[ATGC]*"
    
matched_list = sorted(re.findall(pattern, data), key=len, reverse=True)
print(len(matched_list[0]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    s = input()
    dna = ['A', 'C', 'G', 'T']

    ans = 0
    tmp = 0
    for i in range(len(s)):
        if s[i] in dna:
            tmp += 1
        else:
            if tmp > ans:
                ans = tmp
                tmp = 0
            else:
                tmp = 0
    if tmp > ans:
        ans = tmp

    print(ans)

Submission status: Accepted

Solution code:
s = input()
count = 0
maxcount = 0

for i in range(len(s)):
    check = s[i:i+1]
    if check == "A" or check == "C" or check == "G" or check == "T":
        count += 1
    else:
        maxcount = max(maxcount, count)
        count = 0

maxcount = max(maxcount, count)
print(maxcount)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
s = {'A','C','T','G'}
ans = 0
for i in range(len(n)):
    count = 0
    for j in range(i, len(n)):
        if n[j] in s:
            count += 1
        else:
            break
    ans = max(ans, count)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

ans=[]

count=0
max=0

for i in range(len(s)):
  if s[i]=='A' or s[i]=='G' or s[i]=='C' or s[i]=='T':
    ans.append(s[i])
    count=count+1
    #print(ans,count)
    if count>=max:
      max=count
  else:
    count=0
#print(ans)
print(max)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

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

def main():
    s = ns()
    ACGT = "AGCT"
    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)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
for i in range(1,n+1):
    for j in range(n-i+1):
        target = S[j:j+i]
        flag = True
        for t in target:
            if t not in ['A', 'C', 'G', 'T']:
                flag = False
                break
            
        if flag:
            ans = max(ans, len(target))

print(ans)

Submission status: Accepted

Solution code:
s =  list(input())
nucleotide = ['A', 'C', 'G', 'T']
paircount, maxpair = 0, 0
for i in s:
  if (i in nucleotide) == True:
    paircount += 1
  else:
    paircount = 0
  if maxpair <= paircount:
    maxpair = paircount
print(maxpair)

Submission status: Accepted

Solution code:
s = input()


def checkSpell(c):
    return c=="A" or c =="C" or c =="G" or c =="T"

cnt = 0
res = 0
for i in s:
    if checkSpell(i) == True:
        cnt += 1
        res = max(res,cnt)
    else:
        cnt = 0
        
print(res)

Submission status: Accepted

Solution code:
s=input()
left,ans=0,0
word=["A","C","G","T"]
for i in range(len(s)):
    point=i
    while point!=len(s):
        if s[point] in word:
            point +=1
        else:break
    ans=max(ans,point-left)
    left +=1
print(ans)

Submission status: Accepted

Solution code:
s = input()
acgt = ['A', 'C', 'G', 'T']
if s[0] in acgt:
  tmp = 1
else:
  tmp = 0
res = tmp
for i in range(len(s)-1):
  if s[i+1] in acgt:
    tmp += 1
    res = max(res, tmp)
  else:
    tmp = 0
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

count = 0
count_list = [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:
        count_list.append(count)
        count = 0
count_list.append(count)
print(max(count_list))

Submission status: Accepted

Solution code:
#abc122_b
#word = 'HATAGAYA'
#word = 'SHINJUKU'
word = input()
chl = ['A','C','G','T']
lmax = 0
temp = 0
for ch in word:
    if ch in chl:
        temp += 1
    else:
        temp = 0
    if temp >= lmax:
            lmax = temp
print(lmax)

Submission status: Accepted

Solution code:
S = list(input())

ans = 0
acgt = ['A', 'C', 'G', 'T']
conti = 0

for i in S:
    if i in acgt:
        conti += 1
        if ans < conti:
            ans = conti
    else:
        conti = 0

print(ans)

Submission status: Accepted

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

c=0
ans=0

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

Submission status: Accepted

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

c = 0
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import re
S = input()
S = re.sub("[ACGT]", "*", S)
cnt = 0
for i in range(len(S)):
    for j in range(i, len(S) + 1):
        if S[i:j] == "*" * (j - i):
            cnt = max(j - i, cnt)
print(cnt)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
cnt = 0
MAX = 0
base = set(['A', 'C', 'G', 'T'])
for char in S:
    if char in base:
        cnt += 1
    else:
        MAX = max(MAX, cnt)
        cnt = 0
MAX = max(MAX, cnt)
print(MAX)

Submission status: Accepted

Solution code:
s=input()+'X'
ans=0
x=0
for i in range(len(s)):
  if s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T':
    x+=1
  else:
    ans=max(ans,x)
    x=0
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("ACGT".count(c) for c in s[i:j+1]):
      ans=max(ans,j-i+1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        l.append(S[i:j])
    
for i in range(len(l)):
    for c in l[i]:
        if c not in ans:
            flag = True
            break
    if flag:
        flag = False
        continue
    A = max(A, len(l[i]))

print(A)

Submission status: Accepted

Solution code:
S = input()

l = len(S)
maxv = 0

for i in range(l):
    count = 0
    if 'A' == S[i] or 'C' == S[i] or 'G' == S[i] or 'T' == S[i]:
        count = 1
        for j in range(i+1, l):
            if 'A' == S[j] or 'C' == S[j] or 'G' == S[j] or 'T' == S[j]:
                count += 1
            else:
                break

    if maxv < count:
        maxv = count

print(maxv)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
n = len(S)
ans = 0
k = 0
agct = ['A','G','C','T']
for i in range(n):
    if S[i] in agct:
        k+=1
        continue
    ans = max(k,ans)
    k = 0

ans = max(ans,k)
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	s = IS()
	ans = 0
	cnt = 0
	for ss in s:
		if ss=="A" or ss=="T" or ss=="G" or ss=="C":
			cnt += 1
		else:
			ans = max(ans,cnt)
			cnt=0
	ans = max(ans,cnt)
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

cnt = 0
ans = 0
check = ["A", "C", "G", "T"]

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

Submission status: Accepted

Solution code:
S = input()
ls = len(S)
c = [0]*ls

for i in range(ls):
  if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
    for j in range(i,ls):
      if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
        c[i] += 1
      else:
        break
      
print(max(c))

Submission status: Accepted

Solution code:
moji = str(input())
length = len(moji)
mojilst = list(moji)
ans = 0
temp = []
for i in range(length):
  if str(mojilst[i]) == "A" or str(mojilst[i]) == "G" or str(mojilst[i]) == "C" or str(mojilst[i]) == "T":
    temp.append(str(mojilst[i]))
  else:
    if ans < len(temp):
      ans = len(temp)
    temp = []
if ans < len(temp):
      ans = len(temp)
print(ans)

Submission status: Accepted

Solution code:
s = input()
j = 0
a = [0]
for i in s:
    if (i == 'A') or (i == 'C') or (i == 'G') or (i == 'T'):
        a[j] += 1
    else:
        a.append(0)
        j += 1
a = sorted(a,reverse = True)
print(a[0])

Submission status: Accepted

Solution code:
s = input()
count = 0
temp = 0
for i in range(len(s)):
  if s[i] in "ACGT":
    temp += 1
  elif temp:
    if count < temp:
      count = temp
    temp = 0
if count < temp:
  count = temp
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ACGT = ["A","C","G","T"]
ans = 0
ANS = [0]

for i in range(len(s)):
    if s[i] in ACGT:
        ans += 1
    else:
        ans = 0
        
    ANS.append(ans)
        
print(max(ANS))

Submission status: Accepted

Solution code:
s = list(input())
key = ['A','T','G','C']
count = 0
flag = False
ans = 0
for i in range(len(s)):
  if s[i] in key:
    count += 1
    flag = True
  if flag==True and (s[i] not in key):
    ans = max(ans,count)
    count = 0
    flag = False
ans = max(ans,count)
print(ans)

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()

S += "Z"
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
S = list(input())

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

print(res)

Submission status: Accepted

Solution code:
s=input()
n=int(len(s))
count=0
ans=0
for i in range(n):
  if s[i]=='A' or s[i]=='T' or s[i]=='G' or s[i]=='C':
    count+=1
    if ans<count:
      ans=count      
  else:
    count=0

else:
  print(ans)

Submission status: Accepted

Solution code:
s=input()
n=int(len(s))
count=0
ans=0
for i in range(n):
  if s[i]=='A' or s[i]=='T' or s[i]=='G' or s[i]=='C':
    count+=1
    if ans<count:
      ans=count      
  else:
    count=0

else:
  print(max(count,ans))

Submission status: Accepted

Solution code:
import numpy as np
s = input()
ans = 0
reg = 0
for i in range(len(s)):
    if(s[i] == 'A' or s[i] == 'G' or s[i] == 'C' or s[i] == 'T'):
        reg += 1
    else:
        reg = 0
        continue
    if(ans<reg):
        ans = reg
print(ans)

Submission status: Accepted

Solution code:
S = input()
atgc = ["A", "T", "G", "C"]
anset = set()
L = 0
for i in range(len(S)):
    if S[i] in atgc:
        L += 1
    else:
        anset.add(L)
        L = 0
    if i == len(S)-1:
        anset.add(L)

print(max(anset))

Submission status: Accepted

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

print(max(count))

Submission status: Accepted

Solution code:
def myAnswer(S:str) -> int:
   ans = 0
   a=[chr(i) for i in range(65, 65+26)]
   a.remove("A")
   a.remove("T")
   a.remove("C")
   a.remove("G")
   counter = 0
   for s in S:
      if((s in a) == False):
         counter +=1
      else:
         ans=max(counter,ans)
         counter=0
   return max(ans,counter)


def modelAnswer():
   tmp=1
def main():
   S = input()
   print(myAnswer(S))

if __name__ == '__main__':
   main()

Submission status: Accepted

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


flag = False
best = 0
a = 0

for s in S:
    if s in acgt:
        if flag:
            a += 1
        else:
            a = 1
            flag = True
        if a > best:
            best = a
    else:
        if flag:
            flag = False
print(best)

Submission status: Accepted

Solution code:
string_data = list(input())

N = len(string_data)
match_word_lits = ['A', 'C', 'G', 'T']
count = 0
max_word = 0
for i in range(N):
    if string_data[i] in match_word_lits:
        count += 1
        if max_word < count:
            max_word = count
    else:
        count = 0

print(max_word)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

s = input().replace("\n","")

ans = 0

for i in range(len(s)):
    cnt = 0
    for j in range(i,len(s)):
        # print(len(s),i)
        # print(s[j:])
        # print(s[j])
        if s[j] == 'A' or s[j] == 'C' or s[j] == 'G' or s[j] == 'T':
            cnt += 1
            if cnt > ans:
                ans = cnt
        else:
            # print("AGCT意外です。カウント数：",cnt)
            break

print(ans)

Submission status: Accepted

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

ans = 0
cnt = 0
suffix = 0

while suffix < len(s):
    if s[suffix] in acgt:
        cnt += 1
    else:
        cnt = 0
    ans = max(ans, cnt)
    suffix += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

ans = 0
cnt = 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))

Submission status: Accepted

Solution code:
S = input()
c = 0
MAX = 0
 
for i in S:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        c += 1
        if MAX < c:
            MAX = c
 
    else:
        c = 0
 
print(MAX)

Submission status: Accepted

Solution code:
S = input()

cnt = 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
    cnt = max(cnt, tmp)
print(cnt)

Submission status: Accepted

Solution code:
M=L=0
for i in input():
    if i in'ATCG':L+=1;M=max(M,L)
    else:L=0
print(M)

Submission status: Accepted

Solution code:
#python3

def main():
    s = input()
    n = len(s)
    
    ans = 0
    cnt = 0 
    for i in range(n):
        if not ((s[i] == 'A') or (s[i] == 'T') or (s[i] == 'C') or (s[i] == 'G')):
            cnt = 0
        else:
            cnt += 1
        ans = max(cnt, ans)
    print(ans)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

tmp = 0
big = 0

for i in s:
    if i not in ['A', 'C', 'G', 'T']:
        tmp = 0
    else:
        tmp += 1
        big = max(tmp, big)

print(big)

Submission status: Accepted

Solution code:
ans=0;now=0
for i in list(input()):
    if i in {"A","G","C","T"}:now+=1
    elif now:ans=max(now,ans);now=0
print(max(now,ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
s += "B"
l = len(s)
c = 0
mx = 0
for i in range(l):
  if s[i] in ["A","G","C","T"]:
    c += 1
  else:
    if c > mx:
      mx = c
      c = 0
    else:
      c = 0
print(mx)

Submission status: Accepted

Solution code:
s = input()
ary1 = "".join([x if x in ["A","C","G","T"] else " " for x in s]).split()
if ary1 ==[]:
  print(0)
else:  
  print(max([len(x) for x in ary1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s =input()
count = 0
count_list = [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
    count_list.append(count)
  else:
    count = 0
    
print(max(count_list))

Submission status: Accepted

Solution code:
s=input()
n=len(s)
def check(s):
    a=list(set(list(s)))
    b=list("ACGT")
    for i in b:
        if i in a:
            a.remove(i)
    if a==[]:
        return len(s)
    return 0
ans=0
for i in range(n):
    for j in range(n+1):
        ans=max(ans,check(s[i:j]))
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(len(S)):
    for j in range(i,len(S)):
        s = S[i:j+1]
        if sum([s.count(x) for x in 'ACGT']) == len(s):
            ans = max(ans, len(s))

print(ans)

Submission status: Accepted

Solution code:
def hantei(n):
    for i in range(len(n)):
        if n[i]!="A" and n[i]!="G" and n[i]!="T" and n[i]!="C":
            return False

s=input()
T=[]
n=[]
m=[]
x=0

for i in range(len(s)-1):
    for j in range(i+1,len(s)):
        T.append(s[i:j+1])

for i in range(len(s)):
    T.append(s[i])

flag=False
for i in range(len(T)):
    w=T[i]
    if hantei(w)!=False:
        n.append(w)


for i in range(len(n)):
    m.append(len(n[i]))

if not m:
    print(0)
else:
    print(max(m))

Submission status: Accepted

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