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:
# -*- coding: utf-8 -*-
import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation



'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  # [1, 0, 3]

'''

def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''


########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

def main():
    w=1
    steps=0
    state=0
    j=0
    k=0
    le=0
    ans=0
    dic=['A','C','G','T']
    #n=int(input())
    #a,b=map(int, input().split(" "))
    S=input()

    a=[i for i in S]#int取るとstrでも行ける
    #nl=list(map(int, input().split(" ")))#数字の時
    #print(a)
    for i in range(len(S)):
        if a[i] in dic:
            le +=1
            ans=max(le,ans)
            #どこで値を更新するかはとても大切
        else:
            ans=max(le,ans)
            le=0


    print(ans)
    '''
    out = 0
    tmp = 0
    for s in S:
        if s in 'ACGT':
            tmp += 1
            out = max(tmp, out)
        else:
            tmp = 0
    print(out)
    '''
    #if state in known_states and not flag: # state => 2 steps => 5
        #こうやってある要素がリストの中にあるか探すのか
    #print(f'steps: {steps}, state: {state}')
    #こう書いてあるとデバックしやすい

    #dp= [[0]*3 for i in range(5)]#列　行
    #dp用の0の入ったやつ
    #dp= [[0]*(w+1) for i in range(n+1)]#0からwまでのw+1回計算するから
    #print(dp)＃初期条件が入る分計算回数+1列分必要(この場合は判断すべきものの数)
    DP = np.zeros(w+1, dtype=int)#これでも一次元リストが作れる
    exdp=np.zeros((3,4)) # ３×４の２次元配列を生成。2次元ならこう
    #dtypeは指定しないとfloatになる
    #for i in range(n):#ちょっとした入力に便利
    #    a, b = map(int, input().split())
        #dp[i][0] += [a]
        #これだとintとlistをつなぐことになって不適
    #    dp[i] += [a]
    #    dp[i] += [b]
        #これはうまくいく
        #やり方はいろいろあるということ
    #print(dp)


    "1行1つの整数を入力を取得し、整数と取得する"
    #nl=list(map(int, input().split(" ")))#数字の時
    #print(number_list)
    "12 21 332 とか入力する時に使う"
    "1行に複数の整数の入力を取得し、整数として扱う"
    #brray=[list(map(int, input().split(" ")))for i in range(N)
    #print(brray)


    #s=input()
    #a=[int(i) for i in s]#int取るとstrでも行ける
    #print(a)
    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]#内包表記に慣れろ
    #print(pin_l)

    ls = ["a", "b", "c", "d", "e"]


    #print(ls[2:5])
    #スライスでの取得

    #print(ls[:-3])
    #一番左端から右から3番目より左まで取得

    #print(ls[:4:2])
    #スライスで1個飛ばしで取得
    #ないときは左端スタート
    #始点のインデックス番号 : 終点のインデックス番号 : スキップする数+1
    #print(ls[::2])
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

out = 0
tmp = 0
for s in S:
  if s in 'ACGT':
    tmp += 1
    out = max(tmp, out)
  else:
    tmp = 0
print(out)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

max_cnt = 0
cnt = 0
for c in S:
    if c in "ACGT":
        cnt += 1
        if cnt > max_cnt:
            max_cnt = cnt
    else:
        cnt = 0

print(max_cnt)

Submission status: Accepted

Solution code:
s = input()
s_list = list(s)
a_list = ['A','C','G','T']
c = 0
ans = 0
k = 0
for hoge in s_list:
  if hoge in a_list:
    c += 1
  else:
    ans = max(ans,c)
    c = 0
  k += 1
  if k == len(s_list):
    ans = max(ans,c)
print(ans)

Submission status: Accepted

Solution code:
def solve(S):
    ret = 0
    tmp_ret = 0
    for s in S:
        if s in ["A", "T", "C", "G"]:
           tmp_ret += 1
        else:
            ret = max(ret, tmp_ret)
            tmp_ret = 0
    ret = max(ret, tmp_ret)
    return ret

if __name__ == '__main__':
    S = input()
    print(solve(S))

Submission status: Accepted

Solution code:
#ABC122B
def main():
    import sys
    S = sys.stdin.readline().rstrip()
    #print(S)
    L = ['A', 'C', 'G', 'T']
    cnt, ans = 0, 0
    for s in S:
        if s in L:
            cnt+=1
        else:
            if ans < cnt:
                ans = cnt
            #print(ans)
            cnt=0
    else:
        if ans < cnt:
            ans = cnt
    print(ans)


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    S = input() + 'Z'
    flag = False
    length = 0
    ans = 0
    for i, c in enumerate(S):
        if flag and (c == 'A' or c == 'T' or c == 'C' or c == 'G'):
            length += 1
        elif flag:
            ans = max(ans, length)
            length = 0
            flag = False
        elif c == 'A' or c == 'T' or c == 'C' or c == 'G':
            flag = True
            length = 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

s = input()
for i in range(len(s)):
    if s[i] in ['A','C','G','T']:
        f = 1
    else:
        f = 0
    if f:
        neko = neko + 1
    if nya < neko:
        nya = neko
    if f == 0:
        neko = 0
print(nya)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
max = 0
for i in range(len(s)):
    c = 0
    if s[i] != 'A' and s[i] != 'T' and s[i] != 'G' and s[i] != 'C':
        continue
    c += 1
    for j in range(i + 1, len(s)):
        if s[j] == 'A' or s[j] == 'T' or s[j] == 'G' or s[j] == 'C':
            c += 1
        else:
            break
    if max < c:
         max = c
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

S = list(input())
tmp = 0
count = 0

for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp += 1
        if count < tmp:
            count = copy.copy(tmp)
    else:
        tmp = 0

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    S=input()
    s="AGCT"
    cnt=0
    ans=0
    for i in range(len(S)):
        if S[i] in s:
            cnt+=1
        else:
            ans=max(ans,cnt)
            cnt=0
    ans=max(ans,cnt)
    print(ans)

#%%submit!    
resolve()

Submission status: Accepted

Solution code:
s = input()

max_len = 0
len_tmp = 0
for i in s:
    if i in "ATGC":
        len_tmp += 1
    else:
        max_len = max(max_len, len_tmp)
        len_tmp = 0
print(max(max_len, len_tmp))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
import itertools
def judge(k):
    if s[k] == "A" or s[k] == "C" or s[k] == "G" or s[k] == "T":
        return True
    return False

ans = 0
for comb in itertools.combinations(range(len(s)),2):
    i,j = comb
    true = 1
    for k in range(i,j+1):
        if not judge(k):
            true = 0
            break
    if true == 1:
        ans = max(ans,j-i+1)
if ans == 0:
    for k in range(len(s)):
        if judge(k):
            ans = 1
            break
print(ans)

Submission status: Accepted

Solution code:
s=input()

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

res=max(res,cnt)
print(res)

Submission status: Accepted

Solution code:
s = input()
dp = [0]*(len(s) + 1)

for i, x in enumerate(s):
    if x in "ACGT":
        dp[i+1] = dp[i] + 1
print(max(dp))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
n= len(S)
m = 0
def isACGT(str):
    return all(list(map(lambda c: c in 'ATCG', str)))

for i in range(n):
    for j in range(i+1, n+1):
        if isACGT(S[i:j]):
            m = max(m, j-i)

print(m)

Submission status: Accepted

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


S = input()
ml = 0
for l in range(len(S)+1):
    for r in reversed(range(len(S)+1)):
        if l <= r and is_acgt(S[l:r]):
            ml = max(ml, r-l)
print(ml)

Submission status: Accepted

Solution code:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

s=s0()

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

Submission status: Accepted

Solution code:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

s=s0()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

inf = float("inf")


def count(S):
    ret = 0
    for s in S:
        if s in 'AGCT':
            ret += 1
        else:
            return 0
    return ret

def main():
    S = input()
    length = len(S)
    ret = 0
    
    for i in range(length):
        if i == 0:
            ret = count(S)
        else:
            for j in range(i+1):
                _S = S[j:length-(i-j)]        
                ret = max(ret, count(_S))
                
    print(ret)
        
      
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    from sys import stdin
    s = str(stdin.readline().rstrip())
    n = len(s)
    dp = [0]*(n+1)
    g = set({"A","T","C","G"})
    l ="0"+s
    for i in range(1,n+1):
        if l[i] in g:
            dp[i]=dp[i-1]+1
        else:
            dp[i]=0
    
    print(max(dp))
main()

Submission status: Accepted

Solution code:
S= str(input())
#N,K = map(int,input().split())
#N = int(input())
#V = list(map(int,input().split()))
C=[]
c=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='T' or S[i]=='C' or S[i]=='G':
        c+=1
    else:
        C.append(c)
        c=0
C.append(c)
print(max(C))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    t = 'ATGC'
    ans = 0
    S = input()
    temp = 0
    for s in S:
        if s in t:
            temp += 1
        else:
            ans = max(ans, temp)
            temp = 0

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    t = 'ATGC'
    ans = 0
    s = input()
    temp = 0
    for i in range(len(s)):
        temp = 0
        if s[i] in t:
            temp += 1
            for j in range(i+1, len(s)):
                if s[j] in t:
                    temp += 1
                else:
                    break
            ans = max(ans, temp)

    print(ans)

if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
S = input()

cnt = 0
ml = 0

for i in range (len(S)):
  cnt = 0
  for j in range(i+1, len(S)+1):
    cnt = S[i:j].count("A") + S[i:j].count("T") + S[i:j].count("G") + S[i:j].count("C") 
    
    if cnt == len(S[i:j]) and cnt > ml:
      ml = cnt
  
print(ml)

Submission status: Accepted

Solution code:
s = input()

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

max_len = 0
cnt = 0
for i in s:
    if i in acgt:
        cnt += 1
        if max_len < cnt:
            max_len = cnt
    else:
        cnt = 0
print(max_len)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ACGT = ['A','C','G','T']
NS = []
for i in S:
    if i in ACGT:
        NS.append('A')
    else:
        NS.append(' ')
L = ''.join(NS).split()
max_l = 0
for l in L:
    max_l = max(max_l, len(l))
print(max_l)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
s = {"A", "T", "C", "G"}

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

Submission status: Accepted

Solution code:
S = input()

ACGT = ('A', 'C', 'G', 'T')

def is_ACGT(string):
  for c in string:
    if c not in ACGT:
      return False
  return True


max_len = 0
for i in range(len(S)+1):
  for j in range(i+1, len(S)+1):
    sub = S[i:j]
    if is_ACGT(sub):
      max_len = max(max_len, len(sub))

print(max_len)

Submission status: Accepted

Solution code:


def main():
    s = input()
    res = 0
    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]):
                res = max(res, j-i+1)
    print(res)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = list(input())
l = []
for i in range(len(s)):
    j = i
    

    cnt = 0
    if s[i] in ["A",'C','G','T']:
        cnt +=1
        while j <= len(s)-2 :
            j = j + 1    
            if s[j] in ["A",'C','G','T']:
                cnt += 1
            else:
                break
    l.append(cnt)
print(max(l))

Submission status: Accepted

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

Submission status: Accepted

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

for char in S:
    if char in 'ACGT':
        count += 1
    else:
        count = 0
    ans = max(ans, count)
print(ans)

Submission status: Accepted

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

s = list()
for i in range(N):
    if S[i] == "A" or S[i] == "T" or S[i] == "G" or S[i] == "C":
        s.append(1)
    else:
        s.append(0)
#print(s)

lz = list()
cnt = 0
for i in range(N):
    if s[i] == 1:
        if cnt == 0:
            cnt = 1
        else:
            cnt += 1
    else:
        lz.append(cnt)
        cnt = 0
lz.append(cnt)
print(max(lz))

Submission status: Accepted

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

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):
        s = S[i:j]
        tmp = 0
        for ss in s:
            if ss not in acgt: break
            tmp += 1
        ans = max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
def solve():
    S = input()
    ans = 0
    serial = 0
    for s in S:
        if s in 'ATGC':
            serial += 1
        else:
            ans = max(ans,serial)
            serial = 0
    ans = max(ans,serial)
    return ans
print(solve())

Submission status: Accepted

Solution code:
l=list(input())
N=len(l)
Long=list()
for i in range(N):
  long=0
  for x in range(i,N):
    if l[x]=='A' or l[x]=='T' or l[x]=='C' or l[x]=='G':
      long+=1
    else:
      break
    Long.append(long)
if len(Long)==0:
  print('0')
else:
  print(max(Long))

Submission status: Accepted

Solution code:
s = input()
s += "B"# AGCT以外の適当な文字

max_len = 0

count = 0
for i in s:
    if i in "ACGT":
        count += 1
    else:
        max_len = max(max_len,count)
        count = 0

print(max_len)

Submission status: Accepted

Solution code:
s = input()

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

tmp_ans = 0
ans = 0
for c in s:
    if c in valid_chars:
        tmp_ans += 1
        ans = max(tmp_ans, ans)
    else:
        tmp_ans = 0

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
S = input()
c = 0
m = 0
for i in S:
    if 'A' == i or 'C' == i or 'G' == i or 'T' == i:
        c += 1
        m = max(c, m)
    else:
        c = 0
print(m)

Submission status: Accepted

Solution code:
S = list(input())

length_max = 0
for i in range(len(S)):
    if S[i] in ["A", "G", "C", "T"]:
        length = 1
        for j in range(i+1, len(S)):
            if S[j] in ["A", "G", "C", "T"]:
                length += 1
            else:
                break
        if length > length_max:
            length_max = length
print(length_max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定



# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
s = input()
n = len(s)
ans = 0
for i in range(n):
    for j in range(i + 1, n + 1):
        t = s[i : j]
        ok = True
        for k in t:
            if k not in ["A", "C", "G", "T"]:
                ok = False
                break
        if ok:
            ans = max(ans, j - i)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri May  8 01:38:54 2020

@author: Kanaru Sato
"""

s = list(input())
count = 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":
        count += 1
        ans = max(ans,count)
    else:
        count = 0

print(ans)

Submission status: Accepted

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

for i in range (len(S)):
  cnt = 0
  for j in range (i+1, len(S)+1):
    cnt = S[i:j].count("A")+ S[i:j].count("T")+ S[i:j].count("G")+ S[i:j].count("C")
   
    if cnt == len(S[i:j]) and cnt > ml:
      ml = cnt
      
print(ml)

Submission status: Accepted

Solution code:
S = input()

max_len = 0
counter = 0
for i in S:
    if i in 'ACGT':
        counter += 1
        if max_len < counter:
            max_len = counter

    else:
        counter = 0
    

print(max_len)