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:
n = input()
cnt = 0
ans = 0
for i in range(len(n)):
    if n[i] in "ACGT":
        cnt += 1
        if ans <= cnt:
            ans = cnt
    else:
        cnt = 0
print(ans)

Submission status: Accepted

Solution code:
'''     ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█  
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     '''


# [temp1.py] => [29-07-2020 @ 10:25:10] 
# Author & Template by : Udit "luctivud" Gupta
# https://www.linkedin.com/in/udit-gupta-1b7863135/


import math;   from collections import *
import sys;    from functools import reduce
import time;   from itertools import groupby

# sys.setrecursionlimit(10**6)

def input()         : return sys.stdin.readline()
def get_ints()      : return map(int, input().strip().split())
def get_list()      : return list(get_ints())
def get_string()    : return list(input().strip().split())
def printxsp(*args) : return print(*args, end="")
def printsp(*args)  : return print(*args, end=" ")


DIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)] 
NEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1),\
              (+1, +1), (+1, +0), (+1, -1), (+0, +1)]


CAPS_ALPHABETS = {chr(i+ord('A')) : i for i in range(26)}
SMOL_ALPHABETS = {chr(i+ord('a')) : i for i in range(26)}
INF = float('inf')


# Custom input output is now piped through terminal commands.
# for _test_ in range(int(input())): 
s = input()
ans = temp = 0
target = "ATGC"
for i in s:
	if i in target:
		temp += 1
		ans = max(temp, ans)
	else:
		temp = 0
print(max(ans, temp))



# print("Time Elapsed: {}".format(float(S34p-S34t)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(max_length)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
s=input()
n=len(s)
ans=0
for i in range(n):
  for j in range(n):
    S=s[i:j+1]
    #print(S)
    m=re.fullmatch(r'[ATCG]+',S)
    #print(m)
    if m!=None:
      ans=max(ans,len(S))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(n):
    k = 0
    l = 0
    while i + k < n:
        if s[i+k] == 'A' or s[i+k] == 'C' or s[i+k] == 'G' or s[i+k] == 'T':
            k += 1
            l += 1
        else:
            break
    ans = max(ans, l)

print(ans)

Submission status: Accepted

Solution code:
S = input()
ret = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        f = True
        for k in S[i:j + 1]:
            if k not in ("ACGT"):
                f = False
                break
        if f:
            ret = max(ret, (j + 1) - i)
print(ret)

Submission status: Accepted

Solution code:
#! python3
#  solve_122B.py

S = input()

t = [0]*len(S)

if S[0] in ["A","C","G","T"]:
    t[0] = 1

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

print(max(t))

Submission status: Accepted

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

S = readline().rstrip()

right = 0
ans = 0
for left in range(len(S)):
  while right + 1 < len(S) and S[right] in "ACGT":
    right += 1
    
  if right + 1 == len(S):
    if S[right] in "ACGT" and ans < right - left + 1:
      ans = right - left + 1
      break
  
  if ans < right - left:
    ans = right - left
    
  if right == left:
    right += 1
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    s = input()
    cnt = 0
    trial = 0
    for i in s: # 本当に全通りO（n^2）やらなくても最長の部分がわかれば良い
        if i in "ACGT":
            trial += 1
        else:
            cnt = max(cnt, trial)
            trial = 0
    print(cnt)

if __name__=="__main__":
    main()

Submission status: Accepted

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

def main():
    s = input()
    len_s = len(s)
    cnt = 0
    for i in range(len_s):
        trial = 0
        for k in range(i,len_s):
            if s[k] in "ACGT":
                trial += 1
            else:
                cnt = max(cnt,trial)
                break
    print(cnt)

if __name__=="__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = max(cnt, ans)

print(ans)

Submission status: Accepted

Solution code:
S = input()
res = 0
l = ['A', 'C', 'G', 'T']
for i in range(len(S)):
  sub = 0
  for j in range(i, len(S)):
    if S[j] in l:
      sub += 1
    else:
      break
  if sub > res: res = sub
print(res)

