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()
sl = len(s)
l = [0]*sl
c = 0
ans = 0

for i in range(sl):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        l[i] = 1

for i in range(sl):
    if l[i] == 1:
        c += 1
    else:
        ans = max(ans, c)
        c = 0

ans = max(ans, c)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 09:40:38 2020

@author: black
"""


S = list(input())

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

Submission status: Accepted

Solution code:
def solve():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n):
        for j in range(i+1,n+1):
            tmp = s[i:j]
            tmp = tmp.replace('A','').replace('T','').replace('G','').replace('C','')
            if len(tmp)==0:
                ans = max(ans,j-i)
    print(ans)
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 02:20:28 2020

@author: liang
"""

S = input()
i = 0
max = 0
cnt = 0
chars = ['A', 'C', 'G', 'T']
for i in range(len(S)):
    if S[i] in chars :
        cnt += 1
    else:
        cnt = 0
    if cnt > max:
        max = cnt
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

S = list(input())

lenS = len(S)
ans = 0

for i in range(1, lenS+1):
    for j in range(lenS-i+1):
        tmp = S[j:j+i]
        if set(tmp).issubset(['A', 'C', 'G', 'T']):
            #print(tmp)
            ans = max(len(tmp), ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s = s.translate(str.maketrans('ACGT', '1111'))
ans = 0
tmp = 0
for i in s:
    if i == '1':
        tmp += 1
    else:
        tmp = 0
    ans = max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
s = input()

ans = 0
n = 0
acgt = ('A', 'C', 'G', 'T')
for si in s:
    if si in acgt:
        n += 1
    else:
        if n > ans:
            ans = n
        n = 0
if n > ans:
    ans = n
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
import re
s = input()

print(max(map(len,re.split("[^ACGT]",s))))

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    S = input()
    acgt = ('A', 'C', 'G', 'T')
    ans = 0

    for l in range(len(S)):
        for r in range(l+1, len(S)+1):
            # print(l, r, S[l:r])
            if S[r-1] not in acgt:
                ans = max(r-1-l, ans)
                break
            if r==len(S):
                ans = max(len(S)-l, ans)
 
    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 
import re

def resolve():
    S = input()
    acgt = ('A', 'C', 'G', 'T')
    ans = 0
    # l = 0
    # while (l < len(S)) and (len(S)-l > ans):
    #     r = l+1
    #     while (r < len(S)+1) and (S[r-1] in acgt):
    #         r += 1
    #     ans = max(r-1-l, ans)
    #     l += 1

    for l in range(len(S)):
        for r in range(l+1, len(S)+1):
            # print(l, r, S[l:r], re.fullmatch(r'[ACGT]*', S[l:r]))
            if re.fullmatch(r'[ACGT]*', S[l:r]):
                ans = max(r-l, ans)
            # if S[r-1] not in acgt:
            #     ans = max(r-1-l, ans)
            #     break
 
    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    S = input()
    acgt = ('A', 'C', 'G', 'T')
    ans = 0
    l = 0
    while (l < len(S)) and (len(S)-l > ans):
        r = l+1
        while (r < len(S)+1) and (S[r-1] in acgt):
            r += 1
        ans = max(r-1-l, ans)
        l += 1

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

ret=0

for i in range(n):
    j=i
    while j<n and s[j] in chk:
        j+=1

    ret=max(ret,j-i)

print(ret)

Submission status: Accepted

Solution code:

import math
import itertools
import statistics
#import collections
#x = int(input())
#k, n = (map(int, input().split()))
#A= (map(int, input().split()))

#x個の赤りんごp　y緑りんごq c個無色r
#n =  list(map(int, input().split()))
s = input()
max_ = 0
count = 0

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

    if max_ <= count:
        max_ = count
    
    

print(max_)

Submission status: Accepted

Solution code:
def main():
    ans,tmp=0,0
    S=input()
    ACGT=list('ACGT')
    for s in S:
        if s in ACGT:
            tmp += 1
            ans = max(ans, tmp)
        else:
            tmp = 0
    print(ans)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(map(str,input()))
count = 0
ans = 0

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

Submission status: Accepted

Solution code:
#conding utf-8
S=input()
ATGC=["A","T","G","C"]
ans=0
tmp=0
for i in range(len(S)):
  if S[i:i+1] in ATGC:
    tmp +=1
  else:
    tmp=0
  if ans<tmp:
    ans=tmp

print(ans)

Submission status: Accepted

Solution code:
s_list = list(input())
n = len(s_list)
dic = {"A", "C", "G", "T"}
ans = 0
tmp_ans = 0
for i in range(n):
    for j in range(i, n):
        if s_list[j] in dic:
            tmp_ans += 1
        else:
            ans = max(ans, tmp_ans)
            tmp_ans = 0
        if j == n - 1:
            ans = max(ans, tmp_ans)
            tmp_ans = 0
ans = max(ans, tmp_ans)
print(ans)

Submission status: Accepted

Solution code:
# Problem B - ATCoder

# input
S = list(input())

# initialization
max_count = 0
atgc_list = ['A', 'T', 'G', 'C']

# count
tmp = 0
for i in range(len(S)):
    if S[i] in atgc_list:
        tmp += 1
    else:
        max_count = max(max_count, tmp)
        tmp = 0
max_count = max(max_count, tmp)
# output
print(max_count)

Submission status: Accepted

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

s = input()
s = s+" "

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

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

print(ans)

Submission status: Accepted

Solution code:
def main():
  #n = int(input())
  s = input()
  #s = input().split()
  #a,b = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  for i in s:
    if i in "ACGT":
      count += 1
      ans = max(ans,count)
    else:
      count = 0
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
ATGC=['A', 'T', 'G', 'C']
S=input()
N=len(S)
maxlen=0
count=0

for i in range(N):
    if S[i] in ATGC:
        count+=1
    else:
        count=0
    if count>maxlen:
        maxlen=count
print(maxlen)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

str_max = ""
int_max = 0
str_temp = ""
int_temp = 0

for i in s:
    if i == "A"or i == "C"or i == "G"or i == "T":
        str_temp += i
        int_temp += 1
        # print("OK", i)
    else:
        str_temp = ""
        int_temp = 0
        # print("NG", i)

    if int_max < int_temp:
        int_max = int_temp
        str_max = str_temp

print(int_max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

S=input()
ans = sorted((re.findall("[AGCT]*", S)), reverse=True, key=len)
print(len(ans[0]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ans = 0
for s in range(len(S)):
    for e in range(s + 1, len(S) + 1):
        ss = S[s:e]
        for c in ss:
            if not c in "ACGT":
                break
        else:
            ans = max(ans, len(ss))
print(ans)

Submission status: Accepted

Solution code:
s = str(input())
n = len(s)
ACGT = {"A", "C", "G", "T"}

res = []
for i in range(n):
    cnt = 0
    for j in range(i, n):
        if s[j] in ACGT:
            cnt += 1
        else:
            break
    res.append(cnt)

print(max(res))

Submission status: Accepted

Solution code:
s = input()

def agct(s):
    for t in s:
        if not t in 'ACGT':
            return False
    else:
        return True
count = 0
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if agct(s[i:j]):
            count = max(count, len(s[i:j]))
print(count)

Submission status: Accepted

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

s = input()
ans = 0
tmp = 0

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

Submission status: Accepted

Solution code:
def RLE(S):
    res = []
    N = len(S)
    i = 0
    while i < N:
        cnt = 1
        while i < N - 1 and S[i] == S[i + 1]:
            cnt += 1
            i += 1
        res.append((S[i], cnt))
        i += 1
    return res


if __name__ == "__main__":
    S = list(input())
    term = "ATCG"
    X = ""
    for s in S:
        if s in term:
            X += "1"
        else:
            X += "0"
    rle = RLE(X)
    ans = 0
    for k, v in rle:
        if k == "1":
            ans = max(ans, v)
    print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc122/tasks/abc122_b


def is_acgt(c):
    acgt = ['A', 'C', 'G', 'T']

    return c in acgt


if __name__ == "__main__":
    S = input()

    result = 0
    tmp_result = 0
    for c in S:
        if (is_acgt(c)):
            tmp_result += 1
            result = max(result, tmp_result)
        else:
            tmp_result = 0

    print(result)

Submission status: Accepted

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

max_len = 0
now = 0
for char in s:
    if char not in atcg:
        max_len = max(now,max_len)
        now = 0
        continue
    now += 1
print(max(now,max_len))

Submission status: Accepted

Solution code:
# 部分文字列のうち、acgtのみからなるものの最大長
# 先頭から探索して、acgtなら長さを+1する
ans = 0
length = 0
s = input()
for i in s:
  if i in ["A","C","G","T"]:
    length += 1
    ans = max(ans,length)
  else:
    length = 0
print(ans)

Submission status: Accepted

Solution code:
s = input()

num = 0
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
S = list(input())
s = ['A','C','G','T']
cnt = 0
max = 0
for i in range(len(S)):
  for j in range(i,len(S)):
    if s.count(S[j]) != 0:
      cnt += 1
    else:
      break
  if max < cnt:
    max = cnt
  cnt = 0
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc122/tasks/abc122_b


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

ans = 0
n = 0
for s in S:
    if s in SPECIAL:
        n += 1
    else:
        if ans < n:
            ans = n
        n = 0
if ans < n:
    ans = n

print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

S = i_s()

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

ans = max(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
s = input()

len = 0
result = 0

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

Submission status: Accepted

Solution code:
#n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

s=list(input())
n=len(s)
l=["A","C","G","T"]
ansl=[0]
for i in range(n):
    for j in range(n):
        if i>j:
            continue
        partial=s[i:j+1]
        flag=True
        for p in partial:
            if not p in l:
                flag=False
                break
        if flag:
            ansl.append(len(partial))
print(max(ansl))

Submission status: Accepted

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

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

print(maxcount)

Submission status: Accepted

Solution code:
S = input()

len = 0
ans = 0
for ch in S:
    if ch in 'ACGT':
        len += 1
        ans = max(ans, len)
    else:
        len = 0
print(ans)

Submission status: Accepted

Solution code:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


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

    S = iss()
    ret = 0
    cnt = 0
    for s in S:
        if 'A' in s: cnt += 1
        elif 'C' in s: cnt += 1
        elif 'G' in s: cnt += 1
        elif 'T' in s: cnt += 1
        else: cnt = 0
        ret = max(ret, cnt)

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = list(input())
counter = 0
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

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

Submission status: Accepted

Solution code:
S = list(map(str, input()))
cnt = 0
CNT = []
for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T':
        cnt += 1
        if i==len(S)-1:
            CNT.append(cnt)
    if S[i]!='A' and S[i]!='C' and S[i]!='G' and S[i]!='T':
        CNT.append(cnt)
        cnt = 0

print(max(CNT))

Submission status: Accepted

Solution code:
print(len(max(''.join(str(+(c in'ATGC'))for c in input()).split('0'))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

S = input()
N = len(S)
m = 0
for i in range(N+1):
    for j in range(i+1):
        s = S[j:i]
        l = list(s)
        l = [k for k in l if k not in ["A", "G", "C", "T"]]
        if len(l) == 0:
            m = max(m, i-j)
print(m)

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    atcg=set(['A','T','C','G'])
    s=STR()
    ct=0
    for i in range(len(s)):
        if s[i] in atcg:
            temp=1
            for k in range(1,len(s)-i):
                if s[i+k] in atcg:
                    temp+=1
                    #print('aa')
                else:
                    break
            ct=max(temp,ct)
    print(ct)
if __name__ == '__main__':
    do()

Submission status: Accepted

Solution code:
s=input()
cnt=0
temp=0
for i in s:
    if i in 'ATGC':
        temp+=1
        continue
    if cnt<temp:
        cnt=temp
        temp=0
if cnt<temp:cnt=temp
print(cnt)

Submission status: Accepted

Solution code:
import sys


def get_ngram(n, s):
    return [''.join(s[i:i+n]) for i in range(len(s)-n+1)]


def main():
    S = input()
    chars = {'A', 'C', 'G', 'T'}

    for i in range(len(S), -1, -1):
        for c in get_ngram(i, S):
            if set(c) <= chars:
                print(i)
                sys.exit()


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import combinations
import sys


def get_ngram(n, s):
    return [''.join(s[i:i+n]) for i in range(len(s)-n+1)]


def main():
    S = input()
    chars = {'A', 'C', 'G', 'T'}

    for i in range(len(S), -1, -1):
        for c in get_ngram(i, S):
            if set(c) <= chars:
                print(i)
                sys.exit()


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
n = len(s)
x = [0] * n
fl = 1
if s[0] == 'A' or s[0] == 'T' or s[0] == 'C' or s[0] == 'G':
    x[0] = 1
        
for i in range(1,n):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
        x[i] = x[i-1] + 1
    else:
        x[i] = 0

print(max(x))

Submission status: Accepted

Solution code:
s = input()
ans = 0
for start in range(len(s)):
    for end in range(len(s)):
        tmps = s[start:end+1]
        if set(tmps) <= {"A","G","C","T"}:
            ans = max(ans,len(tmps))
print(ans)

Submission status: Accepted

Solution code:
def inpl():
    return list(map(int, input().split()))


S = input()

ans = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        if S[j] not in "AGTC":
            ans = max(j - i, ans)
            break
    else:
        ans = max(len(S) - i, ans)
print(ans)

Submission status: Accepted

Solution code:
S = input()

c = 0
cmax = -1
for s in S:
  if s in ['A', 'C', 'G', 'T']:
    c += 1
  else:
    if c > cmax:
      cmax = c
    c = 0
    
if c > cmax:
  cmax = c
c = 0

print(cmax)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
S=list(input())

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

Submission status: Accepted

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

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())

def main():
	ACGT="ACGT"
	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)














if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    S = readline().strip()

    ans = 0
    acgt = ["A", "C", "G", "T"]
    for i in range(len(S)):
        for j in range(i, len(S)):
            flag = True
            for k in S[i:j+1]:
                if k in acgt:
                    continue
                else:
                    flag = False
            if flag:
                ans = max(ans, j - i + 1)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    S = readline().strip()

    ans = 0
    acgt = ["A", "C", "G", "T"]
    for i in range(len(S)):
        if S[i] in acgt:
            m = i
            tmp = 0
            while m < len(S) and S[m] in acgt:
                tmp += 1
                m += 1
            ans = max(ans, tmp)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

max_len = 0
for i in range(len(S)):
    for j in range(i, len(S)+1):
        tmp = S[i:j]
        for t in tmp:
            if t != 'A' and t != 'C' and t != 'G' and t != 'T':
                break
        else:
            if len(tmp) >= max_len:
                max_len = len(tmp)

print(max_len)

Submission status: Accepted

Solution code:
s=input()
cnt=0
tmp=0
for i in s:
    if i=="A" or i=="T" or i=="C" or i=="G":
        tmp+=1
    if tmp>0 and (i!="A" and i!="T" and i!="C" and i!="G"):
        cnt=max(cnt,tmp)
        tmp=0
cnt=max(cnt,tmp)
print(cnt)

Submission status: Accepted

Solution code:
S = input()

res = 0
cur = 0
N = len(S)
ACGT = ["A", "C", "G", "T"]
for i in range(N):
  if S[i] in ACGT:
    cur += 1
  else:
    cur = 0
  if cur > res:
    res = cur

print(res)

Submission status: Accepted

Solution code:
N = list(input())
m = 0
cnt = 0
for x in N:
    
    if x == 'A' or x == 'C' or x == 'G' or x == 'T':
        cnt += 1
    else:
        m = max(cnt, m)
        cnt = 0

m = max(cnt, m)

print(m)

Submission status: Accepted

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

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

S = input()

ans = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        s = S[i:j+1]
        a = s.count('A')
        g = s.count('G')
        c = s.count('C')
        t = s.count('T')
        if a+g+c+t == len(s) and len(s) > ans:
            ans = len(s)

print(ans)

Submission status: Accepted

Solution code:
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
# mod = 10**9 + 7

s = input()
mx = 0
for i in range(0,len(s)):
    for j in range(i,len(s)):
        sp = s[i:j + 1]
        # print(sp)
        at = True
        for k in range(j-i+1):
            if sp[k] != 'A' and sp[k] != 'G' and sp[k] != 'C' and sp[k] != 'T':
                at = False

        if at:
            mx = max(mx, len(sp))
            # print(mx)

print(mx)

Submission status: Accepted

Solution code:

def resolve():

    S = input()
    ans = 0
    ACGT = {"A", "C", "G", "T",}

    for i in range(len(S)):
        ss = S[i:]
        cnt = 0
        for s in ss:
            if s in ACGT:
                cnt += 1
            else:
                break
        ans = max(ans, cnt)
    return print(ans)
if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
ACGT = ['A', 'C', 'G', 'T']
def ok(S):
    for c in S:
        if c not in ACGT:
            return False
    return True
def main():
    S = input()
    res = ''
    for i in range(len(S)):
        for j in range(1, len(S)+1):
            ps = S[i:j]
            if ok(ps) and len(ps) > len(res):
                res = ps

    print(len(res))
    

main()

Submission status: Accepted

Solution code:
s=input()
ACGT=["A","C","G","T"]
moji=[]
for i in range(len(s)):
    #print(moji)
    if s[i] in ACGT:
        moji.append(s[i])
        for j in range(i+1,len(s)):
            if s[j] in ACGT:
                moji[i]+=s[j]
            else:
                break
    else:
        moji.append("")
index=0
for i in moji:
    moji[index]=len(i)
    index+=1
print(max(moji))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

s = input()

# regex = re.compile(r'([ACGT]+)')
mo = re.findall(r'([ACGT]+)', s)
if mo != None:
    ma = 0
    for m in mo:
        ma = max(ma, len(m))
    print(ma)
else:
    print(0)

Submission status: Accepted

Solution code:
import re
S = input()
ACGT = re.findall('[ACGT]+',S)
if len(ACGT) > 0:
    print(max([len(s) for s in ACGT]))
else:
    print(0)

Submission status: Accepted

Solution code:
s = input()
res, ans = 0, 0

for i in s:
    if i in ['A', 'C', 'G', 'T']:
        res += 1   # 指定した文字列がどれだけ連続しているか
    else:
        ans = max(res, ans)
        res = 0    # 文字列の連続が途切れた場合、0にリセット

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

S = input()
raw = '[ACGT]+'
pattertn = re.compile(raw)
p = pattertn.findall(S)
if p is None:
    print(0)
else:
    m = 0
    for q in p:
        m = max(m,len(q))
    print(m)

Submission status: Accepted

Solution code:
s = str(input())
ACGT = {"A", "C", "G", "T"}

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

Submission status: Accepted

Solution code:
#reの練習
import re
s = input()
s2 = re.sub('[QWERYUIOPSDFHJKLZXVBNM]',' ',s)
ss = s2.split(' ')

ans = 0
for si in ss:
    ans = max(ans, len(si))
    
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
pattern = 'ACGT'
ans = 0
length = 0

for c in S:
    if c in pattern:
        length += 1
        ans = max(ans, length)
    else:
        length = 0

print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = 0
for l in range(len(s)):
    for r in range(l+1, len(s)+1):
        substr = s[l:r]
        if set(substr).issubset({"A", "C", "G", "T"}):
            ans = max(ans, len(substr))
print(ans)

Submission status: Accepted

Solution code:
import re

s = input()
m = re.findall(r"[ACGT]*", s)

print(max([len(i) for i in m]))

Submission status: Accepted

Solution code:
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)
t = list("ACGT")

ans = 0
cnt = 0
for i in range(N):
  if s[i] in t:
    cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
else:
  ans = max(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
S = input()
count = 0
c = [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:
        c.append(count)
        count = 0
c.append(count)
print(max(c))