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:
acgt = ['A','C','G','T']
max = 0
cur = 0
str = input() + 'Z'
 
for c in str:
  if(c in acgt):
    cur += 1
  else:
    if(max < cur):
      max = cur
    cur = 0
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re;print(max([len(i)for i in re.findall('[ACGT]+',input())]+[0]))

Submission status: Accepted

Solution code:
s = input().strip()
cur = 0
mx = 0
for x in s:
    if x in "GCAT":
        cur += 1
        mx = max(mx, cur)
    else:
        cur = 0
print(mx)

Submission status: Accepted

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

for i in range(len(S)):
    if S[i] in answer:
        j = 0
        count = 0
        while S[i+j] in answer:
            count += 1
            if count > max_count:
                max_count = count
            j += 1
            if i + j >= len(S):
                break;
print(max_count)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    tokens = lines[0].split(" ")
    s = tokens[0]

    return (s,)


def solve(s):

    m = 0
    for ss_length in range(len(s) + 1):
        for i in range(len(s)):
            if i+ss_length > len(s):
                break

            ss = s[i:i+ss_length]
#            print("ss=%s" % ss)
            count = 0
            for c in ss:
                if c in "ACGT":
                    count = count + 1
            if count == ss_length and m < ss_length:
                m = ss_length
                break


    return m

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()

Submission status: Accepted

Solution code:
s = input()
s += 'B'

ans = 0
cnt = 0
for c in s:
    if (c == 'A' or c == 'C'
            or c == 'G' or c == 'T'):
        cnt += 1
    else:
        if (ans < cnt):
            ans = cnt
        cnt = 0

print(ans)

Submission status: Accepted

Solution code:
S = str(input())

count = 0
result = []

for i in range(len(S)):
  if (S[i] == "A") or (S[i] == "C") or (S[i] == "G") or (S[i] == "T"):
    count += 1
    if i == len(S) - 1:
      result.append(count)
  else:
    result.append(count)
    count = 0
    if i == len(S) - 1:
      result.append(count)

maxi = result[0]
    
for j in range(len(result)):
  if maxi < result[j]:
    maxi = result[j]

print(maxi)

Submission status: Accepted

Solution code:
s = input().strip()
cur = 0
mx = 0
for x in s:
    if x in ["G", "C", "A", "T"]:
        cur += 1
        mx = max(mx, cur)
    else:
        cur = 0
print(mx)

Submission status: Accepted

Solution code:
s = list(input())
n = len(s)
p = ['A','C','G','T']

res = 0
for i in range(n):
    cnt = 0
    k = i
    while k != n and s[k] in p:
        cnt += 1
        k += 1
    res = max(res,cnt)
print(res)

Submission status: Accepted

Solution code:
S = input() + 'x'
acgt = ('A','C','G','T')
curran = 0
longest = 0

def check1(l):
    for i in acgt:
        if l == i:
            return True
    return False

for i in S:
    if check1(i):
        curran += 1
    elif not check1(i):
        if curran > longest:
            longest = curran
        curran = 0
        
print(longest)

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()
N = len(S)
count = 0
max = 0
for i in range (N):
  if S[i] == "A" or S[i] == "T" or S[i] == "C" or S[i] == "G":
    count = count + 1
  else:
    if count > max:
      max = count
    count = 0
if count > max:
  max = count
  
print(max)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
B - ATCoder
https://atcoder.jp/contests/abc122/tasks/abc122_b