Submission status: Accepted

Solution code:
S = list(input())

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

res = 0

t = 0

for s in S:
    if s in acgt:
        t += 1
    else:
        res = max(res, t)
        t = 0

res = max(res, t)

print(res)

Submission status: Accepted

Solution code:
s = input()
res = 0


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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
li = list(input())
ans = 0
num = 0
for i in range(len(li)):
    if li[i] == 'A' or li[i] == 'G' or li[i] == 'C' or li[i] == 'T':
        num += 1
    else:
        if ans < num:
            ans = num
        num = 0
if ans == 0:
    ans = num
if ans < num:
    ans = num
print(ans)

Submission status: Accepted

Solution code:
s = input()

acgt = 'ACGT'
res = cnt = 0
for i in s:
    if i in acgt:
        cnt += 1
    else:
        res = max(cnt, res)
        cnt = 0
res = max(cnt, res)
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=[0]
for i in input():
 if i in "ACGT":a+=[a[-1]+1]
 else:a+=[0]
print(max(a))

Submission status: Accepted

Solution code:
S = input()

max_len = 0
for i in range(10):
    for j in range(i, 10):
        s = S[i:j+1]
        for n, k in enumerate(s, 1):
            if k not in ['A', 'T', 'G', 'C']:
                break
            if n == len(s):
                max_len = max(max_len, len(s))
print(max_len)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n=[*'ACGT'];s=input();count,result=0,0
for i in range(len(s)):
  for j in range(i,len(s)):
    if s[j] not in n:
      break
    else:
      count+=1
  result=max(result,count)
  count=0
print(result)

Submission status: Accepted

Solution code:
lngs = input()

ACGT = ["A", "C", "G", "T"]
out_list = []
out_list_long = []


for lng in lngs:

    if lng in ACGT:
        out_list += lng
    else:
        if len(out_list) > len(out_list_long):
            out_list_long = []
            out_list_long = out_list
        out_list = []

if len(out_list) > len(out_list_long):
    out_list_long = []
    out_list_long = out_list

print(len(out_list_long))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import re

m = re.findall(r'[ATCG]+', input())
print(max([len(x) for x in m]) if m else '0')

Submission status: Accepted

Solution code:
import re

m = re.findall(r'[ATCG]+', input())
if m:
    print(max([len(x) for x in m]))
else:
    print('0')

Submission status: Accepted

