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 sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

s=SR()
atcoder=0
m=0
target=('A','C','G','T')

for i in range(len(s)):
    if s[i] in target:
        atcoder+=1
    else:
        m=max(m,atcoder)
        atcoder=0
print(max(atcoder,m))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
c = 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"):
        c += 1
        if (ans < c):
            ans = c
    else:
        c = 0
print(ans)

Submission status: Accepted

Solution code:
s = input()
a = [-1]
b = 0
for n in range(len(s)):
    if s[n] != "A" and s[n] != "C" and s[n] != "G" and s[n] != "T":
        a.append(n)
a.append(len(s))
for n in range(len(a)-1):
    b = max(b, a[n+1]-a[n]-1)
print(b)

Submission status: Accepted

Solution code:
S = input()
l_list = ['A','C','T','G']
ans_list = str()
for i,l in enumerate(S):
  if l in l_list:
    ans_list += '1'
  else:
    ans_list += '0'
ans_list = ans_list.split('0')
print(max([len(i) for i in ans_list]))

Submission status: Accepted

Solution code:
s=input()
length=0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        ans=s[i:j].replace('A','').replace('T','').replace('C','').replace('G','')
        if ans=='' and len(s[i:j])>=length:
            length=len(s[i:j])
print(length)

Submission status: Accepted

Solution code:
S = input()
M = 0
con = 0

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

for i,s in enumerate(S):
  if S[i] in L:
    con += 1
    M = max(M,con)
  elif S[i] not in L:
    con = 0
    M = max(M,con)

print(M)

Submission status: Accepted

Solution code:
s = input()

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

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

Submission status: Accepted

Solution code:
S = input()
cnt = 0
ans = []
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:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
print(max(ans))

Submission status: Accepted

Solution code:
S = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
for i in range(len(S), 0, -1):
    for j in range(len(S) - i + 1):
        for k, s in enumerate(S[j:i + j]):
            if not s in acgt:
                break
            if k == len(S[j:i + j]) - 1:
                ans = len(S[j:i + j])
            
        if ans != 0:
            break
    else:
        continue
   
    break    
    
print(ans)

Submission status: Accepted

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

def main():
    s = input()
    acgt = ('A', 'C', 'G', 'T')
    s += 'x'
    max_ = 0
    cnt = 0

    for char in s:
        if char in acgt:
            cnt += 1
        else:
            if cnt > max_:
                max_ = cnt
            cnt = 0

    print(max_)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
table = [0 for i in range(len(s))]
acgt = ['A', 'C', 'G', 'T']
for i in range(len(s)):
    if s[i] in acgt:
        table[i] += 1

count = 0
ans = 0
for i in table:
    if i:
        count += 1
        ans = max(ans, count)
    else:
        count = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
i = 0
ans = 0
atcg = "ACGT"
for i in range(len(s)):
    for j in range(i, len(s)):
        t = s[i: j + 1]
        cnt = 0
        for n in range(4):
            cnt += t.count(atcg[n])
        
        if cnt == len(t):
            ans = max(ans, cnt)
        
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(s)):
  if s[i] in acgt:
    cnt += 1
  else:
    cnt = 0
  ans.append(cnt)

print(max(ans))

Submission status: Accepted

Solution code:
import itertools
S = input()
L = len(S)

ans = 0
for i,j in itertools.combinations(range(L+1),2):
  ss = S[i:j]
  ok = True
  for s in list(ss):
    if not(s == 'A' or s == 'C' or s == 'G' or s == 'T'):
      ok = False
      break
      
  if ok:
    ans = max(ans,j-i)
    
print(ans)

Submission status: Accepted

Solution code:
import re
S=input()
match=re.findall(r'[AGCT]+',S)
if len(match)==0:
  print(0)
else:
  print(max(len(s) for s in match))

Submission status: Accepted

Solution code:
import math
import sys
s = input()
def isACGT(n):
    for i in range(len(n)):
        if (n[i] != 'A' and n[i] != 'C' and n[i] != 'G' and n[i] != 'T'):
            return False
    return True
