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:
def ATCoder(s,can):
    n = len(s)
    count = 0
    #print(s)
    for i in range(n):
        if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
            count += 1
        else:
            if count > can:
                can = count
                count = 0
            can = ATCoder(s[i+1:],can)
            break
    else:
        if count > can:
            can = count
            count = 0

    return can
if __name__ == "__main__":
    s = input()
    print(ATCoder(s,0))

Submission status: Accepted

Solution code:
S = input()
valid = ['A', 'T', 'C', 'G']
count = 0
max_len = 0

for i in range(len(S)):
    for j in range(i, len(S)):
        if S[j] in valid:
            count += 1
        else:
            break
    if count > max_len:
        max_len = count
    count = 0

print(max_len)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
max_length=0
length=0
for c in s:
    if c in 'AGCT':
        length+=1
    else:
        max_length=max(max_length, length)
        length=0
print(max(max_length, length))

Submission status: Accepted

Solution code:
S = input()
l = len(S)
A = {'A', 'C', 'G', 'T'}
ans = 0
for i in range(l):
    for j in range(l):
        if i + j > l:
            continue
        flag = True
        for s in S[i:l-j]:
            if s not in A:
                flag = False
                break
        if flag:
            ans = max(ans, len(S[i:l-j]))
print(ans)

Submission status: Accepted

Solution code:
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

s = readChar()

ans = -1

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

print(max(ans,0))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans=0
t_ans=0
for i in s:
  if i in 'ATGC':
    t_ans+=1
  else:
    ans=max(t_ans,ans)
    t_ans=0
print(ans)

Submission status: Accepted

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

ans=0
t_ans=0
for i in range(len(s)):
  if s[i] in 'ATGC':
    t_ans+=1
  else:
    ans=max(t_ans,ans)
    t_ans=0
print(ans)

Submission status: Accepted

Solution code:
s = input()

ans=0
for i in range(len(s)):
    ch=0
    for j in range(i,len(s)):
        if s[j] in 'ACGT':
            ch+=1
        else:
            ans=max(ans,ch)
            ch=0
    ans=max(ans,ch)
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

for i in range(len(S)):
    window = len(S) - i
    for j in range(len(S) - window + 1):
        if set(S[j:j + window]).issubset(acgt):
            print(len(S[j:j + window]))
            break
    else:
        continue
    break
else:
    print(0)

Submission status: Accepted

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

count=0
v=0
for ch in S:
  if ch in DNA:
    count+=1
  else:
    if v < count:
      v=count
      count=0
    else:
      count=0
if v < count:
  v=count

print(v)

Submission status: Accepted

Solution code:
l=["A", "C", "G", "T"]

s=input()
ans=0
a=[]
for i in range(len(s)):
    if s[i] in l:
        ans+=1
        if i==len(s)-1:
            a.append(ans)
    elif s[i] not in l and i==len(s)-1:
        a.append(ans)
        ans=0
    else:
        a.append(ans)
        ans=0
print(max(a))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 20:16:43 2020

