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()
ans = 0
tmp = 0
for c in s:
    if c in 'ACGT':
        tmp += 1
    else:
        tmp = 0
    ans = max(ans, tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  5 16:48:09 2019

@author: adachi-lab
"""

input_code = input()
L1 = len(input_code)
list_3 = []
list_4 = []
list_5 = []

for w in range(L1):
    list_3.append(0)
    list_4.append(0)


for i in range(L1):
    code = input_code[i]
    if code == 'A' or code == 'C' or code == 'G' or code == 'T':
        list_3[i] = 1
        
c = 0

for n,m in zip(list_3,list_4):
    
    if n == m:
        c = 0
        list_5.append(c)
        
    else:
        c += 1
        list_5.append(c)
        
print(max(list_5))

Submission status: Accepted

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

s = input()
ansf = 0
anss = 0
for i in s:
    if i== "A" or i =="C" or i =="G" or i == "T":
        ansf += 1
    else:
        ansf = 0
    anss = max(anss,ansf)

print(anss)

Submission status: Accepted

Solution code:
ACGT = input()

result = 0
tmp = 0
for c in ACGT:
  if c in 'ACGT':
    tmp += 1
  else:
    tmp = 0
  result = max(result, tmp)

print(result)

Submission status: Accepted

Solution code:
s = input()

maxx = 0
count = 0
data = ["A","C","T","G"]
for i in range(len(s)): # i == 先頭の文字
    for j in range(i,len(s)): # j == 動かす文字
        if s[j] in data:
          count += 1
        else:
          break
    if maxx < count :
        maxx = count
    count = 0

print(maxx)

Submission status: Accepted

Solution code:
S = input()
L = 0
max_L = 0
 
for i in range(len(S)):
  s = S[i]
  TF = any(['A' in s, 'C' in s, 'G' in s, 'T' in s])
  if TF:
    L += 1
    if L >= max_L:
        max_L = L
  elif L >= max_L:
    max_L = L
    L = 0

print(max_L)

Submission status: Accepted

Solution code:
import re 
S = input()
 
p = re.compile('[ATCG]+')
f = p.finditer(S)
 
candidate = [i.span()[1]- i.span()[0] for i in f]
if candidate == [] :
    print(0)
else :
    print(max(candidate))

Submission status: Accepted

Solution code:
s = ["A","T","C","G"]
a = str(input())
max = 0
tmp = 0
for c in a:
  if c in s:
    tmp = tmp + 1
    if tmp > max:
      max = tmp
  else:
    tmp = 0
print("{}".format(max))

Submission status: Accepted

Solution code:
import re
s = input()
ms = re.findall('[ACGT]*', s)
ma = 0
for m in ms:
  ma = max(ma, len(m))
print(ma)

Submission status: Accepted

Solution code:
import re
base_pattern = re.compile(r"[A|T|C|G]*")
base_list = base_pattern.findall(input())
print(max(list(map(len,base_list))))

Submission status: Accepted

Solution code:
def main():
    S = list(input())
    count = 0
    counts = []
    for i in S:
        if i in ['A', 'T', 'C', 'G']:
            count += 1
        else:
            counts.append(count)
            count = 0
    counts.append(count)
    print(max(counts))
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())

c=0
max=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
    if c>max :
      max=c
  else :
    c=0
  
print(max)

Submission status: Accepted

Solution code:
S = input() + 'E'
for w in list('ACGT'):
    S = S.replace(w, ' ')
count = 0
max_count = 0
for w in S:
    if w == ' ':
        count += 1
    elif count > max_count:
        max_count = count
        count = 0
print(max_count)

Submission status: Accepted

Solution code:
S = input()
acgt = ['A','C','G','T']
for base in acgt:
    S = S.replace(base, ' ')
S += 'E'
maxlen = 0;
count = 0;
for w in S:
    if w == ' ':
        count += 1
    else:
        if count > maxlen:
            maxlen = count
        count = 0
print(maxlen)

Submission status: Accepted

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


for i in S:
    if i=="A" or i=="C" or i=="G" or i=="T":
         count = count + 1
         if count >= num:
             num = count
    else:
        count = 0

print(num)

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)
H = list('ATGC')
m = 0
ans = 0
for i in range(N):
    if S[i] in H:
        m += 1
        if ans < m:
            ans = m
    else:
        m = 0
print(ans)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
max_n = 0
for n in range(N):
    for m in range(n, N):
        s = S[n:m+1]
        if all("ATCG".count(ss) == 1 for ss in s):
            max_n = max(max_n, len(s))
print(max_n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
def ACGT(S):
    for d in S:
        if not d in "AGCT":
            return False
    return True
def solve(S):
    res = 0
    for i in range(len(S)):
        for j in range(i,len(S)+1):     
            if (ACGT(S[i:j])):
                res = max(j-i,res)
    return res
print(solve(S))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Apr  4 14:15:23 2019

@author: fumito
"""

S = str(input())
S_list = [i for i in S]
list1 = []
for i in S_list:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        list1.append(0)
    else:
        list1.append(1)

list2 = []
count = 0    
for j,k in enumerate(list1): 
    if k == 0:
        count += 1
    if k == 1 or j == len(list1)-1:
        list2.append(count)
        count = 0
print(max(list2))

Submission status: Accepted

Solution code:
s = str(input())
#s = 'ATCODER'

count = 0
count_max = 0
for i in s:
    if i == 'A' or i == 'T' or i == 'G' or i == 'C':
        count += 1
    else:
        if count_max < count:
            count_max = count
            count = 0

if count_max < count:
    count_max = count

print(count_max)

Submission status: Accepted

Solution code:
cnt=0
m_cnt=0
for c in input():
    if c in ['A','C','G','T']:
        cnt+=1
        if cnt > m_cnt:
            m_cnt=cnt
    else:
        cnt=0
print(m_cnt)

Submission status: Accepted

Solution code:
l=['A','C','G','T']
cnt=0
max_cnt=0
for c in input():
    if (c in l):
        cnt+=1
        if (cnt > max_cnt):
            max_cnt=cnt
    else:
        cnt=0
print(max_cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
str = input()
maxans = []
ans = []

for j in range(0,len(str)):
  for i in range(j,len(str)):
    if str[i] == 'A' or str[i] == 'C' or str[i] == 'G' or str[i] == 'T':
      ans.append(str[i])
    else:
      break
  if len(ans) >= len(maxans):
    maxans = ans
  ans = []
      
print(len(maxans))

Submission status: Accepted

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

for i in S:
    if i in ACGT:
        sum += 1
    else:
        listResult.append(sum)
        sum = 0
else:
    listResult.append(sum)
    
print(max(listResult))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = str(input())

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

print("{}".format(max))

Submission status: Accepted

Solution code:
import re

s = input()
sr = re.split('[^ATGC]', s)
print(len(max(sr, key=len)))

Submission status: Accepted

Solution code:
import re

s = input()

s = re.split('[^ACGT]', s)

print(max([len(i) for i in s]))

Submission status: Accepted

Solution code:
s = input()
ans = 0
l = []
for i in range(len(s)):
    if s[i] in list('ACGT'):
        ans += 1
    else:
        l.append(ans)
        ans = 0
l.append(ans)
print(max(l))

Submission status: Accepted

Solution code:
s = input()
atcg = set(["A", "T", "C", "G"])

ans = 0
tmp = 0
for si in s:
  if si in atcg:
    tmp += 1
  else:
    ans = max(ans, tmp)
    tmp = 0
    
ans = max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
n = len(s)
ans = 0
li = []
for i in range(n):
    if s[i] in list('ACGT'):
        ans += 1
    else:
        li.append(ans)
        ans = 0
li.append(ans)
print(max(li))

Submission status: Accepted

Solution code:
input = input()

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

Submission status: Accepted

Solution code:
b = input()
bls = []

for x in range(0,len(b)):
    bls.append(b[x])

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


now = 0
maxx = 0

for x in bls:
    if ACGT(x):
        now += 1
    elif now >= maxx:
        maxx = now
        now = 0
    else:
        now = 0

if now >= maxx:
    maxx = now

print(maxx)

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    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 bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    S = input()

    ans = 0

    c = 0

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

    print(ans)


main()

Submission status: Accepted

Solution code:
b = input()

a, a_cur =0,0

for c in b:
  if c in "ACGT":
    a_cur += 1
  else:
    a_cur = 0
  a = max(a,a_cur)
  
print(a)

Submission status: Accepted

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

    ans = 0
    for i in range(len(s)):
        cur = 0
        for j in range(i,len(s)):
            if s[j] in {"A", "C", "G", "T"}:
                cur += 1

            else:
                break

            ans = max(cur, ans)


    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
judgeList = ['A', 'C', 'G', 'T']
maxLength = 0
currentLength = 0
for i, v in enumerate(S):
    if v in judgeList:
        currentLength += 1
    else:
        maxLength = max(currentLength, maxLength)
        currentLength = 0
maxLength = max(currentLength, maxLength)
print(maxLength)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
h=''.join(['1' if s in 'ATCG' else '0' for s in S])
print(max([c.count('1') for c in h.split('0')]))

Submission status: Accepted

Solution code:
s = input()
t = ''
for i in range(len(s)):
    if s[i] in ('A', 'C', 'G', 'T'):
        t += '1'
    else:
        t += '0'
"""
print(t)
print(t.split('0'))
"""

print(max(map(len, t.split('0'))))

Submission status: Accepted

Solution code:
input = input().strip()
max = 0
max_tmp = 0
for i in range(len(input)):
  s = input[i]
  if s not in ['A', 'T', 'C', 'G']:
    max_tmp = 0
    continue
  max_tmp += 1
  if max_tmp > max:
    max = max_tmp
print(max)

Submission status: Accepted

Solution code:
s = input()

a, a_cur = 0, 0

for c in s:
    if c in "ACGT":
        a_cur += 1
    else:
        a_cur = 0
    a = max(a, a_cur)

print(a)

Submission status: Accepted

Solution code:
S = input()
l = len(S)
x = 0
for i in range(l):
    j = i + x + 1
    while(j <= l):
        k = i
        flag = True
        while(k < j):
            if S[k] not in ['A', 'C', 'G', 'T']:
                flag = False
                break
            else:
                k += 1
        if flag:
            x = j - i
        j += 1
print(x)

Submission status: Accepted

Solution code:
S = input()
i = ["A","G","C","T"]
list_S = [S]
ch = 0
an = 0
for j in S :
  if j in i :
    ch += 1
  else :
    an = max(an, ch)
    ch = 0
print(max(an,ch))

Submission status: Accepted

Solution code:
import re

S = input()

splitted = re.split("[^ATGC]", S)

max_length = 0
for inv in splitted:
    max_length = max(max_length, len(inv))

print(max_length)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    dp = [0]*(len(S)+1)
    for i in range(len(S)):
        if(S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T'):
            dp[i+1] = dp[i]+1
    print(max(dp))
main()

Submission status: Accepted

Solution code:
input = input()

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

count_list = []
count = 0
for letter in input:
    if letter in acgt:
        count += 1
        count_list.append(count)
    else:
        count = 0
        count_list.append(count)
print(max(count_list))

Submission status: Accepted

Solution code:
s = input()
k = ['A', 'G', 'C', 'T']
i = 0

while i < len(s):
    if s[i] in k:
        s = s
    else:
        s_changed = s[:i] + 'z' + s[i + 1:]
        s = s_changed
    i += 1

s_split = s.split('z')
ans = len(max(s_split, key=len))
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import re

S = input()

print(max(0, *map(len, re.findall("[AGCT]*", S))))

Submission status: Accepted

Solution code:
atcoder = input()
ACGT = list('ACGT')

s = ''
sub_list = []
for i, l in enumerate(list(atcoder)):
    if l in ACGT:
        s += l
        if i == len(atcoder)-1:
            sub_list.append(len(s))
    else:
        sub_list.append(len(s))
        s = ''
print(max(sub_list))

Submission status: Accepted

Solution code:
# coding:utf-8

def main():
    s = input()
    ans = 0
    for i in range(len(s)+1):
        for j in range(i,len(s)+1):
            temp = s[i:j]
            # print(i,j)
            # print(temp)
            if atgc_check(temp) and len(temp) > ans:
                ans = len(temp)
    print(ans)

def atgc_check(sub_s):
    for si in sub_s:
        if not si in ["A","T","G","C"]:
            return False
    return True

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
L = ["A","T","C","G"]
S = input()
S += "B"
count = 0
maxcount = 0
for i in S:
  if i in L:
    count += 1
  else:
    maxcount = max(count,maxcount)
    count = 0
print(maxcount)

Submission status: Accepted

Solution code:
import re
str = input()
c = 0
ls = re.findall(r'[ACGT]*', str)
for _ in range(len(ls)):
    if (c < len(ls[_])):
        c = len(ls[_])
print(c)

Submission status: Accepted

Solution code:
L = ["A","T","C","G"]
S = input()
S = S+"B"
count = 0
maxcount = 0
for i in S:
    if i in L:
        count += 1
    else:
        maxcount = max(count,maxcount)
        count = 0

print(maxcount)

Submission status: Accepted

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

count = 0
for i in S:
    if i in acgt:
        count += 1
    else:
        count = 0
    count_list.append(count)

print(max(count_list))

Submission status: Accepted

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

print(max(map(len, t.split('0'))))

Submission status: Accepted

Solution code:
s=input()
acgt=["A","C","G","T"]
s=[s[i] in acgt for i in range(len(s))]
max_len=0
flag=False
for n in range(len(s),0,-1):
  for i in range(len(s)-n+1):
    if all(s[i:i+n]):
      max_len=n
      flag=True
      break
  if flag:
    break
print(max_len)

Submission status: Accepted

Solution code:
def main():
	s = input()
	max_len = 0
	this_len = 0
	is_start = False
	for c in s:
		if is_acgt(c):
			this_len += 1
			is_start = True
			if max_len < this_len:
				max_len = this_len
		else:
			this_len = 0
			is_start = False
	print(max_len)


def is_acgt(c: str) -> bool:
	if c in ["A", "C", "G", "T"]:
		return True
	return False

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in S:
    if i in acgt:
        count += 1
        if count > max_count:
            max_count = count
    else:
        count = 0

print(max_count)

Submission status: Accepted

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

for i in S:
    if i in acgt:
        count += 1
    else:
        if count > max_count:
            max_count = count
        count = 0

print(max(max_count, count))

Submission status: Accepted

Solution code:
S = input()
max = 0
ans = 0
if S.isupper() and 0 < len(S) < 11:
    for str in S:
        if str == 'A' or str == 'C' or str == 'G' or str == 'T':
            ans += 1
            if max < ans:
                max = ans
        else:
            if max < ans:
                max = ans
            ans = 0
print(max)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ACGT = "ACGT"
#s = "SHINJUKU"

def isACGT(c):
    if (c in ACGT):
        return True
    else:
        return False

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random


s = list(str(input()))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

maxC = 0
count = 0

for c in S:
    if c in "ACTG":
        count += 1
    else:
        if maxC < count:
            maxC = count
        count = 0

print(max(count,maxC))

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = 0
for i in range(N):
	for j in range(i, N):
		if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
			ans = max(ans, j - i + 1)
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
ans = 0
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 ans < count:
      ans = count
  else:
    count = 0
print(ans)

Submission status: Accepted

Solution code:
S = input()
L = 'ACGT'
n, num = 0, 0
for s in S:
    if s in L:
        n += 1
    else:
        num = max(num, n)
        n = 0
num = max(num, n)
print(num)

Submission status: Accepted

Solution code:
def check(s,i):
   global count
   count+=1
   if i+1 < len(s):
       if s[i+1] == 'A' or s[i+1] == 'C' or s[i+1] =='G' or s[i+1] =='T':
           check(s,i+1) 

s=input()
count=0
list=[]
for i in range(len(s)):
    count=0
    if s[i] == 'A' or s[i] == 'C' or s[i] =='G' or s[i] =='T':
        check(s,i)
    list.append(count)

print(max(list))

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(i, N):
        if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
            ans = max(ans, j - i + 1)
print(ans)

Submission status: Accepted

Solution code:
S = input()
L = ['A', 'T', 'C', 'G']
n, num = 0, 0
for s in S:
    if s in L:
        n += 1
    else:
        if n > num:
            num = n
        n = 0
if n > num:
    num = n
print(num)

Submission status: Accepted

Solution code:
S = raw_input()
length = 0
max_length = 0
for s in S:                                                                                                         
    if s == "A" or s == "C" or s == "G" or s == "T":
        length += 1
        if max_length < length:
            max_length = length
    else:
        length = 0
print max_length

Submission status: Accepted

Solution code:
s=input()

res=0
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
        cnt=0
        for x in s[i:j]:
            if x not in ['A','G','C','T']:
                break
            cnt+=1
        if res<cnt:
            res=cnt

print(res)

Submission status: Accepted

Solution code:
def atcoder(string):
    acgt = set('ACGT')                                               
    on_count = False                                                 
    count = 0 
    max_count = 0                                                    
    
    for c in string:
        if c in acgt:
            if not on_count:
                on_count = True                                      
            count += 1                                               
        else:
            if on_count:
                on_count = False
                max_count = max(max_count, count)
                count = 0 

    if on_count:
        max_count = max(max_count, count)
                                  
    return max_count              
                                  
                                  
if __name__ == "__main__":
    string = input()
    print(atcoder(string))

Submission status: Accepted

Solution code:
argv = input()

n = 0
r = 0
for s in argv:
    if s == "A" or s == "T" or s == "G" or s == "C":
        n += 1
    else:
        n = 0
    r = max(r, n)
print(r)

Submission status: Accepted

Solution code:
S = input()
X = 'ATCG'
res = [0]
cnt = 0
for s in S:
    if s in X:
        cnt += 1
        res.append(cnt)
    else:
        cnt = 0
print(max(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def func1(x):
    if x == 'A':
        num = 1
    elif x == 'T':
        num = 1
    elif x == 'C':
        num = 1
    elif x == 'G':
        num = 1
    else:
        num = 0
    return num

x = list(input())

ans = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
j = 0
for i in range(len(x)):
    z = func1(x[i])
    if z == 1:
        ans[j] += 1
    else:
        j += 1
        continue

print(max(ans))

Submission status: Accepted

Solution code:
S = input()

ACGT = 'ACGT'
l = 0
max_l = 0
for i in S:
  if i in ACGT:
    l += 1
    max_l = max(max_l, l)
  else:
    l = 0
print(max_l)

Submission status: Accepted

Solution code:
def main():
    s = input()
    
    ans = 0
    for i in range(len(s)):
        cur = 0
        for j in range(i, len(s)):
            if s[j] in {'A', 'C', 'G', 'T'}:
                cur += 1
            else:
                break
                
            ans = max(cur, ans)
    
    print(ans)
    
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

lst = []
cnt = 0

for x in s:
  if x in tgt:
    cnt = cnt +1
  else:
    lst.append(cnt)
    cnt = 0
    
lst.append(cnt)

print(max(lst))

Submission status: Accepted

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

def main():
    b = input()

    maxcnt = 0
    scnt = 0
    for c in b:
        if(c=='A' or c=='C' or c=='G' or c=='T'):
            scnt += 1
        else:
            if(maxcnt<scnt):
                maxcnt=scnt
            scnt = 0

    print(max(scnt,maxcnt))

main()

Submission status: Accepted

Solution code:
input_str=input()
j=0
l1=[0]
for i in range(len(input_str)):
  k=input_str[i]
  if (k=="A"or k=="T"or k=="G"or k=="C"):
    j+=1
  else:
    l1.append(j)
    j=0
l1.append(j)
print(max(l1))

Submission status: Accepted

Solution code:
def main():
    *S, = input()
    count = 0
    maximum = 0
    for i in S:
        if i == "A" or i == "C" or i == "G" or i == "T":
            count += 1
        else:
            if maximum < count:
                maximum = count
            count = 0
    print(max(count, maximum))
main()

Submission status: Accepted

Solution code:
s = input()
n = len(s)
check = {"A", "C", "G", "T"}
ans = {0}
for i in range(n):
    tmp = s[i]
    if tmp not in check:
        continue
    ans.add(1)
    for j in range(i+1, n):
        if s[j] not in check:
            break
        tmp += s[j]
        ans.add(len(tmp))

print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def change(c):
  if c in atcg:
    return "1"
  else:
    return "0"
  
s = input()
atcg = "ATCG"
s = "".join([change(i) for i in s])
print(max([len(i) for i in s.split("0")]))

Submission status: Accepted

Solution code:
S = input()
def change(i):
  if i in "ATGC":
    return "1"
  else:
    return "0"
  
S = "".join([change(i) for i in S])
print(max([len(i) for i in S.split("0")]))

Submission status: Accepted

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

print(solve(input()))

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, len(s[i:j + 1]))

print(ans)

Submission status: Accepted

Solution code:
import re
S = re.split('B|D|E|F|[H-S]|[U-Z]',input())
#print(S)
len_S = [len(x) for x in S]
print(max(len_S))

Submission status: Accepted

Solution code:
import re
s = input()

result = re.sub('[^ACGT]', ',', s).split(',')

print(max([len(r)for r in result]))

Submission status: Accepted

Solution code:
import re

str = input()


pattern = r"[ATCG]+"

matched_list = re.findall(pattern, str)

maxlength = 0
for item in matched_list:
    tmplength = len(item)
    if maxlength < tmplength:
        maxlength = tmplength

print(maxlength)

Submission status: Accepted

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

counter_list = []
for j in range(s_len):
    counter = 0

    for i in range(j, s_len):
        if s[i] == 'A' or s[i]=='T' or s[i]=='G' or s[i]=='C':
            counter += 1
        else:
            break
    counter_list.append(counter)
    
print(max(counter_list))

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)