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:
s = input()

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

Submission status: Accepted

Solution code:
S = list(input())

cnt=0
ans=0
for x in S:
    if x=="A" or x=="C" or x=="G" or x=="T":
        cnt+=1
    else:
        if ans < cnt:
            ans = cnt

        cnt=0

    if ans < cnt:
        ans = cnt

print(ans)

Submission status: Accepted

Solution code:
s = input()
l = len(s)
import collections
s = collections.deque(s)
ans = collections.deque()
chk = 0
for i in range(l):
  c = s.popleft()
  if c == 'A' or c == 'T' or c == 'C' or c == 'G':
    chk += 1
  else:
    ans.append(chk)
    chk = 0
ans.append(chk)
print(max(ans))

Submission status: Accepted

Solution code:
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
import time
from bisect import bisect_left, insort_left, bisect_right
import sys
import random
import itertools

input = sys.stdin.readline
_NUMINT_ALL = list(range(10))
_START_TIME = time.time()


def main():
    ans = solve()

    if ans is True or ans is False:
        YesNo(ans)
    elif ans is not None:
        print(ans)


def solve():

    s = input()

    ans = 0
    n = 0
    for i in s:
        if i in ("A", "C", "G", "T"):
            n += 1
        else:
            n = 0
        ans = max(n, ans)

    print(ans)


#####################################################ライブラリ集ここから




def kiriage_warizan(a, b):
    return -(-a//b)


def iip(listed=True):  # 数字のinputをlistで受け取る
    d = input().rstrip("\n").split()
    try:
        ret = [int(i) for i in d]
    except:
        ret = [int(i) if i in _NUMINT_ALL else i for i in d]
        if len(ret) == 1 and listed is False:
            return ret[0]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iipt(l, listed=True, num_only=True):  # 縦向きに並んでいるデータをリストに落とし込む(iip利用)
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed))
    return ret


def saidai_kouyakusuu(A):  # 最大公約数
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m

def time_debug_10percent():
    a = random.randint(0, 9)
    if a == 9:
        sys.exit()

def time_debug(t):
    time.sleep(_START_TIME + t - time.time())
    sys.exit()


def make_graph_edge_flat(N):  # グラフ作成のための辺をリストで返す
    ret = []
    for i in range(N-1):
        a, b, c = iip()
        a -= 1
        b -= 1
        ret[a].append((b, c))
        ret[b].append((a, c))
    return ret


def sort_tuples(l, index):  # タプルのリストを特定のインデックスでソートする
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  # リストの中身の個数を種類分けして辞書で返す
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  # listの中身を取り出す時、listからはみ出たり
    if index >= len(l):                      # マイナスインデックスになったりするのを防ぐ
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def sortstr(s):  # 文字列をソートする
    return "".join(sorted(s))


def iip_ord(startcode="a"):  # 文字列を数字の列に変換する(数字と文字は1:1対応)
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  # TrueFalseや1, 0をYesNoに変換する
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  # リストを平たくしてprintする(二次元リストを見やすくしたりとか)
    for i in s:
        print(i)


def bitall(N):  # ビット全探索用のインデックスを出力
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  # リストの中身をスペース区切りで出力する
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  # リストの中身を改行区切りで出力する
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  # 素因数分解
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  # nCrをmodを使って計算する
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):  #  modnにおける逆元を計算
    return power(n, mod - 2)


def power(n, p, mod_=mod):  # 繰り返し二乗法でn**p % modを計算
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


def nibutan_func(func, target, left, right, side="left"): # 関数を二分探索
    l = left
    r = right
    x = (l + r) // 2
    while r-l > 1:
        x = (l+r)//2
        if func(x) == target:
            return x
        elif func(x) > target:
            r = x
        else:
            l = x

    if side == "left" or func(x) == target:
        return l
    else:
        return r