@author: Kanaru Sato
"""

s = list(input())
acgt= set(["A","C","G","T"])
ans = 0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        flag = 1
        t = s[i:j]
        for moji in t:
            if moji not in acgt:
                flag = 0
                break
        if flag == 1:
            ans = max(ans,len(t))
print(ans)

Submission status: Accepted

Solution code:
import re

S = input()
r, ans, tmp = 0, 0, ''
N = len(S)
for l in range(N):
    while r < N and re.match(r'[ACGT]', S[r]):
        tmp += S[r]
        r += 1
    ans = max(ans, r - l)
    if l == r:
        r += 1
    else:
        tmp = tmp[l:]
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans1 = 0
ans2 = 0

for a in s:
  if a == "A" or a == "T" or a == "C" or a == "G":
    ans2 += 1
  else:
    if ans1 < ans2:
      ans1 = ans2
      ans2 = 0
    else:
      ans2 = 0
print(max(ans1, ans2))

Submission status: Accepted

Solution code:
s=list(input())
maximum=0#黒字ならok.緑字になったりしたらint object is not callableが発生しかねない。
temp=0
k=0
for i in range(len(s)):
    sets=set(s[i])
    if sets.issubset(set("ATGC")):
        k=k+1
        if k>=maximum:
            maximum=k
    else:
        k=0
print(maximum)

Submission status: Accepted

Solution code:
s = input()
t = "ACGT"

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

Submission status: Accepted

Solution code:
import re
s=input()
ans=re.findall(r"((A|T|G|C)+)",s)#先に(が手てくる方から行列が形成される。

if ans==[]:#リストではなくてタプルなので注意・
    print(0)
else:
    #max関数はnumpyでないと一次元に特化していてなかなか思い通りに動かないので
    max=0
    for i in range(len(ans)):
        temp=ans[i][0]
        if len(temp) >= max:
            max=len(temp)
    print(max)

Submission status: Accepted

Solution code:
import re
s =input()
ans = re.finditer(r'(A|T|G|C)+',s)
max=0
for a in ans:
    temp=len(a.group())
    if temp>=max:
        max=temp
print(max)

Submission status: Accepted

Solution code:
s=input()
import re
ans=re.findall("[ATGC]+",s)#findall、なかったら[]が帰ってくる。matchのようにNoneが帰ってくるわけではない。
if ans==[]:
    print(0)
else:
    print(len(max(ans,key=len)))#このときfindallで返される行列は先頭から見つかったもの順に並べられることに注意すること。

Submission status: Accepted

Solution code:
s=input()
import re
ans=re.findall("[A,T,G,C]+",s)#findall、なかったら[]が帰ってくる。matchのようにNoneが帰ってくるわけではない。
if ans==[]:
    print(0)
else:
    print(len(max(ans,key=len)))#このときfindallで返される行列は先頭から見つかったもの順に並べられることに注意すること。

Submission status: Accepted

Solution code:
S = input()
maxlen=count=0
isT = True
for i in range(len(S)):
  if S[i] == "T":
    isT = True
  if S[i] == "T" or S[i] == "G" or S[i] == "C" or S[i] == "A":
    count += 1
  else:
    if isT and maxlen < count:
      maxlen = count
    count = 0
    isT = False
    
if isT and maxlen < count:
  maxlen = count

print(maxlen)

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(c in "AGCT" for c in S[i : j + 1]):
            ans = max(ans, j - i + 1)
print(ans)

Submission status: Accepted

Solution code:
S = input() + "0"
length = 0
count = 0

for char in S:
    if char in "AGCT":
        count += 1
    else:
        length = max(length, count)
        count = 0

print(length)

Submission status: Accepted

Solution code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
#n, m = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

n = len(s)

temp = 0
max = 0

for i in range(n):
    if(s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T"):
        temp += 1
    else:
        temp = 0
    if (max < temp):
        max = temp


print(max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
length = len(S)
res = 0
for i in range(length):
  for j in range(i,length):
    if all(s in 'ATGC' for s in S[i:j+1]):
      res = max(res,j+1-i )
print(res)

Submission status: Accepted

Solution code:
import sys
s = sys.stdin.readline()
ans = 0
for i in range(len(s)):
    # print(f'{s[i]=}')
    if s[i] not in {'A', 'C', 'G', 'T'}: continue
    length = 1
    for j in range(i + 1, len(s)):
        if s[j] in {'A', 'C', 'G', 'T'}:
            # print(f'{s[j]=}')
            length += 1
        else: break
    ans = max(ans, length)
    # print(f'{ans=}')
print(ans)

Submission status: Accepted

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

ans = 0
tmp = 0
for i in range(len(s)):
  c = s[i]
  if c in acgt:
    tmp += 1
  else:
    tmp = 0
  ans = max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
import copy
s = input()

maximum = 0 
count = 0

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

print(maximum)

Submission status: Accepted

Solution code:
s = input()
l = len(s)
a = 0
ls = ["A","T","C","G"]
for i in range(l):
    for j in range(i + 1,l + 1):
        t = s[i:j]
        l2 = len(t)
        if a < l2:
            b = 0
            for k in range(l2):
                if t[k] not in ls:
                    b = 1
            if b == 0:
                a = l2

print(a)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
import itertools

def main():
    S = list(str(sys.stdin.readline()))
    
    # print(S)
    
    S_len = len(S)
    dp = [0]*(S_len+1)
    target = ["A", "C", "G", "T"]
    
    for i in range(1, S_len+1):
        if S[i-1] in target:
            dp[i] = max(1, dp[i-1]+1)
            
    print(max(dp))
                
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
N = len(S)
a,b = 0,0
l = [0]

for i in range(N):
  if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
    a += 1
    b = 1
  else:
    if b:
      l.append(a)
      b = 0
      a = 0
else:
  if a:
    l.append(a)
  print(max(l))

Submission status: Accepted

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

length = 0
for i in range(N):
  for j in range(i,N):
    if all([(c in 'ACGT') for c in S[i:j+1]]):
      length = max(length, len(S[i:j+1]))

print(length)

Submission status: Accepted

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

acgt_flag = False
length = 0
l = 0

for i in range(len(s)):
  if s[i] in acgt:
    if acgt_flag:
      l+=1
    else:
      l=1
      acgt_flag = True
  else:
    if acgt_flag:
      length = max(length, l)
      acgt_flag = False

length = max(length, l)
print(length)

Submission status: Accepted

Solution code:
s=input()
lens=len(s)
#ACGT
acgt = set(["A","C","G","T"])
kekka = [0 for _ in range(lens)]

for i in range(lens):
    if s[i] in acgt:
        kekka[i] = 1

maxsum = 0

for i in range(lens):
    if kekka[i] == 1:
        sum = 0
        for j in range(i, lens):
            if kekka[j] == 1:
                sum += 1
            else:
                break
        if sum >= maxsum:
            maxsum = sum

print(maxsum)

Submission status: Accepted

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    print(max(map(len,re.findall('[ACGT]*', S))))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

ans = 0
flag = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

for s in S:
  if s in 'ACGT':
    count +=1
    max_s = max(count,max_s)
  else:
    count = 0
    
print(max_s)

Submission status: Accepted

Solution code:
def ATGC(i):
    if i == 'A' or i == 'T' or i == 'G' or i == 'C':
        return True

s = input()
a = 0
streak = 0
for i in s:
    if ATGC(i):
        streak += 1
    else :
        if a < streak :
            a = streak
            streak = 0
if streak > a:
    a = streak 
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    s = input()
    n = len(s)
    b = [char in ['A', 'T', 'G', 'C'] for char in s]
    ans = 0
    current_streak = 0
    for i in range(n):
        if b[i]:
            current_streak += 1
        else:
            current_streak = 0
        ans = max(ans, current_streak)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
import numpy as np
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

tmp = []
tmp.append(-1)
for i, x in enumerate(S):
	if x != "A" and x != "T" and x != "G" and x != "C":
		tmp.append(i)
tmp.append(len(S))
#print(tmp)

tmp2 = [tmp[i+1] - tmp[i] for i in range(len(tmp)-1)]
print(max(tmp2)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

S = input()

match = re.findall(r'[ACGT]+', S)
result = ""
for i in match:
    if len(result) <= len(i):
        result = i
print(len(result))

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
import numpy as np
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
atc = ["A", "C", "G", "T"]

ans = 0

for l in range(len(S)):
	r = l
	while r < len(S) and S[r] in atc:
		r += 1

	ans = max(ans, r-l)

print(ans)

Submission status: Accepted

Solution code:
s = input()
acgt = ["A","C","G","T"]
ans = 0
for i in range(len(s)+1):
	for l in range(1,len(s)+1):
		t = s[i:l].replace("A","").replace("C","").replace("G","").replace("T","")
		if len(t) == 0:
 			if len(s[i:l]) > ans:
	  			ans = len(s[i:l])
		
print(ans)

Submission status: Accepted

Solution code:
s = input()

MAX = 0
m = 0
for i in s:
  if i == "A" or i == "G" or i == "C" or i == "T":
    m += 1
    MAX = max(MAX,m)
  else:
    m = 0
print(MAX)

Submission status: Accepted

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

ACGT = ['A', 'C', 'G', 'T']
ans = 0
for i in range(N):
    for j in range(i, N):
        flag = True
        for s in S[i:j + 1]:
            if s not in ACGT:
                flag = False
                break
        if flag and (j - i + 1) > ans:
            ans = j - i + 1
    
print(ans)

Submission status: Accepted

Solution code:
s = input()

tmp = 0
ans = 0
chars = ['A', 'C', 'G', 'T']

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

ans=0
now=0
l=[i for i in "ACGT"]

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

print(ans)

Submission status: Accepted

Solution code:
s=input()
l=list("ACGT")
ans=0
for i in range(len(s)):
    for k in range(i+1,len(s)+1):
        if all(i in l for i in s[i:k]):
            ans=max(ans,len(s[i:k]))
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:
S = input()
S = list(S)
str_list =  {"A","C","G","T"}
str_max = 0
#print(S)
#print(len(S))
for start in range(len(S)):
    for end in range(start+1, len(S)+1):
        S_list = S[start:end]

        if str_list | set(S_list) == str_list:
            str_max = max(str_max, len((S_list)))
           # print(str(S_list)+'はオッケーでした，記録は'+str(len(set(S_list))))
        #else:
           # print(str(S_list)+'はダメでした')

print(str_max)

Submission status: Accepted

Solution code:
S=str(input())
ans=0
temp=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 i==len(S)-1:
            ans=max(ans,temp)
    else:
        ans=max(ans,temp)
        temp=0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=str(input())
s=list(s)
l=len(s)
ans=0
temp=0
for i in range(0,l):
  if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
    temp=temp+1
    ans=max(ans,temp)
  else:
    temp=0
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:
s=input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
import re
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

s = S()
ACGT = {'A', 'C', 'G', 'T'}
T = [x for x in re.split(r'[^ACGT]', s) if x != '']
ans = 0
for t in T:
    ans = max(ans, len(t))
print(ans)

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
man = 0
cnt = 0
l = ['A', 'C', 'G', 'T']
for s in S:
    res = False
    for i in l:
        if s == i:
            cnt += 1
            res = True
    if res == False:
        cnt = 0
    if man < cnt:
        man = cnt
print(man)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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