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

Submission status: Accepted

Solution code:
s = input()
temp = []
maximum = 0
count =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
            maximum = max(maximum,count)
    else:
        count = 0

print(maximum)

Submission status: Accepted

Solution code:
s = str(input())

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

score = 0
tmp = 0
for i in s:
  if(i in list):
    tmp += 1
  else:
    score = max(score,tmp)
    tmp = 0

score = max(score,tmp)
print(score)

Submission status: Accepted

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

res=0
cnt=0

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    import re
    span = [len(i) for i in re.findall('[ACGT]*', str(input()))]
    if span:
        print(max(span))
    else:
        print(0)


resolve()

Submission status: Accepted

Solution code:
s = input()
dic = set(['A','T','G','C'])
count = 0
ans = 0
for char in s:
  if char in dic:
    count += 1
  else:
    ans = max(ans,count)
    count = 0

print(max(ans,count))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S = input()
N = len(S)

ans = 0
for i in range(N):
    if S[i] not in ["A", "C", "G", "T"]:
        continue
    s = S[i]
    for j in range(i+1, N):
        if S[j] not in ["A", "C", "G", "T"]:
           break 
        s += S[j]
    ans = max(ans, len(s))
print(ans)

Submission status: Accepted

Solution code:
s = input()

cnt = 0
max_cnt = 0

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

print(max_cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
n=len(s)
ans=""
res=[]
for i in range(n):
    if s[i]=="A" or s[i]=="T" or s[i]=="G" or  s[i]=="C":
        ans+=s[i]
    else:
        if ans!="":
            res.append(ans)
        ans=""
        continue
res.append(ans)
if not res:
    print(0)
    exit()
print(len(max(res, key=len)))

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())
L = ['A','C','G','T']
c = 0
ans = 0

for i in S:
    if i in L:
        c += 1
        ans = max(ans,c)
    else:
        c = 0

print(ans)

Submission status: Accepted

Solution code:
S = list(input())
L = ['A','C','G','T']
c = 0
ans = 0

for i in S:
    if i in L:
        c += 1
        if ans < c:
            ans = c
    else:
        c = 0

print(ans)

Submission status: Accepted

Solution code:
S = list(input())

c = 0
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
n = len(S)
ATGC = set(['A', 'T', 'G', 'C'])
ans = 0
for i in range(n):
    for j in range(i+1, n+1):
        tmp_s = S[i:j]
        if len(set(tmp_s) - ATGC) == 0:
            ans = max(ans, j-i)
print(ans)

Submission status: Accepted

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

ans = 0
tmp = ""
for s in S:
  if s in l:
    tmp += s
    if len(tmp) > ans:
      ans = len(tmp)
  else:
    tmp = ""

print(ans)

Submission status: Accepted

Solution code:
S = input()

res = []
tmp = []
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp.append(s)
    else:
        res.append(len(tmp))
        tmp = []
res.append(len(tmp))
print(max(res))

Submission status: Accepted

Solution code:
string = input()
lis = ["A","C","G","T"]

result  = 0
flag = 0
for i in string:
    if i in lis:
        flag +=1
    else :
        flag = 0
    if result <= flag :
        result = flag
print(result)

Submission status: Accepted

Solution code:
S = input()
T = "ACGT"
ans = 0
cnt = 0
for s in S:
    if s in T:
        cnt += 1
    else:
        if cnt > ans:
            ans = cnt
        cnt = 0
if cnt>ans:
    ans = cnt
print(ans)

Submission status: Accepted

Solution code:
s = [i for i in input()]
atgc = {"A","T","G","C"}
tmp = 0
lng = 0
for p in s:
  if p in atgc:
    tmp += 1
  else:
    if tmp > lng:
      lng = tmp
    tmp = 0
if tmp > lng:
  lng = tmp
print(lng)

Submission status: Accepted

Solution code:
S=input()
sum,ans=0,[0]

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

Submission status: Accepted

Solution code:
s = input()

max_len = 0
counter = 0

for s_i in s:
  if s_i in ['A','C','G','T']:
    counter += 1
  else:
    counter = 0
  max_len = max(max_len, counter)
  
print(max_len)

Submission status: Accepted

Solution code:
s=input()
cnt=0
ans=0
for i in s:
    if i=="A" or i=="C" or i=="G" or i=="T":
        cnt += 1
        ans = max(ans, cnt)
    else:
        #ans = max(ans, cnt)ここに書くとすべてAVGTの時にansが更新されない
        cnt=0
print(ans)

Submission status: Accepted

Solution code:
S = input()

max = 0
now = 0

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

Submission status: Accepted

Solution code:
S = input()