ans=0
for i in range(len(s)):
    for j in range(1, len(s)+1):
        if (isACGT(s[i:j]) and len(s[i:j]) > ans):
            ans = len(s[i:j])
print(ans)

Submission status: Accepted

Solution code:
S = input()

ACGT = 'ACGT'

ans = 0
for i in range(len(S)):
    for j in range(i, len(S) + 1):
        if all(c in ACGT for c in S[i:j]):
            ans = max(ans, j - i)

print(ans)

Submission status: Accepted

Solution code:
S = input()
a = 'ACGT'
memo = []
cnt = 0
for s in S:
  if s in a:
    cnt += 1
  else:
    cnt = 0
  memo.append(cnt)
print(max(memo))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    s=input()
    num=0
    for i in range(len(s)):
        for j in range(len(s)+1):
            s1=s[i:j]
            if 'B' not in s1 and 'D' not in s1 and 'E' not in s1 and 'F' not in s1\
                    and 'H' not in s1 and 'I' not in s1 and 'J' not in s1 and 'K' not in s1 and 'L' not in s1 and\
                    'M' not in s1 and 'N' not in s1 and 'O' not in s1 and 'P' not in s1 and 'Q' not in s1 and\
                    'R' not in s1 and 'S' not in s1 and 'U' not in s1 and 'V' not in s1 and 'W' not in s1 and\
                    'X' not in s1 and 'Y' not in s1 and 'Z' not in s1 and len(s1)>=num:
                num=len(s1)
    print(num)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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


while len >= 1:
  for i in range(n-len + 1):
    sub = s[i:i+len]    
    for c in sub:
      if c not in ['A','T','G','C']:
      	break
    else:
      print(len)
      exit()
  len-=1
  
print(len)

Submission status: Accepted

Solution code:
s = input()
conti_cnt = 0
max_conti = 0
for i in s:
    if i in ['A', 'T', 'C', 'G']:
        conti_cnt += 1
    else:
        if max_conti < conti_cnt:
            max_conti = conti_cnt
            conti_cnt = 0
if max_conti < conti_cnt:
    max_conti = conti_cnt
print(max_conti)

Submission status: Accepted

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

s=input()
n=len(s)

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

Submission status: Accepted

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

print(max(ans))

Submission status: Accepted

Solution code:
N = list(input())
dp = [0]*(len(N)+1)
for i in range(len(N)):
  if N[i] in'ACGT':
    dp[i] += 1
    dp[i+1] = dp[i]
  else:
    dp[i] = 0
print(max(dp))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
s = input()

n = len(s)

ans = 0
res = 0
for i in range(n):
  if s[i] in ['A','C','G','T']:
    res += 1
  else:
    ans = max(ans,res)
    res = 0

print(max(ans,res))

Submission status: Accepted

Solution code:
S = input()

N = len(S)
T = ['A', 'C', 'G', 'T']
ans = 0
now = 0

for a in S:
    isATCG = False
    if a in T:
        isATCG = True

    if isATCG:
        now += 1
        ans = max(ans, now)
    else:
        now = 0
        isATCG = False

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import sys

input = sys.stdin.readline

S = input()

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

x = []
for i in range(len(S)):
    if S[i] in acgt:
        x.append(True)
    else:
        x.append(False)

ans = 0
cnt = 0
for i in x:
    if i :
        cnt+=1
    else:
        ans = max(ans,cnt)
        cnt = 0

print(ans)

Submission status: Accepted

Solution code:
s = input()
s_x = s+"X"
list_s = ["A","C","T","G"]
ans = []
count=0
for i in s_x:
    #print(i)
    if i in list_s:
        count+=1
    else:
        ans.append(count)
        count=0

print(max(ans))

Submission status: Accepted

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

def is_agct(c):
    return c == 'A' or c == 'G' or c == 'T' or c == 'C'

def find_agct(s, l):
    n = len(s)
    while (l < n and not is_agct(s[l])):
        l = l + 1
    return l

ans = 0

l = find_agct(s, 0)
r = l + 1
while (l < n):
    while (r < n and is_agct(s[r])):
        r = r + 1
    ans = max(ans, r - l)
    l = find_agct(s, r)
    r = l + 1

