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()
m=0
cnt=0
for i in s:
  if i in "ACGT":
    cnt += 1
  else:
    cnt = 0
  m=max(m,cnt)
print(m)

Submission status: Accepted

Solution code:
S=input()
max=0
flag=0
count=0
for i in range(len(S)):
    if (S[i]=="A")or(S[i]=="T")or(S[i]=="G")or(S[i]=="C"):
        flag=1
    else:
        flag=0

    if flag==1:
        count=count+1
    else:
        count=0

    if max<count:
        max=count
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC122 B
S=input()
ans=0
cnt=0
for s in S:
    if s == "A" or s == "T" or s == "G" or s == "C":
        cnt+=1
    else:
        cnt=0
    ans=max(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = 0
lis = []
for i in range(len(s)):
    if s[i] in "ACGT":
        ans += 1
        lis.append(ans)
    else:
        ans = 0 #初期化
        lis.append(ans)
print(max(lis))

Submission status: Accepted

Solution code:
S = input()

cnt = 0
results = []

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools

b=input()
list=[]
count=0


for i in range(len(b)):
	if b[i]=="A" or b[i]=="G" or b[i]=="T" or b[i]=="C":
		count+=1
	else :
		count=0
	list.append(count)

print(max(list))

Submission status: Accepted

Solution code:
S = list(input())
ACGT = set(["A","C","G","T"])
ans = 0
acgt_length = 0

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby
# https://atcoder.jp/contests/abc122/tasks/abc122_b
S = list(input())
b = [i in list('ACGT') for i in S]

ans = 0
for i, j in groupby(b):
    num_elements = len(list(j))
    if i and num_elements > ans:
        ans = num_elements
print(ans)

Submission status: Accepted

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

S = list(input())

ans = 0
tmp = 0

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

print(ans)

Submission status: Accepted

Solution code:
S = str(input())
m=0
point=0
for i in S:
    if i == "A" or i == "G" or i == "C" or i == "T":
        point+=1
    else:
        point*=0
    m = max(m, point)
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = input()
i = 0
ans = 0
for xi in x:
  if xi == 'A' or xi == 'T' or xi == 'G' or xi == 'C':
    i = i + 1
  else:
    if ans < i:
      ans = i
    i = 0
if ans < i:
  ans = i
print(ans)

Submission status: Accepted

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


def read_list():
    return list(read_values())


def main():
    S = input()
    res = 0
    tmp = 0
    for s in S:
        if s in ("A", "T", "C", "G"):
            tmp += 1
        else:
            res = max(res, tmp)
            tmp = 0
    res = max(res, tmp)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
H="AGTC"

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

Submission status: Accepted

Solution code:
s = input()
l = ["A", "C", "G", "T"]
count = 0
m = []

for i in range(len(s)):
  if s[i] in l:
    count += 1
  else:
    m.append(count)
    count = 0
m.append(count)
    
print(max(m))

Submission status: Accepted

Solution code:
def ABC122B():
    S = input()
    target = ['A', 'G', 'C', 'T']
    flag = False
    cnt = 0
    ans = 0
    for s in list(S):
        if s in target:
            cnt += 1
            if flag == False:flag = True
        if flag == True and s not in target:
            flag = False

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

ABC122B()

Submission status: Accepted

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

z = len(x)
y = [0]
a = 1
if z == 1:
    if x[0] == 1:
        y.append(a)
else:
    for j in range(1,z):
        if x[j] == 1:
            if x[j-1] == 1:
                a += 1
                if j == z-1:
                    y.append(a)
            else:
                y.append(a)
                a = 1
        else:
            if x[j-1] == 1:
                y.append(a)
                a = 1
print(max(y))

Submission status: Accepted

Solution code:
s = list(input())
#print(s)
x = []
for i in s:
    if i in ('A' 'C' 'G' 'T'):
        x.append(1)
    else:
        x.append(0)
#print(x)

z = len(x)
y = [0]
a = 1
if z == 1:
    if x[0] == 1:
        y.append(a)
else:
    for j in range(1,z):
        if x[j] == 1:
            if x[j-1] == 1:
                a += 1
                if j == z-1:
                    y.append(a)
            else:
                y.append(a)
                a = 1
        else:
            if x[j-1] == 1:
                y.append(a)
                a = 1
#print(y)
print(max(y))

Submission status: Accepted

Solution code:
s = input()

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

if result < count:
  result = count

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
T = input()
ACGT = ['A', 'C', 'G', 'T']
ans = 0
count = 0

for t in T:
    if t in ACGT:
        count += 1
        ans = max(ans, count)
    else:
        count = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    result = []
    strings = ["A", "T", "G", "C"]
    S = input()
    tmp = 0
    for s in S:
        if s in strings:
            tmp += 1
        else:
            result.append(tmp)
            tmp = 0
    result.append(tmp)
    print(max(result))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().decode('utf8').rstrip()
L = len(S)
ans = 0
for left in range(L):
    for right in range(left, L):
        T = S[left:right + 1]
        if set(T) <= set('ACGT'):
            ans = max(ans, right - left + 1)

print(ans)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

AT = {'A', 'C', 'G', 'T'}
S = list(read().decode('utf8').rstrip())

lis = [0] * len(S)
for s in range(len(S)):
    if S[s] in AT:
        if lis[s - 1] != 0:
            lis[s] += lis[s - 1] + 1
        else:
            lis[s] = 1
    else:
        lis[s] = 0

print(max(lis))

Submission status: Accepted

Solution code:
import sys

atcg = set('ATCG')

s = sys.stdin.readline().rstrip()

def main():
    t = s + '$'
    l = len(t)
    res = 0
    cnt = 0
    for i in range(l):
        if t[i] in atcg:
            cnt += 1
        else:
            res = max(res, cnt)
            cnt = 0
    return res

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    ACGT = set(['A', 'C', 'G', 'T'])

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

c = -1
ans = []
for i in range(len(s)):
   if (s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T'):
      if (c < 0):
         c = i
   else:
      if (c >= 0):
         ans.append(i - c)
         c = -1

if (c >= 0):
   ans.append(len(s) - c)
try:
   print(max(ans))
except:
   print(0)

Submission status: Accepted

Solution code:
s = input()
ans = 0
temp = 0
for c in s:
  if c in 'ATCG':
    temp += 1
    ans = max(ans, temp)
  else:
    temp = 0
print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0 
ans_lis = [0]

for i in range(len(S)):
    if S[i] in "ACGT":
        ans = ans + 1 
    else:
        ans_lis.append(ans)
        ans = 0 

ans_lis.append(ans)
print(max(ans_lis))

Submission status: Accepted

Solution code:
S = input()

ans = 0 
ans_lis = [0]

for i in range(len(S)):
    if S[i] in "ACGT":
        ans = ans + 1 
        if i == (len(S)-1):
            ans_lis.append(ans)
    else:
        ans_lis.append(ans)
        ans = 0 

print(max(ans_lis))

Submission status: Accepted

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

ans = 0 
ans_lis = [0]

for i in range(len(S)):
    if S[i] in ACGT:
        ans = ans + 1 
        if i == (len(S)-1):
            ans_lis.append(ans)
    elif S[i] not in ACGT:
        ans_lis.append(ans)
        ans = 0 

print(max(ans_lis))

Submission status: Accepted

Solution code:
import re

s = input()
ans = max(
    map(len, re.findall('[AGCT]+', s)),
    default=0
)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

ans =[]
cnt = 0
for i in s:
    if i in DNA:
        cnt += 1
        if i == s[-1]:
            ans.append(cnt)
    else:
        ans.append(cnt)
        cnt = 0

print(max(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
S = str(input())

T = "ACGT"

S2 = ""
for i in range(len(S)) :
  if S[i] in T :
    S2 += "#"
  else :
    S2 += " "
S3 = list(map(str, S2.split()))
#print (S2)
l = 0
for i in range(len(S3)) :
  l = max(l, len(S3[i]))
  
print (l)

Submission status: Accepted

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

print(max(ans))

Submission status: Accepted

Solution code:
l = list(input())
ans = []
ans.append(0)
count = 0
for i in range(len(l)):
  if l[i] == "A" or  l[i] == "G" or  l[i] == "T" or  l[i] == "C":
    count += 1
  else:
    ans.append(count)
    count = 0
    
ans.append(count)
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = ns()
ans = 0
c = 0
acgt = ["A", "C", "G", "T"]
for si in s:
    if si in acgt:
        c += 1
    else:
        ans = max(c, ans)
        c = 0
if c != 0:
    ans = max(c, ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().strip()
ans = 0
tmp = 0
for _, x in enumerate(s):
    if x == "A" or x == "C" or x == "G" or x == "T":
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0

if tmp != 0:
    ans = max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
S = input()

d = set(['A', 'T', 'C', 'G'])
len_ = 0
ans = 0
for s in S:
    if s in d:
        len_ += 1
    else:
        # この部分書き換える
        # if len_ > ans:
        #     ans = len_
        ans = max(len_, ans)
        len_ = 0
ans = max(len_, ans)
print(ans)

Submission status: Accepted

Solution code:
S = input()

d = set(['A', 'T', 'C', 'G'])
len_ = 0
ans = 0
for s in S:
    if s in d:
        len_ += 1
    else:
        if len_ > ans:
            ans = len_
        len_ = 0
if len_ > ans:
    ans = len_
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    S=list(input())
    ans=0
    tmp=0
    for s in S:
        if s=='A' or s=='T' or s=='G' or s=='C':
            tmp+=1
        else:
            ans=max(ans,tmp)
            tmp=0
    ans=max(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

res = []

for i in range(len(s)):
    for j in range(i, len(s)):
        check = s[i:j+1]
        if len(check) == check.count("A")+check.count("T")+check.count("C")+check.count("G"):
            res.append(len(check))
print(0 if res == [] else max(res))

Submission status: Accepted

Solution code:
import re
s = input()

ans = ""
tmp_ans = ""
for i in range(len(s)):
    if re.fullmatch(r"[ATGC]", s[i]):
        tmp_ans += s[i]
    else:
        if len(ans) < len(tmp_ans):
            ans = tmp_ans
        tmp_ans = ""

if len(ans) < len(tmp_ans):
    ans = tmp_ans

print(len(ans))

Submission status: Accepted

Solution code:
S = str(input())

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

acgt = ''
for s in S:
    if s not in data:
        acgt += '.'
    else:
        acgt += s

ans = 0
for s in acgt.split('.'):
    ans = max(ans, len(s))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = list(str(input()))

tmp = []
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        tmp.append(1)
    else:
        tmp.append(0)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
code = ["A","C","G","T"]
mask = [None] * len(S)
ans = 0
temp = 0

for el in S:
    if el in code:
        temp += 1
    else:
        ans = max(ans,temp)
        temp = 0
ans = max(temp, ans)
print(ans)

Submission status: Accepted

Solution code:
def main():
	# a,b,k = map(int,input().split())
	# n,k = map(int,input().split())
	s = list(str(input()))
	# a = list(map(int,input().split()))
	# rsp = list(str(input()))
	# l = [list(map(int, input().split())) for _ in range(n-1)]
	# s = list(s)
	avoid = 0
	ans = 0
	ans_rec = []
	for i in range(len(s)):
		if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
			# print("when i = {} is true".format(i))
			ans += 1
		else:
			ans_rec.append(ans)
			ans = 0
	ans_rec.append(ans)
			
	print(max(ans_rec))

 
if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby
S = input()
d = {"A", "C", "G", "T"}
print(max(map(lambda p: int(p[0])*len(list(p[1])), groupby(S, lambda s: s in d))))

Submission status: Accepted

Solution code:
s = input()
l = []
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:
        l.append(count)
        count = 0
    if i == len(s)-1:
        l.append(count)

print(max(l))

Submission status: Accepted

Solution code:
import sys

S = list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=[i for i in input()]
l=[]
cnt=0
for i in range(len(s)):
  if s[i] in {"A","T","C","G"," "}:
    cnt+=1
    if i==len(s)-1:
      l.append(cnt)
  else:
    l.append(cnt)
    cnt=0    
print(sorted(l)[-1])

Submission status: Accepted

Solution code:
s=[i for i in input()]
l=[]
cnt=0
for i in range(len(s)):
  if s[i]=="A" or s[i]=="T" or s[i]=="C" or s[i]=="G" or s[i]==" ":
    cnt+=1
    if i==len(s)-1:
      l.append(cnt)
  else:
    l.append(cnt)
    cnt=0  
print(max(l) if len(l)>1 else l[0])

Submission status: Accepted

Solution code:
import re
S = input()

a = (re.split('[BDEFHIJKLMNOPQRSUVWXYZ]', S))

A = []

for i in a:
    A.append(len(i))
print(max(A))

Submission status: Accepted

Solution code:
S=input()
ans=0
maxi=0

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

Submission status: Accepted

Solution code:
S = input()
ans = 0

K = ('A', 'C', 'G', 'T')
for i in range(len(S)):
    cnt = 0
    if S[i] not in K:
        continue
    else:
        cnt += 1
    for j in range(i+1, len(S)):
        if S[j] not in K:
            break
        cnt += 1
    if ans < cnt:
        ans = cnt

print(ans)

Submission status: Accepted

Solution code:
s = input()
lst = [0]

for i in range(len(s)):

    if s[i] in 'ACGT':
        tmp = 0
        for j in range(len(s)-i):
            if s[i+j] in 'ACGT':
                tmp += 1
            else:
                break

            lst.append(tmp)


print(max(lst))

Submission status: Accepted

Solution code:
S = str(input())
S_list = list(S)
S_switch = []

for i in range(len(S_list)):
    if S_list[i]=="T" or S_list[i]=="A" or S_list[i]=="G" or S_list[i]=="C":
        S_switch.append(1)
    else:
        S_switch.append(0)

count = 0
max_count = 0
for i in range(len(S_switch)):
    if S_switch[i] == 1:
        count = count + 1
    else:
        if count > max_count:
            max_count = count
        count = 0

if count > max_count:
    max_count = count
count = 0

print(max_count)

Submission status: Accepted

Solution code:
import re
s = input()
match = re.findall(r"[ACGT]+",s)
if len(match)==0:
    print(0)
else:
    print(max([len(i) for i in match]))

Submission status: Accepted

Solution code:
s = input()
ret = 0
for left in range(len(s)):
    for right in range(left, len(s)):
        if set(s[left:right + 1]).issubset(set('ACGT')):
            ret = max(ret, right - left + 1)
print(ret)

Submission status: Accepted

Solution code:
S = input()

n = 0

ans = 0

counter = 0

while n != len(S):
    if S[n] == 'A' or S[n] == 'C' or S[n] == 'T' or S[n] == 'G':
        counter += 1
    else:
        counter = 0
    if ans < counter:
        ans = counter
    n += 1

print(ans)

Submission status: Accepted

Solution code:
s = input()
tmp = ''
for i in s:
	if i not in 'ACGT':
		tmp += '-'
	else:
		tmp += i
print (max(len(i) for i in tmp.split('-')))

Submission status: Accepted

Solution code:
import os, sys, re, math

(S) = input()

max_len = 0
for i in range(0, len(S)):
    for j in range(i + 1, len(S) + 1):
        substr = S[i:j]
        if len(re.sub('[ATGC]', '', substr)) == 0:
            max_len = max(max_len, len(substr))

print (max_len)

Submission status: Accepted

Solution code:
S = input()
ret = 0
t = ''
for s in S + ' ':
    if s in ['A', 'C', 'G', 'T']:
        t += s
    else:
        ret = max(ret, len(t))
        t = ''

print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
N=len(S)
cnt=0
data=list("AGCT")
ans=0
for i in range(N):
    if S[i] in data:
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
ans=max(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


S = fetch_one_line()
is_ACGT = []
ACGT = "A C G T".split()

for s in S:
    is_ACGT.append(s in ACGT)

longest = -1
count = 0
for b in is_ACGT:
    if b:
        count += 1
    else:
        if count > longest:
            longest = count
            count = 0


if count > longest:
    longest = count

print(longest)

Submission status: Accepted

Solution code:
s = input()

st = 'ACGT'
ans = 0
cur = 0
for x in s:
  if x in st:
    cur += 1
  else:
    cur = 0
  ans = max(cur, ans)
print(ans)

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

S = sys.stdin.buffer.readline().decode().rstrip()
N = len(S)
ans = 0
for l in range(N + 1):
    for r in range(N + 1):
        if re.match(r'^[AGCT]*$', S[l:r]):
            ans = max(ans, r - l)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

max = 0
for i in range(len(s)):
    for j in reversed(range(len(s) + 1)):
        cnt = 0
        for k in range(i, j):
            if s[k] == "A" or s[k] == "C" or s[k] == "G" or s[k] == "T":
                cnt += 1
            else:
                cnt = 0
                break
        if max < cnt:
            max = cnt
print(max)

Submission status: Accepted

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

S = input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

S = input()

ans = 0
for s in re.findall(r"[ACGT]+", S):
    ans = max(ans, len(s))

print(ans)

Submission status: Accepted

Solution code:
def solve():
    S = input()
    
    N = len(S)
    ans, i = 0, 0
    while i < N:
        count = 0
        j = i
        while j < N:
            if S[j] == 'A' or S[j] == 'C' or S[j] == 'G' or S[j] == 'T':
                count += 1
                j += 1
            else:
                break
        i = j + 1
        ans = max(ans, count)
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
targ = 'ACGT'

ans = 0
ans_tmp = 0
for i, Si in enumerate(S):
    if Si in targ:
        ans_tmp += 1
    else:
        ans = max(ans, ans_tmp)
        ans_tmp = 0
else:
    ans = max(ans, ans_tmp)

print(ans)

Submission status: Accepted

Solution code:
A, = [s.split() for s in open(0)]
if len(A) == 0:
    A = [""]
else:
    A = A[0]
acgt = []
for i in range(len(A)):
    for j in range(len(A), 0, -1):
        sub_string = A[i:j]
        for s in sub_string:
            if s not in ["A", "C", "G", "T"]:
                break 
        else:
            acgt.append(sub_string)
if len(acgt) == 0:
    print(0)
else:
    print(max([len(s) for s in acgt]))

Submission status: Accepted

Solution code:
s = input()
maxacgt = 0
cnt = 0

for i in list(s):
    if i in ("A","C","G","T"):
        cnt += 1
    else:
        if cnt > maxacgt:
            maxacgt = cnt
        cnt = 0
else:
    if cnt > maxacgt:
            maxacgt = cnt
    ans = maxacgt

print(ans)

Submission status: Accepted

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

ans = [0]
count = 0

for i in s:
    if i in acgt:
        count += 1
    else:
        ans.append(count)
        count = 0
ans.append(count)

print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ltrs = "ACGT"
curr_max = 0
curr_len = 0
for ltr in S:
    if ltr in ltrs:
        curr_len += 1
    else:
        curr_max = max(curr_max, curr_len)
        curr_len = 0
print(max(curr_len, curr_max))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = []
ll = 0
for i in range(len(S)):
    if S[i] in AA:
        ll += 1
    else:
        ans.append(ll)
        ll = 0
ans.append(ll)

print(max(ans))

Submission status: Accepted

Solution code:
import re
s = input()
max_re = 0
for i in range(len(s)):
    tar_s = s[i:]
    tar_s = re.search(r'(A|T|C|G)*', tar_s).group()
    max_re = max(max_re, len(tar_s))
print(max_re)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
max_cnt = 0
cnt = 0
for v in s:
  if v in ['A', 'T', 'C', 'G']:
    cnt += 1
  else:
    max_cnt = cnt if max_cnt < cnt else max_cnt
    cnt = 0

max_cnt = cnt if max_cnt < cnt else max_cnt
print(max_cnt)