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:
# -*- coding: utf-8 -*-

def get_input() -> str:
    """
    標準入力を取得する.

    Returns:\n
        str: 標準入力
    """
    S = input()

    return S


def main(S: str) -> None:
    """
    メイン処理.

    Args:\n
        S (str): 長さ1以上10以下の英大文字列
    """
    # 求解処理
    N = len(S)
    ans = 0
    for i in range(N):
        for j in range(i, N):
            if all("ACGT".count(c) == 1 for c in S[i: j + 1]):
                ans = max(ans, j - i + 1)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    S = get_input()

    # メイン処理
    main(S)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 標準入力を取得
S = input()

# 求解処理
ACGT = ["A", "C", "G", "T"]


def is_acgt(s: str) -> bool:
    return s in ACGT


N = len(S)
ans = 0
for s in range(N):
    S_s = S[s]
    if not is_acgt(S_s):
        continue
    acgt_length = 1
    for e in range(s + 1, N):
        S_e = S[e]
        if not is_acgt(S_e):
            break
        acgt_length += 1
    ans = max(ans, acgt_length)

# 結果出力
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
T='ATCG'

flag =0
ans =0
now =0

for i in range(len(S)):
    flag =0
    for j in range(4):
        if S[i] == T[j]:
            flag +=1
    if flag !=1:
        now =0
    else:
        now +=1
        ans = max(now, ans)
        


print(ans)

Submission status: Accepted

Solution code:
S=input()
N=len(S)
left=0
right=0
ans=0
for left in range(N):
    while(right<N and (S[right] in ["A","C","G","T"])):
        right+=1
        ans=max(ans,right-left)
    if left==right:
        right+=1
print(ans)

Submission status: Accepted