def nibutan_list(list_, target, side="left"):  # リストを二分探索
    if not isinstance(list_, list):
        list_ = list(list_)

    l = 0
    r = len(list_)
    x = (l + r) // 2
    while r-l > 1:
        x = (l+r)//2
        if list_[x] == target:
            return x
        elif list_[x] > target:
            r = x
        else:
            l = x

    if side == "left" or list_[x] == target:
        return l
    else:
        return r


class UfTree():
    def __init__(self, maxnum):
        self.parent = list(range(maxnum))
        self._size = [1] * maxnum
        self.rank = [0] * maxnum

    def size(self, a):
        return self._size[self.root(a)]

    def root(self, a):
        rank = 0
        cur = a
        while True:
            if self.parent[cur] == cur:
                #for i in path: # 経路圧縮
                #    self.parent[i] = cur
                return cur
            else:
                self.parent[cur] = self.parent[self.parent[cur]]
                cur = self.parent[cur]
                rank += 1

    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return self

        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        return self

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=input()
res=0
for i in range(len(S)+1):
    for j in range(i):
        t=True
        s=S[j:i]
        for k in range(len(s)):
            if(s[k]!='A' and s[k]!='C' and s[k]!='G' and s[k]!='T'):
                t=0
                break
        if(t):
            res=max(res,len(s))
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

for left in range(n):
    right = left
    while (right < n and S[right] in {'A', 'T', 'G', 'C'}):
        maxs = max(maxs, S[left:right+1], key=len)
        right += 1

print(len(maxs))

Submission status: Accepted

Solution code:
import numpy as np
import sys
readline = sys.stdin.readline
read = sys.stdin.read

b = readline().rstrip()
ans = 0
i = 0
while i < len(b):
	cnt = 0
	while i < len(b) and (b[i] == 'A' or b[i] == 'T' or b[i] == 'G' or b[i] == 'C'):
		cnt += 1
		i += 1
	if cnt > ans:
		ans = cnt
	i += 1
print(ans)

Submission status: Accepted

Solution code:
S = input()
max = 0

if len(S) == 1:
    if S == 'A' or S == 'C' or S == 'G' or S == 'T':
        max = 1
    else:
        max = 0
    print(max)
    quit()


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

print(max)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def isACGT(a):
    return a in ['A', 'C', 'G', 'T']

def main():
    n = input()
    max_len = 0
    for i in range(len(n)):
        cnt_len = 0
        if isACGT(n[i]):
            cnt_len += 1
            for j in range(i+1, len(n)):
                if isACGT(n[j]):
                    cnt_len += 1
                else:
                    break
        if cnt_len > max_len:
            max_len = cnt_len
    print(max_len)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = input()
L = "ACGT"
ans = ""
ss = ""
for i in range(len(s)):
  if s[i] in L:
    ans += s[i]
    if i == len(s)-1:
        if len(ans)>len(ss):
            ss = ans
            #print(len(ss))
  else:
    if len(ans)>len(ss):
      
      ss = ans
      #print(ans,ss)
      ans = ""
print(len(ss))

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:
s = list(input())
n = len(s)

def atcg(s):
    slength = len(s)
    cnt = 0
    for i in range(slength):
        if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
            cnt +=1
        else:
            break
    return cnt

ans = []
for i in range(n):
    ans.append(atcg(s[i:]))


print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
length = []
t = 0
for i in range(len(S)):
  if S[i] == "A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
    t += 1
  else:
    length.append(t)
    t = 0
length.append(t)
print(max(length))

Submission status: Accepted

Solution code:
a = input()
check = 'ACGT'
ans_list = []
for p in range(len(a)):
    for q in range(len(a)-1):
        
        count = 0
        for r in range(len(a[p:len(a)-q])):
            
            if a[p:len(a)-q][r] in check:
                count += 1
                if count == len(a[p:len(a)-q]):
                    ans_list.append(a[p:len(a)-q])
                    break
ls =[]
for i in range(len(ans_list)):
    ls.append(len(ans_list[i]))
if len(ls) == 0:
    if a[0] in check:
        print(1)
    else:
        print(0)
