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 = list(input())
temp = ""
list = []
ans = 0
for n in range(len(S)):
  if S[n]=="A" or S[n]=="C" or S[n]=="G" or S[n]=="T":
    temp += S[n]
  else:
    list.append(temp)
    temp = ""
list.append(temp)
temp = 0
for n in range(len(list)):
  if temp < len(list[n]):
    temp = len(list[n])
print(temp)

Submission status: Accepted

Solution code:
s = input()
ans = []
counter = 0
for i in s:
    if i in 'ATGC':
        counter += 1
    else:
        counter = 0
    ans.append(counter)
print(max(ans))

Submission status: Accepted

Solution code:
s=input()
i=1
n=0
ans=[0]
sta=0

 
while i<=len(s):
  if s[i-1]=='A'or s[i-1]=='C' or s[i-1]=='G' or s[i-1]=='T':
    n=n+1
    sta=1
  elif sta==1:
    ans.append(n)
    n=0

  if i<=len(s)&n==len(s):
    ans.append(n)
  elif n!=0:
      ans.append(n)
    
  i=i+1
  
print(max(ans))

Submission status: Accepted

Solution code:
import re

S = input()
num_list = [len(s) for s in re.split(r'[^ATCG]', S)]

print(max(num_list))

Submission status: Accepted

Solution code:

import sys
import re

input_line = sys.stdin.readline()

result = re.sub(r'[^ACGT]+', ' ', input_line).split(' ')

result_list = []
for i in result :
  result_list.append(len(i))

print(max(result_list))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:


text = input()

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

exist = False
for i in targets:
    if i in list(text):
        exist = True
        break

max_len_answer = ''

if exist:
    answer = ''
    for i in range(len(text)):
        if text[i] in targets:
            answer += text[i]
        else:
            if len(answer) >= len(max_len_answer):
                max_len_answer = answer
            answer = ''
        if i == len(text) - 1:
            if len(answer) >= len(max_len_answer):
                max_len_answer = answer


print(len(max_len_answer))

Submission status: Accepted

Solution code:
S = input()
max_l = 0
temp_l = 0

for s in S:
    if s == 'A' or s=='G' or s=='C' or s=='T':
        temp_l += 1
        max_l = max(max_l, temp_l)
    else:
        temp_l = 0

print(max_l)

Submission status: Accepted

Solution code:
s = input().strip()
st = "ACGT"
i, c,start = 0,0,0
while i < len(s):
    if s[i] not in st:
        c = max(i - start, c)
        start = i + 1
    i += 1
print(max(c,i - start))

Submission status: Accepted

Solution code:
#encoding: utf-8

s = input()

max_c = 0
count = 0
for i in s:
    if "ATCG".count(i):
        count += 1
        max_c = max(max_c, count)
    else:
        count = 0

print(max_c)

Submission status: Accepted

Solution code:
def calc(S,T):
    ans = 0
    for i in range(N):
        count = 0
        for j in range(i,N):
            flag = False
            for k in range(M):
                if S[j] == T[k]:
                    flag = True
            if flag:
                count = count + 1
                ans = max(count,ans)
            else:
                break
    print(ans)

if __name__ == "__main__":
    S = input()
    N = len(S)
    Target = "ATGC"
    M = len(Target)
    calc(S,Target)

Submission status: Accepted

Solution code:
def measure_ACGT(str):
  elements = ['A','C','G','T']
  length = 0
  for s in str:
    if not(s in elements):
      break
    else:
      length += 1    
  return length

def start_positions():
  return [0,1,2,3,4,5,6,7,8,9]

def find_longest_block(str):
  length = 0
  positions = start_positions()
  for pos in positions:
    s2 = str[pos:]
    ln = measure_ACGT(s2)
    if ln > length:
      length = ln
  return length

S = input()
print(find_longest_block(S))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ACGT = 'ACGT'
S = input()
for i in S:
    if i not in ACGT:
        S = S.replace(i, '-')
