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:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

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

mod = 1000000007

if __name__ == "__main__":
    S= list(sys.stdin.readline().rstrip())
    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]): #all()は中身がすべてTrueならTrueを返す。S部分文字列から１個ずつ取り出して"ACGT".count(c) == 1で判定
                ans = max(ans, j-i+1)
            # print(all("ACGT".count(c) == 1 for c in S[i:j+1]))

    print(ans)

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
# ABC 122 B

S = input()

def isValidChar(c):
    if c == 'A' or c == 'C' or c == 'G' or c == 'T':
        return True
    else:
        return False

tmpLen = 0
maxLen = 0

for i in range(len(S)):
    if isValidChar(S[i]):
        tmpLen += 1
        maxLen = max(maxLen, tmpLen)
    else:
        tmpLen = 0

print(maxLen)

Submission status: Accepted

Solution code:
s = input()
lis = ["A", "G", "C", "T"]
count = 0
ans = 0

for i in range(len(s)):
    for j in range(i, len(s)):
        if s[j] in lis:
            count += 1
        else:
            break
    ans = max(ans, count)
    count = 0

print(ans)

Submission status: Accepted

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


def check(T):
    M = len(T)
    for m in range(M):
        if T[m] not in "ATCG":
            return False
    return True


ans = 0
for i in range(N):
    for j in range(i + 1, N + 1):
        T = S[i:j]
        if check(T):
            ans = max(ans, len(T))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())
max_length = 0
combo = 0
bases = set("ATGC")
for i in range(len(S)):
    if S[i] in bases:
        combo += 1
        if max_length < combo:
        	max_length = combo
    else:
        combo = 0

print(max_length)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Str = list(input())
tmp = 0
maxLen = 0

for s in Str:
    if s in "ACGT":
        tmp += 1
        maxLen = max(maxLen, tmp)
    else:
        tmp = 0


print(maxLen)

Submission status: Accepted

Solution code:
S = input()
n = [0]
k=0
for c in S:
    if c in 'ACGT':
        k+=1
    elif k>0:
        n.append(k)
        k=0
if k>0: n.append(k)

print(max(n))

Submission status: Accepted

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

cnt = 0
max_s = 0

for s in S_list:
    if (s == "A") or (s == "C") or (s == "G") or (s == "T"):
        cnt += 1
    else:
        if max_s < cnt:
            max_s = cnt
        cnt = 0
if max_s < cnt:
    max_s = cnt
print(max_s)

Submission status: Accepted

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

cnt = 0



for i in range(N):
    for j in range(i, N):
        if all([s in "ACGT" for s in S[i:j+1]]):
            cnt = max(cnt, len(S[i:j+1]))

print(cnt)

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
a = input()
b = 0
c = 0
for i in range(len(a)):
    if a[i] in list("ACGT"):
        b += 1
        c = max(c, b)
    else:
        b = 0
print(c)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
S = input()
ACGT = ["A","C","G","T"]
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:
print(len(max(''.join(['a' if t in ['A','T','G','C'] else ',' for t in input()]).split(','))))

Submission status: Accepted

Solution code:
print(max([len(x) for x in ''.join(['a' if t=='A' or t=='T' or t=='G' or t=='C' else ',' for t in input()]).split(",")]))

Submission status: Accepted

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

if count > ans:
    ans = count
print(ans)

Submission status: Accepted

Solution code:
a = input()
b = c = 0
d = list("ACGT")
for i in range(len(a)):
    if a[i] in d:
        c += 1
        b = max(b, c)
    else:
        c = 0