"""
import sys
import re

def solve(S):
    return max([len(f) for f in re.findall(r'[ACGT]+', S)], default=0)


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
s = list(input())
c,max = 0,0
for i in range(0,len(s)):
  if s[i] in "ATCG":
    c=1
    for j in range(i,len(s)):
      if s[j] in "ATCG":
        if j!=i:
          c+=1
      else:
        break
  if max < c:
    max=c      
print(max)

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

def cnt(s):
    count = 0
    for st in s:
        if st is 'A' or st is 'C' or st is 'G' or st is 'T':
            count += 1
        else:
            return count
    return count

cs = 0
max = 0
for s in str:
    res = cnt(str[cs:len(str)])
    if max < res:
        max = res
    cs += 1
print(max)

Submission status: Accepted

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

for i in s:
    if i in arr:
        tmp += 1
    else:
        tmp = 0
    if ans < tmp:
        ans = tmp
print(ans)

Submission status: Accepted

Solution code:
b = input()
m, c = 0, 0
for i in b:
    if i in "ACGT":
        c += 1
        if c > m:
            m = c
    else:
        c = 0
print(m)

Submission status: Accepted

Solution code:
S = input()
m = 0
t = 0
for x in range(len(S)):
    if S[x] in ["A","T","G","C"]:
        t += 1
    else:
        m = max(m, t)
        t = 0
m = max(m, t)
print(m)

Submission status: Accepted

Solution code:
class Test:
    def __init__(self):
        pass

class CustomUtils:
    def __init__(self):
        pass
    def to_int(self, inputs, sp=' '):
        if sp == '':
            return [int(d) for d in list(inputs)]
        else:
            return [int(d) for d in inputs.split(sp)]
    def debug_print(self, inputs, debug=False):
        if debug:
            print(inputs)

# 引用　python する man,「Pythonでの再帰関数とメモ化」, PSM, ２０１７、７/４
# http://muromura.hatenablog.com/entry/2017/07/04/204908#%E3%83%A1%E3%83%A2%E5%8C%96
def memorize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func
debug = False


u = CustomUtils()
iarray = list(input())

@memorize
def acgt(i):
    if i < 0:
        return 0
    elif iarray[i] in ['A', 'C', 'G', 'T']:
        return acgt(i -1) + 1
    else:
        return 0
result = max(acgt(i) for i in range(len(iarray)))
print("{}".format(result))

Submission status: Accepted

Solution code:
# coding: utf-8
	
S = input()
T = ""

result = 0

while True:
	counter = 0

	for val in range(len(S)):
		if S[val] == "A":
			T = S[val:]	
			counter += 1
			break
		elif S[val] == "C":
			T = S[val:]	
			counter += 1
			break
		elif S[val] == "G":
			T = S[val:]	
			counter += 1
			break
		elif S[val] == "T":
			T = S[val:]	
			counter += 1
			break

	if val+1 != len(S):

		for val in range(1,len(T)):
			if T[val] == "A":
				counter += 1
			elif T[val] == "C":
				counter += 1
			elif T[val] == "G":
				counter += 1
			elif T[val] == "T":
				counter += 1
			else:
				S = T[val:]
				break


	if result < counter:
		result = counter

	if val+1 == len(S):
		break
	if val+1 == len(T):
		break

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
acgt = ["A","C","G","T"]
b = list(input())
count = 0
cmax = 0
for i in range(len(b)):
    if b[i] in acgt:
        count+=1
        if( cmax < count):
            cmax = count
    else:
        count = 0
print(cmax)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
d = ["A","G","T","C"]
s = input()
r=[0]
n = 0
bf =0
for t in s:
    if t in d:
        n +=1
        bf = 1
        continue
    if bf == 1:
        r.append(n)
        n=0
    bf = 0
if bf == 1:
        r.append(n)
        
print(max(r))

Submission status: Accepted

Solution code:
import re
s = str(input())
answer = 0
for first in range(len(s)):
    for last in range(first,len(s)):
        if all('ACGT'.count(c) == 1 for c in s[first:last + 1]):
                answer = max(answer, last - first + 1)
print(answer)

Submission status: Accepted

Solution code:
words = list(input())
binary_list = []
for word in words:
  if word == "A" or word == "T" or word == "C" or word == "G":
      binary_list.append(1)
  else:
      binary_list.append(0)
max_counter = 0
for first in range(len(binary_list)):
    counter = 0
    multi = 1
    if binary_list[first] == 1:
        while(multi):
            multi *= binary_list[first]
            if multi == 0:
                break
            counter += 1
            if counter >= max_counter:
                max_counter = counter
            if first == len(binary_list) - 1:
                break
            else:
                first += 1
print(max_counter)

Submission status: Accepted

Solution code:
import re
S = input()
slist = re.findall(r'[ACGT]+', S)
if slist:
  print(max(map(len, slist)))
else:
  print(0)

Submission status: Accepted

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

S = input().strip()

res = 0
count = 0
for c in S:
    if c in 'ACGT':
        count += 1
    else:
        res = max(res, count)
        count = 0

print(max(res, count))

Submission status: Accepted

Solution code:
S = input()
counter = 0
max_ = 0
for s in S:
  if s == "A" or s == "G" or s == "C" or s == "T":
    counter += 1
  else:
    if max_ < counter:
      max_ = counter
    counter = 0
if max_ < counter:
  max_ = counter
print(max_)

Submission status: Accepted

Solution code:
s=input()
ok = "ATGC"
ans = 0
cnt = 0
isok = False

for i in range(len(s)):
    for j in range(4):
        if s[i] == ok[j]:
            isok = True
    if isok == False:
        cnt = 0
        continue
    cnt += 1
    ans = max(ans,cnt)
    isok = False
print(ans)

Submission status: Accepted

Solution code:
# 入力
S = str(input())
T = 'ATCG'

ans = 0
now = 0

for i in range(len(S)):
    isATCG = False
    for j in range(len(T)):
        if S[i] == T[j]:  # 対象の文字列がATCGのいずれかであるかどうか判定
            isATCG = True
    # 対象の文字列がATCGであればisATCGの値はTrueになっている
    if not isATCG:
        # 違う場合はnowを0にする
        now = 0
    else:
        # ATCGの場合はnowをインクリメント
        now += 1
        ans = max(now, ans)  # 最大値を更新する

print(ans)

Submission status: Accepted

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

part_len = 0
max_len = 0

for s in s_list:
	if s in acgt:
		part_len += 1
		if part_len > max_len:
			max_len = part_len
	else:
		part_len = 0

print(max_len)

Submission status: Accepted

Solution code:
import re

s = input()
l = re.findall('[ACGT]*', s)
print(len(max(l,key=len)))

Submission status: Accepted

Solution code:
s = input()

acgt = "ACGT"
s_list = list(s)

cur_len = 0
max_len = 0

for c in s_list:
    if c in acgt:
        cur_len += 1
        if max_len < cur_len:
            max_len = cur_len
    else:
        cur_len = 0

print(max_len)

Submission status: Accepted

Solution code:
s = input()

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

n_max = 0
n_acgt = 0
for c in s:
  if c in lis:
    n_acgt += 1
  else:
    if n_acgt > n_max:
      n_max = n_acgt
    n_acgt = 0

if n_acgt > n_max:
      n_max = n_acgt
    
print(n_max)

Submission status: Accepted

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


def main():
    s = input()
    n = len(s)
    ans = 0

    for i in range(1, n + 1):
        for j in range(n - i + 1):
            t = s[j:j + i]

            if len(t.replace('A', '').replace('C', '').replace('G', '').replace('T', '')) == 0:
                ans = max(ans, i)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
wordList = 'ACGT'
t = []
tmp = []
lead = 0
ans = 0
slist = list(s)
for i in range(len(slist)):
    if not slist[i] in wordList:
        ans = max(ans, (i - lead))
        lead = i + 1
ans = max(ans, (len(slist) - lead))
print(ans)

Submission status: Accepted

Solution code:
s = input()

S = []
for i in range(len(s)):
    S.append(s[i:])
    for j in range(len(s) - i - 1):
        S.append(s[i:-(j+1)])

ans = []
for i in range(len(S)):
    if (('A' in set(S[i])) + 
        ('C' in set(S[i])) + 
        ('G' in set(S[i])) + 
        ('T' in set(S[i])) == len(set(S[i]))):
        ans.append(len(S[i]))
    else:
        ans.append(0)

print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
answer_list = []
answer = 0

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

Submission status: Accepted

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

if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

OK = ["A", "C", "G", "T"]
s = input()[:-1]
l = 0
r = 0
ans = 0
N = len(s)
while l < N and r < N:
    if s[r] in OK:
        ans = max(ans, r-l+1)
        r += 1
    else:
        l = r+1
        r += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby
import random

s = input()


def ans_1():
    temp, ans = 0, 0
    acgt = {"A", "C", "G", "T"}
    for i in range(len(s)):
        if s[i] in acgt:
            temp += 1
            ans = max(ans, temp)
        else:
            temp = 0
    print(ans)


def ans_2():
    def check(c):
        return c in "AGCT"

    ans = 0
    for k, grp in groupby(s, check):
        temp = len(list(grp))
        if k:
            ans = max(ans, temp)

    print(ans)


def ans_3():
    temp, ans = 0, 0
    for c in s:
        if c in "AGCT":
            temp += 1
            ans = max(ans, temp)
        else:
            temp = 0
    print(ans)


method = random.randrange(3)
if method == 0:
    ans_1()
elif method == 1:
    ans_2()
else:
    ans_3()

Submission status: Accepted

Solution code:
import sys

def sub(a):
    return [a[i : j + 1] for i in range(len(a)) for j in range(i,len(a))]


s = input()
l = sub(s)
maks = 0

for i in l:
    sum = 0
    for x in i:
        if x == 'A' or x == 'C' or x == 'T' or x == 'G':
           sum += 1
    if sum == len(i):
        maks = max(maks, len(i)) 

print(maks)

Submission status: Accepted

Solution code:
S=list(input())

s=[]

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

Submission status: Accepted

Solution code:
S = input()
len_now = 0
len_max = 0
list_s = ["A","C","G","T"]

for i in range(len(S)):
    if S[i] in list_s:
        len_now += 1
        if len_now > len_max:
            len_max = len_now
    else:
        len_now = 0
print(len_max)

Submission status: Accepted

Solution code:
s = input()

ans = 0
tmp = ''
for i in range(len(s)):
  if s[i] in 'ACGT':
    tmp += s[i]
  else:
    tmp = ''
  if ans <= len(tmp):
    ans = len(tmp)
print(ans)

Submission status: Accepted

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

print(max)

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 = raw_input()

max_count = 0
length = len(S)
for idx in xrange(length):
    count = 0
    for i in range(idx, length):
        if 'ACGT'.find(S[i]) >= 0: count += 1
        else: break
    if count > max_count: max_count = count
print max_count

Submission status: Accepted

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


def solve(S: str):
    def is_valid(s):
        for c in s:
            if not c in 'AGTC':
                return False
        return True
    n = len(S)
    ret = ''
    for i in range(n):
        for j in range(i, n):
            if is_valid(S[i:j + 1]) and j - i + 1 > len(ret):
                ret = S[i:j + 1]
    print(len(ret))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
l=list(input())
c=0
cl=[]
for i in l:
  if i=="A" or i=="T" or i=="G" or i=="C":
    c+=1
  else:
    cl.append(c)
    c=0
cl.append(c)
print(max(cl))

Submission status: Accepted

Solution code:
S = input()

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

max_count = 0
count = 0
for c in S:
    if c in atgc:
        count += 1
        if count > max_count:
            max_count = count
    else:
        count = 0

print(max_count)

Submission status: Accepted

Solution code:
in_str = input()
length_str = len(in_str)
inner_count = 0
inner_length = 0
for i in range(len(in_str)):
    if (in_str[i] == "A") or (in_str[i] == "C") or (in_str[i] == "G") or (in_str[i] == "T"):
        inner_count +=1

    else :
        if inner_length <= inner_count:
            inner_length = inner_count
        inner_count = 0

if inner_length <= inner_count:
            inner_length = inner_count
print(inner_length)

Submission status: Accepted

Solution code:
words = ['A', 'C', 'T', 'G']

S = str(input())

ans = 0
answers = []

for i in range(len(S)):
    if S[i] in words:
        ans += 1
    else:
        answers.append(ans)
        ans = 0

answers.append(ans)

print(max(answers))

Submission status: Accepted

Solution code:
# import re
# pattarn = re.compile('A|C|G|T')
# S = str(input())
# ans = re.match(pattarn, S)
# print(ans.group())


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

S = str(input())

ans = 0
answers = []

for i in range(len(S)):
    if S[i] in words:
        ans += 1
    else:
        answers.append(ans)
        ans = 0

answers.append(ans)

print(max(answers))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest122-B
# 解説ベースの修正版 Vol1 20190328
#  https://atcoder.jp/contests/abc122/tasks/abc122_b

def solveProblem(inputString):
	stringLength = len(inputString)
	answerStringList = list()
	maxStringLength = 0
	for i in range(0,stringLength,+1):
		for j in range(i,stringLength,+1):
			AllATGCList = list()
			for c in inputString[i:j+1]:
				x = 'AGTC'.count(c) == 1
				AllATGCList.append(x)
			if all(AllATGCList) :
				strATGCLength = len(inputString[i:j+1])
				if maxStringLength < strATGCLength :
					maxStringLength = strATGCLength
	answer = maxStringLength
	return answer

if __name__ == '__main__':
	S = str(input().strip())
	solution = solveProblem(S)
	print("{}".format(solution))

Submission status: Accepted

Solution code:
S = input()
m = k = 0
for c in S:
  if c in 'ACGT':
    k += 1
  else:
    m = max(m, k)
    k = 0
m = max(m, k)
print(m)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import bisect
from datetime import datetime as dt

S = raw_input()
i = 0
max = 0
tmp = 0
while i < len(S):
    if S[i] in 'ACGT':
        tmp += 1
    else:
        if max < tmp:
            max = tmp
        tmp = 0
    i += 1
if max < tmp:
    max = tmp
print max

Submission status: Accepted

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

if ans < counter:
    ans = counter

print(ans)

Submission status: Accepted

Solution code:
s = input()
s = s.translate(str.maketrans({'T': 'A', 'G': 'A', 'C': 'A'}))
s = list(s)+['END']

if s[0] == 'A':
    counter = 1
else:
    counter = 0

ans = 0

for i in range(len(s)):
    if s[i - 1] == s[i] == 'A':
        counter += 1
    else:
        if ans < counter:
            ans = counter
        if s[i] == 'A':
            counter = 1
        else:
            counter = 0
print(ans)

Submission status: Accepted

Solution code:
s = input()

s_list = ['T', 'C', 'G']

out = 0

for i in s_list:
  s = s.replace(i, 'A')

count = 0
for i in s:
  if i == 'A':
    count += 1
    if out < count:
      out = count
  else:
    count = 0

print(out)

Submission status: Accepted

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

for s in range(len(S)):
    #    print(S[s])
    match = 0
    for acgt in ACGT:
        if S[s] == acgt:
            length += 1
            if max_length < length:
                max_length = length
            match = 1
#            print(acgt)
    if match == 0:
        length = 0

print(max_length)

Submission status: Accepted

Solution code:
ans=0
tmp=0
for i in input():
    if i=='A' or i=='C' or i=='G' or i=='T':
        tmp += 1
    else:
        tmp = 0
    if ans<tmp:
        ans = tmp
print(ans)

Submission status: Accepted

Solution code:
def main():

    s = input()
    count = [0] * len(s)

    for i in range(len(s)):
        if s[i] in ['A', 'C', 'T', 'G']:
            count[i] = count[i-1] + 1

    print(max(count))


main()

Submission status: Accepted

Solution code:
S=input()

i=0
ans,temp=0,0
while(i<len(S)):
    if(S[i]=='A' or S[i]=='T' or S[i]=='G' or S[i]=='C'):
        temp+=1
        ans=max(ans,temp)
    else:
        temp=0
    i+=1

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input();
charList=list(s);
result=0;
tmp=0;
for c in charList:
 if c=='A' or c=='T' or c=='G' or c=='C':
   tmp=tmp+1;
 else:
  if tmp>result:
   result=tmp;
  tmp=0;
if tmp>result:
 result=tmp;
print(result);

Submission status: Accepted

Solution code:
S = input()
ans = 0
l = 0
for i in range(len(S)):
    if S[i] in 'ATGC':
        l += 1
    else:
        l = 0
    if l > ans:
        ans = l
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
remove = ["A","T","C","G"]
mxm = 0
i = 0
counter = 0
while i < len(s):
    if s[i] in remove:
        counter += 1
        i += 1
    else:
        if counter > mxm:
            mxm = counter
        counter = 0
        i += 1
if counter > mxm:
    mxm = counter
print(mxm)

Submission status: Accepted

Solution code:
S = list(input())
answer = 0
index = len(S)
i = 0
s = 0
while(i < index):
    str = S[i]
    if(str == "A" or str == "C" or str == "G" or str == "T"):
        s += 1
    else:
        s = 0
    if(answer < s):
        answer = s
    i += 1
print(answer)

Submission status: Accepted

Solution code:
text = input()
rule = 'ATCG'

max_len = 0
text_len = 0
for char in text:
    if char in rule:
        text_len += 1
    else:
        if text_len > max_len:
            max_len = text_len
        text_len = 0
if text_len > max_len:
    max_len = text_len
print(max_len)

Submission status: Accepted

Solution code:
s = input()
l = len(s)
ans = 0
ls = ['A','C','G','T']

i = 0
while i<=l-1 :
    
    if s[i] in ls :
        
        j = i + 0
        while (j<=l-1) and (s[j] in ls) :
            j += 1
        
        if j-i > ans :
            ans = j-i
        
        i = j + 0

    else :
        i += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = str(input())

cnt = 0
cnt_max = 0



for i in range(len(a)):
    if((a[i]=="A") or(a[i]=="C") or (a[i]=="G") or (a[i]=="T")):
        cnt += 1
    else:
        cnt = 0
    
    if(cnt >= cnt_max):
        cnt_max = cnt
        

print(cnt_max)

Submission status: Accepted

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

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

if counter > ans:
    ans = counter
        
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 + 2]):
            ans = max(ans, len(S[i:j + 2]))

print(ans)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

import re

S = input()
S = re.sub("[ACGT]", "-", S)

for i in range(1, 12):
    if not ("-" * i) in S:
        print(i - 1)
        exit()

Submission status: Accepted

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

for i in range(len(s)):
    count = 0
    while (1):
        if (s[i] == 'A'):
            i += 1
            count += 1
        elif (s[i] == 'T'):
            i += 1
            count += 1
        elif (s[i] == 'G'):
            i += 1
            count += 1
        elif (s[i] == 'C'):
            i += 1
            count += 1
        else:
            output.append(count)
            break

max = 0
for i in output:
    if (i >= max):
        max = i

print(max)

"""

