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

Solution (Python):
import re
S = input()
S = re.split(r'[^ACGT]', S)
maxlen = max(len(s) for s in S)
print(maxlen)

Solution (Python):
s=list(input())
ATGC=['A','G','T','C']
counter=0
max_count=0

for i in s:
    if i in ATGC:
        counter+=1
    else:
        max_count=max(counter,max_count)
        counter=0
max_count=max(counter,max_count)
print(max_count)

Solution (Python):
s = input()
n = len(s)
ans = 0
def check(s):
    for i in s:
        if i not in 'AGCT':
            return False
    return True

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

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    s = SI()

    res = 0
    for l in range(len(s)):
        for r in range(l, len(s)):
            t = s[l:r + 1]
            if all([1 if c in 'ACGT' else 0 for c in t]):
                res = max(res, len(t))

    return res


print(main())

Solution (Python):
S=input()
res=0
B=0
for i in range(len(S)):
  if S[i]=="A" or S[i]=="T" or S[i]=="C" or S[i]=="G":
    res+=1
  else:
    res=0
  if B<res:
    B=res
print(B)

Solution (Python):
s = input()

ans = 0

for i in range(len(s)):
    cnt = 0
    for ch in s[i:]:
        if ch not in ("A", "T", "G", "C"):
            break
        cnt += 1
    ans = max(cnt, ans)

print(ans)

Solution (Python):
S=input()

L=len(S)
ANS=0
SET={"A","C","G","T"}
for i in range(L):
    for j in range(i,L+1):
        X=S[i:j]

        for x in X:
            if x in SET:
                continue
            else:
                break

        else:
            ANS=max(ANS,len(X))

print(ANS)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    S = SI()
    ans = 0
    tmp = 0
    for s in S:
        if s in 'ACGT':
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0
    ans = max(ans, tmp)

    return ans

print(main())

Solution (Python):
S = input()
ans = 0
for b in range(len(S)):
    now = 0
    while S[b + now] in ['A', 'T', 'C', 'G']:
        now += 1
        if b + now == len(S):break
    ans = max(ans, now)
print(ans)

Solution (Python):
word = input()
ans = 0

for i in range(len(word)):
  tmp = 0
  for j in range(len(word)-i):
    if word[j+i]=="A" or word[j+i]=="T" or word[j+i]=="C" or word[j+i]=="G":
      tmp += 1
    else: break
  if tmp>ans: ans = tmp

print(ans)

Solution (Python):


















import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right

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

S = input()

ans = 0
tmp = 0
for si in S:
    if si == "A" or si == "T" or si == "C" or si == "G":
        tmp += 1
    else:
        if tmp > ans:
            ans = tmp

        tmp = 0
    if tmp > ans:
        ans = tmp

print(ans)

Solution (Python):


s = input()

cur = 0
max = 0

for index,item in enumerate(s):
    if item == "A" or item == "T" or item == "G" or item == "C":
        cur += 1
        if cur >= max:
            max = cur
    else:
        cur = 0

print(max)

Solution (Python):
S = input()

count = 0
max_count = 0
for s in S:
    if s == "A" or s == "T" or s == "G" or s == "C":
        count += 1
    else:
        count = 0
    if max_count <= count:
        max_count = count

print(max_count)

Solution (Python):
s = str(input())
L = list("ACGT")
ans = 0
check = 0
for i in range(len(s)):
  if s[i] in L:
    check +=1
  else:
    ans = max(ans, check)
    check = 0
ans = max(ans, check)
print(ans)

Solution (Python):
S = input()

count = 0
num = 0
acgt = "ACGT"
for s in S:
  if s in acgt:
    num += 1
  else:
    num = 0
    
  if num > count:
    count = num
    
print(count)

Solution (Python):
S = input()
n = 0
maxn = 0
for s in S:
    if s == 'A' or s == 'G' or s == 'T' or s == 'C':
        n += 1
        maxn = max(maxn, n)
    else:
        n = 0
print(maxn)

Solution (Python):
S = list(input())

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

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

print(max(li))

Solution (Python):
def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int,ss_raw())

INF = 1<<29

def make1d_arr(n,val=INF):
    return [val for i in xrange(n)]

