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 main():
    S = input()
    ans = 0
    cnt = 0

    for i in range(len(S)):
        if S[i] in "ACGT":
            cnt += 1

        if S[i] not in "ACGT" and cnt > ans:
            ans = cnt
            cnt = 0

        if i == len(S) - 1 and cnt > ans:
            ans = cnt
            cnt = 0

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

counts = []
a = 0
i = 0
while i < len(S):
    if S[i] in ATCG:
        a += 1
    else:
        counts.append(a)
        a = 0
    
    i += 1
    if i == len(S):
        counts.append(a)

print(max(counts))

Submission status: Accepted

Solution code:
def main():
    s = input()
    max_length = 0
    cur_length = 0
    for i, si in enumerate(s):
        if si in ["A", "T", "G", "C"]:
            cur_length+=1
        else:
            if max_length<cur_length:
                max_length = cur_length
            cur_length = 0

    if max_length<cur_length:
        max_length = cur_length
    print(max_length)

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

max = 0
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
        if max < cnt:
            max = cnt
    else:
      cnt = 0

print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

max = 0
count = 0

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

print(max)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    S = input()
    word_arr = ["A","T","G","C"]
    max_count,count = 0,0
    for c in S:
        if c in word_arr:
            count += 1
        else:
            max_count = max(count,max_count)
            count = 0
    max_count = max(count,max_count)
    print(max_count)

Submission status: Accepted