print(b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def counter(p):
    if p == 'A':
        return 1
    elif p == 'C':
        return 1
    elif p == 'G':
        return 1
    elif p == 'T':
        return 1
    else:
        return 0

count = 0
max_b = 0

S = input()
Sl = list(S)

for i in Sl:

    if counter(i) == 1:
        count += 1
    else:
        count = 0
    
    max_b = max(max_b,count)

print(max_b)

Submission status: Accepted

Solution code:
S = input()

def AGCT(S,i):
    if S[i] == "A" or S[i] == "T" or S[i] == "G" or S[i] == "C":
        return 0
    else:
        return 1

c = 0
ANS = []
for i in range(len(S)):
    if AGCT(S,i) == 0:
        c += 1
    else:
        ANS.append(c)
        c = 0
ANS.append(c)
print(max(ANS))

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
tmp = 0

for s in S:
    if s in ACGT:
        tmp += 1
        if ans < tmp:
            ans = tmp
    else:
        tmp = 0

print(ans)

Submission status: Accepted

Solution code:
def main():

    """ convenient functions
    # for i, a in enumerate(iterable)
    # q, mod = divmod(a, b)
    # divmod(x, y) returns the tuple (x//y, x%y)
    # Higher-order function: reduce(operator.mul, xyz_count, 1)
    # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
    """

    """convenient decorator
    # @functools.lru_cache():
    # to facilitate use of recursive function
        # ex:
        # from functools import lru_cache
        # import sys
        # sys.setrecursionlimit(10**9)
        # @lru_cache(maxsize=None)
        # def fib(n):
        #     if n < 2:
        #         return n
        #     return fib(n-1) + fib(n-2)
        # print(fib(1000))
    """
    
    # import numpy as np
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html
    # accumulate() returns iterator! to get list: list(accumulate())
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  # prime factor
        b, e = 2, 0  # base, exponent
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        # TODO: How should I do when n - r is negative?
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict # https://docs.python.org/ja/3/library/collections.html#collections.deque
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
    from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
    import operator
    from operator import itemgetter
    # ex1: List.sort(key=itemgetter(1))
    # ex2: sorted(tuples, key=itemgetter(1,2))
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)

    # first create factorial_list
    # fac_list = mod_factorial_list(n)
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) # Recursive function in python is slow!
    def modinv(a, p = MOD):
        # evaluate reciprocal using Fermat's little theorem:
        # a**(p-1) is identical to 1 (mod p) when a and p is coprime
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        # fac_list = modfactorial_list(100)
        # print(modcomb(100, 5, modfactorial_list(100)))
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    """ initialize variables and set inputs
    # initialize variables
        # to initialize list, use [0] * n
        # to initialize two dimentional array, use [[0] * N for _ in range(N)]
    # set inputs
        # open(0).read() is a convenient method:
        # ex) n, m, *x = map(int, open(0).read().split())
        #     min(x[::2]) - max(x[1::2])
        # ex2) *x, = map(int, open(0).read().split())
        #     don't forget to add comma after *x if only one variable is used
    # preprocessing
        # transpose = [x for x in zip(*data)]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
        # flat = [flatten for inner in data for flatten in inner]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [1, 2, 3, 4, 5, 6, 7, 8, 9]
    # calculate and output
        # output pattern
        # ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6
    """

    # functions used
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    R = lambda: list(map(int, r().split()))
    Rmap = lambda: map(int, r().split())
    Rfloat = lambda: list(map(float, r().split()))
    Rtuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    # single int: int(r())
    # single string: r()
    # single float: float(r())
    # line int: R()
    # line string: r().split()
    # line (str, int, int): [j if i == 0 else int(j) for i, j in enumerate(r().split())]
    # lines int: [R() for _ in range(n)]
    """

    if __name__ != '__main__':
        # for test
        sys.stdin = open('sample.txt')

    # ----------------------------------
    # main

    S = r()
    tmp = 0
    ans = 0
    for i in S:
        if i in ('A', 'T', 'G', 'C'):
            tmp += 1
            ans = max(ans, tmp)
        else:
            tmp = 0
            
    print(ans)
    
    # end of main
    # ----------------------------------

    """memo: how to use defaultdict of list
    # initialize
    Dic = defaultdict(list)
    # append / extend
    Dic[x].append(y)
    # for
    for k, v in Dic.items():
    """

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import re
s = input()
ans = [re.search("[AGCT]*", s[i:]) for i in range(len(s))]
ans = max([len(x.group(0)) if x else 0 for x in ans])
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = list(inputs[0])
    ACGT = {"A", "C", "G", "T"}

    max_length = 0
    for i in range(0, len(S)):
        length = 0
        j = i
        while j < len(S) and S[j] in ACGT:
            length += 1
            j += 1
        max_length = length if length > max_length else max_length
    return max_length


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())
li=0
li2=[]
for i in S:
	if i=='A' or i=='C' or i=='G' or i=='T':
		li+=1
	else:
		li2.append(li)
		li=0
li2.append(li)
print(max(li2))

Submission status: Accepted

Solution code:
inp = input()
inpmax, inplen = 0, 0
for inp_c in inp:
  if inp_c in 'ATCG':
    inplen += 1
  else:
    inpmax = max(inpmax, inplen)
    inplen = 0
inpmax = max(inpmax, inplen)
print(inpmax)

Submission status: Accepted

Solution code:
s = str(input())

if set(list(s)) <= {'A', 'T', 'G', 'C'}:
  print(len(s))
  exit()

ans = 0

for i in range(len(s)):
  for j in range(i, len(s)+1):
    sp = s[i:j]
    sp = list(sp) 
    if set(sp) <= {'A', 'T', 'G', 'C'}:
      ans = max(ans, len(sp))
print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = int(0)
L = [0]
atcg = 'A','C','G','T'
for i in range(len(S)):
    if S[i] in atcg:
            ans += 1
            L.append(ans)
            continue
    else:
            ans = 0

print(max(L[:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
smax = 0
slen = 0
for c in s:
  if c in 'ATCG':
    slen += 1
  else:
    smax = max(smax, slen)
    slen = 0
smax = max(smax, slen)
print(smax)

Submission status: Accepted

Solution code:
# ABC122 B-ATCoder

S = input()
ans = 0
l, r = 0, 0
ls = len(S)

for i in range(ls):
    if S[i] in "ATGC":
        r += 1
    else:
        r += 1
        l = r
    ans = max(ans, r-l)
print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()

    acgt = []
    flag = False
    count = 0
    for s in S:
        if s == "A" or s == "C" or s == "G" or s == "T":
            if flag:
                count += 1
            else:
                flag = True
                count = 1
        else:
            acgt.append(count)
            flag = False
            count = 0

    if count > 0:
        acgt.append(count)
        
    print(max(acgt))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
ACGT = ['A', 'C', 'G', 'T']
S = input()
countlist = [0]
if S[0] in ACGT:
	countlist[0] += 1
for i in range(1, len(S)):
	if S[i] in ACGT:
		countlist.append(countlist[-1]+1)
	else:
		countlist.append(0)
countlist.sort()
print(countlist[-1])

Submission status: Accepted

Solution code:
s = list(input())

ans = []

for i in range(len(s)):
	ans.append(0)
	j = i
	while s[j] == "A" or s[j] == "C" or s[j] == "G" or s[j] == "T" :
		ans[i] += 1
		if j >= len(s) - 1:
			break
		else:
			j += 1
		
ans =sorted(ans, reverse = True)

print(ans[0])

Submission status: Accepted

Solution code:
s = input()

n = len(s)

ans = 0

for i in range(n):
    for j in range(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()

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

Submission status: Accepted

Solution code:
S = input()

len_s = len(S)
bases = ('A', 'C', 'G', 'T')

ans = 0
cnt = 0

for i in range(len_s):
  if S[i] in bases:
    cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
if cnt > 0:
  ans = max(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0
tmp = 0
flag = False

for i in S:
    if (i == "A") or (i == "C") or (i == "G") or (i == "T"):
        tmp += 1
        flag = True
    elif (tmp > ans) and flag:
        ans = tmp
        tmp = 0
        flag = False
    elif flag:
        tmp = 0
        flag = False

if (ans < tmp):
    ans = tmp

print(ans)

Submission status: Accepted

Solution code:
def rensa(s,i):
    a=["A","C","G","T"]
    num=i+1 
    l=len(s)
    check=0
    combo=1
    while check==0 and num<=l-1:
        if any(s[num]==a[j] for j in range(4)):
            combo+=1
            num+=1
        else:
            check=1
    return combo

s=input()
l=len(s)
a=["A","C","G","T"]
max=0
for i in range(l):
    if any(s[i]==a[j] for j in range(4)):
        combo=rensa(s,i)
        if combo>max:
            max=combo
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

ans = 0
ans_m = 0
for s in S:
    if s in ["A","C","G","T"]:
        ans += 1
        if ans > ans_m:
            ans_m = ans
    else:
        ans = 0

print(ans_m)

Submission status: Accepted

Solution code:
s = input()
acgt = {'A','C','G','T'}
max_len = 0
count=0
for si in s:  
  if si in acgt:
    count+=1
    if max_len < count :
      max_len = count    
  else:
    count=0
print(max_len)

Submission status: Accepted

Solution code:
a = input()
b = ["A","C","G","T"]
c = 0
d = [0]

for s in a:
  if s in b:
    c += 1
    d.append(c)
  else:
    c = 0
    d.append(c)
else:
  print(max(d))

Submission status: Accepted

Solution code:
S = list(input())
acgt = ['A', 'C', 'G', 'T']
lengths = []
l = 0
for x in S:
  if x in acgt:
    l += 1
  else:
    lengths.append(l)
    l = 0

if len(lengths) == 0 or l > 0:
  lengths.append(l)

print(max(lengths))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
max = 0
temp = 0
for str in n:
    if str in 'ACGT':
        temp += 1
        if max < temp:
            max = temp
    else:
        temp = 0
print(max)

Submission status: Accepted

Solution code:
n = input()
max = 0
temp = 0
for str in n:
    if str == 'A' or str == 'T' or str == 'C' or str == 'G':
        temp += 1
        if max < temp:
            max = temp
    else:
        temp = 0
print(max)

Submission status: Accepted

Solution code:
n = input()
l =[]
counter = 0
for str in n:
    if str == 'A' or str == 'T' or str == 'C' or str == 'G':
        counter += 1
    else:
        l.append(counter)
        counter = 0
l.append(counter)
print(max(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = list(input())

    len_max = 0
    len_cur = 0
    for t in s:
        if t in {'A', 'C', 'G', 'T'}:
            len_cur += 1
        else:
            len_max = max(len_max, len_cur)
            len_cur = 0

    len_max = max(len_max, len_cur)
    print(len_max)


main()

Submission status: Accepted

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

S = input()

acgt = {'A', 'C', 'G', 'T'}
longest = 0
length = 0
for c in S:
    if c in acgt:
        length += 1
        longest = max(length, longest)
    else:
        length = 0

print(longest)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

cnt_max = 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
        cnt += 1
    if cnt_max < cnt:
        cnt_max = cnt

print(cnt_max)

Submission status: Accepted

Solution code:
s=input()
n=len(s)
at=["A","T","G","C"]
ans=[-1]
for i in range(n-1):
    if s[i] not in at:
        ans.append(i)#-ans[-1])
if s[n-1] in at:
    ans.append(n)
else:
    ans.append(n-1)

m=len(ans)
ans2=[]
for j in range(m-1):
    ans2.append(ans[j+1]-ans[j]-1)

#print(ans)
#print(ans2)

if len(ans)==1:
    print(n)
elif len(ans2)==0:
    print(0)
else:
    print(max(ans2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

s = input()
ans = tmp = 0
for i in s:
  if "ACGT".count(i) == 1:
    tmp += 1
    if tmp > ans:
      ans = tmp
  else:
    tmp = 0
print(ans)

Submission status: Accepted

Solution code:
count = 0
MAX = 0
S = list(input())
for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':
    count += 1
    if MAX < count:
        MAX = count
  else:
    count = 0

print(MAX)

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input()
    str = 'ACGT'
    tmp = 0
    maxv = 0
    for i in range(len(S)):
        if S[i] in str:
            tmp += 1
        else:
            tmp = 0
        maxv = max(maxv, tmp)
    print(maxv)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
gene = "ACGT"
right = 0
c = 0

for i in range(len(S)):
  right = max(right, i)
  while right < len(S) and S[right] in gene:
    right += 1
  c = max(c, right-i)
print(c)

Submission status: Accepted

Solution code:
a = input()
b = ["A", "C", "G", "T"]
c = 0
d = 0
for i in range(len(a)):
    e = False
    for j in range(len(b)):
        if a[i] == b[j]:
            e = True
            break
    if e:
        c += 1
        if c > d:
            d = c
    else:
        c = 0
print(d)

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    cnt = 0
    max_cnt = 0
    for i in s:
        if i == "A" or i == "T" or i == "C" or i == "G":
            cnt += 1
            max_cnt = max(max_cnt,cnt)
        else:
            cnt = 0
    print(max_cnt)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0
len = 0
for i in s:
    if i in "ACGT":
        len += 1
        ans = max(ans, len)
    else:
        len = 0
        
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:
def B(n):
    r = ""
    c = 0
    for _ in range(len(n)):
        s = ""
        for i in n[c:]:
            c+=1  
            if i in ["A","T","G","C"]:
                s+=i
            else:
                break
        
        if len(s) > len(r):
            r = s 
    return r

b = input()
print(len(B(b)))

Submission status: Accepted

Solution code:
S = input()
acgt = 'ACGT'

ans = 0
cnt = 0
for c in S:
    if acgt.find(c) >= 0:
        cnt += 1
    else:
        cnt = 0

    if cnt > ans:
        ans = cnt

print(ans)

Submission status: Accepted

Solution code:
def judge(target):
	ACGT = ['A','C','G','T']
	for A in ACGT:
		if str(target) == A:
			return True
	return False

Inp = list(input())
max_count = 0
#リストのすべての文字で検証する
for j in range(len(Inp)):
	count = 0
	match = 1
	for i in range(j,len(Inp)):
		if judge(Inp[i]):
			count += 1
			if count >= max_count :
				max_count = count
		else:
			match = 0
			break
	if match == 0:
		continue


print(max_count)

Submission status: Accepted

Solution code:
s = list(input())
c = int(0)
result = int(0)
result2 = int(0)

for i in s:
        if(i=="A" or i=="C" or i=="G" or i=="T"):
                c+=1
                result2 = c
        else:
                if(c>result):
                        result = c
                c=0
if(result > result2):
        print(result)
else:
        print(result2)

Submission status: Accepted

Solution code:
s = input()

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

tmp = 0
ans = 0

for i in range(len(s)):
    if ls.__contains__(s[i]):
        tmp += 1
    else:
        tmp = 0
    if ans < tmp :
        ans = tmp


print(ans)