LIST = S.split('-')
LIST.sort(key = lambda n:len(n), reverse=True)
print(len(LIST[0]))

Submission status: Accepted

Solution code:
cnt = 0
max = 0
for s in input():
    if 'ATCG'.count(s):
        cnt +=1
        if cnt > max:
            max = cnt
    else:
        cnt = 0 
print(max)

Submission status: Accepted

Solution code:
S = list(input())

AGCT = ['A','G','C','T']
Ans = [0]
for i in range(len(S)):
    for j in range(len(S)):
        if all(AGCT.count(c) == 1 for c in (S[i:j+1])) == True:
            Ans.append(len(S[i:j+1]))

print(max(Ans))

Submission status: Accepted

Solution code:
S = input()

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

for c in S:
  if c in ok_list:
    count += 1
    if ans < count:
      ans = count
  else:
    count = 0

print(ans)

Submission status: Accepted

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

def count(s):
	max = 0
	cnt = 0
	for i in range(0, len(s)):
		if s[i] in acgt:
			cnt += 1
		else:
			cnt = 0
		if cnt > max:
			max = cnt
	return max

print count(raw_input())

Submission status: Accepted

Solution code:
S = input()
N = len(S)
max = 0
for i in range(N):
    if N-i<=max:
        break
    flag = 0
    for j in range(N-i):
        for k in range(j+1):
            if S[i+k]!='A' and S[i+k]!='T' and S[i+k]!='G' and S[i+k]!='C':
                flag = 1
                break
        if flag==0:
            if max < j+1:
                max = j+1
print(max)

Submission status: Accepted

Solution code:
def is_ACGT(c):
    if (c == "A") or (c == "C") or (c == "G") or (c == "T"):
        return True
    else:
        return False

def get_ACGT_length(s):
    if len(s) == 0:
        return 0

    if not is_ACGT(s[0]):
        return 0

    return 1 + (get_ACGT_length(s[1:]))


s = str(input())

result = 0
for i, c in enumerate(s):
    if is_ACGT(c):
        result = max(get_ACGT_length(s[i:]), result)

print(result)

Submission status: Accepted

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

import sys, re

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=input()
N=len(S)

ans=0
# 0文字以上でACGTのいずれかのみ
pattern = re.compile(r'^[ACGT]*$')
for i in range(N):
    for j in range(i+1, N+1):
        if pattern.match(S[i:j]):
            ans=max(ans, j-i)
print(ans)

Submission status: Accepted

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

max_length_str = ''
tmp_str = ''
for n in string:
  if n in acgt:
    tmp_str += n
  else:
    if len(tmp_str) > len(max_length_str):
      max_length_str = tmp_str
      tmp_str = ''

if len(tmp_str) > len(max_length_str):
  max_length_str = tmp_str
  tmp_str = ''

print(len(max_length_str))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

maxlen = 0
templen = 0
for i in range(len(S)):
    if S[i] in li:
        templen += 1
    else:
        maxlen = max(maxlen, templen)
        templen = 0
maxlen = max(maxlen, templen)
print(maxlen)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())
Check_list=['A','T','G','C']
 
out_num=0
for i in range(len(S)):
  for l in range(i,len(S)): 
    
    c=[x for x in S[i:l+1] if x not in Check_list]
    
    if (len(c) == 0) & (len(S[i:l+1]) >= out_num):
      out_num=len(S[i:l+1])
       
print(out_num)

Submission status: Accepted

Solution code:
def function(S):
    ACGT = ['A', 'C', 'G', 'T']
    ret = 0
    N = len(S)
    for i in range(0, N):
        for j in range(i+1, N+1):
            temp = 0
            l = S[i:j]
            const = 0
            for x in l:
                if x not in ACGT:
                    const = 1
                    break
            if const == 1:
                break
            temp = len(l)
            if temp >= ret:
                ret = temp
    return ret

S = input()
print(function(S))

Submission status: Accepted

Solution code:
str = list(input())