Solution code:
n= input()
ans,temp = 0,0
for x in n:
    if x in 'ACGT':
        temp += 1
    else:
        temp = 0
    ans = max(ans,temp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
count=0
flg = False
max=0
for x in range(len(s)):
    if s[x] == 'A' or s[x] == 'T' or s[x] == 'C' or s[x] == 'G':
        count+=1
        if max <= count:
            max=count
    else:
        count=0
print(max)

Submission status: Accepted

Solution code:
def main():
    S = input()
    combs = set()
    max_len = 0
    for i in range(len(S)):
        for j in range(len(S), i - 1, -1):
            S_tmp = S[i:j]
            for s in S_tmp:
                if s not in ["A", "C", "G", "T"]:
                    break
            else:
                combs.add(S_tmp)

    for s in combs:
        max_len = max(max_len, len(s))

    print(max_len)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=input()
c=0
d=0
for i in S:
    if i=="A":
        c+=1
    elif i=="C":
        c+=1
    elif i=="G":
        c+=1
    elif i=="T":
        c+=1
    else:
        c=0
    if c>d:
        d=c
print(d)

Submission status: Accepted

Solution code:
s = input()
longest = 0

n_max = 0
for i, x in enumerate(s):
  if x in ["A", "C", "G", "T"]:
    n_max += 1
    longest = max(longest, n_max)
  else:
    n_max = 0
    
print(longest)

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

S = list(input())
for i in range(len(S)):
    if S[i] != "A" and S[i] != "C" and S[i] != "G" and S[i] != "T":
        S[i] = ' '
S2 = "".join(S)
L_ans = list(map(lambda x: len(x), S2.split()))
# print(L_ans)
if L_ans:
    print(max(L_ans))
else:
    print(0)

Submission status: Accepted

Solution code:
if __name__ =='__main__':
    s = input()
    ans = 0
    seq = 0
    for c in s:
        if c=='A' or c=='T' or c=='G' or c=='C':
            seq+=1
        else:
            ans = max(ans,seq)
            seq=0
    ans = max(ans,seq)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import re

print(sorted([len(s) for s in re.split('[^ATGC]',input())],reverse=True)[0])

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

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


print(count)

Submission status: Accepted

Solution code:
import re
sin = input()
match = re.findall(r'[ACTG]+',sin)
m_len = [len(m) for m in match]
print(max(m_len if m_len else '0'))

Submission status: Accepted

Solution code:
X = str(input())
Y = 'ACGT'
X += "*"
sm = 0
ans = 0
# dp表

for x in X:
    if x in ('A', 'C', 'G', 'T'):
        sm += 1
    else:
        ans = max(ans, sm)
        sm = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()

ans = 0
count = 0
for i in S:
    if i == 'A' or i == 'T' or i == 'C' or i == 'G':
        count += 1
    else:
        if ans < count:
            ans = count
        count = 0
if ans < count:
    ans = count
print(ans)

Submission status: Accepted

Solution code:
S = input()
ACGT = ['A', 'C', 'G', 'T']
res = 0
idx = 0
while idx < len(S):
    if S[idx] in ACGT:
        tmp = S[idx]
        while idx + 1 < len(S) and S[idx+1] in ACGT:
            tmp += S[idx+1]
            idx += 1
        if res < len(tmp):
            res = len(tmp)
    idx += 1
print(res)

Submission status: Accepted

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

for i, s_i in enumerate(s):
  if s_i in acgt:
    counter+=1
  else:
    ans = max(ans, counter)
    counter=0
    
  if i==len(s)-1:
    ans = max(ans, counter)
    counter=0
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
S=[s[i] for i in range(len(s))]
A={'A','C','G','T'}
B=[S[i] in A for i in range(len(S))]
max_length=0
for i in range(len(B)):
  if B[i]==1:
    count_length=1
    count=i
    while (count+1)<len(B) and B[count+1]==1:
      count_length=1+count_length
      count=1+count
      max_length=max(max_length,count_length)
    max_length=max(max_length,1)
      
print(max_length)

Submission status: Accepted

Solution code:
S = input()

max_length = 0
length = 0
for s in S:
    if s in ["A", "C", "G", "T"]:
        length += 1
    else:
        if length > max_length:
            max_length = length
        length = 0
if length > max_length:
        max_length = length
print(max_length)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input().strip()
smax = 0
c = 0
for i in s:
    if i == 'A' or i == 'T' or i == 'C' or i == 'G':
        c += 1
    else:
        if smax < c:
            smax = c
        c = 0
if smax < c:
    smax = c
print(smax)

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:
ss=['A','G','C','T']
s=list(input())
ans=0
for i in range(len(s)):
  if s[i] in ss:
    j=i
    cnt=0
    while j<len(s):
      if s[j] in ss:
        cnt+=1
        j+=1
      else:
        break
      
    ans=max(ans,cnt)
      
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
atgc = set(['A', 'T', 'G', 'C'])
maxcnt = 0
cnt = 0
for i in s:
  if i in atgc:
    cnt += 1
    if cnt > maxcnt:
      maxcnt = cnt
  else:
    cnt = 0
print(maxcnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    ansmax = 0
    anstmp = 0
    for i in S:
        if i == "A" or i == "T" or i == "G" or i == "C":
            anstmp = anstmp + 1 
            ansmax = max(ansmax,anstmp)
        else: 
            ansmax = max(ansmax,anstmp)
            anstmp = 0
    print(ansmax)
resolve()

Submission status: Accepted

Solution code:
import sys
from collections import deque
from itertools import *


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


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


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


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


s = S()

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

Submission status: Accepted

Solution code:
S = input()

dp = [0] * (len(S)+1)

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

for i in range(1,len(S)+1) :
   if S[i-1] in acgt:
       dp[i] = dp[i-1] + 1
   else:
       dp[i] = 0

print(max(dp))

Submission status: Accepted

Solution code:
S = input()
N = len(S)
res = 0
for i in range(N):
  if S[i] in "ACGT":
    cnt = 1
    for j in range(i+1, N):
      if S[j] in "ACGT":
        cnt += 1
      else:
        break
    res = max(res, cnt)

print(res)

Submission status: Accepted

Solution code:
s=input()
tar="ACGT"
res=0
ans=0
for ch in s:
    if ch in tar: ans+=1
    else:
        if ans>res: res=ans
        ans=0
if ans>res: res=ans
print(res)

Submission status: Accepted

Solution code:
s = input()
a = ['A','C','G','T']
c = 0
j = 0

for i in range(len(s)):
    if s[i] in a:
        j += 1
    else:
        if j > c:
            c = j
            j = 0

if j > c:
    print(j)
else:
    print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

ans=0
memory=0

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

ans=max(ans,memory)
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
from itertools import groupby
S = input()
S = re.sub("[ACGT]", "?", S)
ans = 0
cnt = 0
for s,l in groupby(S):
    if s=="?":
        ans = max(ans, len(list(l)))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

N = len(S)

ACGT = {"A", "C", "G", "T"}

ans = 0
for i in range(N):
    if S[i] in ACGT:
        cnt = 0
        for j in range(i, N):
            if S[j] in ACGT:
                cnt += 1
            else:
                break
        ans = max(ans, cnt)

print(ans)

Submission status: Accepted

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

for head in range(0, N):
  for tail in range(head, N):
    for index in range(head, tail+1):
      check = True
      if not (S[index] in ACGT):
        check = False
        break
    if check:
      ans = max(ans, tail-head+1)
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    cnt = 0
    maxC = 0
    for s in S:
        if s in "ACGT":
            cnt += 1
            maxC = max(maxC, cnt)
        else:
            cnt = 0
    print(maxC)


resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()

cnt = 0
li = []
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:
        li.append(cnt)
        cnt = 0

li.append(cnt)
print(max(li))

Submission status: Accepted

Solution code:
from itertools import combinations

s = input() 
res = [s[x:y] for x, y in combinations(range(len(s) + 1), r = 2)] 

ans = 0
t = "AGCT"

for s in res:
    if all(c in t for c in s):
        if len(s) > ans: ans = len(s);

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ACGT = ['A','C','G','T']
tmp = 0
X = []

for i in range(N):
    if S[i] in ACGT:
        tmp += 1
    else:
        X.append(tmp)
        tmp = 0

X.append(tmp)
print(max(X))

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = input()


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

Submission status: Accepted

Solution code:
S=input()
ACGT=["A","C","G","T"]
ans=0
count=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:
s=input()
x="ATCG"
mx=0
i=0
sm=0
while i < len(s):
    if s[i] in x:
        sm+=1
        if sm>mx:mx=sm
    else: sm=0
    i+=1
print(mx)

Submission status: Accepted

Solution code:
S = input()
T = "ACGT"
ans = 0

i = 0
while i < len(S):
    if S[i] in T:
        temp = 1
        for j in range(i+1, len(S)):
            if S[j] in T:
                temp += 1
            else:
                break
        ans = max(ans, temp)
        i += 1
    else:
        i += 1

print(ans)

Submission status: Accepted

Solution code:
s=input()
x="ATCG"
mx=0
i=0
sm=0
while i < len(s):
    if s[i] in x:
        sm+=1
        if sm>mx:mx=sm
    else: sm=0
    i+=1
print(mx)

Submission status: Accepted

Solution code:
s=input()
l = set()
check = set(['A','G','C','T'])
for i in range(len(s)):
  for j in range(i+1,len(s)+1):
    #print(s[i:j])
    if len(set(s[i:j]) | check) == 4:
      l.add(j-i)
if len(l) == 0:
  print(0)
else:
  print(max(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = raw_input()
a = set(list('ACGT'))
j = 0
i = 0
r = 0
while( j < len(s)):
	if s[j] not in a:
		j += 1
		i = j 
	else:
		while(j < len(s) and s[j] in a): j+=1
		r = max(r, j - i )
		i = j
print r

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
output = 0
ACGT = set(["A","G","C","T"])
tmp = 0
for i in s:
  if i not in ACGT:
    tmp = 0
  else:
    tmp += 1
  if tmp > output:
    output = tmp
  
print(output)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    s = input()
    ans = ''
    for i in range(len(s)+1):
        for j in range(i+1, len(s)+1):
            if s[i:j].replace('A', '').replace('C', '').replace('G', '').replace('T', '') == '':
                if len(ans) < len(s[i:j]):
                    ans = s[i:j]
    print(len(ans))


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
S = input()
S = "".join(list(S.replace("A","*").replace("C","*").replace("T","*").replace("G","*")))
count = 0
if S.count("*"*10) == 1:
  count = 10
elif S.count("*"*9) == 1:
  count = 9
elif S.count("*"*8) == 1:
  count = 8
elif S.count("*"*7) == 1:
  count = 7
elif S.count("*"*6) == 1:
  count = 6
elif S.count("*"*5) == 1:
  count = 5
elif S.count("*"*4) >= 1:
  count = 4
elif S.count("*"*3) >= 1:
  count = 3
elif S.count("*"*2) >= 1:
  count = 2
elif S.count("*"*1) >= 1:
  count = 1
else:
  count = 0
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=0
S=list(input())
c=len(S)
if S[-1]=="A" or S[-1]=="G" or S[-1]=="C" or S[-1]=="T":
  k=1
else:
  k=0
for i in range(c-1):
  for j in range(i+1,c+1):
    if j-i<=k:
      continue
    t=set(S[i:j])
    if "A" in t:
      s+=1
    if "C" in t:
      s+=1
    if "T" in t:
      s+=1
    if "G" in t:
      s+=1
    if s==len(t):
      k=j-i
    s=0
print(k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    max_len = 0
    length = 0

    s = list(s)
    s.append('')

    for i in s:
        if i in ['A', 'C', 'G', 'T']:
            length += 1
        else:
            if length > max_len:
                max_len = length
                length = 0

    print(max_len)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = len(s)
ans = 0
for i in range(N):
    for j in range(i, N):
        # if all(c in ['A', 'G', 'C', 'T'] for c in s[i : j + 1]):
        if all('ACGT'.count(c) for c in s[i : j + 1]):
            ans = max(ans, j - i + 1)
print(ans)

Submission status: Accepted

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

N = len(s)
ans = 0
for i in range(N):
    for j in range(i, N):
        if all(c in ['A', 'G', 'C', 'T'] for c in s[i : j + 1]):
            ans = max(ans, j - i + 1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# template by 3xC and starkizard.
# contributors: 

#####################################################################################
from __future__ import division, print_function 

import sys
import os
from collections import Counter, deque, defaultdict
import itertools
import math
import io


"""Uncomment modules according to your need"""


# from bisect import bisect_left, bisect_right, insort
# from heapq import heappop, heapify, heappush
# from random import randint as rn
# from Queue import Queue as Q
# from copy import deepcopy
# from decimal import *
# import re
# import operator

#####################################################################################
# this enables you to write python3 code with PyPy2 (Python 2)
if sys.version_info[0] < 3:
    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

#####################################################################################

"""value of mod"""
MOD = 998244353
mod = 10**9 + 7

"""Uncomment next 4 lines if doing huge recursion"""
# import threading
# threading.stack_size(1<<27)
# sys.setrecursionlimit(10000

def prepare_factorial(mod=mod):
    """ returns two lists, factorial and inverse factorial modulo argument by default 10**9 +7 """
    # Comment code out when you don't need inverse factorial or vice versa
    fact = [1]
    for i in range(1, 200005):
        fact.append((fact[-1] * i) % mod)

    ifact = [0] * 200005
    ifact[200004] = pow(fact[200004], mod - 2, mod)
    for i in range(200004, 0, -1):
        ifact[i - 1] = (i * ifact[i]) % mod

    return fact, ifact

def modinv(n, p):
    """ returns N inverse modulo p """
    return pow(n, p - 2, p)

def ncr(n, r,  fact, ifact):
    """ takes 4 arguments: n , r and factorial and inverse factorial lists"""
    t = (fact[n] * (ifact[r]*ifact[n-r]) % MOD)% MOD
    return t


def get_n(Sum):    
    """this function returns the maximum n for which Summation(n) <= Sum"""
    ans = (-1 + sqrt(1 + 8*Sum))//2
    return ans

def sieve(n):
    """ returns a list of prime numbers till n """
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r



def divs(n, start=1):
    """ returns a list of all divisors till n """
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors



def divn(n, primes):
    """ returns the number of divisors, two arguments n and the sieve till n """
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t



def lrfind(d, x, default=-1):
    """ Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found """
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return default, default
    else:
        return left, right

def gcd(x, y): # math.gcd is slower
    """ returns greatest common divisor of x and y """
    while y:
        x, y = y, x % y
    return x

def check_sorted(a):
    ''' returns True/False '''
    for i in range(len(a)-1):
        if a[i]>a[i+1]:
            return False
    return True
def ceil(n, k=1): return n // k + (n % k != 0) #returns math.ceil but protecting against floating inconsistencies
def input(): return sys.stdin.readline().strip()
def ii(): return int(input()) #inputs integer
def mi(): return map(int, input().split()) # inputting space seperated variables for example x,y,z
def li(): return list(map(int, input().split())) #inputting a space seperated list of integers
def lw(): return input().split() #inputting a space seperated list of strings
def lcm(a, b): return abs(a * b) // gcd(a, b) #returns LCM of two arguments
def prr(a, sep=' ', end='\n'): print(sep.join(map(str, a)), end=end) #For printing an iterable with seperator sep as optional second argument (default : " "), ending character (default: "\n") as optional third
def dd(): return defaultdict(int) #returns a dictionary with values defaulted to 0
def ddl(): return defaultdict(list) #returns a dictionary with values defaulted to []
def write(s): return sys.stdout.write(s)












###################################################################
def main():
    #CODE GOES HERE:
    s=input()
    answer=0
    temp=0
    for i in s:
        if i=="A" or i=="T" or i=="G" or i=="C":
            temp+=1
        else:
            answer=max(temp,answer)
            temp=0
    answer=max(temp,answer)
    print(answer)


















    
""" -------- Python 2 and 3 footer by Pajenegod and c1729 ---------"""

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192

class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill();
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):

    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode('ascii'))
            self.read = lambda: self.buffer.read().decode('ascii')
            self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

""" main function"""

if __name__ == '__main__':
    main()
    # threading.Thread(target=main).start()

Submission status: Accepted

Solution code:
s = input()

d = len(s)
ans = [0] * 10
tmp = 0
for i in range(d):
    if s[i] in "ACGT":
        ans[tmp] += 1
    else:
        tmp += 1
print(max(ans))

Submission status: Accepted

Solution code:
s = input()

d = len(s)
ans = [0] * 10
tmp = 0
for i in range(d):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        ans[tmp] += 1
    else:
        tmp += 1
print(max(ans))