else:
    print(max(ls))

Submission status: Accepted

Solution code:
s = input()

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

ans = 0
ans_max = 0
flg = False
for c in s:
    if c in ACGT:
        ans += 1
        flg = True
    elif flg:
        ans_max = max(ans_max, ans)
        ans = 0
        flg = False

ans_max = max(ans_max, ans)

print(ans_max)

Submission status: Accepted

Solution code:
a = list(input())
ans = 0
count = 0
for i in a:

    if i == 'A':
        count +=1
    elif i == 'C':
        count+=1
    elif i == 'G':
        count+=1
    elif i == 'T':
        count+=1
    else:
        ans = max(ans ,count)
        count = 0

print(max(ans,count))

Submission status: Accepted

Solution code:
S = input()
n = len(S)
ans = 0
for i in range(n):
    for j in range(n):
        begin = i
        end = n-j
        if begin >=end:continue
        s = S[begin:end]
        ok = True
        for x in s:
            if x!='A' and x !='G' and x!='C' and x != 'T':
                ok = False
                break
        if ok:ans = max(ans,len(s))
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
agct = ['A','G','C','T']
count = 0
max_count = 0
for key in S:
    if key in agct:
        count += 1
    else:
        max_count = max(max_count,count)
        count = 0
print(max(count,max_count))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

s = readline()
n = len(s)
answer = 0
for i in range(n):
    for j in range(i, n):
        t = s[i:j + 1]
        if set(t) <= set('ACGT'):
            answer = max(answer, j - i + 1)
print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

s = readline()
n = len(s)
count = 0
max = 0
for i in range(n):
    if s[i] in 'ACGT':
        count +=1
        if max < count:
            max = count
    else:
        count = 0
print(max)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 122
# B - ATCoder
# https://atcoder.jp/contests/abc122/tasks/abc122_b

S = input()
n = len(S)

maxl = 0
for i in range(n):
    for j in range(i, n):
        for s in S[i:j+1]:
            if s not in 'ACGT':
                break
        else:
            if maxl < j-i+1:
                maxl = j-i+1

print(maxl)

Submission status: Accepted

Solution code:
s = input()

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

sub = []
for i in range(len(s)):
  for j in range(i+1,len(s)+1):
    tmp = s[i:j]
    flag = True
    for k in range(len(tmp)):
      if tmp[k] in lis:
        pass
      else:
        flag = False
    if flag: sub.append(tmp)
      
ma = 0
for i in sub:
  l = len(i)
  if l > ma: ma = l
print(ma)

Submission status: Accepted

Solution code:
import re
print(max(map(len, re.findall("[ACGT]*", input()))))

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
S = input()
c = 0
MAX = 0

for i in S:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        c += 1
        if MAX < c:
            MAX = c

    else:
        c = 0

print(MAX)

Submission status: Accepted

Solution code:
S = list(input())

C = 0
ans = 0


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

print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0
temp = 0
for x in S:
    if x in ["A", "G", "C", "T"]:
        temp += 1
        ans = max(ans, temp)
    else:
        temp = 0

print(ans)

Submission status: Accepted

Solution code:
s = input()
_s = {"A", "C", "G", "T"}
t = 0
ans = 0
for i in s:
    if i in _s:
        t += 1
        ans = max(ans, t)
    else:
        t = 0

print(ans)

Submission status: Accepted

Solution code:
s = input()
_s = {"A", "C", "G", "T"}
t = 0
ans = 0
for i in s:
    if i in _s:
        t += 1
    else:
        ans = max(ans, t)
        t = 0

ans = max(ans, t)

print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = 0
for i in range(len(s) - 1):
    if s[i] not in {'A', 'C', 'G', 'T'}:
        continue
    length = 1
    for j in range(i + 1, len(s)):
        if s[j] not in {'A', 'C', 'G', 'T'}:
            break
        length += 1
    ans = max(ans, length)
if len(s) == 1:
    ans = 0 if s not in {'A', 'C', 'G', 'T'} else 1