tmp = ''
ans = ''
for s in str:
  if (s in ['A', 'T', 'G', 'C']):
    tmp += s
    if (len(tmp) > len(ans)):
      ans = tmp
  else:
    tmp = ''

print(len(ans))

Submission status: Accepted

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

for i in range(len(s), -1, -1):
  for j in range(len(s)):
    if j + i > len(s):
      break
    else:
      sub = s[j:i+j]
      if set(sub).issubset(possible):
        ans = max(ans, len(sub))

print(ans)

Submission status: Accepted

Solution code:
Ss = input() + '#'

ans = 0
num = 0
for S in Ss:
    if S in 'ACGT':
        num += 1
    else:
        ans = max(ans, num)
        num = 0

print(ans)

Submission status: Accepted

Solution code:
ACGT = "ACGT"

s= input()
nums = []
num = 0
for _s in s:
    if _s not in ACGT:
        nums.append(num)
        num = 0
        continue
    num += 1
nums.append(num)
print(max(nums))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
s = input()
dic_ = str.maketrans({'T':'1','A':'1','C':'1','G':'1'})
s = s.translate(dic_)
count = 0
result = 0
pre_i = ''

for i in s:
  if pre_i == '1' and i == '1':
    count += 1
    
  elif pre_i =='1':
    if count > result:
      result = count
    count = 0
    pre_i = ''
  
  elif i == '1':
    count += 1
    pre_i = '1'
if result < count:
  result = count
print(result)

Submission status: Accepted

Solution code:
S = input()
max_l = 0
tmp = 0

for i in S:
  if i == 'A' or i == 'C' or i == 'G' or i == 'T':
    tmp += 1
    if max_l < tmp:
      max_l = tmp
  else:
    tmp = 0
print(max_l)

Submission status: Accepted

Solution code:
n=input()
dic = {'A': True, 'C': True, 'G': True, 'T': True}
lens = []

for i in range(0, len(n)):
    length = 0
    s = n[i]

    if s not in dic:
        lens.append(length)
        continue

    length += 1
    for j in range(i+1, len(n)):
        t = n[j]
        if t not in dic:
            break

        length += 1

    lens.append(length)
print(max(lens))

Submission status: Accepted

Solution code:
str = input()
ans = []
allow = ["A","C","G","T"]
count = 0
for s in str:
  if s in allow:
    count = count + 1
    ans.append(count)
  else:
    count = 0
    
if len(ans) == 0:
  print(0)
else:
  print(sorted(ans)[-1])

Submission status: Accepted

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

Submission status: Accepted

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

for s in S:
	if (s == 'A') | (s == 'C') | (s == 'G') | (s == 'T'):
		temp += 1
	else:
		if temp > max_len:
			max_len = temp
		temp = 0
if temp > max_len:
    max_len = temp
print(max_len)

Submission status: Accepted

Solution code:
s = list(input())
ans = 0
acgt = ["A","C","G","T"]
for i in range(len(s)):
    if s[i] in acgt:
        temp = 1
        j = 1
        while len(s) > i + j and s[i + j] in acgt:
            temp += 1
            j += 1
        ans = max(temp, ans)

print(ans)

Submission status: Accepted

Solution code:
S = input()

S = ''.join(list(map(lambda s: 'x' if s in 'ACGT' else 'y', S)))
S = S.split('y')
S = [len(s) for s in S]

print(max(S))

Submission status: Accepted

Solution code:
mojiretu=input()
b="ACGT"
length=0
temp=[]
for i in range(len(mojiretu)):
    if mojiretu[i] in b:
        length += 1
    else:
        temp.append(length)
        length=0

temp.append(length)

print(max(temp))

Submission status: Accepted

Solution code:
mojiretu = input()
length = 0
dict = ["A","G","C","T"]
answers =[]
for i in range(len(mojiretu)):
  if mojiretu[i] in dict:
    length += 1
  else:
    answers.append(length)
    length = 0