def make2d_arr(w,h,val =INF):
    return [[val for i in xrange(w)]for i in xrange(h)]

table = {"A":"T", "C":"G", "G":"C", "T":"A" }
S = raw_input()

ans = 0
for i in xrange(len(S)):
    for j in xrange(i,len(S)):
        if S[j] in table:
            ans = max(ans,j-i+1)
        else:
            break
print ans

Solution (Python):
A = list(input())
B = ['A', 'C', 'G', 'T']
ans = 0
k = [0]
for i  in A:
    if(i in B):
        ans += 1
        k.append(ans)
    else:
        ans = 0
    
print(max(k))

Solution (Python):

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

main()

Solution (Python):
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

s = input()
ans1 = 0
ans = 0
for a in s:
    if a == "A":
        
        ans+=1
    elif a == "T":
        
        ans += 1

    elif a == "C":
        ans += 1
    elif a == "G":
        ans+=1
    else:
        ans = 0
    if ans > ans1:
        ans1 = ans
print(ans1)

Solution (Python):
S = input()

t = ["A", "T", "C", "G"]
ans = 0
now = ""
for s in S:
    if s in t:
        now += s
    else:
        now = ""
    ans = max(ans, len(now))
print(ans)

Solution (Python):
n = list(input())

co = 0
su = 0

for i in range(len(n)):
    if n[i] == "A" or n[i] == "T" or n[i] == "C" or n[i] == "G":
        co += 1
    else:
        su = max(su,co)
        co = 0
su = max(su,co)
print(su)

Solution (Python):
A=input()
arr=["A","T","C","G"]
count=0
maxcount=0
for i in A:
    if i in arr:
        count+=1
    else:
        count=0
    maxcount=max(maxcount,count)
print(maxcount)

Solution (Python):
S = input()
max_len = 0
current_len = 0
for c in S:
    if c=='A' or c=='C' or c=='G' or c=='T':
        current_len += 1
    else:
        if current_len > max_len:
            max_len = current_len
        current_len = 0
if current_len > max_len:
    max_len = current_len
print(max_len)

Solution (Python):

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

Solution (Python):
from math import *





s=input()

c=0

for i in range(len(s)):
	for j in range(i,len(s)):
		d=s[i:j+1]
		if(len(d)==(d.count('A')+d.count('C')+d.count('G')+d.count('T'))):
			c=max(c,len(d))
print(c)

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

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

Solution (Python):
s = input()
n = len(s)
cnt = 0
ans = 0
for i in range(n):
  if s[i] in "ATCG":
    cnt += 1
  else:
    if cnt > ans:
      ans = cnt
    cnt = 0
print(max(cnt,ans))

Solution (Python):
import atexit
import io
import sys

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())

s = raw_input()
n = len(s)
ans = 0
l = ['A', 'C', 'T', 'G']
for i in xrange(n):
	for j in xrange(i,n):
		valid = 1
		for k in xrange(i,j+1):
			if s[k] not in l:
				valid = 0
				break
		if valid:
			ans = max(ans, j-i+1)	
print ans

Solution (Python):
s = input()


tar=['A','C','G','T']
fs = [c in tar for c in s]
res = 0
cnt=0
for f in fs:
    if f:
        cnt+=1
        res=max(res,cnt)
    else:
        cnt=0
print(res)

Solution (Python):
s = input()

maxlen = 0

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



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

print(maxs)

Solution (Python):
S = input()

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

print(max(ma,ans))

Solution (Python):

S = input()
N = len(S)

ans = 0
for i in range(N):
    if not S[i] in "ATCG":
        continue
    tmp = 0
    j = i
    while S[j] in "ATCG":
        j += 1
        tmp += 1
        if j >= N:
            break
    ans = max(ans, tmp)

print(ans)

Solution (Python):
a = input()
ans = 0
tmp = 0
for i in a:
  if i == "A" or i == "C" or i == "G" or i == "T":
    tmp += 1
  else:
    if ans < tmp:
      ans = tmp
      tmp = 0
if ans < tmp:
  ans = tmp
print(ans)

Solution (Python):
s = input()

ans = 0
temp = 0