print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    n = len(S)
    acgt = ['A', 'C', 'G', 'T']
    cnt = 0
    maxlen = 0
    for i in range(n):
        if S[i] in acgt:
            cnt += 1
            maxlen = max(maxlen, cnt)
        else:
            cnt = 0
    print(maxlen)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    n = len(S)
    acgt = ['A', 'C', 'G', 'T']
    maxlen = 0
    for i in range(n):
        tmp = 0
        if S[i] in acgt:
            tmp += 1
            for j in range(i+1, n):
                if S[j] in acgt:
                    tmp += 1
                else:
                    break
            maxlen = max(maxlen, tmp)
    print(maxlen)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

solution()

Submission status: Accepted

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

solution()

Submission status: Accepted

Solution code:
def solution():
    s = input()
    acgt = ['A','C','G','T']
    st = None
    ed = None
    cnt = 0
    ans = 0
    for i in range(len(s)):
        cnt = 0
        for ss in s[i:]:
            if ss in acgt:
                cnt += 1
            else:
                break
        ans = max(cnt, ans)
    print(ans)

solution()

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
S=list(input())
A=[0]*10
c=0
for i in range(len(S)):
  if S[i]=="A" or S[i]=="G" or S[i]=="C" or S[i]=="T":
    A[c]+=1
  else:
    c+=1
print(max(A))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
List = list(S)

ans = 0
arr = []
for i in range(len(List)):
  if List[i] == "A" or List[i] == "C" or List[i] == "G" or List[i] == "T":
    ans += 1
  else:
    arr.append(ans)
    ans = 0
    
arr.append(ans)

print(max(arr))

Submission status: Accepted

Solution code:
s = input()
ans = 0
leng = 0
t = ('A','C','G','T')

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

Submission status: Accepted

Solution code:
import re

S = input()
S = re.sub('[^ACGT]', '_', S)
S = S.split('_')
ans = 0
for s in S:
    ans = max(ans, len(s))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
