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()
x=0
y=0
for i in range(len(s)):
  if s[i] in ['A','T','C','G']:
    y+=1
    x=max(x,y)
  else:
    y=0
    
print(x)

Submission status: Accepted

Solution code:
S = input()
count = 0
MAX = 0
for s in S:
    if s in ['A','C','G','T']:
        count += 1
    else:
        MAX = max(MAX,count)
        count = 0
MAX = max(MAX,count)
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):
    is_ACGT = True
    for k in range(i, j+1):
      if S[k] not in ['A', 'C', 'G', 'T']:
        is_ACGT = False
        break
    if is_ACGT:
      ans = max(ans, j-i+1)

print(ans)

Submission status: Accepted

Solution code:
s=list(input())
n=len(s)
ans=[]
if n==1:
  if s.pop() in list('ATCG'):
    print(1)
    exit()

for i in range(n-1):
  for j in range(i+1,n+1):
    part=set(s[i:j])
    flag=True
    for p in part:
      if p not in list('ATGC'):
        flag=False
        break
    if flag==True:
      ans.append(len(s[i:j]))
#print(ans)
if ans:
  print(max(ans))
else:
  print(0)

Submission status: Accepted

Solution code:
def main():
    ans = []
    s = input()
    count = 0
    for i in s:
        if i in "ATGC":
            count += 1
        else:
            ans.append(count)
            count = 0
    ans.append(count)
    print(max(ans))
        
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
m=[]
t = 0
for i in list(s):
  if i == 'A' or i == 'C' or i == 'G' or i == 'T':
     t += 1
  else:
     t = 0
  m.append(t)

print(max(m))

Submission status: Accepted

Solution code:
S = input()

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

ans = 0
ok = False
tmp = 0
for s in S:
    if not ok:
        if s in acgt:
            ok = True
            tmp += 1
        else:
            pass
    elif ok:
        if s in acgt:
            tmp += 1
        else:
            ok = False
            ans = max(tmp,ans)
            tmp = 0
ans = max(tmp,ans)
print(ans)

Submission status: Accepted

Solution code:
s = input()

"""A, C, G, T"""
res = 0
cha = 0
for i in range(len(s)):
  if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
    cha = 1
    for j in range(i+1,len(s)):
      if s[j] == "A" or s[j] == "C" or s[j] == "G" or s[j] == "T":
        cha += 1
      else:
        #print("c")
        break
    if cha > res:
      res = cha
    if res >= len(s[res:]):
      break

print(res)

Submission status: Accepted

Solution code:
s=input()
n=len(s)
 
res=0
for i in range(n):
  for j in range(i,n):
    sub=s[i:j+1]
    flg=True
    for k in sub:
      if(k not in ['A','G','C','T']):
        flg=False
    if(flg):
      res=max(res,len(sub))
      
print(res)

Submission status: Accepted

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

print(maxcount)

Submission status: Accepted

Solution code:
from sys import stdin

matches = ['A','C','G','T']
S = stdin.readline().rstrip()
cnt_row = 0
cnt_max = 0
for s in S:
    if s in matches:
        cnt_row += 1
        if cnt_max < cnt_row:
            cnt_max = cnt_row
    else:
        cnt_row = 0