Solution code:
S=input()
l=len(S)
ans=0
str='ACGT'
for i in range(l):
    for j in range(i,l):
        if all (str.count(x)==1 for x 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
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()

ans = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        sub_s = S[i:j+1]
        is_acgt = True
        for s in sub_s:
            if s == "A" or s == "C" or s == "G" or s == "T":
                continue
            else:
                is_acgt = False
        if is_acgt:
            ans = max(ans, len(sub_s))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
S = input()
T = re.findall(r'[ATGC]*', S)
print(len(max(T, key=len)))

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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


def check(T, usable: set):
    for t in T:
        if t not in usable:
            return 0
    return len(T)


def main():
    S = input().rstrip("\n")
    usable = {"A", "C", "G", "T"}
    candidates = []
    for i in range(len(S)):
        for j in range(i, len(S)):
            T = S[i:j+1]
            res = check(T, usable)
            candidates.append(res)

    print(max(candidates))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

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

l=0
for i in range(len(S)):
  for j in range(i+1,len(S)+1):
    s = set(S[i:j])
    if s <= {'A','C','G','T'} and len(S[i:j])>l:
      l = len(S[i:j])
      
print(l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    S = str(input())
    longest = 0
    if len(S) < 2:
        if S == 'A' or S == 'G' or S == 'C' or S == 'T':
            print(1)
            return
        else:
            print(0)
            return
    for i in range(len(S)):
        cnt = 0
        loop = 0
        t = 0
        while cnt == 0 and loop + i < len(S):
            if S[loop + i] == 'A' or S[loop + i] == 'G' or S[loop + i] == 'C' or S[loop + i] == 'T':
                t += 1
                if longest < t:
                    longest = t
                loop += 1
            else:
                cnt = 1
    print(longest)
main()

Submission status: Accepted

Solution code:
s = input()

counter = 0
max_counter = 0
for c in s:
    if c in 'ACGT':
        counter += 1
    else:
        counter = 0
    if max_counter < counter:
        max_counter = counter
print(max_counter)

Submission status: Accepted

Solution code:
s=input()
ans=0
for i in range(len(s)):
    for j in range(len(s)):
        new_s=list(s[i:(len(s)-j)])
        if all((i in ["A","T","G","C"]) for i in new_s) and len(new_s)>ans:
            ans=len(new_s)
print(ans)

Submission status: Accepted

Solution code:
s = input()
c = ["A","C","G","T"]
ans = 0
count = 0
f = False
for i,ss in enumerate(s):
    if i == 0 and s[i] in c:
        count = 1
        f = True
        continue
    if f:
        if s[i] in c:
            count += 1
        else:
            ans = max(count,ans)
            count = 0
            f = False
    else:
        if s[i] in c:
            count += 1
            f = True
ans = max(count,ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# abc122_b.py
# https://atcoder.jp/contests/abc122/tasks/abc122_b

# B - ATCoder /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 英大文字からなる文字列 Sが与えられます。Sの部分文字列 (注記を参照) であるような最も長い ACGT 文字列 の長さを求めてください。
# ここで、ACGT 文字列とは A, C, G, T 以外の文字を含まない文字列です。

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

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

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# Sの部分文字列であるような最も長い ACGT 文字列の長さを出力せよ。

# 入力例 1
# ATCODER

# 出力例 1
# 3

# ATCODER の部分文字列であるような ACGT 文字列のうち、最も長いものは ATC です。

# 入力例 2
# HATAGAYA

# 出力例 2
# 5

# HATAGAYA の部分文字列であるような ACGT 文字列のうち、最も長いものは ATAGA です。

# 入力例 3
# SHINJUKU

# 出力例 3
# 0

# SHINJUKU の部分文字列であるような ACGT 文字列のうち、最も長いものは (空文字列) です。


def calculation(lines):
    line = lines[0]
    # N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[1].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 0
    tmp = 0

    # print(f'line=[{line}]')

    for char in line:

        # print(f'char=[{char}]')

        if char == 'A':
            flag = True
        elif char == 'C':
            flag = True
        elif char == 'G':
            flag = True
        elif char == 'T':
            flag = True
        else:
            flag = False

        if flag:
            tmp += 1
            # print(f'result=[{result}], tmp=[{tmp}]')
            if result < tmp:
                result = tmp
        else:
            tmp = 0

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['ATCODER']
        lines_export = [3]
    if pattern == 2:
        lines_input = ['HATAGAYA']
        lines_export = [5]
    if pattern == 3:
        lines_input = ['SHINJUKU']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
words = input()

lst = ['A', 'C', 'G', 'T']
max_count = 0
count = 0
for i in range(len(words)):
  if words[i] in lst:
    count += 1
    if i == len(words) - 1:
      if count > max_count:
        max_count = count
  else:
    if count > max_count:
      max_count = count
    count = 0
print(max_count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

max_value = 0
count = 0
for c in s:
  if c in "ACGT":
    count += 1
  else:
    count = 0
  max_value = max(max_value, count)
print(max_value)

Submission status: Accepted

Solution code:
S = input()

ans = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        ok = True
        for k in range(i, j+1):
            if not (S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T"):
                ok = False
                break
        if ok:
            ans = max(ans, j - i + 1)

print(ans)

Submission status: Accepted

Solution code:
s=list(input())

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

Submission status: Accepted

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
chk_str = ""
chk = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        chk_str += s[i]
    else:
        if chk < len(chk_str):
            chk = len(chk_str)
        chk_str = ""
if chk < len(chk_str):
    chk = len(chk_str)
print(chk)

Submission status: Accepted

Solution code:
S = input()
RES = 0

def countACGT(s):
  res = 0
  res += s.count("A")
  res += s.count("C")
  res += s.count("G")
  res += s.count("T")
  if res == len(s):
    return res
  else:
    return 0

for i in range(len(S)+1):
  for j in range(len(S)+1):
    RES = max(RES,countACGT(S[i:j]))
print(RES)

Submission status: Accepted

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

def main():

    S = input()

    listS = list(S)

    listStr = ['A', 'C', 'G', 'T']
    counter = 0
    flag = False
    ans = 0

    for i in listS:
        if i in listStr:
            counter += 1
            if ans < counter:
                ans = counter
            flag = True

        else:
            flag = False
            counter = 0


    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

S = re.findall('[ACGT]*', input())
print(max([len(s) for s in S]))

Submission status: Accepted

Solution code:
a=list(input())
m=['A','C','G','T']
result=['']
for i in range(len(a)+1):
    for j in range(i):
        n=a[j:i]
        ans=0
        for k in range(len(n)):
            if n[k]=='A' or n[k]=='C' or n[k]=='G' or n[k]=='T':
                continue
            else:
                ans+=1
        if ans==0:
            result.append(n)
print(len(max(result,key=len)))

Submission status: Accepted

Solution code:
S = input()

max_len = 0

for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        bs = S[i:j]
        is_acgt = True
        for c in 'BDEFHIJKLMNOPQRSUVWXYZ':
            if c in bs:
                is_acgt = False

        if is_acgt:
            length = len(bs)
            if length > max_len:
                max_len = length

print(max_len)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
a = 0
count=[]

for i in range(len(S)):
  if S[i] in ["A", "C", "G", "T"]:
    a += 1
    count.append(a)
  else:
    a = 0
    count.append(a)
print(max(list(map(int, count))))

Submission status: Accepted

Solution code:
s=input()

score=0

for i in range(len(s)):
    for j in range(i,len(s)):
        isbad = 0
        for k in range(i,j+1):
            if s[k] != "A" and s[k] != "C" and s[k] != "G" and s[k] != "T": 
                isbad=1
                break
        if isbad==0:
            score = max(j+1-i,score)
            # print(s[i:j+1])
        
print(score)

Submission status: Accepted

Solution code:
x=["A","G","C","T"]
ans=0
now=0

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

Submission status: Accepted

Solution code:
S=input()
lst=['A','C','G','T']
ans=0
a=0
i=0
while i<len(S):
    if not (S[i] in lst):
        i+=1
    else:
        a=1
        i+=1
        while i<len(S) and S[i] in lst:
            a+=1
            i+=1
    if ans<a:
        ans=a
    a=0
print(ans)

Submission status: Accepted

Solution code:
S = input()

max_leng = 0
i = 0
while i < len(S):
  count = 0
  while S[i] == 'A' or S[i] == 'C' or S[i] == 'G'or S[i] == 'T':
    count += 1
    i += 1
    if i == len(S):
      break
  if max_leng < count:
    max_leng = count
  i += 1
print(max_leng)

Submission status: Accepted

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

Submission status: Accepted

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


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

    print(ans)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = list(input())
N = len(s)

ref = ["A","C","G","T"]
lst = []

for i in range(N):
    ans = ""
    if s[i] in ref:
        while s[i] in ref:
            ans = ans + s[i]
            i += 1
            if i >= N:
                break
    lst.append(ans)

ans = -float("inf")
for i in range(N):
    ans = max(ans, len(lst[i]))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

# 結果出力
print(ans)

Submission status: Accepted

Solution code:
S = input()

c = 0
m = 0

for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" :
        c += 1
        m = max(c,m)
    elif S[i] == "G" or S[i] == "T" :
        c += 1
        m = max(c,m)
    else :
        m = max(c,m)
        c = 0

print(m)

Submission status: Accepted

Solution code:
N = input()
ACGT = ["A", "C", "G", "T"]

ans = [0]
count = 0
for n in N:
    if n in ACGT:
        count += 1
    else:
        ans.append(count)
        count = 0
ans.append(count)
print(max(ans))

Submission status: Accepted

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

ans = 0
temp = 0
for res in tf:
    if res:
        temp += 1
    else:
        temp = 0
    ans = max(ans, temp)
print(ans)

Submission status: Accepted

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

for n in range(len(S)):
  T = S[n:]
  for t in T:
    if t in "ACGT":
      L[n]+=1
    else:
      break
      
print(max(L))

Submission status: Accepted

Solution code:
S = input()
n = len(S)
ma = 0
c = 0
for i in range(n):
    for j in range(i,n):
        c = 0
        for k in range(i,j+1):
            if not S[k] in 'ACGT':
                break
            c += 1
        ma = max(ma,c)

print(ma)

Submission status: Accepted

Solution code:
def abc122_b():
    s = input()
    ans = 0

    # listのスライス操作でバグらないように!!!
    # list[0]はすらいすでとろうとするとlist[0:1]

    acgt = list('ACGT')

    for i in range(len(s)):
        for j in range(i, len(s)):

            # スライスなので、jには1加える必要あり。
            if all([x in acgt for x in ｓ[i : j + 1]]):
                # ifとか書かなくてもmaxで大きいほうを勝手に格納してしまう
                ans = max(ans, len(ｓ[i : j + 1]))

    print(ans)

if __name__ == '__main__':
    abc122_b()

Submission status: Accepted

Solution code:

def abc122_b():
    s = input()
    acgt = ['A', 'C', 'G', 'T']

    check = [1 if s[i] in acgt else 0 for i in range(len(s))]

    result = 0
    for i in range(len(check)):
        for j in range(i, len(check)):
            if check[i : j + 1].count(0) == 0:
                if result < len(check[i:j + 1]):
                    result = len(check[i:j + 1])

    print(result)

if __name__ == '__main__':
    abc122_b()

Submission status: Accepted

Solution code:
S = input()
N = len(S)
l = []
for i in range(N):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        l.append(1)
    else:
        l.append(0)

#print(l)

ans = 0

for i in range(N):
    for j in range(i, N):
        tf = True
        for k in range(i, j + 1):
            if l[k] == 0:
                tf = False
        if tf == True:
            ans = max(ans, j - i + 1)
print(ans)

Submission status: Accepted

Solution code:
s = input()
res = 0
cnt = 0
for i in range(len(s)):
    if s[i] in 'ATGC':cnt += 1
    else:
        res = max(res, cnt)
        cnt = 0
print(max(res, cnt))

Submission status: Accepted

Solution code:
n = list(input())

count = 0

word = 0
flag = 0

for j in range(len(n)):
  if(flag == 0):
    if(n[j] == 'A' or n[j] == 'C' or n[j] == 'T' or n[j] == 'G'):
      word += 1
      flag = 1
  else:
    if(n[j] != 'A' and n[j] != 'C' and n[j] != 'T' and n[j] != 'G'):
      if(count < word):
        count = word
      word = 0
      flag = 0
    else:
      word += 1

if(count < word):
  count = word

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans = 0
ACGT = {"A", "C", "G", "T"}
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        if set(s[i:j]) <= ACGT:
            ans = max(ans, len(s[i:j]))
print(ans)

Submission status: Accepted

Solution code:
s=input()
cnt=0
mx=0
for i in s:
    if i in "ATGC":
        cnt+=1
        mx=max(cnt,mx)
    else:
        cnt=0

print(mx)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = 0
acgt = set(['A','C','G','T'])
for i in range(N):
    for j in range(i,N):
        if all(c in acgt for c in S[i:j+1]):
            ans = max(ans,j-i+1)
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	#全探索
	S = input()
	s_len = len(S)
	s1 = {"A","C","G","T"}
	
	m_len = 0
	for x in range(s_len):
		for y in range(x+1,s_len+1):
			s2 = set(S[x:y])
			s_union =  s1.union(s2)
			if len(s_union) == 4:
				m_len = max(m_len,len(S[x:y]))
	print(m_len)

Submission status: Accepted

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