answers.append(length)

print(max(answers))

Submission status: Accepted

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

print(ansMax)

Submission status: Accepted

Solution code:
s=input()
at='ACGT'
cnt=0
ans=[0]
for i in s:
    if i in at:
        cnt+=1
        ans+=[cnt]
    else:

        cnt=0
ans.sort()
print(ans[-1])

Submission status: Accepted

Solution code:
S = list(input())

count = 0
max = 0

for moji in S:
    if moji == "A"or moji == "T"or moji == "G"or moji == "C":
        count += 1
        if count > max:
            max = count
    else:
        count = 0
print(max)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

def count_acgt(s, i):
    v = 0
    for t in range(i, len(s)):
        if s[t] in acgt:
            v += 1
        else:
            break
    return v

for i, _ in enumerate(s):
    n = count_acgt(s, i)
    if n >= ml:
        ml = n

print(ml)

Submission status: Accepted

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

ans = 0
length = 0
for i in range(len(S)):
    if S[i] in ACGT:
        length += 1
        ans = max(ans, length)
    else:
        length = 0

print(ans)

Submission status: Accepted

Solution code:
s = input()
alp = [chr(ord('A') + i) for i in range(26)]
alp.remove('A')
alp.remove('C')
alp.remove('G')
alp.remove('T')

