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

ACGT = ["", ""]
lenACGT = [0, 0]
idx = 1
for s in S:
#    print("s = {}, ACGT = {}".format(s, ACGT))
    if("A" == s):
        add = 1
    elif("C" == s):
        add = 1
    elif("G" == s):
        add = 1
    elif("T" == s):
        add = 1
    else:
        if("" != ACGT[idx]):
            ACGT.append("")
            lenACGT.append(0)
            idx += 1
        add = 0
        continue
    if(1 == add):
        ACGT[idx] += s
        lenACGT[idx] += 1

#print("ACGT = {}".format(ACGT))
#print("lenACGT = {}".format(lenACGT))
print(str(max(lenACGT)))

Submission status: Accepted

Solution code:
S = input()
N = len(S)
alphabets = "BDEFHIJKLMNOPQRSUVWXYZ"

ans = 0
for width in range(1, N+1):
    for start in range(N-width+1):
        b = True
        char = S[start:start + width]
        # print(char)
        for al in alphabets:
            if al in char:
                b = False
        if b:
            ans = max(ans, len(char))

print(ans)

Submission status: Accepted

Solution code:
s = input()
sl = len(s)
dic = {"A":1,"C":1,"G":1,"T":1}
cntmax = 0
for i in range(sl):
    cnt=0    
    for j in range(i,sl):
        try :
            # print(str(cnt) +" "+ s[j])
            cnt += dic[s[j]]
        except KeyError:
            # print(s[j])
            if cntmax < cnt:
                # print(str(i)+" "+str(j)+" "+str(cntmax)+" "+str(cnt))
                cntmax = cnt
            break
    if cntmax < cnt:
        cntmax = cnt
print(cntmax)

Submission status: Accepted

Solution code:
p = 'ACGT'
s = input()
l = len(s)
r = 0
i = -1
while i < l:
 i = next((i for i in range(i + 1, l) if s[i] in p), l)
 j = next((i for i in range(i + 1, l) if s[i] not in p), l)
 r = max(r, j - i)
 i = j
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

m = [0] * len(S)

for i, s in enumerate(S):
    if s in "AGCT":
        if i == 0:
            m[i] = 1
        else:
            m[i] = m[i-1] + 1
    else:
        m[i] = 0

print(max(m))

Submission status: Accepted

Solution code:
import re
pattern = r'[ACGT]+'
ans = 0
# text = 'SHINJUKU'
text = input()
match_list = re.findall(pattern, text)

# print(match_list)
if match_list:
    match_list_len = [len(x) for x in match_list]
    ans = max(match_list_len)

print(ans)

Submission status: Accepted

Solution code:
s = input()
k = 0
ans = 0
tmp = -1 * float('inf')
for i in range(len(s)):
  if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
    k = k + 1
    if k >= tmp:
      tmp = k
      ans = k
  else:
    k = 0
print(ans)

Submission status: Accepted

Solution code:
import re

S = input()
max = 0

for i in range(len(S)) :
    for j in range(i + 1, len(S) + 1) :
        pattern = re.compile(r'[A|T|C|G]{%d}' % int(j - i))
        subStr = S[i:j]

        if pattern.match(subStr) and j - i > max :
            max = j - i

