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 = 'ACGT'
res = 0
cnt = 0

for a in s:
    cnt += 1
    if not a in acgt:
        cnt = 0
    res = max(res, cnt)
print(res)

Submission status: Accepted

Solution code:
S = input()
S=S.replace("T","A")
S=S.replace("G","A")
S=S.replace("C","A")
for i in range(10,-1,-1):
  if S.find("A"*i) != -1:
    print(i)
    break

Submission status: Accepted

Solution code:
S=list(input())
S.append("X")
i=0
ans=0
for j in range(len(S)):
  if S[j]!="A" and S[j]!="T" and S[j]!="C" and S[j]!="G":
    ans=max(ans,len(S[i:j]))
    i=j+1
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
s=list(input())
ls = list("ATGC")
a=[]
for i in range(len(s)):
  if s[i] in ls:
    a.append(i)
if a == []:
  print(0)
  sys.exit()
for i in range(len(a)):
  a[i] -= i+1
c=Counter(a)
print(c.most_common(1)[0][1])

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

s = rs()
res = [0] * len(s)
for i, c in enumerate(s):
    if c in 'ACGT':
        if i > 0:
            res[i] = res[i - 1] + 1
        else:
            res[i] = 1
print(max(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
ans=[0]
for i in range(len(a)+1):
    for j in range(i,len(a)+1):
        s=a[i:j]
        if set(s)<=set('ACGT'):
            ans.append(len(s))
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
ans = 0
for i in s:
    
    if (i in Lists):
        cnt += 1
    else:
        cnt = 0

    if (ans < cnt):
        ans = cnt

print(ans)

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
        ans=max(ans,cnt)
    else:
        cnt=0
print(ans)

Submission status: Accepted

Solution code:
s = input()
for i in s:
    if i not in "ACGT":
        s = s.replace(i, "1")
s = s.split("1")
print(len(max(s, key=len)))

Submission status: Accepted

Solution code:
s = input()

count = 0
Max = 0
for i in s:
    if i in "ACGT":
        count += 1
        Max = max(Max, count)
    else:
        count = 0
print(Max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
l = ["A","T","C","G"]
ans=[0]
t = 0
for i in s:
    if  i in l:
        t += 1
    else:
        ans.append(t)
        t = 0
else:
    ans.append(t)

print(max(ans))

Submission status: Accepted

Solution code:
import sys, os
import collections

def solve(input_stream):
  line = input_stream.readline().strip()
  start = 0
  end = 1
  ans = 0
  while end < len(line) + 1:
    target = line[end - 1]
    if target in ["A", "C", "G", "T"]:
      ans = max(ans, end - start)
      end += 1
    else:
      start = end
      end += 1
  return [str(ans)]

if __name__ == "__main__":
    outputs = solve(sys.stdin)
    for line in outputs:
      print(line)

Submission status: Accepted

Solution code:
S = input()
ACTG = ["A","C","T","G"]
TF = [False]*len(S)
for i,s in enumerate(S):
    if s in ACTG:
        TF[i] = True
cnt = 0
ans = 0
for tf in TF:
    if tf:
        cnt+=1
    else:
        cnt = 0
    ans = max(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
s=input()
l=list(s)
m=0
for i in range(len(l)):
    if l[i]!="A" and l[i]!="T" and l[i]!="C" and l[i]!="G":
        l[i]="."

ss="".join(l)
ll=ss.split(".")
lll=[0]
for i in ll:
    lll.append(len(i))
print(max(lll))

Submission status: Accepted

Solution code:
import re
res = 0
tmp = 0
for s in input():
    if re.search('[ACGT]', s):
        tmp += 1
    else:
        res = max(res, tmp)
        tmp = 0
res = max(res, tmp)
print(res)

Submission status: Accepted

Solution code:
s=input()
ret=0
now=0
for c in s:
  if 'ATCG'.count(c)!=0:
    now+=1
  else:
    now=0
  ret=max(now,ret)
print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())

n=len(S)
l=list("ACGT")
ans=[]

for i in range(n):
  count=0
  for j in range(i,n):
    if S[j] in l:
      count+=1
    else:
      break
  ans.append(count)
print(max(ans))

Submission status: Accepted

Solution code:
S = input()
L = len(S)
answer = 0
for left in range(L):
  for right in range(left,L):
    T = S[left:right+1]
    if set(T) <= set('ACGT'):
      answer = max(answer,right-left+1)

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
d = ['A','T','G','C']
l = len(S)
acgt = []
a = ''
for i in range(l):
    if S[i] in d:
        a = a + S[i]
        if i == l-1:
            acgt.append(a)
    else:
        acgt.append(a)
        a = ''

max = 0
for a in acgt:
    if len(a) > max:
        max = len(a)
print(max)

Submission status: Accepted

Solution code:
def p_b():
    s = input()
    s = s.replace("A", ".").replace("T", ".").replace("C", ".").replace("G", ".")
    ans = 0
    tmp = 0
    for e in s:
        if e != ".":
            ans = max(ans, tmp)
            tmp = 0
        else:
            tmp += 1
    ans = max(ans, tmp)
    print(ans)
    
p_b()

Submission status: Accepted

Solution code:
S = input()
ans = 0

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

Submission status: Accepted

Solution code:
a = "ATGC"

inp = input()

ans = 0

for i in range(len(inp)):
	if inp[i] in a:
		cnt, j = 0, i
		while j < len(inp) and inp[j] in a:
			cnt += 1
			j += 1
		ans = max(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0
ACGT = ("A", "C", "G", "T")

count = 0
count_list = [0]
for s in S:
    if s not in ACGT:
        count_list.append(count)
        count = 0
        continue
    else:
        count += 1
count_list.append(count)
print(max(count_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

S=input()

m_len=0
len=0

acgt={'A','C','G','T'}

for i in S:
    if i in acgt:
        len+=1
        #print(i,len)
    else:
        #print(i,len,m_len)
        if len>m_len:
            m_len=len
        len=0
        
if len>m_len:
    m_len=len

print(m_len)

Submission status: Accepted

Solution code:
S = str(input())

count = 0
ans = 0
for s in S:
    if s in 'AGCT':
        count += 1
        ans = max(ans, count)
    else:
        count = 0

print(ans)

Submission status: Accepted

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

cnt = 0
b = []
for i in range(len(s)):
	if s[i] in a:
		cnt += 1
	else:
		b.append(cnt)
		cnt = 0
b.append(cnt)
print (max(b))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
tuples = ("A", "C", "G", "T")
def print_ans(B):
    """Test Case
    >>> print_ans("ATCODER")
    3
    >>> print_ans("HATAGAYA")
    5
    >>> print_ans("SHINJUKU")
    0
    """
    max_len = 0
    tmp = 0
    for b in B:
        if b in tuples:
            tmp += 1
            max_len = max(max_len, tmp)
        else:
            tmp = 0
    print(max_len)

    

if __name__ == '__main__':
    B = input().rstrip()
    print_ans(B)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = list(input())
cheack = ['A','C','G','T']
counter,max_lenge = 0,0
for char in s:
  if char in cheack:
    counter += 1
    if counter > max_lenge:
      max_lenge = counter
  else:
    counter = 0
print(max_lenge)

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))
S = input()
C = set("ACGT")

tmp = 0
ans = 0

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = list(input())
N = len(S)
tmp = ["A","G","C","T"]
ans = 0
for s in range(N):
    for t in range(s,N+1):
        # print(s,t,S[s:t])
        flag = True
        for x in S[s:t]:
            if x not in tmp:
                flag = False

        if flag:
            ans = max(ans,t-s)


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

m = 0
count = 0

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

m = max(count, m)
count = 0

print(m)

Submission status: Accepted

Solution code:
a = list(input())

enki = set(["A", "C", "G", "T"])
cnt = 0
cntmax = 0
for i in a:
  if i in enki:
    cnt += 1
  else:
    if cntmax < cnt:
      cntmax = cnt
    cnt = 0
if cntmax < cnt:
  cntmax = cnt

print(cntmax)

Submission status: Accepted

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

count = 0
maxi = 0
for i in s:
    if i in acgt:
        count += 1
        if count > maxi:
            maxi = count
    else:
        count = 0
print(maxi)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
N = len(S)
L = [0 for i in range(N + 1)]
R = [0 for i in range(N + 1)]

t = 'ACGT'

cnt = 0
for i in range(N):
    if S[i] in t:
        cnt += 1
    else:
        cnt = 0
    L[i] = cnt
cnt = 0
for i in range(N - 1, -1, -1):
    if S[i] in t:
        cnt += 1
    else:
        cnt = 0
    R[i] = cnt

ans = L[0]
for i in range(1, N):
    ans = max(ans, L[i - 1] + R[i])

print(ans)

Submission status: Accepted

Solution code:
S = input()

t = ''.join(c if c in 'ACGT' else ' ' for c in S)
print(max(map(len, t.split(' '))))

Submission status: Accepted

Solution code:
ls_s = [_ for _ in input()]

cnt = 0
cmax = 0

for i in range(len(ls_s)):
    if (ls_s[i] == 'A') or (ls_s[i] == 'C') or (ls_s[i] =='G') or (ls_s[i] =='T'):
        cnt += 1
    elif cnt >= cmax:
        cmax = cnt
        cnt = 0
    else:
        cnt = 0
print(max(cmax, cnt))

Submission status: Accepted

Solution code:
import sys

def main():
    s = sys.stdin.readline().rstrip()
    
    ATCG = set('ATCG')
    res = 0
    cnt = 0
    for char in s:
        if char in ATCG:
            cnt += 1
        else:
            res = max(res, cnt)
            cnt = 0
    res = max(res, cnt)

    print(res)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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':
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
        

        
ans = max(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
import re


def main(s: str):
    length = [len(_s) for _s in re.findall(r'[ACGT]+', s)]

    if length == []:
        print(0)
        return

    print(max(length))


if __name__ == '__main__':
    s = input()

    main(s)

Submission status: Accepted

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

Submission status: Accepted

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

def func(a):
    return True if a!='' else False

for start in range(len(S)):
    for end in range(0,len(S)):
       l.append(S[start:end+1])

l = list(filter(func,l))

o=[]
r=[]
for m in l:
    for n in m:
        if n!='A' and n!='C' and n!='G' and n!='T':
            o.append(m)
            break

for p in o:
    l.remove(p)

for q in l:
    r.append(len(q))


if len(r)==0:
    print(0)
else:
    print(max(r))

Submission status: Accepted

Solution code:
import re
s = input()
print(max(map(len, re.sub(r'[^ATCG]', '1', s).split('1'))))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

length = 0
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
S += "_"

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

print(res)

Submission status: Accepted

Solution code:
max_num = 0
num = 0
for c in input():
    if c in {"A", "C", "G", "T"}:
        num += 1
    else:
        max_num = max(max_num, num)
        num = 0
max_num = max(max_num, num)
print(max_num)

Submission status: Accepted

Solution code:
s = input()
atgc = ["A","T","C","G"]
str = 0
max_ = 0
for i in range(len(s)):
  	if s[i] in atgc:
  		str += 1
  		if str >= max_:
  			max_ = str
  	else:
  		str = 0
print(max_)

Submission status: Accepted

Solution code:
s=input()
def c(b):
  return b=='A' or b=='G' or b=='T' or b=='C'

suc=[]
ct=0
for let in s:
  if c(let):
    ct+=1
  else:
    suc.append(ct)
    ct=0
suc.append(ct)
print(max(suc))

Submission status: Accepted

Solution code:
S = list(input())
s = ["A", "T", "G", "C"]
for i in range(len(S)):
    if S[i] not in s:
        S[i] = "takayg"
S = ''.join(S)
S = S.split("takayg")
ans = []
for i in S:
    ans.append(len(i))
print(max(ans))

Submission status: Accepted

Solution code:
S = list(input())

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

Submission status: Accepted

Solution code:
s = input()
b = 'ACGT'
a = t = 0

for c in s:
    if c in b:
        t += 1
    else:
        a = max(a, t)
        t = 0

print(max(a, t))

Submission status: Accepted

Solution code:
import re
s = input()
pattern = "[ATGC]+"

result = re.finditer(pattern, s)

lens = [len(res.group()) for res in result]
if len(lens)==0:
  ret=0
else:
  ret=max(lens)
print(ret)

Submission status: Accepted

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

atcg = ["A","T","C","G"]
ans = [0]*n
if s[0] in atcg:
    ans[0] += 1
    
for i in range(1,n):
    if s[i] in atcg:
        ans[i] += ans[i-1] + 1
        
print(max(ans))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ABC 122: B – ATCoder
s = input()
acgt = 'ACGT'

length = 0
max_length = 0

for i in range(len(s)):
    if s[i] in acgt:
        for j in range(len(s) - i):
            if s[i + j] in acgt:
                length += 1
            else:
                break

        max_length = max(max_length, length)
        length = 0

print(max_length)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
a = ["A", "C", "G", "T"]
ans = 0
count = 0
for i in S:
  if i in a:
    count += 1
  elif ans < count:
    ans = count
    count = 0

if count != 0:
  if ans < count:
    ans = count

print(ans)

Submission status: Accepted

Solution code:
s = input()

cnt = 0
maxc = 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 maxc < cnt:
    maxc = cnt

print(maxc)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
S = input()
pattern = '[AGCT]+'
print(max(map(len, re.findall(pattern, S)), default=0))

Submission status: Accepted

Solution code:
s = list(input())
i = 0
ans = []
while i < len(s):
    count = 0
    while s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T" :
        count += 1
        i += 1
        if i >= len(s):
            break
    ans.append(count)
    i += 1
print(max(ans))

Submission status: Accepted

Solution code:
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    permitted = 'ACGT'
    continuous_count = []
    count = 0

    for i in range(len(s)):
        char = s[i]
        if char in permitted:
            count += 1
        else:
            continuous_count.append(count)
            count = 0
        if i == len(s) - 1:
            continuous_count.append(count)
    
    if not continuous_count:
        print(len(s))
    else:
        print(max(continuous_count))



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    all_words = []
    for i in range(1, len(s) + 1):
        for letters in itertools.product('ATCG', repeat=i):
            word = ''.join(letters)
            all_words.append(word)
    
    for i in range(len(all_words)-1, 0-1, -1):
        if all_words[i] in s:
            print(len(all_words[i]))
            sys.exit()
    print(0)




if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print(max(map(lambda x:len(x), "".join([_ if _ in "ACGT" else "_" for _ in str(input())]).split("_"))))

Submission status: Accepted

Solution code:
print(max([len(_) for _ in "".join([_ if _ in "ACGT" else "_" for _ in str(input())]).split("_")]))

Submission status: Accepted

Solution code:
S = str(input())
tmp = S.replace('A', '_').replace('T','_').replace('G','_').replace('C','_')

for i in range(len(tmp)):
    if tmp[i] != '_':
        S = S.replace(S[i], '_')
print(max([len(x) for x in S.split('_')]))

Submission status: Accepted

Solution code:
b = list(input())

ans = 0
now = 0
for i in b:
    if i in ["A", "C","G","T"]:
        now += 1
        if now > ans:
            ans = now
    else:
        now = 0
        
print(ans)

Submission status: Accepted

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

def main():
    S = input().strip()
    ma = 0
    ACGT = ['A', 'C', 'G', 'T']
    count = 0
    for s in S:
        if s in ACGT:
            count += 1
        else:
            ma = max(ma, count)
            count = 0
    ma = max(ma, count)
    print(ma)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = str(input())
ans = 0
count = 0
out = ''
for i in range(len(S)):
  if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T':
    out += '1'
  else:
    out += '0'
out += '$'
for i in range(len(S)):
  if out[i]=='1':
    count += 1
    if out[i+1]!='1' and count>=ans:
      ans = count
      count = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
i=0
k=0
ans=0
while i<len(s):
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        while i<len(s):
            if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
                k+=1
            else:
                break
            i+=1
    i+=1
    ans=max(k,ans)
    k=0
print(ans)

Submission status: Accepted

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

S=one_str()

count=0
max_count=0
for s in S:
    if s in ["A","G","C","T"]:
        count+=1
    else:
        if max_count < count:
            max_count = count
        count=0
if max_count < count:
    max_count=count
print(max_count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

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

Submission status: Accepted

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

s = list(input())

tmp = 0
ans = 0

for i in range(len(s)) :
    if acgt.count(s[i]) == 1 :
        tmp += 1
    else :
        tmp = 0
    
    if tmp > ans :
        ans = tmp

print(ans)

Submission status: Accepted

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


print(ans)

Submission status: Accepted

Solution code:
s = list(str(input()))
info = []
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
        info.append(cnt)
    else:
        cnt = 0
        info.append(cnt)
print(max(info))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
S = input()
n = len(S)
l = np.zeros(n, dtype=int)
DNA = ['A', 'G', 'C', 'T']

if S[0] in DNA:
  ll = [1]
else:
  ll = [0]

for i in range(1, n):
  if S[i] in DNA:
    ll.append(ll[i-1]+1)
  else:
    ll.append(0)

print(max(ll))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

max_length = 0
for i in range(len(S)):
  if S[i] in "ACGT":
    if i == len(S) - 1:
      length = 1
    else:
      for j in range(i+1, len(S)):
        if S[j] in "ACGT":
          length = j - i + 1
        else:
          length = j - i
          break

    if length > max_length:
      max_length = length

print(max_length)

Submission status: Accepted

Solution code:
s = input()

count = 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':
    count += 1
    ans = max(ans, count)
  else:
    count = 0

print(ans)

Submission status: Accepted

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

    array = ['A', 'C', 'G', 'T']
    count = 0
    ans = 0
    for i in range(len(S)):
        if S[i]!=array[0] and S[i]!=array[1] and S[i]!=array[2] and S[i]!=array[3]:
            ans = max(ans, count)
            count = 0
        else:
            count += 1

    ans = max(ans, count)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

count_list = []
for i in S:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count_list.append(True)
    else:
        count_list.append(False)

l = len(S)
freq_list = []
for i in range(l):
    count = 0
    for j in range(l-i):
        if count_list[i+j] is True:
            count += 1
            freq_list.append(count)
        else:
            freq_list.append(count)
            break

print(max(freq_list))

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
acgt = {'A', 'C', 'G', 'T'}
cnt = 0
res = 0
for i,t in enumerate(s):
    if t in acgt:
        cnt += 1
    else:
        cnt = 0
    res = max(res, cnt)
print(res)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for i in range(n):
    for j in range(i,n):
        if any(k not in "ACGT" for k in s[i:j+1]):
            break
        ans = max(ans, j-i+1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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