ans = 0
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        flg = True
        for k in alp:
            if k in s[i:j]:
                flg = False
                break
        if flg:
            ans = max(ans, j - i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
le = len(S)
ACGT = ['A','C','G','T']
cntlist = []
for i in range(le):
    cnt = 0
    for d in ACGT:
        if S[i] == d:
            cnt += 1
            for j in range(i+1,le):
                t = 0
                for d_ in ACGT:
                    if S[j] == d_:
                        cnt += 1
                        t += 1
                if t == 0: break
                    
    cntlist.append(cnt)

#print(cntlist)
print(max(cntlist))

Submission status: Accepted

Solution code:
data=input()
count=0
start=0
maxLen=0
for i in range(len(data)):
  if data[i] in "AGCT":
    if i>0:
      if data[i-1] not in "AGCT":
        start=i
    else:
      start=i
    if i<len(data)-1:
      if data[i+1] not in "AGCT":
        length=i-start+1
        if length>maxLen:
          maxLen=length
    else:
      length=i-start+1
      if length>maxLen:
        maxLen=length
print(maxLen)

Submission status: Accepted

Solution code:
s = input()

atgc = 'ATGC'
count= 0
max_count = 0

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

Submission status: Accepted

Solution code:
S = input()

ans = 0
for s in range(len(S)):
    for e in range(1,len(S) - s + 1):
        c = 0
        str = S[s:s+e]
        c += str.count('A')
        c += str.count('C')
        c += str.count('G')
        c += str.count('T')
        if c == len(str):
            ans = max(ans,len(str))
            # print(str)

print(ans)

Submission status: Accepted

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

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	str=list(io())
	
	agct=list('AGCT')
	max=0
	current=0
	
	for c in str:
		if c in agct:
			current+=1
			max = current if current > max else max
		else:
			current=0	
	
	return max

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Submission status: Accepted

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

Submission status: Accepted

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

for str in S:
  if str in {'A', 'C', 'G', 'T'}:
    cnt += 1
  else:
    if max < cnt:
      max = cnt
    cnt = 0
    
if max < cnt:
  max = cnt
  
print(max)

Submission status: Accepted

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

l = list(s)
#print(chars)
a=len(l)
#print(a)
ans=[0]*a
j=0
for i in range(a):
  if l[i]=="A":
    ans[j]+=1
  else:
    j+=1
 
print(max(ans))

Submission status: Accepted

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


def solve(S: str):
    max_len = 0
    def isvalid(s):
        return s in ['A', 'C', 'G', 'T']

    for i in range(len(S)):
        if not isvalid(S[i]):
            continue
        j = i + 1
        while j < len(S) and isvalid(S[j]):
            j += 1
        max_len = j-i if j-i > max_len else max_len
    print(max_len)
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = list(input())
b = 0
c = 0

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

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:
import re
print(max(map(len,re.split("[^ACGT]",input()))))

Submission status: Accepted

Solution code:
S = input()
mx = 0
for i in range(len(S)):
    for j in range(i, len(S) + 1):
        s = S[i:j]
        flag = True
        for si in s:
            if si not in ["A", "C", "G", "T"]:
                flag = False
        if flag:
            mx = max(mx, len(s))

print(mx)

Submission status: Accepted

Solution code:
s = input()

ans=0
base = set(['A','C','G','T'])
i = 1
while i <= len(s):
    j = 0
    while j+i <= len(s):
        word = set(s[j:j+i])
        if word <= base:
            ans = len(s[j:j+i])
        j += 1
    i += 1
print (ans)

Submission status: Accepted

Solution code:
a = input()
count = 0
mx = 0
for i in range(len(a)):
    if a[i] == "A" or a[i] == "C" or a[i] == "G" or a[i] == "T":
        count += 1
    else:
        count = 0
    if mx < count:
        mx = count
print(mx)

Submission status: Accepted

Solution code:
from itertools import groupby
s = input()
a = [1 if c in ['A', 'G', 'C', 'T'] else 0 for c in s]
l = 0
for n, c in groupby(a):
	c = sum(1 for i in c)
	if n == 1 and c > l:
		l = c
print(l)

Submission status: Accepted

Solution code:

S = input()
ans = 0
count = 0

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

print(ans)

Submission status: Accepted

Solution code:
S = list(input())
A = "ATCG"
count = 0
res = [0]
for s in S:
	if s in A:
		count += 1
		res.append(count)
	else:
		count = 0
print(max(res))

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

len_ = 0
ans = 0

for ch in S:
    if ch in "AGCT":
        len_ += 1
        ans = max(ans, len_)
    else:
        len_ = 0
print(ans)

Submission status: Accepted

Solution code:
S = str(input())
l = ['A','C','G','T']
c = 0
cplus = 0

for i in S:
    if i in l:
        cplus += 1
        c = max(c, cplus)
    else:
        cplus = 0
print(c)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(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:
import re
# 入力をACGT以外の文字で分割、それぞれについて文字列の長さに変換、その最大値を出力
print(max(map(len, re.split('[^ACGT]', input()))))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
s = list(input())
ans = 0
count = 0
for i in s:
    if i in "AGCT":
        count += 1
        ans = max(ans, count)
    else:
        count = 0

print(ans)

Submission status: Accepted

Solution code:
S = input()
maxLength = 0
start, flag = -1, False
for i in range(len(S)):
    if S[i] in {"A", "G", "C", "T"}:
        if not flag:
            flag = True
            start = i
    else:
        if flag:
            maxLength = max(maxLength, i - start)
            flag = False
if flag: maxLength = max(maxLength, len(S) - start)
print(maxLength)

Submission status: Accepted

Solution code:
s = "ACGT"

a = input()
n = len(a)

ans = 0
for i in range(n):
    if a[i] not in s:
        continue

    j = i
    while j<n and a[j] in s:
        j += 1
    ans = max(ans, j-i)

print(ans)

Submission status: Accepted

Solution code:
S=input()
count=0
result=0
for i in S:
    if i in 'AGTC':
        count+=1
        result=max(result,count)
    else:
        count=0
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding=utf-8
# Author: lee215

get = lambda: int(raw_input().strip())
gets = lambda: [int(i) for i in raw_input().strip().split()]
getss = lambda n: [gets() for _ in xrange(n)]


m = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}


def solve(S):
    res = cur = 0
    for c in S:
        if c in m:
            cur += 1
            res = max(res, cur)
        else:
            cur = 0
    print res

S = raw_input().strip()
solve(S)
# solve("HATAGAYA")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
cnt = 0
for i in range(len(S)):
  if S[i] in 'ATCG':
    cnt += 1
    ans = max(ans,cnt)
  else:
    cnt = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
ans = 0
c = 0
for i in S:
    if i == "A" or i == "T" or i == "G" or i == "C":
        c += 1
    else:
        c = 0
    if c > ans:
        ans = c

print(ans)

Submission status: Accepted

Solution code:



def start_process(a):
    dict = ['A', 'G', 'T', 'C']

    ans = 0
    count = 0
    for char in list(a):
        if char in dict:
            count += 1
        else:
            if ans < count:
                ans = count
            count = 0
    if ans < count:
        ans = count
    print(ans)


def main():
    a = input()
    start_process(a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#123
s = input()
temp = 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'):
        temp += 1
        if(temp>ans):
            ans = temp
    else:
        temp = 0
print(ans)

Submission status: Accepted

Solution code:
S=input()
A=[0 for x in range(len(S))]

if S[0]=="A" or S[0]=="T" or S[0]=="C" or S[0]=="G":
  A[0]=1

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

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('ATGC'.count(k) == 1 for k in s[i:j+1]):
            ans = max(ans,j-i+1)

print(ans)

Submission status: Accepted

Solution code:
string = input()
ch = string[0]
max_string_len = 0
prev_len = 0
for idx,ch in enumerate(string):
  if ch  in {"A","T","G","C"}:
    prev_len += 1
    max_string_len = max(max_string_len,prev_len)
  else:
    prev_len = 0
    
print(max_string_len)

Submission status: Accepted

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

alp = 'ATCG'
cnt = []

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

print(max(cnt))

Submission status: Accepted

Solution code:
S = list(input())
ma = 0
n = len(S)

for i in range(n):
    for j in range(n):
        if i <= j:
            reS = S[i:j+1]
            l = len(reS)
            re = reS.count("A") + reS.count("C") + reS.count("G") + reS.count("T")
            if l == re:
                ma = max(ma, re)

print(ma)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
tmp = ['']
x = {'A', 'C', 'G', 'T'}
for i in range(N):
    for j in range(i, N):
        if set(S[i:j+1]) <= x:
            tmp.append(S[i:j+1])
print(max(map(len, tmp)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inp = input()
res = 0
for i in range(len(inp)+1):
  for j in range(i+1, len(inp)+1):
    if len([w for w in inp[i:j] if w in ["A", "C", "G", "T"]]) == (j-i):
      res = max(res, j-i)
print(res)

Submission status: Accepted

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

S=str(input())
L=len(S)
count=0
ans=0
for i in range(L):

    if S[i] in dna:
        count += 1
    else:
        ans = max(ans,count)
        count=0

print(max(ans,count))

Submission status: Accepted

Solution code:
S = input()
atgc = ['A', 'T', 'G', 'C']
cnt = 0
ans = []
for c in S:
    if c in atgc:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
N = len(S)
x = 0
for a in range(N):
  for b in range(a+1,N+1):
    if all(x in 'ATGC' for x in S[a:b]):
      x = max(x, b-a)
      
      
print(x)

Submission status: Accepted

Solution code:
S=input()
flag=0
count=0
begin=0
max_begin=0
max_count=0
for i in range(len(S)):
    if flag==0:
        
        if S[i]=="A" or S[i]=="T" or S[i]=="C" or S[i]=="G":
            begin=i
            count+=1
            flag=1
            
    else:
        if S[i]=="A" or S[i]=="T" or S[i]=="C" or S[i]=="G":
            count+=1
            
        else:
            if max_count<count:
                max_count=count
                max_begin=begin
            flag=0
            count=0
if max_count<count:
    max_count=count
print(max_count)

Submission status: Accepted

Solution code:
S = input()
S = S+"0"
max = 0
j = -1
for i in range(0, len(S)):
    if not(S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T"):
        if max<i-j-1:
            max = i-j-1
        j = i
print("{}".format(max))