for c in s:
    if c == "A" or c == "C" or c == "G" or c == "T":
        temp += 1
    else:
        if ans < temp:
            ans = temp
            temp = 0

if ans < temp:
    ans = temp

print(ans)

Solution (Python):
s = input()

cnt = 0
cnt_array = []
for i in s:
    if i == "A" or i == "G" or i == "C" or i == "T":
        cnt += 1
    else:
        cnt_array.append(cnt)
        cnt = 0
else:
    cnt_array.append(cnt)
    print(max(cnt_array))

Solution (Python):
def solve(S):
    ans = 0
    tans = 0
    for s in S:
        if s in "ACGT":
            tans += 1
            ans = max(ans, tans)
        else:
            tans = 0
    return ans

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

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

count = 0
max_count = 0
for i in s:
    if i in acgt:
        count += 1
    else:
        count = 0
    if max_count < count:
        max_count = count
print(max_count)

Solution (Python):

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

S=input()
count=0
max_count=0
for i in range(len(S)):
    if S[i] in atgc:
        count+=1
    else:
        count=0
    max_count=max(count,max_count)

print(max_count)

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

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

Solution (Python):
s=str(input())
n=len(s)
ans=0
i=0
while(i<n):
	if(s[i] in 'ACGT'):
		count=0
		while(i<n and s[i] in 'ACGT'):
			i+=1
			count+=1
		ans=max(ans,count)
	else:
		i+=1
print(ans)

Solution (Python):
S = input()

start = -1
answer = 0

for i, s in enumerate(S):
  if s in ['A','T','G','C']:
    answer = max(answer, i-start)
  else:
    start=i
print(answer)

Solution (Python):
S = input()
ans = 0
tmp = 0
for c in S:
  if c not in ['A', 'T', 'C', 'G']:
    ans = ans if ans > tmp else tmp
    tmp = 0
  else:
    tmp += 1
print(ans if ans > tmp else tmp)

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

Solution (Python):
S = input()
count = 0
ans = [0]

for s in S:
    if s in 'ACGT':
        count += 1
    else:
        ans.append(count)
        count = 0
ans.append(count)
print(max(ans))

Solution (Python):


import itertools
import collections
import bisect

def main():
    S = list(input())
    ans = 0
    current = 0
    for i in range(len(S)):
        if S[i] in ['A', 'C', 'G', 'T']:
            current += 1
            ans = max(ans, current)
        else:
            current = 0
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()
tmp = 0
num = 0
for i in range(len(S)):
    if S[i] in ['A', 'T', 'C', 'G']:
        tmp += 1
    else:
        num = max(num, tmp)
        tmp = 0

num = max(num, tmp)
print(num)

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

Solution (Python):
import collections as c
ip = lambda : map(int, input().split())


S = input()
r = 0
tmp = 0
for i in S:
    if i in ['A','G','C','T']:
        tmp += 1
        r = max(r,tmp)
    else:
        tmp = 0

print(r)

Solution (Python):
s = input()
ans=0
now=0
for a in s:
    if(a=='A' or a=='G' or a=='C' or a=='T'):
        now+=1
    else:
        now=0
    ans=max(ans,now)
print(ans)

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

Solution (Python):
s = input()
res = 0
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        t = s[i:j]
        c = 0
        for sss in 'ATGC':
            c += t.count(sss)
        if c == len(t):
            res = max(res, c)
print(res)

Solution (Python):
S = input()
seq = 0
ans = 0
for c in S:
    if c in 'ACGT':
        seq += 1
        ans = max(ans, seq)
    else:
        seq = 0
print(ans)

Solution (Python):
from collections import deque, defaultdict as ddic
from itertools import combinations, permutations, product
from heapq import heappush, heappop, heapify
import sys
stdout = sys.stdout
rr = lambda: input().strip()
rri = lambda: int(rr())
rrm = lambda: list(map(int, rr().split()))

from itertools import groupby
def solve(S):
    def f(c):
        return c in 'ACGT'
    ans = 0
    for k, grp in groupby(S, f):
        w = len(list(grp))
        if k:
            ans = max(ans, w)
    return ans

T = 1 
for tc in range(1, T+1):
    S = rr()
    ans = solve(S)
    print(ans)

Solution (Python):
S = input()

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