print(ans)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
"""
https://atcoder.jp/contests/abc122/tasks/abc122_b
"""

def solve():
    S = input()

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

    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input() #sys.stdin.readlineは最後が改行

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

Submission status: Accepted

Solution code:
import sys
s = input()
b = True
max_ = 0
for i in range(len(s)):
    s1 = s[i:]
    for k in range(len(s1)):
        b = True
        s2 = s1[:len(s1)-k]
        for j in s2:
            if j != 'A' and j!='T' and j != 'G' and j!='C':
                b = False
        if b:
            max_ = max(max_, len(s2))
print(max_)

Submission status: Accepted

Solution code:
c,m=0,0
for i in input():
  if i in "AGCT":
    c+=1
  else:
    if c > m:
      m=c
    c=0
if c > m:
      m=c
print(m)

Submission status: Accepted

Solution code:
import math
import sys

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

ans = max(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
S = input()

l = len(S)

max_cnt = 0
for i in range(l):
    for j in range(i, l):
        res = [1 if s == "A" or s == "C" or s == "G" or s == "T" else 0 for s in S[i : j + 1]]
        if sum(res) == len(res):
            max_cnt = max(sum(res), max_cnt)
print(max_cnt)

Submission status: Accepted

Solution code:
import math
import itertools
import numpy as np

def solve():
    s = input()
    le = len(s)
    ans = 0
    for i in range(le):
        for j in range(i, le):
            if all("AGCT".count(k) == 1 for k in s[i:j+1]):
                ans = max(ans, j-i+1)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
# input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        yield map(int, input().split())


def main():
    s = input()

    subst = 0
    for i in range(len(s)):
        if s[i] in "ACGT":
            subst += 1
        else:
            yield subst
            subst = 0
    
    yield subst
    

print(max(main()))

Submission status: Accepted

Solution code:
s = input()
ch = ['A', 'C', 'G', 'T']
ans = 0
tmp = 0
for c in s:
    if c in ch:
        tmp += 1
    else:
        tmp = 0
    ans = max(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
S = str(input())
count = 0
Answer = 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
        for j in range(len(S)-1-i):
            if S[i+1+j] == "A" or S[i+1+j] == "C" or S[i+1+j] == "G" or S[i+1+j] == "T":
                count+=1
            else:
                break
        if Answer < count:
            Answer = count
            count = 0
        else:
            count = 0

print(Answer)

Submission status: Accepted

Solution code:
s = input()
items = ['A', 'T', 'G', 'C']
length = 0
maxLen = 0

for i in s:
    if i in items:
        length += 1
    else:
        if length >= maxLen:
            maxLen = length

        length = 0


    if length >= maxLen:
        maxLen = length

print(maxLen)

Submission status: Accepted

Solution code:
import re

s = input()
s = s.translate(str.maketrans({'A': 'x', 'C': 'x', 'G': 'x', 'T': 'x'}))
s = re.sub(r'[^x]', ' ', s)
s_ls = list(map(len, (s.split())))
if len(s_ls) == 0:
    print(0)
else:
    s_ls.sort()
    print(s_ls[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

mx = 0
cnt = 0
for s in S:
    if s not in ['A', 'T', 'C', 'G']:
        mx = max(mx, cnt)
        cnt = -1
    cnt += 1
mx = max(mx, cnt)
print(mx)

Submission status: Accepted

Solution code:
S = input()

A = 0
B = 0
for i in S:
  if "AGTC".count(i) == 1:
    B += 1
  else:
    A = max(A,B)
    B = 0
A = max(A,B)
print(A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
ACGT_filter = ['A', 'C', 'G', 'T']

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
for i in s:
    if i not in 'ACGT':
        s = s.replace(i, '0')
print(len(max(s.split('0'), key = len)))

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    word = stdin.readline()
    max = 0
    count = 0
    for i in range(len(word)):
        if word[i] == "A" or word[i] == "C" or word[i] == "G" or word[i] == "T":
            count += 1
        elif max < count:
            max = count
            count = 0
    print(max)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
s1 = []
s2 = [0]

for n in S:
	if n == "A" or n == "C" or n == "G" or n == "T":
		s1.append(1)
	else:
		s1.append(0)

for i in range(len(S)):
	if s1[i] == 0:
		s2.append(0)
	else:
		s2.append(s2[i] + s1[i])

print(max(s2))

Submission status: Accepted

Solution code:
s = input()
possible_answers = [0]
possible_answer = 0
acgt = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    if s[i] in acgt:
        possible_answer += 1
    else:
        possible_answers.append(possible_answer)
        possible_answer = 0

possible_answers.append(possible_answer)
print(max(possible_answers))

Submission status: Accepted

Solution code:
S=input()
ACGT=['A','C','G','T']
ans=0
tmp=0
for s in S:
  if tmp==0:
    if s in ACGT:
      tmp+=1
      if ans==0: ans=1
  else:
    if s in ACGT:
      tmp+=1
      if tmp>ans: ans=tmp
    else:
      tmp=0
print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
dp = [0 for i in range(n+1)]
for i in range(n):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'T' or s[i] == 'G':
        dp[i+1] = dp[i] + 1
print(max(dp))

Submission status: Accepted

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

S2 = ''
for i in range(len(S)):
    if S[i] in l:
        S2 += S[i]
    else:
        S2 += '-'
S2 = S2.split('-')
ans = 0
for s in S2:
    if ans < len(s):
        ans = len(s)
print(ans)

Submission status: Accepted

Solution code:
S = input()

L = []
for i in range(len(S)):
    if(S[i] in 'ACGT'):
        count = 1
        L.append(1)
        for j in range(i + 1, len(S)):
            if (S[j] in 'ACGT'):
                count += 1
            else:
                L.append(count)
                break
            if (j + 1 == len(S)):
                L.append(count)
                break
    else:
        continue

if (len(L) == 0):
    print('0')
else:
    print(max(L))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
res = 0
for i in range(n):
    cnt = 0
    for j in range(i, n):
        if s[j] in "ACGT":
            cnt += 1
        else:
            break
    if cnt >= res:
        res = cnt
print(res)

Submission status: Accepted

Solution code:
S = input()
llist = [0 for i in range(10)]

for i in range(len(S)):
    for j in range(len(S)-i):
        if S[i+j] == "A" or S[i+j] == "T" or S[i+j] == "G" or S[i+j] == "C":
            llist[i] += 1
        else:
            break

print(max(llist))

Submission status: Accepted

Solution code:
S = input()
max = 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':
    ans += 1
    if ans > max:
      max = ans
  else:
    ans = 0

print(max)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
c=0
m=0
for e in s:
  if e in "ACGT":
    c+=1
  else:
    if c>m:
      m=c
    c=0
if c>m:
  m=c
print(m)

Submission status: Accepted

Solution code:
s = input()

compare = ['A', 'C', 'G', 'T']
max_str = ''
tmp = ''
for si in s:
    if si in compare:
        tmp += si
        if len(tmp) > len(max_str):
            max_str = tmp
    else:
        tmp = ''

print(len(max_str))

Submission status: Accepted

Solution code:
def check_ACGT(S):
    length = len(S)
    for i in range(length):
        if not(S[i] == "A" or  S[i] == "G" or S[i] == "C" or S[i] == "T"):
            return 0
    
    return length

S = input()

tmp = 0
length = len(S)
for i in range(length):
    for j in range(i+1, length):
        # print(S[i:j+1])
        tmp = max(tmp, check_ACGT(S[i:j+1]))
tmp = max(tmp, check_ACGT(S[-1]))
# print(S[-1])
print(tmp)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7

s=input().rstrip()
mx=0
for i in range(len(s)):
    l=0
    for j in range(i,len(s)):
        if s[j]=="A" or s[j]=="T" or s[j]=="G" or s[j]=="C":
            l+=1
        else:
            break
    if l>mx:
        mx=l
print(mx)

Submission status: Accepted

Solution code:
S = input()
cnt = 0
tmp = 0

for i in S:
    if  i in ['A', 'C', 'G', 'T']:
        tmp+=1
    elif cnt < tmp:
        cnt = tmp
        tmp = 0
if cnt < tmp:
    print(tmp)
else:
    print(cnt)

Submission status: Accepted

Solution code:
S = list(input())

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

Submission status: Accepted

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

ans = 0
current = 0

for c in s:
    if c in 'ACGT':
        current += 1
    else:
        ans = max(ans, current)
        current = 0

ans = max(ans, current)
print(ans)

Submission status: Accepted

Solution code:
s = input() + 'n'
ans = 0
fans = 0
for i in range(len(s)):
    if s[i] in 'ACGT':
        ans += 1
    elif fans < ans:
        fans = ans
        ans = 0
print(fans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

answer = ''
number_of_consecutive_times = 0
maxium_number_of_consecutive_times = 0
for char in S:
    is_included = char in ['A', 'C', 'G', 'T']

    if is_included:
        number_of_consecutive_times += 1
        maxium_number_of_consecutive_times = max(
            number_of_consecutive_times,
            maxium_number_of_consecutive_times,)
    else:
        number_of_consecutive_times = 0

print(maxium_number_of_consecutive_times)

Submission status: Accepted

Solution code:
S = input()

answer = ''
number_of_consecutive_times = 0
maxium_number_of_consecutive_times = 0
for char in S:
    is_included = char in ['A', 'C', 'G', 'T']

    if is_included:
        number_of_consecutive_times += 1
    else:
        maxium_number_of_consecutive_times = max(
            number_of_consecutive_times,
            maxium_number_of_consecutive_times,)
        number_of_consecutive_times = 0
maxium_number_of_consecutive_times = max(
            number_of_consecutive_times,
            maxium_number_of_consecutive_times,)

print(maxium_number_of_consecutive_times)

Submission status: Accepted

Solution code:
def cntLetter(s):
    cnt = 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'):
            cnt += 1  
            ans = max(ans, cnt)
        else:
            cnt = 0
    return ans

def main():
    s = input()
    print(cntLetter(s))
main()

Submission status: Accepted

Solution code:
def is_acgt(s):
    for c in list(s):
        if c not in ["A", "C", "G", "T"]:
            return False
    return True


S = input()
N = len(S)
ans = 0
for l in range(N):
    for r in range(N, l, -1):
        ss = S[l:r]
        if is_acgt(ss):
            ans = max(ans, len(ss))
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
l = ["A", "C", "G", "T"]
ans = 0
tmp = 0
for i in range(len(s)):
    if s[i] in l:
        tmp += 1
        if ans <= tmp:
            ans = tmp
    else:
        tmp = 0
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
l = ["A", "C", "G", "T"]
ans = 0
tmp = 0
for i in range(len(s)):
    if s[i] in l:
        tmp += 1
        if ans <= tmp:
            ans = tmp
    else:
        tmp = 0
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

se = {'A', 'C', 'G', 'T'}
S = sr()
cand = []
answer = []
for s in S:
    if s in se:
        cand.append(s)
    else:
        if len(cand) > len(answer):
            answer = cand
        cand = []

if len(cand) > len(answer):
    answer = cand
print(len(answer))

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    s=list(input())
    acgt={"A","C","G","T"}
    sc=[0]*len(s)
    if s[0] in acgt:
        sc[0]=1
    for i in range(1,len(s)):
        if s[i] in acgt:
            sc[i]=sc[i-1]+1
    print(max(sc))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
counts = []
count = 0
for i in range(len(s)):
    c = s[i:len(s)+1]
    for j in c:
        if "A" in j or "C" in j or "G" in j or "T" in j:
            count += 1
        else:
            break
    counts.append(count)
    count = 0
max_count = max(counts)
print(max_count)

Submission status: Accepted

Solution code:
s = list(input())
Max = 0
cnt = 0
D = ["A","C","G","T"]
for i in s:
    if i in D:
        cnt += 1
    else:
        if Max < cnt:
            Max = cnt
        cnt = 0
print(max(Max,cnt))