print(max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

list.append(cnt)

print(max(list) if list else 0)

Submission status: Accepted

Solution code:
s = list(input())
l = ["A","T","G","C"]
maxcount = 0
count = 0
flag = False
for i in range(len(s)):
    if s[i] in l:
        flag = True
        if flag:
            count += 1
        if count > maxcount:
            maxcount = count
    else:
        count = 0
        flag = False
print(maxcount)

Submission status: Accepted

Solution code:
from itertools import product
from collections import Counter

S = input()
ML = len(S)

B = {'A', 'T', 'G', 'C'}
L = 0
for b, e in product(range(ML), repeat=2):
    T = S[b:ML-e]
    cc = Counter(T)
    BB = set(cc.keys()) - B
    if len(BB) == 0 and L < len(T):
        L = len(T)

print(L)

Submission status: Accepted

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

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

print(max(count))

Submission status: Accepted

Solution code:
S = input()
lenS = len(S)
maxl = 0

for i in range(lenS):
    for j in range(i, lenS):

        now = S[i:j+1]

        nowlist = list(now)
        newlist = [n for n in nowlist if n == 'A' or n == 'C' or n == 'G' or n == 'T']
        if len(newlist) == len(nowlist):
            maxl = max(maxl, len(now))
print(maxl)

Submission status: Accepted

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


def not_acgt(s):
    for c in s:
        if c not in ACGT:
            return False

    return True


def main():
    S = input()

    results = []
    # all_results = []
    for i in range(len(S)):
        for j in range(len(S)):
            if not_acgt(S[i:j+1]):
                results.append(S[i:j+1])
            # all_results.append(S[i:j+1])
    try:
        print(max([len(s) for s in results]))
    except Exception:
        print(0)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

s=list(input())



for i in range(len(s)):
    if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
        s[i]=1
    else:
        s[i]=0
list_s=[]
for i in range(len(s)):
    flag=1
    for j in range(len(s)-i):
        if s[i+j]==0:
            list_s.append(j)
            flag=0
            break
    if flag:
        list_s.append(len(s)-i)

print(max(list_s))

Submission status: Accepted

Solution code:
s = input()
count = 0
tmp = 0
for b in s:
    if b == 'A' or b == 'T' or b == 'G' or b == 'C':
        tmp += 1
    else:
        count = max(count, tmp)
        tmp = 0
        continue
count = max(count, tmp)
print(count)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
s = ns()
a = 0
b = 0
for i in range(len(s)):
  if s[i] in "ATCG":
    b += 1
  else:
    if b > 0:
      a = max(a,b)
      b = 0
 
print(max(a,b))

Submission status: Accepted

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

ans = 0
for i in range(length):
    s_ = S[i:]
    for j in range(length, -1, -1):
        # print(s[:-j])
        if j == 0:
            s = s_
        else:
            s = s_[:-j]

        valid = True
        for x in s:
            if x not in ['A', 'C', 'G', 'T']:
                valid = False
                break
        if valid:
            ans = max(ans, len(s))

print(ans)

Submission status: Accepted

Solution code:
base_chars = set("ACGT")

max_len = 0
tmp_len = 0
for c in input().strip():
  if c in base_chars:
    tmp_len += 1
  else:
    max_len = max(max_len, tmp_len)
    tmp_len = 0
max_len = max(max_len, tmp_len)
print(max_len)

Submission status: Accepted

Solution code:
b = input()
ans = ""

for i in range(len(b)):
    if b[i] == "A" or b[i] == "T" or b[i] == "C" or b[i] == "G":
        ans += "1"
    else:
        ans += "0"
#print(ans)

ls = ans.split("0")
#print(ls)
print(len(max(ls)))

Submission status: Accepted

Solution code:
S = input()

max_str = 0
counter = 0

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

print(max_str)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
i = 0
a = 0
while i<n:
    c,j = 0,i
    while j < n:
        t = (s[j:j+1])
        if t == "A" or t == "C" or t == "G" or t == "T":
            j += 1
            c += 1
        else:
            if c > a:
                a = c
            break
    if j==n:
        if c > a:
            a = c
    i = j+1
print(a)

Submission status: Accepted

Solution code:
S = input()
a = []
b = 0

for i in range(len(S)):

    if S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C':

        b += 1

    else:

        a.append(b)
        b = 0

a.append(b)

print(max(a))

Submission status: Accepted

Solution code:
count = 0;
maxnum=0;
s = input();

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

maxnum = max(count,maxnum);
print(maxnum);

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
def check(a):
    ALLOWED = "ACGT"
    for c in a:
        if not c in ALLOWED:
            return False
    return True

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

Submission status: Accepted

Solution code:
S=input()

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

print(ans)

Submission status: Accepted

Solution code:
import re
N = input()
l = []

for m in re.finditer(r"[ATCG]+", N, re.MULTILINE):
    g_counts = len(m.group())
    l.append(g_counts)

if len(l) != 0:
    print(max(l))
else:
    print(0)

Submission status: Accepted

Solution code:
S = input()

ATGC = ['A','T','G','C']
count = 0
goukei = []
for i in range(len(S)):
	count = 0
	for j in range(i,len(S)):
		if(S[j] in ATGC):
			count += 1
			if(j == len(S)-1):
				goukei.append(count)
				break
		else:
			goukei.append(count)
			break
print(max(goukei))

Submission status: Accepted

Solution code:
S = list(input())

def judge1(S):
  for j in range(len(S)):
    judge = 1
    if((S[j]=='A')or(S[j]=='G')or(S[j]=='T')or(S[j]=='C')):
      continue
    else:
      judge = 0
      break
  return judge 

ans = 0
judge = 0
for i in range(len(S)):
  j = 0
  k = len(S) - i
  
  while(1):
   if(j+k-1 > len(S)-1):
    break
   tmp_S = S[j:j+k]
   judge = judge1(tmp_S)
   if(judge == 1):
    ans = len(tmp_S)
    break
   j += 1
  if(judge == 1):
    break
      
print(ans)

Submission status: Accepted

Solution code:
S = input()
rules = set(("A", "C", "G", "T"))

long = 0
result = -1
for s in S:
    if s in rules:
        long += 1
    else:
        result = max(result, long)
        long = 0
result = max(result, long)        
print(result)

Submission status: Accepted

Solution code:
S = input()

text = ""
ans = 0
for idx, moji in enumerate(S):
    
    if moji == "A" or moji == "C" or moji == "G" or moji == "T":
        text += moji
        for j in range(idx+1,len(S)):
            if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
                text += S[j]
                #print(0, text)
            else:
                #print(-1, text)
                if len(text) > ans:
                    ans = len(text)
                text = ""
                break
        if len(text) > ans:
            ans = len(text)
        text = ""
    else:
        text = ""

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 21:18:05 2019

@author: yuta
"""

S = input()

def main(s):
    max_count = 0
    for i in range(len(s)):
        if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
            count = 1
        else:
            continue
        for j in range(1,len(s)-i):
            if s[i+j] == "A" or s[i+j] == "T" or s[i+j] == "G" or s[i+j] == "C":
                count += 1
            else:
                break
        if max_count <= count:
            max_count = count
    print(max_count)
main(S)

Submission status: Accepted

Solution code:
S = input()
maxLength = 0
length = 0


for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        length += 1
    else:
        length = 0
    if maxLength < length:
        maxLength = length

print(maxLength)

Submission status: Accepted

Solution code:
s = list(input())

li = []
result = []
pre = 0
n=0

for i in s:
	n=n+1
	if pre == 0 and (i == "A" or i == "C" or i == "G" or i == "T"):
		li.append(i)
		pre=1
		if n == len(s):
			if len(li)>len(result):
				result = li
	elif pre == 1 and (i == "A" or i == "C" or i == "G" or i == "T"):
		li.append(i)
		if n == len(s):
			if len(li)>len(result):
				result = li
	elif pre==1:
		if len(li)>len(result):
			result = li
		li=[]
		pre=0

print(len(result))

Submission status: Accepted

Solution code:
#AGC032
b = input()
ans = 0
kari = 0
flag = True
for i in range(len(b)):
    #print(b[i])
    if b[i] == "A" or b[i] == "T" or b[i] == "C" or b[i] == "G":
        if flag == True:
            kari += 1
            ans = max(kari,ans)
        else:
            kari = 1
            ans = max(kari,ans)
        flag = True
    else:
        
        flag = False
print(ans)

Submission status: Accepted

Solution code:
S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count+=1
  else:
    list.append(count)
    count = 0
list.append(count)

if len(list)==0:
    print('0')
else:
    print(max(list))

Submission status: Accepted

Solution code:
import re
ptn = re.compile(r"(A|C|T|G)*")

S = input()
T = set()
xx=ptn.match("FAFA")
for i in range(len(S)):
  for j in range(len(S)):
    x = ptn.match(S[i:i+j+1])
    if(x.group(0)):
      T.add(len(x.group(0)))
try:
  print(max(T))
except:
  print(0)

Submission status: Accepted

Solution code:
s=list(input())
n=len(s)
ans=0
tmp=-10
cnt=[0]*20
for i in range(n):
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        cnt[i]=1
for i in cnt:
    if i==1:
        ans+=1
    else:
        if tmp<ans:
            tmp=ans
            ans=0
if tmp==-10:
    print(ams)
else:
    print(tmp)

Submission status: Accepted

Solution code:
s = input()
len(s)
ans = 0
for i in range(len(s)):
    for j in range(len(s) - i):
        part = s[i:j+i+1]
        # print("i", i)
        # print("j", j+i+1)
        # print("part=", part)
        for car in part:
            if car is not "A" and car is not "T" and car is not "C" and car is not "G":
                break
        else:
            if ans < len(part):
                ans = len(part)
                moji = part
            # print("car", car)
            # print("ans", ans)
            # print("moji", moji)

print(ans)

Submission status: Accepted

Solution code:
S=str(input().strip())

T=""
for i in S:
    if i=="A" or i=="C" or i=="G" or i=="T":
        T+="1"
    else:
        T+="0"

TT=T.split("0")
num=0
for i in TT:
    num=max(num,len(i))
print(num)

Submission status: Accepted

Solution code:
inp = list(input())
li = ['A','C','G','T']
co = []
count = 0
for i in inp:
    if i in li:
        count += 1
    else:
       co.append(count)
       count = 0

co.append(count)
co.sort()
print(co[-1])

Submission status: Accepted

Solution code:
s = input()
r = 0
o = [x for x in s]

l = 1
j = []
a, b = 0, 1
for y in range(len(o)):
    for x in range(10):
        j.append([a, b])
        a += 1
        b += 1
    l += 1
    a, b = 0, l

for x in j:
    for y in o[x[0]:x[1]]:
        if not y in ["A", "C", "G", "T"]:
            break
    else:
        if len("".join(o[x[0]:x[1]])) > r:
            r = len("".join(o[x[0]:x[1]]))

print(r)

Submission status: Accepted

Solution code:
S=input()
count = 0
for i in reversed(range(len(S))):
    for j in range(0, len(S)-i):
        S_part = S[j:i+j+1]
        l = list(set(S_part))
        l.sort()
        if set(l)&set(['A','C','G','T'])==set(l):
            count = max(count, len(S_part))
print(count)

Submission status: Accepted

Solution code:
S = input()

targets = list("AGCT")
out = 0
count = 0
for s in S:
    if s in targets:
        count += 1
    else:
        out = max(out, count)
        count = 0

out = max(out, count)
print(out)

Submission status: Accepted

Solution code:
S = list(input())

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

Max = 0
s = []
t = 0
for i in range(len(S)):
  if S[i] in ACGT:
    t += 1
    if t > Max:
      Max = t
  else:
    t = 0
print(Max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
#print(s)
#print(len(s))
s = s+'X'
ans = []
cnt = 0
for i in range(len(s)):
  #print(s[i])
  if (s[i] != 'A') and (s[i] != 'T') and (s[i] != 'C') and (s[i] != 'G'):
    ans.append(cnt)
    #print(ans)
    cnt = 0
  elif s[i] == 'A':
    cnt += 1
    continue
  elif s[i] == 'T':
    cnt += 1
    continue
  elif s[i] == 'C':
    cnt += 1
  elif s[i] == 'G':
    cnt += 1

#print(ans)
print(max(ans))

Submission status: Accepted

Solution code:
acgtlist = ["A","C","G","T"]
acgtlen,old_acgtlen = 0,0
for i in input():
	if i in acgtlist:
		acgtlen += 1 
	else:
		acgtlen = 0

	old_acgtlen = acgtlen if acgtlen > old_acgtlen else old_acgtlen
print(old_acgtlen)

Submission status: Accepted

Solution code:
import re
word = input()
cnt = 0
max = 0

for w in word:
    if w == "A" or w == "C" or w == "G" or w == "T":
        cnt += 1
        if cnt > max:
            max = cnt
    else:
        cnt = 0
print(max)

Submission status: Accepted

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

Submission status: Accepted

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

i = input()

c = 0
c_list = []

if len(i) == 1:
    if i in ['A', 'C', 'G', 'T']:
        print(1)
        exit()
    else:
        print(0)
        exit()

for moji in i:
    if moji in ['A', 'C', 'G', 'T']:
        c += 1
        c_list.append(c)
    else:
        c_list.append(c)
        c = 0

print(max(c_list))

Submission status: Accepted

Solution code:
s = input()

def atgc(l, r):
    global s
    for i in range(l, r):
        if s[i] != "A" and s[i] != "T" and s[i] != "G" and s[i] != "C":
            return False
    return True

t_max = 0

for i in range(0, len(s) + 1):
    for j in range(i + 1, len(s) + 1):
        if atgc(i, j) and t_max < j - i:
            t_max = j - i
            
print(t_max)

Submission status: Accepted

Solution code:
S=input()
slist=[]
for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        slist.append(S[i:j])
ma=0
for s in slist:
    flag = True
    for w in s:
        if w not in ['A','C','G','T']:
            flag = False
    if flag:
        ma = max(ma, len(s))
print(ma)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
max_acgt_len = 0

for i in range(len(s)):
    current_str = s[i:]

    for j in reversed(range(1, len(current_str) + 1)):
        acgt_count = 0
        acgt_count += current_str[:j].count('A')
        acgt_count += current_str[:j].count('G')
        acgt_count += current_str[:j].count('C')
        acgt_count += current_str[:j].count('T')

        if acgt_count == len(current_str[:j]):
            max_acgt_len = max(max_acgt_len, acgt_count)
print(max_acgt_len)

Submission status: Accepted

Solution code:
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix += [int(b) for b in a]
    return intMatrix


def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix


def makeInt(line):
    return int(line.rstrip())


def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    S = input_string
    cnt = 0
    maxCnt = 0
    for N in S:
        if N == 'A':
            cnt += 1
        elif N == 'T':
            cnt += 1
        elif N == 'G':
            cnt += 1
        elif N == 'C':
            cnt += 1
        else:
            if cnt > maxCnt:
                maxCnt = cnt
            cnt = 0
        if cnt > maxCnt:
            maxCnt = cnt
    return maxCnt


def main():
    input_lines = stdin.readline()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = list(input())

acgt = ['']
while len(s) != 0:
	if s[0] == 'A' or s[0] == 'C' or s[0] == 'G' or s[0] == 'T':
		acgt[-1] += s.pop(0)
	else:
		s.pop(0)
		acgt.append('')

print(max([len(e) for e in acgt]))

Submission status: Accepted

Solution code:
word = input()
num = [0]
index = 0
for i in word:
  if i.strip("ATCG") == "":
    num[index] += 1
  else:
    index += 1
    num.append(0)
print(max(num))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    is_prev_atgc = False
    now = 0
    maximum = 0
    target = ("A", "T", "G", "C")
    for char in s:
        if char in target:
            is_prev_atgc = True
            now += 1
            if maximum < now:
                maximum = now
        else:
            is_prev_atgc = False
            now = 0
    print(maximum)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=list(input())
count=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":
    count+=1
  else:
    if count>ans:
      ans=count
    count=0
if count>ans:
  ans=count
print(ans)

Submission status: Accepted

Solution code:
s = input() + '0'
det = 'ACGT'
maxc = 0
for i in range(len(s)):
    for p in range(i, len(s)):
        cnt = 0
        for o in range(i, p + 1):
            if s[o] in det:
                cnt += 1
            else:
                if cnt > maxc:
                    maxc = cnt
                    break
                else:
                    break
            if o == p:
                if cnt > maxc:
                    maxc = cnt
print(maxc)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def diff(tmp):
    if tmp > cnt:
        return tmp
    else:
        return  cnt

list = list(input())

cnt = 0
tmp = 0
for row in list:
    if row in ('ACGT'):
        tmp += 1
        cnt = diff(tmp)
    else:
        cnt = diff(tmp)
        tmp = 0

print(cnt)

Submission status: Accepted

Solution code:
S = input()
start = 0
max = 0
count = 0
for i in range(len(S)):
    if(S[i] != "A")&(S[i] != "T")&(S[i] != "G")&(S[i] != "C"):
        if max < count:
            max = count
        count = 0
    else:
        count = count + 1
if ((S[i] == "A")|(S[i] == "T")|(S[i] == "G")|(S[i] == "C"))&(max < count):
    max = count
print(max)

Submission status: Accepted

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

li_otpt = [0]
for s in S:
  if s in l:
    li_otpt[-1] += 1
  else:    
    li_otpt.append(0)
      
print(max(li_otpt))

Submission status: Accepted

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

Submission status: Accepted

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

results = []
begin, end = None, None
acgt = 'ACGT'
for i, s in enumerate(S):
  if begin is None and s in acgt:
    begin = i
  
  if begin is not None and s not in acgt:
    end = i
  
  if begin is not None and (end is not None or i == len_S - 1):
    if end is None:
      end = len_S
    results.append(end - begin)
    begin, end = None, None

print(max(results) if len(results) > 0 else 0)

Submission status: Accepted

Solution code:
str = input()

def check(text):
  if text=='A' or text=='G' or text=='C' or text=='T':
    return 1
  else:
    return 0

longest=0
sum=0
str=str+'B'
for i in str:
  if check(i)==1:
    sum+=1
  else:
    if longest<sum:
      longest=sum
      sum=0
    else:
      sum=0
print(longest)

Submission status: Accepted

Solution code:
#B問題
S=str(input())
Slist=list(S)
Slen=len(Slist)
MAX=0
for i in range(Slen):
    for j in range(Slen-i-1):
        J=j+i+1
        karis=Slist[i:J+1]
        flag = 0
        for x in karis:
            if x == "A" or x == "T" or x == "C" or x == "G":
                pass
            else:
                flag = 1
                break
        if flag == 0:
            MAX=max(MAX,len(karis))
if MAX == 0:
    if "A" in S or "T" in S or "G" in S or "C" in S:
        print(1)
    else:
        print(0)
else:
    print(MAX)

Submission status: Accepted

Solution code:
S=input()
A=list(S)
number=[]
for i in A:
    if i == "A" or i == "C" or i == "G" or i == "T":
        number.append(1)
    else:
        number.append(0)

count=0
maxcount=0

for i in number:
    if i == 1:
        count = count + 1
        if count > maxcount:
            maxcount=count
    elif i == 0:
        count = 0
        
print(maxcount)

Submission status: Accepted

Solution code:
s = input()

l = ["A","C","G","T"]
res = 0

for i in range(len(s)):
    #print(i)
    tmp = 0
    #print(s[i:])
    for j in s[i:]:
        if j in l:
            tmp += 1
        else:
            res = max(res,tmp)
            #print(res)
            break
    else:
        res = max(res,tmp)
else:
    print(res)

Submission status: Accepted

Solution code:
Ss=[i for i in input()]
anss = []
counter = 0
for i in range(len(Ss)):
    if Ss[i]!="A" and Ss[i]!="C" and Ss[i]!="G" and Ss[i]!="T":
        anss.append(counter)
        counter=0
    else:
        counter+=1
        anss.append(counter)
if len(anss)!=0:
    print(max(anss))
else:
    print(0)

Submission status: Accepted

Solution code:
S = input()

max_ss = 0
current_size = 0

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

max_ss=max(max_ss,current_size)

print(max_ss)

Submission status: Accepted

Solution code:
S = input()

count = 0
max_length = 0
for i in S:
    if i in ('A', 'T', 'C', 'G'):
        count += 1
        if count > max_length:
            max_length = count
    else:
        count = 0

print(max_length)

Submission status: Accepted

Solution code:
S = input()
tmp = 0
ans = 0
index = 0
while index != len(S):
    if S[index] == "A" or S[index] == "T"  or S[index] == "G" or S[index] == "C":
        tmp += 1
    else:
        if tmp > ans:
            ans = tmp
        tmp = 0
    index += 1
if tmp > ans:
    ans = tmp
print(ans)

Submission status: Accepted

Solution code:
b = raw_input()
N = len(b)
#ACGT

score=0
tmp_score=0

for i in range(N):
	for c in range(N+1):
		if b[i:i+c].count('A')+b[i:i+c].count('C')+b[i:i+c].count('G')+b[i:i+c].count('T') == len(b[i:i+c]):
			tmp_score = len(b[i:i+c])

			if score<tmp_score:
				score=tmp_score
print score

Submission status: Accepted

Solution code:
S = input()
import re
regex = re.compile(r"[ATGC]+")
mo = regex.findall(S)
l=[]
for item in mo:
    l.append(len(item))
if l ==[]:
    print("0")
else:
    print(max(l))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 17:18:46 2019
ABC122B
@author: maezawa
"""

s = input()
n = len(s)
cnt = 0
atcgset = set(['A','T','C','G'])
for i in range(n):
    for j in range(i,n):
        subs = s[i:j+1]
        #print(s[i:j+1])
        sset = set(s[i:j+1])
        if atcgset >= sset:
            #print(s[i:j])
            if len(subs) > cnt:
                cnt = len(subs)
print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
s = input()
a = [0] *len(s)
for i in range(len(s)):
    for j in range(len(s) - i):
        if s[i+j: i+j+1] == "A" or s[i+j: i+j+1] == "T" or s[i+j: i+j+1] == "C" or s[i+j: i+j+1] == "G":
            a[i] += 1
        else:
            break
        
print(max(a[i] for i in range(len(s))))

Submission status: Accepted

Solution code:
import re
S = input()

pattern = '[A|C|G|T]+'

# findall 
results = re.findall(pattern, S, re.S)

if len(results) == 0 :
    print(0)
else :
    print(len(max(results,key=len)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = input()
count = 0
result = 0
for i in S:
    if i in ["T", "A", "G", "C"]:
        count += 1
        result = max([result, count])
    else:
        count = 0
print(result)

Submission status: Accepted

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

for i in range(len(s)):
        if s[i] in 'ACGT':
                n = n + 1
        else:
                n = 0
        if ans < n:
                ans = n
print(ans)

Submission status: Accepted

Solution code:
S = input()
enki = {"A", "T", "C", "G"}
T = list(S)
l = [0] * 10
for i in range(len(T)):
    j = i
    while(j<len(T) and T[j] in enki):
        l[i] += 1
        j += 1

print(max(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

L = []
cnt = 0
for i in S:
  if i == "A" or i == "C" or i == "G" or i == "T":
    cnt += 1
  else:
    L.append(cnt)
    cnt = 0

L.append(cnt)

if len(L) == 0:
	print(0)
else:
	print(max(L))