ans = 0
lst = ['A','T','G','C']
for i in range(n):
    if s[i] not in lst:
        continue
    cnt = 0
    for j in range(i,n):
        if s[j] not in lst:
            break
        cnt += 1
    ans = max(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
s = input()
n = len(s)
ans = 0
cnt = 0
for i in range(n):
    if s[i] in ["A", "C", "G", "T"]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
listS = list(S)
N = []
dic = ['A', 'T', 'G', 'C']
count = 0
for i in range(len(listS)):
    if listS[i] in dic:
        count += 1
        N.append(count)
    else:
        count = 0
        N.append(count)
print(max(N))

Submission status: Accepted

Solution code:
import re
s = input()
m = re.findall(r'[A|T|C|G]+', s)
maxlen = 0
for tmp in m:
    maxlen = max(len(tmp), maxlen)
print(maxlen)

Submission status: Accepted

Solution code:
s = input()
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 = 0
        j = i
        while s[j] == "A" or s[j] == "C" or s[j] == "G" or s[j] == "T":
            j = j + 1
            count = count + 1
            if j == len(s):
                break

        ans = max(ans, count)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  s = input() + "X"
  TMP = ['A','C','G','T']
  Nya = 0
  flag = False
  i = 0
  first = 0
  last = 0
  while i != len(s):
    if s[i] in TMP:
      if not flag:
        #print(i,'Change!')
        flag = True
        first = i
    else:
      if flag:
        #print(i,'End!')
        flag = False
        last = i
    Nya = max(Nya,abs(first-last))
    i += 1
  LIST = list(s)
  print(Nya)
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
b=input()

ans = 0
ans_list = [0]*len(b)
for i in range(len(b)):
  if (b[i] == 'A')or (b[i] =='C')or(b[i] =='G')or(b[i] =='T'):
    ans += 1
  else:
    ans = 0
  ans_list[i] = ans
print(max(ans_list))

Submission status: Accepted

Solution code:
S = input()
N = len(S)
L = ["A", "T", "C", "G"]
ans = 0

for i in range(N):
    for j in range(N-i):
        sub = S[j:j+i+1]
        for k in range(len(sub)):
            if sub[k] not in L:
                break
        else:
            ans = len(sub)

print(ans)

Submission status: Accepted

Solution code:






def resolve():
    S= input()

    x=[len(i) for i in "".join(([ i if i in "ACGT" else " " for i in S])).split()]

    if not x:
        print(0)
    else:
        print(max(x))


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
S = list(input())
ACGT = ['A', 'C', 'G', 'T']
Ans = 0

for i in range(len(S)):
    tmp = 0
    for j in range(i, len(S)):
        if S[j] in ACGT:
            tmp += 1
            Ans = max(Ans, tmp)
            continue
        else:
            break
        
print(Ans)

Submission status: Accepted

Solution code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    s = input()
    b = ["A","C","G","T"]

    max =0
    count = 0
    for i in s:
        if i in b:
            count +=1
        else:
            count =0
        if max < count:
            max =count

    print(max)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

S = input()

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

ans = 0
tmp = 0
for ch in S:
    if ch in ch_list:
        tmp += 1
        ans = max(ans, tmp)
    else:
        tmp = 0 

print(ans)

Submission status: Accepted

Solution code:
s=str(input())
cnt=0
for i in range(len(s)):
    tmp=0
    for j in range(len(s)-i):
        
        if(s[i+j]=="A"or s[i+j]=="C"or s[i+j]=="G" or s[i+j]=="T"):
            tmp+=1
        else:
            break
    cnt = max(cnt,tmp)

print(cnt)

Submission status: Accepted

Solution code:
s =input()
s += ' '
ACGT = ['A', 'C', 'G', 'T']

cnt_list = []
cnt = 0
for i in s:
    if i in ACGT:
        cnt += 1
    else:
        cnt_list.append(cnt)
        cnt = 0
print(max(cnt_list))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
acgt = "AGCT"
for i in range(len(S)):
    count = 0
    if S[i] not in acgt:
        continue
    else:
        count += 1
    for j in range(i + 1, len(S)):
        if S[j] in acgt:
            count += 1
        else:
            break
    ans = max(ans, count)
print(ans)

Submission status: Accepted

Solution code:
s = list(input())

ans = [0]*10
for i in range(len(s)):
  if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
    ans[i] += 1
    
count = 0    
cnt = []
for i in range(10):
  if ans[i] == 0:
    cnt.append(0)
    count = 0
  else:
    count += 1
    cnt.append(count)
    
print(max(cnt))

Submission status: Accepted

Solution code:
S = list(input())

def judge(s):
    if s == "A" or s == "C" or s =="G" or s =="T":
        return True
    else:
        return False

pt_l,pt_r,ans = 0,0,0
while pt_r < len(S):
    if judge(S[pt_r]):
        pt_r += 1
    else:
        ans = max(ans,pt_r - pt_l)
        pt_l = pt_r+1
        pt_r = pt_l
ans = max(ans,pt_r - pt_l)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
for i in range(len(s)+1):
    for j in range(len(s)-i+1):
        if [k for k in s[j:j+i]] == [k for k in s[j:j+i] if k=='A' or k=='G' or k=='C' or k=='T']:
            a=i
print(a)

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,len(S)+1):
        clipped_list = list(S[i:j])
        clipped = set(clipped_list)
        for acgt in ACGT:
            try:
                clipped.remove(acgt)
            except:
                pass
        if clipped == set():
            ans = max(ans,len(clipped_list))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
ans=0
cnt=0
# Sを1文字ずつとる
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:
s = str(input())
m = ['A','G','C','T']
ans = 0
cnt = 0
for c in s:
    if c in m:
        cnt += 1
    else:
        ans = max(cnt,ans)
        cnt = 0
else:
    ans = max(cnt,ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ACGT = "ACGT"
cnt = 0
ans = 0

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

print(max(ans, cnt))