s = input()
count = 0

for i in range(len(s)):
    count_tmp = 0
    for j in range(i,len(s)):
        if(s[j] == 'A'):
            count_tmp += 1
        elif(s[j] == 'T'):
            count_tmp += 1
        elif(s[j] == 'G'):
            count_tmp += 1
        elif(s[j] == 'C'):
            count_tmp += 1
        else:
            break
    if(count_tmp > count):
        count = count_tmp

print(count)

Submission status: Accepted

Solution code:
s = input()

cs = ['A', 'G', 'T', 'C']
ans = 0
for i in range(len(s)):
    cur = 0
    for j in range(i, len(s)):
        if s[j] in cs:
            cur += 1
        else:
            break
    ans = max(ans, cur)

print(ans)

Submission status: Accepted

Solution code:
def search_atcg(data):
    atcg = ['A', 'T', 'C', 'G']
    co = 0
    max_co = 0
    for s in data:
        if s in atcg:
            co += 1
            if co > max_co:
                max_co = co
        else:
            co = 0
    return max_co


if __name__ == "__main__":
    data = input()
    print(search_atcg(data))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    t = 'ACGT'
    r = 0
    u = 0
    for c in s:
        if c in t:
            u += 1
        else:
            if r < u:
                r = u
            u = 0
    if r < u:
        r = u

    return r


print(main())

Submission status: Accepted

Solution code:
import re

def main():
    s = input()
    print(solve(s))

def solve(s):
    r = 0
    for x in re.findall(r'[ACGT]+', s):
        r = max(r, len(x))
    return r

main()

Submission status: Accepted

Solution code:
S = input()
temp = ""
ans = 0
for n in range(len(S)):
  if S[n]=="A" or S[n]=="C" or S[n]=="G" or S[n]=="T":
    temp += S[n]
  else:
    if ans < len(temp):
      ans = len(temp)
    temp = ""
if ans < len(temp):
  ans = len(temp)
print(ans)