print(cnt_max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def checks(a):
  if a=="C" or a=="T" or a=="G"or a=="A":
    return True
  else:
    return False
s=str(input())
cnt=0
ans=0
for a in s:
  if checks(a):
    cnt+=1
    ans=max(cnt, ans)
  else:
    cnt=0
print(ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines


def main():

    S = input()

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


s = S()

ans = 0
temp = 0
for a in s:
    if a in 'ACGT':
        temp += 1
    else:
        temp = 0
    ans = max(ans, temp)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
s = s.replace('G', 'A')
s = s.replace('T', 'A')
s = s.replace('C', 'A')


def long_repeat(line):
    cnt = 1
    max = 1
    if line != "":
        for i in range(1, len(line)):
            if line[i] == line[i-1]:
                cnt += 1
                if cnt > max:
                    max = cnt
            else:
                cnt = 1
        return max
    else:
        return 0


if 'A' not in s:
    print(0)
    exit()

print(long_repeat(s))

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

max_len = 0

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

Submission status: Accepted

Solution code:
S = list(input())
P = set(["A","C","T","G"])
count = 0
if P&set(S) == set():
  print(0)
  exit()
else:
  for i in range(0,len(S)):
    for j in range(i+1, len(S)+1):
      if set(S[i:j])-P == set():
        count = max(count,j-i)
        
print(count)

Submission status: Accepted

Solution code:
s = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
cnt = 0
for si in s:
    if si in acgt:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
    #print(ans)
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('ATCG'.count(a)==1 for a in S[i:j+1]):
      ans=max(ans,j+1-i)
      
print(ans)

Submission status: Accepted

Solution code:
S = 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
    else:
        if ans < temp:
            ans = temp
            temp = 0
        else:
            temp = 0

if ans < temp:
    ans = temp

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
S=input()

ans=0
temp=0
l=['A','C','G','T']

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

print(ans)

Submission status: Accepted

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

for i in S:
    if i in ACGT:
        s += i
        l.append(s)
    else:
        l.append(s)
        s = ""

l2 = map(len, l)
print(max(l2))

Submission status: Accepted

Solution code:
S = list(input())
F = ["A", "C", "G", "T"]
count = 0
max = 0
f = 0
for i in S:
    for j in F:
        if j == i:
            count += 1
    if max < count:

        max = count
    else:
        count = 0
        if max != 0:
            f = max
        max = 0
    
print(max if max > f else f)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

s = input()

max_len = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        a = s[i:j + 1]
        if re.fullmatch(r'(A|C|G|T)*', a):
            # print(a)
            max_len = max(max_len, len(a))

print(max_len)

Submission status: Accepted

Solution code:
# ABC122 B ATCoder

s = input()
ans = 0

for i in range(len(s)+1):
    for j in range(i):
        _s = s[j:i]
        _l = len(_s)
        for k in range(_l):
            if _s[k] not in "ACGT":
                break
        else:
            if(ans < _l):
                ans = _l

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

n = input()
m = copy.copy(n)
ans = 0

for x in range(len(n)):
    for l in range(len(n)):
            mm = m[x:len(n)-l]
            if mm.count("A") + mm.count("C") + mm.count("G")+ mm.count("T") == len(mm):
                ans = max(ans, len(mm))

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = [0]*len(s)

for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        t[i] = 1

ans = []
tmp = 0
for j in t:
    if j == 1:
        tmp += 1
    else:
       ans.append(tmp)
       tmp = 0
ans.append(tmp)

print(max(ans))

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
def actual(s):
    is_agct = lambda string: set(string).issubset({'A', 'G', 'C', 'T'})

    N = len(s)

    answer = 0

    for i in range(N):
        for j in range(N):
            substr = s[i:j + 1]  # スライスの後半は要素数を超えてもエラーにならないことに注意

            if is_agct(substr):
                answer = max(answer, len(substr))

    return answer


s = input()
print(actual(s))

Submission status: Accepted

Solution code:
def generate_substrings(s):
    N = len(s)

    if N == 0:
        return {''}

    if N == 1:
        return {'', s}

    substrings = set()

    for i in range(N):
        for j in range(1, N + 1):
            substrings.add(s[i:j])

    return substrings


def actual(s):
    sub_strings = generate_substrings(s)
    is_agct = lambda string: set(string).issubset({'A', 'G', 'C', 'T'})

    agct_length_list = [len(s) for s in sub_strings if is_agct(s)]

    return max(agct_length_list)

s = input()
print(actual(s))

Submission status: Accepted

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    s = input()
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

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

    print(cntmax)
resolve()

Submission status: Accepted

Solution code:
S = str(input())

cnt = 0
ans = [0]

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

Submission status: Accepted

Solution code:
import re
S = input()

result = re.findall(r'[ACGT]*',S)

ans = 0
for r in result:
    if ans < len(r):
        ans = len(r)
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(l) for l in s[i:j + 1]):
            ans = max(ans, j - i + 1)

print(ans)

Submission status: Accepted

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

flag = 0
for i in reversed(range(0,n+1)):
  for j in range(0,n-i+1):
    s = S[j:j+i].replace("A", "").replace("C", "").replace("G","").replace("T","")
    #print("+", s, "+", len(s))
    if len(s) == 0:
      flag=1
      break
  if flag==1:
    break

print(i)

Submission status: Accepted

Solution code:
s = str(input())
arr = []
count = 0
ans = 0

for i in s:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        arr.append(1)
    else:
        arr.append(0)

for i in range(0, len(arr)):
    if arr[i] == 0:
        count = 0
    else:
        count += 1
        ans = max(ans, count)
print(ans)

Submission status: Accepted

Solution code:
s = input()

cnt = 0
max_cnt = 0

for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        j = i
        cnt = 0
        while j < len(s) and (s[j] == 'A' or s[j] == 'C' or s[j] == 'G' or s[j] == 'T'):
            cnt += 1
            j += 1
        max_cnt = max(max_cnt, cnt)

print(max_cnt)

Submission status: Accepted

Solution code:
def readinput():
    s=input()
    return s

def main(s):
    
    maxlen=0
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            sub=s[i:j]
            for c in sub:
                if(c == 'A' or c == 'C' or c == 'G' or c == 'T'):
                    pass
                else:
                    break
            else:
                maxlen=max(maxlen,len(sub))
        
    return maxlen

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def readinput():
    s=input()
    return s

def main(s):
    
    maxlen=0
    templen=0
    for i in range(len(s)):
        if(s[i]=='A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T'):
            templen+=1
        else:
            maxlen=max(maxlen,templen)
            templen=0
        
    return max(maxlen,templen)

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
lis=[]
for i in range(0,len(s)):
    for j in range(min(i+1,len(s)-1),len(s)+1):
        lis.append(s[i:j])
res=0
#print(lis)
for i in lis:
    if i.count("A") + i.count("C") + i.count("G") + i.count("T") == len(i):
        res=max(res,len(i))
print(res)

Submission status: Accepted

Solution code:
import re

S = str(input())

sub = re.findall(r'[ACGT]*', S)
sub = [len(i) for i in sub]
print(max(sub))

Submission status: Accepted

Solution code:
S = input()

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

ans = max(res, ans)
print(ans)

Submission status: Accepted

Solution code:
s=list(input())

def hoge(s):
    if s == "A" or s == "C" or s == "G" or s == "T":
        return True
    else:
        return False


ans_list=[]
for i in range(len(s)):
    ans = 0
    if hoge(s[i]):
        ans+=1
        for j in range(i+1,len(s)):
            if hoge(s[j]):
                ans+=1
            else:
                ans_list.append(ans)
                break
    ans_list.append(ans)
print(max(ans_list))

Submission status: Accepted

Solution code:
S = list(input())

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

print(record)

Submission status: Accepted

Solution code:
import re

S = input()
L = re.findall("[AGCT]+", S)
LL = [len(x) for x in L ]
if LL:
    print(max(LL))
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=str(input())
lst=['A','C','G','T']
ans=0

for i in range(len(S)):
    cnt=0
    if S[i] in lst:
        cnt+=1
        if i==len(S)-1:
            ans = max(ans,cnt)
            break
        while S[i+1] in lst:
            cnt+=1
            i+=1
            if i+1==len(S):
                break
    ans=max(ans,cnt)

print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
S = read().decode('utf-8')
count=0
cnt_max=0
for i in range(len(S)):
  if S[i] in ['A', 'C', 'G', 'T']:
    count +=1
  else:
    cnt_max = max(cnt_max,count)
    count=0
print(cnt_max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
# ACGT
lis=[]
for x in range(len(S)):
	alt=len(S)-x
	for y in range(alt):
		y=len(S)-y
		ts=S[x:y]
		ca=ts.count('A')
		cg=ts.count('G')
		cc=ts.count('C')
		ct=ts.count('T')

		if len(ts)==ca+cg+cc+ct:
			lis.append(len(ts))
if lis !=[]:
	print(max(lis))
else:
	print(0)

Submission status: Accepted

Solution code:
import re
s = input()
#正規表現

result = re.findall('[ACGT]*', s)
ans = max(map(len,result))
print(ans)

Submission status: Accepted

Solution code:

import re
print(max(map(len,re.findall("[ACGT]*",input()))))

Submission status: Accepted

Solution code:
from re import findall

s = input()
res = findall('[ACGT]*', s)
max_len = max(map(len, res))
print(max_len)

Submission status: Accepted

Solution code:
#ABC122B
def main():
    import sys
    S = sys.stdin.readline().rstrip()
    #print(S)
    cnt = 0
    ans = 0
    for s in S:
        if s in ['A', 'G', 'C', 'T']:
            cnt +=1
        else:
            ans = max(ans, cnt)
            cnt=0
    
    ans = max(ans, cnt)
    print(ans)   
            
                    
    

if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
def che(s):
  for c in s:
    if c=='A' or c=='C' or c=='G' or c=='T':
      pass
    else:
      return 0
  return 1
mx=""
for i in range(0,len(s)+1):
  for j in range(0, len(s)+1):
    com=s[i:j]
    if len(com)==0:
      continue
    if len(mx)<len(com) and che(com):
      mx=com
print(len(mx))

Submission status: Accepted

Solution code:
# ABC122B

s=input()

maxl=0
a="ACGT"
for i in range(len(s)):
    cntl=0
    if s[i] in a:
        cntl+=1
        for j in range(i+1,len(s)):
            if s[j] in a:
                cntl+=1
            else:
                break
    i+=cntl
    maxl=max(maxl,cntl)

print(maxl)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
s = input()
len_s = len(s)
max_ACGT = 0

for i in range(len_s):
    for j in range(i + 1, len_s+1):
        partial_s = s[i:j]
        if len(re.findall('A|C|G|T', partial_s)) == len(partial_s) and len(partial_s) > max_ACGT:
            max_ACGT = len(partial_s)

print(max_ACGT)

Submission status: Accepted

Solution code:
s=input()

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    string = 'ACGT'
    current = 0
    ans = 0
    i = 0
    while i <= (len(S)-1):
        if S[i] in string:
            current = 1
            j = i+1
            while j<len(S) and S[j] in string:
                j = j+1
                current = current+1
            if current>ans:
                ans = current
        i = i+1
    print(ans)
main()

Submission status: Accepted

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

no=False
for i in range(n):
    for j in range(i,n):
        for k in range(i,j+1):
            if not S[k] in ("A","C","G","T"):
                no=True
                break
        if no:
            no=False
            break
        ans=max(ans,j-i+1)
print(ans)

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
import sys

def main():
    S = input()
    l = len(S)
    
    ans = 0
    for i in range(l):
        for j in range(i, l):
            if all(['ATGC'.count(c) == 1 for c in S[i:j+1]]):
                ans = max(ans, j-i+1)
            
    print(ans)
main()

Submission status: Accepted

Solution code:
#ABC122B
S = input()
count_max = 0
count = 0
for i in range(len(S)):
    if "A" in S[i] or "C" in S[i] or"G" in S[i] or"T" in S[i]:
        count += 1
    #最長のACGT文字列が、文字列の末尾にあるときに対応する
        if i+1 == len(S) and count>count_max:
            count_max = count
    #まだ列が途中であって、文字が途切れた時、maxを更新する
    elif count > count_max:
            count_max = count
            count = 0
print(count_max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print (ans)

Submission status: Accepted

Solution code:
s = input()
l = len(s)
atgc = {'A', 'T', 'G', 'C'}

ans = 0
for i in range(l+1):
    for j in range(i+1, l+1):
        for k in s[i:j]:
            if k not in atgc:
                break
        else:
            ans = max(ans, j-i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

_max = 0
count = 0

for c in S:
    if c in 'ATGC':
        count += 1
    else:
        _max = max(_max, count)
        count = 0
else:
    _max = max(_max, count)
    
print(_max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ln = input()
output = ''
a = ''
for i in ln:
    if i == 'A' or i == 'T' or i == 'C' or i == 'G' :
        a += i
    else:
        if len(output) < len(a):
            output = a
        a = ''
if len(output) < len(a):
        output = a
a = ''        
print(len(output))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().rstrip()

ans = 0
cnt = 0

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

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

print(ans)

Submission status: Accepted

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

count = 0
clist = []
n = (len(l))
for i in range(n):
    if l[i] in 'ACGT':
        count += 1
        if i == n - 1:
            clist.append(count)
    else:
        clist.append(count)
        count = 0

print(max(clist))

Submission status: Accepted

Solution code:
s = input()
count = 0
ans = 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 = list(input())

now = 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":
    now += 1
    if ans < now:
      ans = now
  else:
    now = 0

print(ans)

Submission status: Accepted

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

s = list(str(input()))

set_ = set(["A", "C", "G", "T"])

ans = 0
count = 0
for i in range(len(s)):
    if s[i] in set_:
        count += 1
    else:
        ans = max(ans, count)
        count = 0

ans = max(ans, count)

print(ans)

Submission status: Accepted

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


def solve(S: str):
    acgt = [1 if s in ["A", "C", "G", "T"] else 0 for s in S]
    ans = 0
    tmp = 0
    for a in acgt:
        if a == 0:
            ans = max(ans, tmp)
            tmp = 0
            continue
        tmp += a
    ans = max(ans, tmp)
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
n=0
ans=0

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

print(ans)

Submission status: Accepted

Solution code:
s = input()

x = []
ss = ["A","T","G","C"]

for i in range(len(s)):
  if(i != len(s)):
    for j in range(i+1,len(s)+1):
      x.append(s[i:j])
  else:
    x.append(s[-1])
ans = []
ans.append(0)
for i in range(len(x)):
  tmp = 0
  for j in range(len(x[i])):
    if(x[i][j] in ss):
      tmp += 1
  if(tmp == len(x[i])):
    ans.append(tmp)
print(max(ans))

Submission status: Accepted

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

while i < len(s):
    if s[i] in acgt:
        count+=1
        if count > max:
            max = count
    else:
        count = 0
    i+=1

print(max)

Submission status: Accepted

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

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("T")+s[i:j].count("C")+s[i:j].count("G")==len(s[i:j]):
            ans=max(ans,len(s[i:j]))
print(ans)

Submission status: Accepted

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