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:
import re
print(len(max(re.split('[^ACGT]',input()),key=len)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


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



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
n = len(s)
dp = [0]*n
if s[0] in 'ATGC':
    dp[0]=1
for i in range(1,len(s)):
    if s[i] in 'ATGC':
        dp[i]=1
    if s[i-1]!=0 and dp[i]!=0:
        dp[i]+=dp[i-1]
print(max(dp))

Submission status: Accepted

Solution code:
import re

s = input()
l = [len(s) for s in re.findall(r'[ACGT]+', s)]
print(0 if len(l) == 0 else max(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
ans, p = 0, ""
for s in S:
    if s in  ["A", "C", "G", "T"]:
        p += s
    else:
        p = ""
    ans = max(ans, len(p))
    
print(ans)

Submission status: Accepted

Solution code:
s=list(map(str,input()))
l=[[]]
count=0
for i in s:
    if i=='A' or i=='C' or i=='G' or i=='T':
        l[count].append(i)
    else:
        count+=1
        l.append([])
maxl=0
for j in l:
    if len(j)>maxl:
        maxl=len(j)
print(maxl)

Submission status: Accepted

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

for x in S:
    if x == 'A' or x == 'C' or x =='G' or x == 'T':
        ACGT += 1
    else :
        ACGT = 0
    ans = max(ans, ACGT)

print(ans)

Submission status: Accepted

Solution code:
s = input()

acgt = set("ACGT")

ans = 0

for i in range(len(s)):
    l = 0
    for j in range(i, len(s)):
        if s[j] in acgt:
            l += 1
            if j == len(s)-1:
                ans = max(ans, l)
        else:
            ans = max(ans, l)
            break

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#n = int(input())
#n, m = map(int, sys.stdin.readline().split())
s = input()
#a = list(map(int, sys.stdin.readline().split()))

ans = 0
for i in range(len(s)):
    p = 0
    for j in range(i, len(s)):
        if s[j] == "A":
            p += 1
        elif s[j] == "G":
            p += 1
        elif s[j] == "C":
            p += 1
        elif s[j] == "T":
            p += 1
        else:
            if p != 0:
                break
            else:
                continue

    if p > ans:
        ans = p

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) == 1 for c in S[i : j + 1]):
      ans = max(ans, j - i + 1)
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
ans, p = 0, ""
for s in S:
    if s in ["A", "C", "G", "T"]:
        p += s
    else:
        p = ""
    ans = max(ans, len(p))
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) == 1 for c in S[i:j+1]):
			ans = max(len(S[i:j+1]), ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ansLst = []

for i in range(len(S)):
    tmp = []
    for j in range(i, len(S)):
        if S[j] in targetLst:
            tmp.append(S[j])
        else:
            break
    ansLst.append(len(tmp))

ansLst.sort()
ansLst.reverse()

print(ansLst[0])

Submission status: Accepted

Solution code:
import re
S = str(input())
acgt = re.compile(r"[A,C,G,T]*")
s = re.findall(acgt, S)
print(max(map(len,s)))

Submission status: Accepted

Solution code:
S = input()
ans = 0
count = 0
for i in range(len(S)):
    if S[i] in 'ACGT':
        count +=1
    else:
        count=0
    if ans<count:
        ans=count

print(ans)

Submission status: Accepted

Solution code:
S = list(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
ans = max(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
s = input()

acgt_max = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[j] != 'A' and s[j] != 'C' and s[j] != 'G' and s[j] != 'T':
            acgt_max = max(acgt_max, j - i)
            break
    else:
        acgt_max = max(acgt_max, j - i + 1)
print(acgt_max)

Submission status: Accepted

Solution code:
S=list(input())
count,count_max=0,0
for s in S:
  if s != 'A' and s != 'C' and s != 'G' and s != 'T':
    count = 0
  else:
    count += 1
  count_max=max(count_max,count)

print(count_max)

Submission status: Accepted

Solution code:
s = input()

ans = 0
flag = 0
alist = []

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


for i in s:
    if i in acgt:
        ans += 1
    else:
        alist.append(ans)
        ans = 0
alist.append(ans)

print(max(alist))

Submission status: Accepted

Solution code:
s = str(input())
cnt = 0
cnt_max = 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
        if cnt > cnt_max:
            cnt_max = cnt
    else:
        cnt = 0
print(cnt_max)

Submission status: Accepted

Solution code:
# 初期入力
import sys
input = sys.stdin.readline
S =input().strip()

#ACGTが連続しているか判定
count =0
count_list=[0]
for i in S:
    if i in "ACGT":
        count +=1
        count_list.append(count)
    else:
        count =0
print(max(count_list))

Submission status: Accepted

Solution code:
L = ['A','C','G','T']
S = list(input()) 
S = ['1' if ((i in L) == True) else '0' for i in S]
S = ''.join(S)
S = S.split('0')
S = [len(i) for i in S]
print(max(S))

Submission status: Accepted

Solution code:
S_list = list(input()) 
S_list = ['1' if i == 'A' or i == 'C' or  i == 'G' or i == 'T' else '0' for i in S_list]
S = ''.join(S_list)
S = S.split('0')
X = 0
for i in range(len(S)):
    if len(S[i]) > X:
        X = len(S[i])
print(X)

Submission status: Accepted

Solution code:
s = input()

acgt_len = 0
max_len = 0

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

for i in range(len(s)):
    if s[i] in ACGT:
        acgt_len += 1
    else:
        max_len = max(acgt_len, max_len)
        acgt_len = 0

print(max(acgt_len, max_len))

Submission status: Accepted

Solution code:
S = input()
result = 0

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

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    s=readline().strip()
    ans=0
    atgc=("A","T","G","C")
    for i in range(len(s)):
        for j in range(i+1,len(s)+1):
            cnt=0
            t=s[i:j]
            for c in t:
                if c in atgc:
                    cnt+=1
                else:
                    break
            else:
                ans=max(ans,cnt)

    print(ans)            

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
s = list(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()

ans = 0
for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        s = S[i:j]
        for c in s:
            if c not in "ACGT":
                break
        else:
            ans = max(ans, len(s))

print(ans)

Submission status: Accepted

Solution code:
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
ans = 0
for i,j in itertools.combinations_with_replacement(range(len(S)),2):
    if all([x in 'ACGT' for x in S[i:j+1]]):
        ans = max(ans,j+1-i)
print(ans)

Submission status: Accepted

Solution code:
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
ans = 0
for i,j in itertools.combinations_with_replacement(range(len(S)),2):
    if all(x in 'ACGT' for x in S[i:j+1]):
        ans = max(ans,j+1-i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def S(): return sys.stdin.readline().rstrip()
S = S()
ans,temp = 0,0
for x in S:
    if x in 'ACGT':
        temp += 1
        ans = max(ans,temp)
    else:
        temp = 0
print(ans)

Submission status: Accepted

Solution code:
import sys
def S(): return sys.stdin.readline().rstrip()
S = S()
N = len(S)
dp = [0]*(N+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:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

s = input()
ans = ""
koho = []
for i in range(len(s)):
    ans = ""
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        ans = s[i]
        for j in range(i+1,len(s)):
            if s[j] == "A" or s[j] == "C" or s[j] == "G" or s[j] == "T":
                ans += s[j]
            else:
                break
    koho.append(ans)
s = set(koho)
c = 0
for i in s:
    c = max(c,len(i))
print(c)

Submission status: Accepted

Solution code:
s=list(input())
ans=0
f=0
mae=True
for x in s:
  if x=="A" or x=="G" or x=="C" or x=="T":
    f+=1
  else:
    f=0
  
  ans=max(ans,f)
  
print(ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    S = readline().strip()
    ACGT = {'A', 'C', 'G', 'T'}

    ans = 0
    for left in range(len(S)):
        for right in range(1, len(S) + 1):
            if all(c in ACGT for c in S[left:right]) and ans < right - left:
                ans = right - left

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
ans = 0
x = ["A","T","G","C"]
c = 0
for i in range(len(s)):
    if (s[i] in x) == True:
        c += 1
        if ans < c:
            ans = c
    else:
        c = 0
print(ans)

Submission status: Accepted

Solution code:
S=list(input())
ans=0; c=0
for i in range(len(S)):
    if not S[i] in list('AGCT'): c=0
    else:
        c+=1
        ans=max(ans,c)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def li():
    return list(map(int, input().split()))


def mi():
    return map(int, input().split())


def ii():
    return int(input())


S = input()
ACGT = ["A", "C", "G", "T"]

length = 0
max_length = 0

for i in range(len(S)):
    if S[i] in ACGT:
        for j in range(i, len(S)):
            if S[j] in ACGT:
                length += 1
            else:
                max_length = max(max_length, length)
                length = 0
                break
        max_length = max(max_length, length)
        length = 0

print(max_length)

Submission status: Accepted

Solution code:
s = list(str(input()))
for i in range(len(s)):
    if s[i] in 'ATCG':
        s[i] = 1
    else:
        s[i] = 0
def shakutori(a, k):
    right, cnt = 0, 0
    for left in range(len(a)):
        while right < len(a) and a[right] == k:
            right += 1
        cnt = max(cnt, right - left)
        if right == left:
            right += 1
    return cnt
print(shakutori(s, 1))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    S = list(input())

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
s = list(input())

tmp = 0
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 += 1
    else:
        ans = max(ans , tmp)
        tmp = 0

ans = max(ans , tmp)
print(ans)

Submission status: Accepted

Solution code:
S = input()

max_len = 0
cnt = 0
acgt = ['A', 'C', 'G', 'T']

for i in range(len(S)):
    if S[i] in acgt:
        cnt += 1
        if max_len < cnt:
            max_len = cnt
    else:
        cnt = 0

print(max_len)

Submission status: Accepted

Solution code:
import  re

ss = input()
ps = r"A|C|G|T"

seq = []
counter = 0
for s in ss:
    if re.match(ps, s):
        counter += 1
        seq.append(counter)
    else:
        counter = 0
seq.append(counter)
print(max(seq))

Submission status: Accepted

Solution code:
s = input()

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ss = input()
dic = {'A': 1, 'C': 1, 'G': 1, 'T': 1}
max_s = 0
tmp = 0
for s in ss:
    if s in dic.keys():
        tmp += 1
    else:
        max_s = max(max_s, tmp)
        tmp = 0
max_s = max(max_s, tmp)
print(max_s)

Submission status: Accepted

Solution code:

import re

S = input()

pattern = "[A|T|G|C]+"
match_result = re.findall(pattern, S)

ans = 0
for word in match_result:
    if ans <= len(word): ans = len(word)

print(ans)

Submission status: Accepted

Solution code:
S = input()
result = 0
for i in range(len(S)):
    for j in range(1, len(S) - i + 1):
        flg = True
        for c in tuple(S[i:i + j]):
            if not (c == 'A' or c == 'C' or c == 'G' or c == 'T'):
                flg = False
            if not flg:
                break
        if flg:
            if result < len(S[i:i + j]):
                result = len(S[i:i + j])
print(result)

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    count_list = [0] * 1
    index = 0
    for i in s:
        if i == "A" or i == "T" or i == "G" or i == "C":
            count_list[index] += 1
        else:
            index += 1
            count_list.append(0)
    
    ans = max(count_list)
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
n = len(s)
l = list("ACGT")
A = 0
for i in range(n):
  for j in range(i+1,n+1):
    x = s[i:j]
    if all(k in l for k in x):
      A = max(A,len(x))
print(A)

Submission status: Accepted

Solution code:
s=input()
count=0
a=0
for i in s:
    if i=='A' or i=='C' or i=='G' or i=='T':
        count+=1
        if a<count:
            a=count
    else:
        count=0
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

s=S()
ans=0
n=len(s)
for i in range(n):
    for j in range(i,n):
        if all('AGCT'.count(c)==1 for c in s[i:j+1]):
            ans=max(ans,j-i+1)
print(ans)

Submission status: Accepted

Solution code:
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

s=S()
ans=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
    else:
        ans=max(ans,tmp)
        tmp=0
ans=max(ans,tmp)
tmp=0
print(ans)

Submission status: Accepted

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

result = []
for i in range(len(S)):
    tmp = 0
    for j in range(len(S)-i):
        if S[j+i] in list:
            tmp += 1
        else:
            break
    result.append(tmp)
print(max(result))

Submission status: Accepted

Solution code:
s=input()
l=list("ACGT")
ans=0
for i in range(len(s)):
    for k in range(i+1,len(s)+1):
        if all(j in l for j in s[i:k]):
            ans=max(ans,len(s[i:k]))
print(ans)

Submission status: Accepted

Solution code:
#B
s = input()
j = 0
ans = 0
for i in s:
    if i == "A" or i == "C" or i == 'G' or i == 'T':
        j += 1
        if ans < j:
            ans = j
    else:
        j = 0
print(ans)

Submission status: Accepted

Solution code:
s=input()+"O"
tmp=""
ans=[]
for i in s:
  if i in ["A","T","G","C"]:
    tmp=tmp+i
  else:
    ans.append(tmp)
    tmp=""
res=0
for i in ans:
  if len(i)>res:
    res=len(i)
print(res)

Submission status: Accepted

Solution code:
from operator import itemgetter
s = input()
l = len(s)
ans = []
flag = False 
for i in range(l):
    if flag:
        if s[i] in "AGCT":
            continue
        else:
            ans.append([i-start,start,i])
            flag = False
    if s[i] in "AGCT":
        flag = True
        start = i 
else:
    if flag:
        ans.append([l-start,start,l])
ans.sort(key=itemgetter(0),reverse=True)
#print(s[ans[0][1]:ans[0][2]])
if ans:
    print(ans[0][0])
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def get_maxlen():
    S = input()
    N = len(S)
    for i in range(N, 0, -1):
        for j in range(N - i + 1):
            if set(S[j:j + i]).issubset({'A', 'T', 'C', 'G'}):
                return i
    return 0


print(get_maxlen())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
n = len(s) # 文字列の長さを取得しておく

res = 0 # 条件になければ0
for i in range(n): # Sの部分文字列を全探索するループ：重複を許す（i==jの時は1文字の部分文字列になる）が入替を許さないループ
    for j in range(i, n):
        sub = s[i: j+1] # i文字目からからj文字目までの部分文字列

        flg = True
        for c in sub: # Python的for文
            if(c not in ['A', 'G', 'C', 'T']): flg = False # こちらも、in はこういう時便利です

        if(flg): res = max(res, len(sub)) # ACGT文字列の長さnumの最大値を保持する

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# input
S = input()

# check
ACGT = ["A", "C", "G", "T"]
S_len = len(S)
max_len = max(
    set(
        [
            len(S[i:j])
            for i in range(S_len)
            for j in range(S_len + 1, i, -1)
            if S[i:j].replace("A", "").replace("C", "").replace("G", "").replace("T", "") == ""
        ] + [0]
    )
)

print(max_len)

Submission status: Accepted

Solution code:
s = str(input())
cnt = 0
ans = 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
		if i == len(s)-1 and ans <= cnt:
			ans = cnt
	else:
		if ans < cnt:
			ans = cnt
		cnt = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().strip()
popa = list("ACGT")
maxx = 0
counter = 0
for i in S:
  if i in popa:
    counter+=1
  else:
    maxx = max(maxx,counter)
    counter = 0
maxx = max(maxx,counter)
print(maxx)

Submission status: Accepted

Solution code:
s = str(input())
t = "ATCG"
ans = 0

for i in range(len(s)):
    now = 0
    for j in range(i, len(s)):
        ok = False
        for k in range(len(t)):
            if s[j] == t[k]:
                ok = True
        if ok:
            now += 1
            ans = max(ans, now)
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
# n = int(input())
s = input()

res = 0
res_max = 0
res_s=""
temps = ""
for i in range(len(s)):



    if s[i] in "ACGT":
        # print(s[i])
        res += 1
        temps += s[i]
        if(len(temps) > len(res_s)):
            res_s = temps
            res_max = res
    else:
        res = 0
        temps = ""


print(res_max)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

S = input()

s = ''
base = ('A', 'C', 'G', 'T')
max_len = 0

for c in S:
    if c not in base:
        s = ''
        continue

    s += c

    current_len = len(s)
    if max_len < current_len:
        max_len = current_len

print(max_len)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s= input()

import re

str_s = re.findall('[ATGC]+',s)

length = [len(p) for p in str_s]

if length==[]:
    print(0)
else:
    print(max(length))

Submission status: Accepted

Solution code:
import math
import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import sys
# import bisect
# import numpy as np
# from scipy.special import comb


def main():
    S = input()

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

    ans = 0
    for i in range(1, len(S) + 1):
        for j in range(len(S) - i + 1):
            if not set(S[j:j + i]) - acgt:
                ans = max(ans, len(S[j:j + i]))

    print(ans)


list(itertools.combinations([1, 2, 3, 4], 2))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
問題文
英大文字からなる文字列 S が与えられます。S の部分文字列 (注記を参照) であるような最も長い ACGT 文字列 の長さを求めてください。
ここで、ACGT 文字列とは A, C, G, T 以外の文字を含まない文字列です。
"""
import string
str_up = string.ascii_uppercase.replace("A","").replace("C","").replace("G","").replace("T","")
S = input()
part = []
for i in range(len(S)):
    for j in range(len(S)-i+1):
        part.append(S[i:i+j])
max_s = 0

for i in part:
    for j in str_up:
        if j in i:
            break
        elif j == "Z":
            if len(i) > max_s:
                max_s = len(i)
print(max_s)

Submission status: Accepted

Solution code:
S=list(input())
line=[]
A=["A","C","G","T"]
num_list=[]
flag=False
for s in S:
    if s in A:
        line.append(s)
        flag=True
    elif flag:
        num_list.append(len(line))
        line=[]
        flag=False
num_list.append(len(line))
if len(num_list)==0:print(0)
else:
    print(max(num_list))

Submission status: Accepted

Solution code:
S = str(input())
N = len(S)
AGCT = ["A", "G", "C", "T"]

ans = 0
for i in range(N + 1):
  for j in range(N + 1):
    if i <= j:
      x = 0
      for k in S[i : j]:
        if k in AGCT:
          x += 1
        else:
          ans = max(ans, x)
          x = -1 * N
    ans = max(ans, x)   
       
ans = max(ans, x)        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

S = input()
cnt=0
LEN = len(S)+1
for s in range(LEN):
    for e in range(LEN):
        if len(set(S[s:e])-set(['A','G','C','T']))==0 and len(S[s:e])>cnt:
            cnt = len(S[s:e])
print(cnt)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
l = []
for i in range(N):
  for j in range(i,N):
    s = S[i:j+1]
    if s.strip("A C G T") == "":
      l.append(s)
if len(l) == 0:
  print(0)
  exit()
      
m = sorted(l, reverse=True, key=len)
print(len(m[0]))

Submission status: Accepted

Solution code:
s = input()
seen = [0] * len(s)
ans = 0
for i in range(len(s)):
    if s[i] in ['A', 'C', 'G', 'T']:
        tmp = 0
        k = 0
        while s[i + k] in ['A', 'C', 'G', 'T']:
            tmp += 1
            k += 1
            if i + k >= len(s):
                break
        ans = max(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
S = str(input())
cnt = 0
l = [0]

for i in range(len(S)):
  if S[i] in 'ATGC':
    cnt += 1
  else:
    l.append(cnt)
    cnt = 0
l.append(cnt)
print(max(l))

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
word = ['A', 'C', 'G', 'T']
count = 0
tmp = 0

for i in s:
    if word.count(i) == 1:
        tmp += 1
    else:
        tmp = 0

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

Submission status: Accepted

Solution code:
s = input()
word = ['A', 'C', 'G', 'T']
count = 0
tmp = 0

for i in s:
    if word.count(i) == 1:
        tmp += 1
    else:
        tmp = 0

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

Submission status: Accepted

Solution code:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


S = instr()

n = len(S)

acgt = "ACGT"
max_len = 0
for i in range(n):
    for j in range(i, n+1):
        s = S[i:j]
        flag = 1
        for ch in s:
            if ch not in acgt:
                flag = 0
                break
        if flag == 1:

            max_len = max(max_len, len(s))
print(max_len)