result = 0
count = 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:
        count = 0
    if result < count:
        result = count

print(result)

Submission status: Accepted

Solution code:
a=input()
ct=[0]*10
hantei=0
ct2=0
for i in a:
    if (hantei==1):
        if i in'ACGT':
            ct[ct2]+=1
        else:
            hantei=0
            ct2+=1
    else:
        if i in 'ACGT':
            ct[ct2]+=1
            hantei=1
print(max(ct))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
import re
sep = 'B|D|E|F|H|I|J|K|L|M|N|O|P|Q|R|S|U|V|W|X|Y|Z'
print(max([len(i) for i in re.split(sep, s)]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def is_acgt_char(c):
  return c == "A" or c == "C" or c == "G" or c == "T"

def main():
  S = input()
  ans = 0

  for i in range(len(S)):
    count = 0
    
    for j in range(i, len(S)):
      if(not is_acgt_char(S[j])):
        break

      count += 1

    ans = max(ans, count)

  print(ans)

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
import math

s=list(input())
cnt = ""
for i in range(len(s)):
    if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
        t = ""
        for j in range(len(s)-i):
            if s[i+j]=="A" or s[i+j]=="T" or s[i+j]=="G" or s[i+j]=="C":
                t += s[i+j]
            else:
                break
        if len(t) >= len(cnt):
            cnt = t
print(len(cnt))

Submission status: Accepted

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

acum = [0] * (n + 1)
acgt = ['A', 'C', 'G', 'T']

for i in range(1, n + 1):
    if s[i - 1] in acgt:
        acum[i] = acum[i - 1] + 1
    else:
        acum[0] = 0

print(max(acum))

Submission status: Accepted

Solution code:
s = input()
ans = 0

if len(s)==1:
    if s.count("A")+s.count("G")+s.count("C")+s.count("T") == 1:
        print(1)
        exit()

 
for i in range(len(s)-1):
    for j in range(i+1, len(s)+1):
        x = s[i:j]
        if x.count("A")+x.count("G")+x.count("C")+x.count("T") == len(x) and len(x) > ans:
            ans = len(x)
 
print(ans)

Submission status: Accepted

Solution code:
s = input()

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

print(count)

Submission status: Accepted

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

moji= []
word = ""
#print(len(S))
for i in range(len(S)):
    #print(S[i])
    if S[i] in ACGT:
        word += S[i]
        moji.append(word)
    else:
        #moji.append(word)        
        word = ""    
#print(moji)

answer = ""
for i in range(len(moji)):
    
    if len(moji[i]) > len(answer):
        answer = moji[i]
print(len(answer))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def check(s):
    return s == 'A' or s == 'C' or s == 'G' or s == 'T'


S = input()
ans = 0
tmp = 0
for s in S:
    tmp = tmp + 1 if check(s) else 0
    ans = max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 122 B - ATCoder
import sys

S = str(input())
target = ['A', 'C', 'G', 'T']

ans = 0
temp_ans = 0
for s in S:
    if s in target:
        temp_ans += 1
    else:
        temp_ans = 0
    ans = max(ans, temp_ans)

print(ans)

Submission status: Accepted

Solution code:
# ABC122B

import numpy as np

def rle(x):
    ''' Run Length Encoding

    rle('001111000000011')
    (array([2, 4, 7, 2]),
     array(['0', '1', '0', '1'], dtype='<U1'))

    rle('aabcccbbbaab')
    (array([2, 1, 3, 3, 2, 1]),
     array(['a', 'b', 'c', 'b', 'a', 'b'], dtype='<U1'))
    '''
    x = np.array(list(x))
    n = len(x)
    if n == 0:
        return (1, '')
    y = list(map(lambda a, b: a != b, x[1:], x[:-1]))
    i = np.hstack((np.where(y)[0]+1, n))
    return (np.diff(np.hstack((0, i))), x[i-1])

s = list(input())
for i in range(len(s)):
    if s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
        s[i] = 'A'
count, value = rle(s)
obj = count[value == 'A']
if len(obj) == 0:
    print(0)
else:
    print(max(obj))

Submission status: Accepted

Solution code:
S = input()
ml = 0

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


def read():
    S = input().strip()
    return S,


def solve(S):
    alphabets = ['A', 'C', 'G', 'T']
    max_count = 0
    count = 0
    for s in S:
        if s in alphabets:
            count += 1
        else:
            max_count = max(max_count, count)
            count = 0
    max_count = max(max_count, count)
    return max_count


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Submission status: Accepted

Solution code:
ACGT = ["A", "C" ,"G", "T"]
s = input()
ans = 0
temp = 0
for i in s:
  ok = False
  for j in ACGT:
    if i == j:
      ok = True
      temp += 1
  if ok == False:
    ans = max(ans, temp)
    temp = 0
ans = max(ans, temp)
print(ans)

Submission status: Accepted

Solution code:
S=input()
res=0
for st in [S[x:y] for x in range(len(S)+1) for y in range(len(S)+1) if x<=y]:
    for c in st:
        if not c in ('A','C','G','T'):
            break
    else:
        if res<len(st):
            res=len(st)
print(res)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(len(S)):
    for j in range(len(S), i, -1):
        trial = {x for x in S[i:j] if x not in 'ACGT'}
        if len(trial) == 0 and ans < len(S[i:j]):
            ans = len(S[i:j])
print(ans)

Submission status: Accepted

Solution code:
s = str(input())

res = 0
max_res = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        res += 1
        if res > max_res:
            max_res = res
    else:
        res = 0
print(max_res)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
ATGC = "ATGC"

cnt_ = 0
for i in range(len(S)):
    cnt = 0
    for j in range(i,len(S)):
        if S[j] in ATGC:
            cnt += 1
        else:
            break
    
    if cnt > cnt_:
        cnt_ = cnt

print(cnt_)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
L=len(s)
cnt=0
ans=0
dic=["A", "G", "C", "T"]

for i in range(L):
    if s[i] in dic:
        cnt+=1
        if cnt > ans:
            ans=cnt
    else:
        if cnt > ans:
            ans=cnt
        cnt=0


print(ans)

Submission status: Accepted

Solution code:
s = input()

l,r = 0,0
ma = 0
for l in range(len(s)):
    if(s[l] not in ['A','C','G','T']):continue
    t = ""
    for r in range(l,len(s)):
        if(s[r] not in ['A','C','G','T']):break
        t += s[r]
    ma = max(ma,len(t))
print(ma)

Submission status: Accepted

Solution code:
s = input()

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

ans = 0
temp = 0
for c in s:
    if c in acgt_list:
        temp += 1
        continue
    ans = temp if temp > ans else ans
    temp = 0
ans = temp if temp > ans else ans
print(ans)

Submission status: Accepted

Solution code:
S = input()

cnt = 0
max_str = 0
flg = True
for x in range(len(S) + 1):
    for y in range(x, len(S) + 1):
        for i in range(len(S[x:y])):
            if "A" in (S[x:y][i]) or "C" in (S[x:y][i]) or "G" in (S[x:y][i]) or "T" in (S[x:y][i]):
                flg = True
            else:
                flg = False
                break
        if flg is True:
            max_str = max(max_str, len(S[x:y]))

print(max_str)

Submission status: Accepted

Solution code:
s = input()
code = ['A','T','G','C']
ans = 0
l = len(s)
for i in range(l):
    for j in range(i,l):
        t = s[i:j+1]
        if set(t) <= set(code):
            ans = max(ans,j-i+1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC122-B
s = input()
atgc = set(['A','T','G','C'])
cnt = 0
acgt_len = []
for i in range(len(s)):
    if s[i] in atgc:
        cnt += 1
        
    else:
        acgt_len.append(cnt)
        cnt = 0
        
acgt_len.append(cnt)

print(max(acgt_len))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
kouho = []

for i in range(len(S) + 1):
  for j in range(1, len(S) + 1):
    s = S[i : j]
    if len(s) == s.count("A") + s.count("C") + s.count("G") + s.count("T"):
      kouho.append(len(s))
print(max(kouho))

Submission status: Accepted

Solution code:
s = input()
ans = 0
for i in range(1,len(s)+1): #i文字の文字列について調べる
    for j in range(len(s)-i+1): #j文字目でスタートしたとして
        if all(s[k]=='A' or s[k]=='G' or s[k]=='C' or s[k]=='T' for k in range(j,j+i)):
            ans = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=str(input())
S=S.translate(str.maketrans({'A': 'a', 'T': 'a', 'C': 'a','G': 'a'}))

if "a" in S:
    l=len(S)
    for i in range(1,l+1):
        b=S.count(str("a"*i))
        if b == 0:
            print(i-1)
            break
        if i==l:
            print(l)
else:
    print("0")

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
lis=["A","C","G","T"]
num=0
mx=0
for i in n:
  if i in lis:
    num+=1
  else:
    num=0
  if mx<num:
    mx=num
print(mx)

Submission status: Accepted

Solution code:
S = input()

sample = ["A", "C", "G", "T"]
result = [0] * len(S)
for i in range(len(S)):
    if S[i] in sample:
        if i == 0:
            result[i] += 1
        else:
            result[i] += 1 + result[i - 1]


print(max(result))

Submission status: Accepted

Solution code:
s = input()

l, cur = 0, 0
for c in s:
    if c in "ACGT":
        cur += 1
        if cur > l:
            l = cur
    else:
        cur = 0
print(l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
le=len(s)
lis=[]
for i in range(0,le):
  if s[i]!="A" and s[i]!="C" and s[i]!="T" and s[i]!="G":
    lis.append(i)
lo=0
for j in range(0,len(lis)-1):
  if lis[j+1]-lis[j]-1>=lo:
    lo=lis[j+1]-lis[j]-1
if bool(lis):
  if lis[0]>=lo:
    lo=lis[0]
  if le-lis[-1]-1>=lo:
    lo=le-lis[-1]-1
  print(lo)
else:
  print(le)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans = []
cnt = 0

for s in input():

    if not s in "ACGT":
        ans.append(cnt)
        cnt = 0
        continue
    
    cnt += 1

ans.append(cnt)

print(max(ans) if len(ans) != 0 else 0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
  S = input()
  
  maxLen = 0
  for start in range(len(S)):
    for end in range(start, len(S)+1):
      if set(S[start:end]) <= set("ATCG"):
        maxLen = max(end-start, maxLen)
        
  print(maxLen)

Submission status: Accepted

Solution code:
s = input()
lst = ["A", "C", "G", "T"]
flag = 0
cnt = 0
cnt_lst = []

for i in s:
    if flag:
        if i not in lst:
            cnt_lst.append(cnt)
            flag = 0
            cnt = 0
        else:
            cnt += 1
    else:
        if i in lst:
            flag = 1
            cnt += 1
if flag:
    cnt_lst.append(cnt)

print(max(cnt_lst)) if cnt_lst else print(0)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
S = input()

cnt = 0
mcnt = 0
for i in S:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        cnt += 1
        mcnt = max(mcnt,cnt)
    else:
        cnt = 0

print(mcnt)

Submission status: Accepted

Solution code:
S = input()
Max = 0
t = 0
for i in range(len(S)):
    if(S[i] == 'A')or(S[i]=='C')or(S[i]=='G')or(S[i]=='T'):
        k=i
        while k<len(S):
            if(S[k] not in ['A','C','G','T']):
                ans = k-i
                if(ans > Max):
                    Max = ans
                break
            elif(k==len(S)-1):
                ans = k-i+1
                if(ans>Max):
                    Max = ans
            k+=1
print(Max)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import re
s = input()
target = re.sub('[^ACGT]', '@', s)
num_list = []
for t in target.split('@'):
  num_list.append(len(t))
print(max(num_list))

Submission status: Accepted

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

for k in range(len(S)):
    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        count=0
print(count_max)

Submission status: Accepted

Solution code:
s = input()
count = 0
count_max = 0

for k in range(len(s)):
    if s[k] == "A" or s[k] == "C" or s[k] == "G" or s[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        if count_max < count:
            count_max = count
        else:
            count = 0
print(count_max)

Submission status: Accepted

Solution code:
s=input()
#for i in range(len(s),0,-1):
#    for j in range(0,len(s)-i+1):
#        #print(j,i+j)
#        s1=s[j:i+j:]
m=0
s1=""
for x in s:
    if x=='A' or x=='G' or x=='T' or x=='C':
        s1+=x
    else:
        #print(s1)
        m=max(m,len(s1))
        s1=""
print(max(m,len(s1)))

Submission status: Accepted

Solution code:
s = input()

chain = 0
max_chain = 0
for i in range(len(s)):
    if (s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T'):
        chain += 1
    else:
        if(chain > max_chain):
            max_chain = chain
            chain = 0
    if (i == len(s)-1):
        if(chain > max_chain):
            max_chain = chain
            chain = 0
            
print(max_chain)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B - ATCoder

S = input()

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    # 入力
    s = input()

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

    cnt = 0
    current_cnt = 0
    for c in s:
        if c in target:
            current_cnt += 1
        else:
            if current_cnt > cnt:
                cnt = current_cnt
            current_cnt = 0

    if current_cnt > cnt:
        cnt = current_cnt
    print(cnt)


main()

Submission status: Accepted

Solution code:
def atcoder(s):

    ans = 0
    count = 0
    acgt = ["A", "C", "G", "T"]

    for i in s:
        if i in acgt:
            count += 1
        else:
            count = 0
        ans = max(ans, count)
    return ans

def main():
    s = list(str(input()))
    print(atcoder(s))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
c = 0
x = 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
    else:
        x = max(c, x)
        c = 0
print(max(c, x))

Submission status: Accepted

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