Solution code:
s = list(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
	else:
		count = 0
	if count > answer:
			answer = count

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())
a=0
b=[0]
for i in range(len(S)-1):
    if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T':
        b[len(b)-1]+=1
    if (S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T') and (S[i+1]!='A' and S[i+1]!='C' and S[i+1]!='G' and S[i+1]!='T'):
        b.append(0)
if S[len(S)-1]=='A' or S[len(S)-1]=='C' or S[len(S)-1]=='G' or S[len(S)-1]=='T':
    b[len(b)-1]+=1
print(max(b))

Submission status: Accepted

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

for i in range(len(S)):
    if S[i] in acgt:
        mylist.append(mylist[-1]+1)
    else:
        mylist.append(0)
print(max(mylist))

Submission status: Accepted

Solution code:
s = input()
streak = 0
nowst = 0
ls = {"A", "C", "G", "T"}
for i in s:
	if i in ls:
		nowst += 1
		streak = max(nowst, streak)
	else:
		nowst = 0
print(streak)

Submission status: Accepted

Solution code:
s=input()
maxc=c=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
        maxc=max(c,maxc)
    else:
        c=0
print(maxc)

Submission status: Accepted

Solution code:
a = list(input())

c = 0
m = 0

for x in a:
    if x in ["A", "C", "G", "T"]:
        c += 1
    else:
        m = max(m, c)
        c = 0

print(max(m, c))

Submission status: Accepted

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

res = 0
for i in range(n):
  for j in range(i,n):
    sub = S[i:j+1]
    flg=True
    for c in sub:
      if c not in ["A","G","C","T"]:
        flg = False
    if flg:
      res = max(res,len(sub))
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(x):
  if x == "A" or x == "C" or x == "G" or x == "T":
    return "1"
  else:
    return "0"
S = input()
s = list(S)
n = len(s)
u = list(map(f,s))
U = "".join(u)
print(max(list(map(len,U.split("0")))))

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

Submission status: Accepted

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

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

print(max(S_num))

Submission status: Accepted

Solution code:
s = input()
atgc = ["A","T","G","C"]
mylist = [0]
for i in range(len(s)):
    if s[i] in atgc:
        mylist.append(mylist[-1] +1)
    else:
        mylist.append(0)
print(max(mylist))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
mx = 0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        cnt = j-i
        p = 0
        for k in list(s[i:j]):
            if k in ["A","C","G","T"]:
                p += 1
        if p == cnt:
            if p > mx:
                mx = p
print(mx)

Submission status: Accepted

Solution code:
s=str(input())
word=["A","C","G","T"]
con,ans=0,0
for i in range(len(s)):
    if s[i] in word:
        for x in range(len(s)-i):
            if s[i+x] in word:
                con+=1
            else:
                break
        if con > ans:
            ans=con
        con=0
print(ans)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

s = input()
n = len(s)
def func(s):
    if s == "A" or s == "C" or s == "G" or s == "T":
        return True
    else:
        return False

ans = 0
for i in range(n):
    le = 0
    if func(s[i]):
        le = 1
        for j in range(i+1,n):
            if func(s[j]):
                le += 1
            else:
                break
    ans = max(ans, le)
print(ans)

Submission status: Accepted

Solution code:
s = input()

max = 0
tmp = 0

for c in s:
    if c in ['A', 'C', 'G', 'T']:
        tmp += 1
        if tmp > max:
            max = tmp
    else:
        tmp = 0

print(max)

Submission status: Accepted

Solution code:
def main():
    s = str(input())
    count = 0
    count_lst = [0]
    flag = False

    for i in range(len(s)):
        letter = s[i]
        string = 'ACGT'

        if letter in string:
            count += 1
            flag = True

        else:
            if flag:
                count_lst.append(count)
            count = 0
            flag = False

    if flag:
        count_lst.append(count)
    longest = max(count_lst)
    print(longest)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

ans = 0
flag = True
li = ['A', 'C', 'G', 'T']

tmp = 0
for each in s:
    if each in li:
        tmp += 1
        ans = max(ans, tmp)
    else:
        tmp = 0

print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    size = len(S)
    ans = 0
    for left in range(size):
        for right in range(left, size):
            T = S[left:right + 1]
            if set(T) <= set("ACGT"):
                ans = max(ans, right - left + 1)
    print(ans)

    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

# ACGT 

num = 0
result = [0]

    
for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    num += 1
  else:
    result.append(num)
    num = 0
result.append(num)
    
#print(result)
print(max(result))

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    strings = input()
    answers=[]
    counter=0

    for string in strings:
        if "A" in string or "C" in string or "G" in string or "T" in string:
            counter+=1
        else:
            answers.append(counter)
            counter=0
    print(max(answers))


if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

ans = 0
j = 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 = str(input())

cnt = 0
max_cnt = 0
acgt = ["A", "C", "G", "T"]

for e in s:
    if(acgt.count(e) == 1):
        cnt += 1
    else:
        if(cnt >= max_cnt):
            max_cnt = cnt
        cnt = 0

if(cnt >= max_cnt):
    max_cnt = cnt
print(max_cnt)

Submission status: Accepted

Solution code:
import re
print(max(map(len, re.split('[^ACGT]', input()))))

Submission status: Accepted

Solution code:
def checkACGT(s):
    ss = ''.join(s)
    check = ss.replace('A', '').replace('C', '')\
    .replace('G','').replace('T', '')
    if len(check) == 0:
        return True
    else:
        return False


s = input()
ans = 0
for i in range(len(s)):
    for j in range(len(s) - i + 1):
        ss = s[i:j + i]
        # print(ss)
        if (checkACGT(ss)):
            ans = max(ans, len(ss))
print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0

for l in range(len(S)):
    for r in range(l, len(S)):
        T = S[l:r+1]
        if set(T) <= set('ACGT'):
            ans = max(ans, r-l+1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
input = lines.pop(0)
acgt = tuple("ACGT")
max_num_list = []
max_num = 0
for c in input:
    if c in acgt:
        max_num += 1
    else:
        max_num_list.append(max_num)
        max_num = 0
max_num_list.append(max_num)
print(max(max_num_list))

Submission status: Accepted

Solution code:
s = input()

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

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

print(max_)

Submission status: Accepted

Solution code:
S = input()
S += '*'
cnt = 0
ans = 0

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

Submission status: Accepted

Solution code:
S = list(input())

count = 0
maximam = 0
for i in S:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count += 1
    else :
        count = 0
    if count > maximam:
        maximam = count
print(maximam)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 標準入力を取得
S = input()

# 求解処理
ACGT = ["A", "C", "G", "T"]
ans = 0
N = len(S)
for i in range(N):
    for j in range(i, N):
        if all([S[k] in ACGT for k in range(i, j + 1)]):
            ans = max(ans, j - i + 1)

# 結果出力
print(ans)

Submission status: Accepted

Solution code:

s = str(input())
acgt = ['A', 'C', 'G', 'T']

temp = 0
ans = 0

for i in range(len(s)):
    tar = s[i]
    if (tar in acgt):
        temp += 1
    else:
        temp = 0

    ans = max(ans, temp)

print(ans)

Submission status: Accepted

Solution code:
s=input()
temp=0
ans=0
tar="ACGT"
for ch in s:
  if ch in tar:
    temp+=1
  else:
    ans=max(ans, temp)
    temp=0

print(max(ans,temp))

Submission status: Accepted

Solution code:
S=list(input())
n=len(S)
ans=0
ansl=[0]
for i in range(n):
    if S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
        ans+=1
    else:
        ans=0
    ansl.append(ans)
ansl.sort(key=int)
print(ansl[n])

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(len(S)):
    for j in range(len(S)-i):
        ACGT = True
        for k in range(len(S)-i-j):
            if S[i:len(S)-j][k] != 'A' and S[i:len(S)-j][k] != 'G' and S[i:len(S)-j][k] != 'C' and S[i:len(S)-j][k] != 'T':
                ACGT = False
                break
        if ACGT and len(S)-i-j > ans:
            ans = len(S)-i-j
print(ans)

Submission status: Accepted

Solution code:
gene = {'A', 'T', 'G', 'C'}
s = input().strip()     #;print(s)

cnt = 0; ans = 0
for w in s:
    if w in gene:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
print(max(ans, cnt))

Submission status: Accepted

Solution code:
s = input()

not_ACGT_list = [-1]
max_len = 0

for i in range(len(s)):
    if s[i] != "A" and s[i] != "C" and s[i] != "G" and s[i] != "T":
        not_ACGT_list.append(i)
not_ACGT_list.append(len(s))
#print(not_ACGT_list)
        
for i in range(len(not_ACGT_list)-1):
    max_len = max(max_len,not_ACGT_list[i+1]-not_ACGT_list[i]-1)

print(max_len)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    S = input()
    acgt_set = set(['A', 'C', 'G', 'T'])
    i, last = 0, len(S)

    ans = 0
    while i < last:
        if S[i] not in acgt_set:
            i += 1
            continue
        j = i+1
        while j < last:
            if S[j] not in acgt_set:
                break
            j += 1
        ans = max(ans, j-i)
        i = j
    # 出力
    print(ans)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = [0]
x = 0

for i in range(N):
    s = S[i]
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        x += 1
        if i == N -1:
            ans.append(x)
    
    else:
        if x != 0:
            ans.append(x)
        x = 0
    
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
import math

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():  # a, b = get_int_multi()
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    a_list = get_string_char_list()
    ans = 0
    count = 0
    for s in a_list:

        if s in ("A","C","G","T"):
            count += 1
            ans = max(ans, count)
        else:
            count = 0
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=input()
 
acgt_list=[0]
for i in range(len(S)):
  for j in range(i+1,len(S)+1):
    slen=len(S[i:j])
    temp=0
    for s in S[i:j] :
      if s=='A' or s=='C' or s=='G' or s== 'T':
        temp+=1      
    if temp==slen:
      acgt_list.append(slen)
      
print(max(acgt_list))

Submission status: Accepted

Solution code:
s = input()
t = ['A', 'C', 'G', 'T']
mx = 0
a = 0
for ss in s:
    if ss in t:
        a += 1
    else:
        mx = max(mx, a)
        a = 0
mx = max(mx, a)
print(mx)

Submission status: Accepted

Solution code:
def solve():
    S = input()
    N = len(S)
    max_length = 0

    for i in range(N):
        for j in range(N):
            if i+j >= N:
                break
            temp_str = S[i:N-j]
            temp_str = temp_str.replace("A", "")
            temp_str = temp_str.replace("C", "")
            temp_str = temp_str.replace("G", "")
            temp_str = temp_str.replace("T", "")
            if (len(S[i:N-j]) > 0 and temp_str == ""):
                if (len(S[i:N-j]) > max_length):
                    max_length = len(S[i:N-j])

    print(max_length)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

max_len = 0
cur = 0

for i in S:
    if i in X: cur += 1
    else:
        if cur> max_len:
            max_len = 0
            max_len +=cur
            cur = 0
        else:
            cur = 0

if cur > max_len:
    print(cur)
    sys.exit()

print(max_len)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ac = ["A","C","G","T"]
acgt = []
for i in range(n+1):
    for j in range(i+1,n+1):
        #print(s[i:j])

        a = list(set(list(s[i:j])))
        for k in range(len(a)):
            if a[k] not in ac:
                break
        else:
            #acgt += [s[i:j]]
            #print(f"○{s[i:j]}")
            acgt += [len(s[i:j])]    

if acgt == []:
    acgt += [0]

print(max(acgt))

Submission status: Accepted

Solution code:
import math


def resolve():

    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)



if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
S = input()

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

ans = ''
a = ''
for i in range(len(S)):
    if S[i] in base:
        a += S[i]
        if len(a) > len(ans):
            ans = a
    else:
        a = ''
print(len(ans))

Submission status: Accepted

Solution code:
s = list(input())
right = 0
ans = 0
for left in range(len(s)):
    while right < len(s) and s[right] in ["A", "C", "G", "T"]:
        right += 1
    ans = max(ans, right - left)
    right = left + 1
print(ans)

Submission status: Accepted

Solution code:
ok='AGCT'
s=list(input())
cnt=0
ans=0
for si in s:
  if si in ok:
    cnt+=1
  else:
    ans = max(ans,cnt)
    cnt=0
ans = max(ans,cnt)
print(ans)

Submission status: Accepted

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

maxLength = 0

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

if maxLength < count:
    maxLength = count

print(maxLength)

Submission status: Accepted

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

Submission status: Accepted

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

acgt.append(tmp)

print(max(acgt))

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().strip()

def is_acgt(ss):
  sset = set(ss)
  sset.discard('A')
  sset.discard('G')
  sset.discard('C')
  sset.discard('T')
  return len(sset) == 0

for i in range(1, len(s)+1)[::-1]:
  for j in range(len(s) - i + 1):
    ss = s[j:j+i]
    if is_acgt(ss):
      print(i)
      exit()
      
print(0)

Submission status: Accepted

Solution code:
S = input().strip()
L = len(S)
l = L
while True:
    l -= 1
    for i in range(L-l):
        if len(set(list(S[i:i+l+1]+"ATGC"))) == 4:
            print(len(S[i:i+l+1]))
            exit()

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

s = S()
ans = 0
temp = 0
for i in s:
    if i in 'ACGT':
        temp += 1
    else:
        temp = 0
    ans = max(ans,temp)
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
count = 0
ACGT = ['A', 'C', 'G', 'T']
for i in range(len(S)):
    for j in range(i, len(S)):
        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:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

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

ans = ""

for i in range(len(s)):
    t = ""
    for j in range(i, len(s)):
        if s[j] in acgt:
            t += s[j]
        else:
            break
        if len(t) > len(ans):
            ans = t

print(len(ans))

Submission status: Accepted

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

print(m)

Submission status: Accepted

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input().strip()
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()

target = list('ACGT')

count_list = [0] * len(S)
for i in range(len(S)):
    if S[i] in target:
        count_list[i] = 1

max_length = 0
for start in range(len(S)):
    if count_list[start] == 0:
        continue
    for end in range(start, len(S)):
        if count_list[end] == 0:
            break

        max_length = max(sum(count_list[start : end+1]), max_length)

print(max_length)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    s = input()
    size = len(s)
    ans = 0
    for beg in range(size):
        for end in range(beg+1, size+1):
            if all('ACGT'.count(c) == 1 for c in s[beg:end]):
                ans = max(ans, end-beg)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

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

ans = max(ans,a)

print(ans)