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

acgt_s = "ACGT"
count_s = 0
count_max = 0

for i in s:
    for j in acgt_s:
        if j == i:
            count_s += 1
            count_max = max(count_max, count_s)
            break
    else:
        count_s = 0


print(count_max)

Submission status: Accepted

Solution code:
S = input()
out = 0
hoge = 0

for k in S:
    if k == "A" or k == "T"or k == "G" or k == "C":
        hoge += 1      
        if hoge >= out:
            out = hoge
    else:
        hoge = 0

print (out)

Submission status: Accepted

Solution code:
s = input()
ans = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        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 = str(input())

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

ans = 0
for i in range(len(S)):
    cnt = 0
    if S[i] in targets:
        for j in range(i, len(S)):
            if S[j] in targets:
                cnt += 1
            else:
                break
        ans = max(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
def check_s(s,list):
    for i in range(len(s)):
        if not s[i] in list:
            return False

    return True


S = input()
#print(S)
l = len(S)
#print(l)
sub_S = ''
list = ['A','C','G','T']

max_len = 0

for k in range(l+1):
    for i in range(l+1-k):
        sub_S = S[i:i+k]
        #print(sub_S)
        if check_s(sub_S,list):
            if len(sub_S) > max_len:
                max_len = len(sub_S)

print(max_len)

Submission status: Accepted

Solution code:
s = input()
c = 0
m = 0
for i in range(len(s)):
  if s[i] in 'AGCT':
    c += 1
  else:
    m = max(m,c)
    c = 0
m = max(m,c)
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    S = input()

    ans = 0
    for i in range(len(S)):
        for j in range(i + 1, len(S) + 1):
            t = S[i:j]

            ok = True
            for c in t:
                if c not in "ACGT":
                    ok = False
            if ok:
                ans = max(ans, len(t))

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import re

S = input()
list = re.split("[BDEFHIJKLMNOPQRSUVWXYZ]", S)
max = 0
for x in list:
    if max < len(x):
        max = len(x)
print(max)

Submission status: Accepted

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

    else:
        I[i]=0
for i in range(len(I)):
    if (I[i]==1 and I[i-1]==0) or (I[i]==1 and i==0):
        ans.append(1)
    elif (I[i]==1 and I[i-1]==1):
        ans[-1]+=1
if ans==[]:
    print(0)
else:
    print(max(ans))

Submission status: Accepted

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

cnt = 0
tmp = 0
for s in S:
  if s in agct:
    tmp = tmp + 1
  else:
    if tmp > cnt:
      cnt = tmp
      tmp = 0
  
if tmp > cnt:
  cnt = tmp

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

temp = 0
c = 0
ACGT = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    if s[i] in ACGT:
        temp += 1
    elif s[i] not in ACGT and temp != 0:
        if temp > c:
            c = temp
        temp = 0
    
    if i + 1 == len(s):
        if temp > c:
            c = temp

print(c)

Submission status: Accepted

Solution code:

S_lst = list(input())

S_len = len(S_lst)

count = 0

count_max = 0

for s in range(0, S_len):

    if S_lst[s] == "A" or S_lst[s] == "C" or S_lst[s] == "G" or S_lst[s] == "T":
        count += 1
        if count > count_max:
            count_max = count

    else:
        count = 0

print(count_max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
n = []
a = 0
for i,s in enumerate(S) :
	if s in ["A","T","G","C"] :
		a += 1
	else :
		n.append(a)
		a = 0
	
	if i+1 == len(S) :
		n.append(a)
		break
print(max(n))

Submission status: Accepted

Solution code:
s = input().rstrip()
ans = 0
count = 0
for i in range(len(s)):
    if s[i] in 'ACGT':
        count += 1
    else:
        if count > 0:
            ans = max(ans, count)
            count = 0
print(max(ans, count))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
f = input()
m=[0,0,0,0,0]
i =0
for k in f:
    if (k=="A" and "T") or (k=="T" and "A") or (k=="C" and "G") or (k=="G" and "C"):
        m[i]+=1
    elif m[i] != 0:
        i += 1
print(max(m))

Submission status: Accepted

Solution code:
#-*- coding: utf-8 -*-
S=list(str(input()))
count=0
count_max=0

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

print(count_max)

Submission status: Accepted

Solution code:
str=list(input())
count=0
count_max=0
for list in str:
  if list=='A' or list=='C' or list=='G' or list=='T':
    count+=1
    if count>count_max:
      count_max = count
  else:
    count=0
    
print(count_max)

Submission status: Accepted

Solution code:
# Coding-utf

S=list(map(str, input()))
lenth=0
max=0
for i in range(len(S)):
    if S[i]=="A" or S[i]=="T" or S[i]=="C" or S[i]=="G":
            lenth+=1
    else:
        if max<lenth:
            max=lenth
            lenth=0
        else:
            lenth=0

if max<lenth:
    max=lenth

print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sub():
    S = input()
    maxCount = 0
    count = 0
    acgt = ["A", "C", "G", "T"]
    for c in S:
        if c in acgt:
            count = count + 1
            if count > maxCount:
                maxCount = count
        else:
            count = 0
    print(maxCount)



sub()

Submission status: Accepted

Solution code:
S=list(input())

ans = 0
tmp = 0
for s in S:
    if s == 'A' or s == 'T' or s == 'G' or s == 'C':
        tmp += 1
        if tmp > ans:
            ans = tmp
    else:
        tmp = 0
print(ans)

Submission status: Accepted

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

ans = 0
num = 0

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

Submission status: Accepted

Solution code:
S=input()

ans = []
for i in range(len(S)):
    for j in range(len(S[i:])):
        if all([S[i:i+j+1][k] in ['A','C','G','T'] for k in range(len(S[i:i+j+1]))]):
            ans.append(S[i:i+j+1])
if len(ans) != 0:
    print(max(list(map(len,ans))))
else:
    print(0)

Submission status: Accepted

Solution code:
s=input()

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

print(max(counts))

Submission status: Accepted

Solution code:
S = input()

counts = []
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
        if i == len(S) - 1:
            counts.append(count)
    else:
        counts.append(count)
        count = 0

print(max(counts))

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(len(S)):
    for j in range(1,len(S)+1):
        if i < j:
            OK = True
            for k in range(i, j):
                if not S[k] in "ACGT":
                    OK = False
            if OK:
                ans = max(ans, j-i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(max(max_count, count))

Submission status: Accepted

Solution code:
S = input()

cur, max_ = 0, 0
for c in S:
    if c in {'A', 'C', 'G', 'T'}:
        cur += 1
    else:
        max_ = max(cur, max_)
        cur = 0
max_ = max(cur, max_)
print(max_)

Submission status: Accepted

Solution code:
s=input()
s1="ATGC"
l=[]
count=0
for i in range(len(s)):
  if s[i] not in s1:
    l.append(count)
    count=0
  else:
    count=count+1
  if i==len(s)-1 and s[i] in s1:
    l.append(count)
    
print(max(l))

Submission status: Accepted

Solution code:
a = input()
count = 0
countd=0
for i in a:
    if i in ('A' , 'T' , 'G' , 'C'):
        count+=1
    else:
        if countd < count:
            countd = count
            count = 0
if countd < count:
    countd = count
    count = 0
print(countd)

Submission status: Accepted

Solution code:
S=str(input())
length=0
longest=0

for i in range(len(S)):
    if S[i]!='A' and S[i]!='C' and S[i]!='G' and S[i]!='T':
        length=0
    else:
        length+=1
    if length>longest:
        longest=length
print(longest)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

s = input()
ans = 0
mch = re.findall('[ATGC]+', s)

for m in mch:
    if len(m) > ans:
        ans = len(m)
print(ans)

Submission status: Accepted

Solution code:
S = input()

max_count = 0
counter = 0
last_s_is_ACGT = False
for i in range(len(S)):
    if S[i] in ["A", "C", "G", "T"]:
        counter += 1
        if counter > max_count:
            max_count = counter
    else:
        counter = 0

print(max_count)

Submission status: Accepted

Solution code:
s = input()
temp = 0
max = 0

for i in range(len(s)):
    if ('A' in s[i]) :
        temp += 1
    elif ('C' in s[i]) :
        temp += 1
    elif ('G' in s[i]) :
        temp += 1
    elif ('T' in s[i]) :
        temp += 1
    else : temp = 0

    if temp > max :
        max = temp

print(max)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

count = 0
max_val = 0

input_str = input()

for i in input_str:
    if(i in acgt_array):
        count += 1
    else:
        count = 0
    if(count > max_val):
        max_val = count
print(max_val)

Submission status: Accepted

Solution code:
inpString = [x for i in input().split() for x in i]
count = 0
maxCount = 0
lst = ["A","C","G","T"]
for i in inpString:
    if(i in lst):
        count+=1
        maxCount = max(maxCount,count)
    else:
        count=0
print(maxCount)

Submission status: Accepted

Solution code:
m=t=0
for _,c in enumerate(input()):
    t += 1 if 'ACGT'.find(c)>=0 else -t
    m=max(m,t)
print(m)

Submission status: Accepted

Solution code:
m=t=0
for _,c in enumerate(input()):
    if 'ACGT'.find(c)>=0:
        t+=1
        m=max(m,t)
    else:
        t=0
print(m)

Submission status: Accepted

Solution code:
s=input()
ans=0
for x in range(1,len(s)+1):
	for left in range(len(s)-x+1):
		z=s[left:left+x]
		flag=True
		for i in range(x):
			if z[i]!="A" and z[i]!="G" and z[i]!="C" and z[i]!="T":
				flag=False
				break
		if flag==True:
			ans+=1
			break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
a = list(a)
k = 0
b = []
for i in range(len(a)):
    if any(x in a[i] for x in ('A','T','G','C')):
        k += 1
    else:
        b.append(k)
        k = 0
b.append(k)
print(max(b))

Submission status: Accepted

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

alp = 'BDEFHIJKLMNOPQRSUVWXYZ'

cnt = []

for i in range(0, N):
    for j in range(i, N+1):
        tmp = S[i:j]
        flg = 1
        for a in alp:
            if a in tmp:
                flg = 0
        if flg:
            cnt.append(len(tmp))

print(max(cnt))

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]=='C' or s[i]=='G' or s[i]=='T'):
        count+=1
        if(i==n-1):
            if(max<=count):
                max=count
    else:
        if(max<=count):
            max=count
        count=0
print(max)

Submission status: Accepted

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

mx = max(mx, len)

print(mx)

Submission status: Accepted

Solution code:
s = input()

l = [0]
cnt = 0
for i in s:
    if i in 'ATCG':
        cnt += 1
    else:
        if cnt > 0:
            l.append(cnt)
        cnt = 0
l.append(cnt)

print(max(l))

Submission status: Accepted

Solution code:
s = input()

atgc = "ATGCF"
ans = 0
flag = 0
tmp = 0
for c in s:
    for key in atgc:
        if c == key:
            tmp += 1
            flag = 1
            break
        if key == "F":
            flag = 0
    if tmp > ans:
        ans = tmp
    if flag == 0:
        tmp = 0
print(ans)

Submission status: Accepted

Solution code:
S = input()
S ="w"+ S + "w"
m = 0
n = 0
lst = []
for i in S:
  n += 1
  if i not in "ACGT":
    lst.append(n)
for y in range(len(lst)-1):
  if (lst[y+1] - lst[y]) > m:
    m = (lst[y+1] - lst[y])
print (m-1)

Submission status: Accepted

Solution code:
s = input()
c = [0]
for i in s:
	if i in 'ACGT':c.append(c[-1] + 1)
	else:c.append(0)
print(max(c))

Submission status: Accepted

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


def isATCG(s):
    if s in "ATCG":
        return True
    return False

def solve(S: str):
    S1 = [0] * len(S)

    c = 0
    for i in range(len(S)):
        if isATCG(S[i]):
            c += 1
        else:
            c = 0
        S1[i] = c

    print(max(S1))

        

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
#入力(これは一つにまとめられる) #lst = [i for i in input()]
s = input()
lst = [i for i in s]
ans = []
#ATGCのいずれかの文字だったらカウントを１増やす
cnt = 0
"""
まえから順にATGCのいずれかであるかを判定する
カウントは毎回ansに追加していくので、lstの要素分だけ追加される
同じ値が続けばカウントは1増えて配列ansにつかされる
最終出力は配列の中の最大値を出力する。
"""
for i in range(len(lst)):
    if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
        cnt += 1
    else:
        cnt = 0
    ans.append(cnt)

print(max(ans))

Submission status: Accepted

Solution code:
s = input()
cnt = 0
ans = []

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

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


s = input()
max_count = 0
now_count = 0
target = ["A", "C", "G", "T"]
for c in s:
        if(c in target):
                now_count += 1
        else:
                max_count = max(max_count, now_count)
                now_count = 0
print(max(max_count, now_count))

Submission status: Accepted

Solution code:
S = input()
maxlen = 0

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

Submission status: Accepted

Solution code:
s = input()
max_count = 0
now_count = 0
target = ["A", "C", "G", "T"]
for c in s:
        if(c in target):
                now_count += 1
        else:
                max_count = max(max_count, now_count)
                now_count = 0
print(max(max_count, now_count))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

ACGT = "ACGT"

cnt = 0
max_num = 0
for i in range(len(s)):
    if s[i] in ACGT:
        cnt+=1
    else:
        max_num = max(cnt, max_num)
        cnt = 0

print(max(max_num,cnt))

Submission status: Accepted

Solution code:
S = input()

count = [0]
counter = 0

for i in S:
  if i == "A" or i == "C" or i == "G" or i == "T":
    counter += 1
    count.append(counter)
  else:
    counter = 0

print(max(count))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ACGT = ["A", "C", "G", "T"]
K = []
for i in range(len(S)):
    if S[i] in ACGT:
        K.append(i)
if len(K) == 0:
    ans = 0
elif len(K) == 1:
    ans = 1
else:
    count = 0
    mx = 0
    for j in range(len(K)-1):
        if K[j+1]-K[j] == 1:
            count += 2
        else:
            ans = max(count, mx)
            count = 0
            mx = ans
    ans = max(count, mx)
    ans = ans/2 + 1
print(int(ans))

Submission status: Accepted

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

ans = 0
for i in range(n):
    for j in range(i,n):
        # ACGTに、sの一文字cが当てはまる場合1
        # それをsの文字ごとにループして調査する
        # すべてのsの文字が当てはまるなら、ansにsの長さを代入する
        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().strip()
max_l = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        if set(s[i:j+1]).issubset({'A', 'C', 'G', 'T'}):
            max_l = max(max_l, j+1 - i)

print(max_l)

Submission status: Accepted

Solution code:
s = (input())
N = len(s)
count_max = 0

alp = 'BDEFHIJKLMNOPQRSUVWXYZ'
n_alp = "ACGT"

for i in range(N):
  count = 0
  for j in range(N - i):
    if s[j + i] in n_alp:
      count += 1
    else :
      break
  if count > count_max:
    count_max = count

print(count_max)

Submission status: Accepted

Solution code:
def main():
    s=input()
    tmp = 0
    cnt = 0
    for i in s:
        if i =='A' or i == 'T' or i =='C' or i=='G':
            cnt +=1
        else:
            if tmp <= cnt:
                tmp = cnt
                cnt = 0
            else:
                cnt = 0

    print(max(tmp,cnt))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S= input()
#S="ATCODER"

r=[]
n=0
for a in S:
    if a in "ACGT":
        n+=1
    else:
        r.append(n)
        n=0
r.append(n)
print(max(r))

Submission status: Accepted

Solution code:
s = input()

max_len = 0
tmp_len = 0
for w in s:
    if w == "A" or w == "C" or w == "G" or w == "T":
        tmp_len += 1
    else:
        tmp_len = 0
    if max_len < tmp_len:
        max_len = tmp_len

print(max_len)

Submission status: Accepted

Solution code:
def judge(character):
	if character == "A" or character == "T" or character == "C" or character == "G":
		return 1
	else:
		return 0

a = list(input())
total = [0]
turn = 0
for i in range(len(a)):
	b = judge(a[i])
	if b == 1:
		total[turn] += 1
	else:
		turn += 1
		total.append(0)
print(max(total))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

work = ""
maxlen = 0
lenwork = 0
for i in range(0, len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        if i > 0 and (S[i - 1] == "A" or S[i - 1] == "C" or S[i - 1] == "G" or S[i - 1] == "T"):
            work += S[i]
            lenwork += 1
        else:
            work = S[i]
            if lenwork == 0:
                lenwork = 1
    else:
        work = ""
        if lenwork > maxlen:
            maxlen = lenwork
        lenwork = 0

if lenwork > maxlen:
    maxlen = lenwork

print(maxlen)

Submission status: Accepted

Solution code:
s=input()
ans=0
temp=0
t="ACGT"
for i in range(len(s)):
  flag=False
  for j in range(4):
    if s[i]==t[j]:
      temp=temp+1
      ans=max(ans,temp)
      flag=True
  if flag==False:
    temp=0
print(ans)

Submission status: Accepted

Solution code:
S = input()
ACGT_counter = [0]*len(S)

for ii in range(len(S)):
    if ii == 0 and (S[ii] == 'A' or S[ii] == 'C' or S[ii] == 'G' or S[ii] == 'T'):
        ACGT_counter[ii] = 1
    elif S[ii] == 'A' or S[ii] == 'C' or S[ii] == 'G' or S[ii] == 'T':
        ACGT_counter[ii] = ACGT_counter[ii-1] + 1
    else:
        ACGT_counter[ii] = 0
        
print(max(ACGT_counter))

Submission status: Accepted

Solution code:
from sys import stdin
S = stdin.readline().rstrip()
# print(S)
n = len(S)
ans = 0
agct = {'A','G','C','T'}
bin_s = ''
for s in S:
    if s in agct:
        bin_s += '1'
    else:
        bin_s += '0'

right = 0
cnt = 0
for left in range(n):
    # print(bin_s[right])
    while (right < n and bin_s[right] == '1'):
        cnt += 1
        # // ex: sum += a[right];
        right += 1
    ans = max(ans, cnt)

    if (right == left):
        right += 1  
    cnt = 0
    # ex: else sum -= a[left];
print(ans)

Submission status: Accepted

Solution code:
S = input()
check = []
for i in range(len(S)):
    if S[i] in ['A', 'C', 'G', 'T']:
        check.append(i)
ans = 1

if len(check) == 0:
    print(0)
else:
    num = 1
    for i in range(len(check) - 1):

        if check[i] + 1 == check[i+1]:
            num += 1
            ans = max(ans, num)
        else:
            num = 1
    print(ans)

Submission status: Accepted

Solution code:
str = input()
dif = ("A","C","G","T")

isdif = False
maxlen = 0
tempdif = ""
for c in str:
    if c in dif:
        if isdif:
            tempdif += c
        else:
            tempdif = c
            isdif = True
    else:
        isdif = False
        if len(tempdif) > maxlen:
            maxlen = len(tempdif)
        tempdif = ""
    if len(tempdif) > maxlen:
        maxlen = len(tempdif)
print(maxlen)

Submission status: Accepted

Solution code:
import sys

b = input()

flg = 0
n = 0
nw = []
for bi in b:
    if bi == 'A' or bi == 'G' or bi == 'C' or bi == 'T':
        flg = 1
        n += 1
    else:
        flg = 0
        n = 0
    nw.append(n)

nw.sort(reverse = True)
print(nw[0])

Submission status: Accepted

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

ans = 0
max = 0
for char in b:
    if char in ["A", "C", "G", "T"]:
        ans += 1
    else:
        ans = 0
    if max < ans:
        max = ans

print(max)

Submission status: Accepted

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

x = 0; l=[]
for c in s:
    if c in acgt:
        x += 1
    else:
        l.append(x)
        x = 0
l.append(x)
print(max(l))

Submission status: Accepted

Solution code:
s = input()
s_0 = s[:]
s_0 = s_0.replace('A', '.').replace('G', '.').replace('C', '.').replace('T', '.')
count = 0
ans = 0

for i in range(len(s_0)):
    if s_0[i] == '.':
        count += 1
        if ans < count:
            ans = count
    else:
        count = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# input
#a = int(input())
a = input()
#a, b, c = map(int, input().split())
#a, b, c = input().split()
o = 0
#o = []

# calc
for i in range(len(a)):
    if a[i] in ('A', 'C', 'G', 'T'):
        t = 1
        for j in range(i+1, len(a)):
            if a[j] in ('A', 'C', 'G', 'T'):
                t += 1
                # print(a[j])
               # if j == len(a)-1 and o < t:
               #     o = t
            else:
               # if o < t:
               #     o = t
                break
        if o < t:
            o = t

# output
print(o)
# for i in range(a):
#    print(o[i])

Submission status: Accepted

Solution code:
import re

s = input()

ACGT = re.compile(r'[ACGT]+')
a = ACGT.findall(s)

ml = 0
for i in a:
    if len(i) > ml:
        ml = len(i)

print(ml)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
str = input()
max_cnt = 0
cnt = 0
for s in str:
  if "ACGT".find(s) >= 0:
    cnt += 1
  else:
    if max_cnt < cnt:
      max_cnt = cnt
    cnt = 0

print(max(cnt,max_cnt))

Submission status: Accepted

Solution code:
s = input()

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

print(mx)

Submission status: Accepted

Solution code:

Str = input()

ans = [0]
count = 0
for s in Str:
    if s in "AGCT":
        count += 1
        ans.append(count)
    if count > 0 and s not in "AGCT":
        count = 0

print(max(ans))

Submission status: Accepted

Solution code:
S = str(input())
res = 0
temp = 0

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

Submission status: Accepted

Solution code:
n = input()
max_count = 0
count = 0
for i in n:
    if i in "ATCG":
        count += 1
        max_count = max(max_count, count)
    else:
        count = 0
print(max_count)

Submission status: Accepted

Solution code:
li = input()

s = 0
ds = 0
for v in li:
  if (v == 'A' or v =='T' or v=='G' or v=='C' ):
    ds+=1
  else:
    ds=0
  s = max(s,ds)
print (s)

Submission status: Accepted

Solution code:
import re
s = input()
m = re.findall(r"([ACGT]+)",s)
print(len(max(m,key=len)) if m else 0)

Submission status: Accepted

Solution code:
S = input()

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


print(max_length)

Submission status: Accepted

Solution code:
S = input()
res = 0
temp = 0

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

print(res)