Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
K,S = map(int, input().split())

ans = 0
for i in range(K+1):
    if 0<= S-i <= K:
        ans += (S-i)+1
    elif S-i <= 2K:
        a = (S-i) -K
        ans += (K-a)+1
print(ans)


Fixed submission:
K,S = map(int, input().split())

ans = 0
for i in range(K+1):
    for j in range(K+1):
        z = S-(i+j)
        if 0<= z and z <= K:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int, input().split())

def binaly_serch(ls,k):#lsはリスト、kが求めたいもの
    ls.sort()
    n = len(ls)
    s = 0
    e = n#あえてls から一つ出たのにしておく。このおかげでk = ls[n-1]の時でも探索できる
    while int(e - s) >= 1:#intでcastして繰り下がった方を見て、e = bという条件にしてるからこれで全部探せる
        b = int((s+e)/2)
        if ls[b] == k:
            return True
        elif ls[b] < k:
            s = b + 1
        else:
            e = b
    return False
ans = 0
kls = [i for i in range(K+1)]
for i in range(K+1):
    for j in range(K+1):
        if S-(i+j) > K:
            continue
        else:
            if binaly_serch(kls,S-(i+j)):
                ans += 1

print(ans)


Fixed submission:
K,S = map(int, input().split())

ans = 0
for i in range(K+1):
    for j in range(K+1):
        z = S-(i+j)
        if 0<= z and z <= K:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int, input().split())

def binaly_serch(ls,k):#lsはリスト、kが求めたいもの
    ls.sort()
    n = len(ls)
    s = 0
    e = n#あえてls から一つ出たのにしておく。このおかげでk = ls[n-1]の時でも探索できる
    while int(e - s) >= 1:#intでcastして繰り下がった方を見て、e = bという条件にしてるからこれで全部探せる
        b = int((s+e)/2)
        if ls[b] == k:
            return True
        elif ls[b] < k:
            s = b + 1
        else:
            e = b
    return False
ans = 0
kls = [i for i in range(K+1)]
for i in range(K+1):
    for j in range(K+1):
        if binaly_serch(kls,S-(i+j)):
            ans += 1

print(ans)



Fixed submission:
K,S = map(int, input().split())

ans = 0
for i in range(K+1):
    for j in range(K+1):
        z = S-(i+j)
        if 0<= z and z <= K:
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())

sa = {0: 0}
for i, val in enumerate(A):
  sa[i+1] = sa[i] + val

sb = {0: 0}
for i, val in enumerate(B):
  sb[i+1] = sb[i] + val

max_num = 0

for i in range(N+1):
  if(sa[i]>K):
    break
  for j in range(M+1):
    if(sb[M-j]<=K-sa[i]):
      break
  max_num = max(max_num,i+M-j)

      
      
print(max_num)

Fixed submission:
N,M,K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())

sa = [0]
for i, val in enumerate(A):
  sa.append(sa[i] + val)

sb = [0]
for i, val in enumerate(B):
  sb.append(sb[i] + val)

max_num = 0
ind_max = M
for i in range(N+1):
  if(sa[i]>K):
    break
  c = 0
  for k in range(ind_max+1):
    if(sb[ind_max-k]<=K-sa[i]):
      break
    c += 1
  ind_max -= c
  max_num = max(max_num,i+ind_max)

      
      
print(max_num)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(i) for i in input().split(' ')]
A = [int(i) for i in input().split(' ')]
 
where_li = []
pre = 0
for i in range(N):
	where_li.append(A[pre])
	pre = A[pre]-1

aa = sorted([x for x in set(where_li) if where_li.count(x) > 1], key=where_li.index)
if(len(aa)==0):
	indexes = [0,0]
else:
	indexes = [i for i, x in enumerate(where_li) if x == aa[0]]
where_li = where_li[:indexes[1]]
len_w = len(where_li)
mod_s = len_w-indexes[0]
if K<=len_w:
	print(where_li[K-1])
else:
	if (K-len_w)%mod_s==0:
		d = mod_s
	else:
		d = (K-len_w)%mod_s
	print(where_li[d-1+indexes[0]])

Fixed submission:
N,K = [int(i) for i in input().split(' ')]
A = [int(i) for i in input().split(' ')]
 
where_li = []
pre = 0
for i in range(N):
	where_li.append(A[pre])
	pre = A[pre]-1

len_w = len(where_li)
a = where_li.index(A[pre])
mod_s = len_w-a
if K<=len_w:
	print(where_li[K-1])
else:
	if (K-len_w)%mod_s==0:
		d = mod_s
	else:
		d = (K-len_w)%mod_s
	print(where_li[d-1+a])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(i) for i in input().split(' ')]
A = [int(i) for i in input().split(' ')]
 
where_li = []
pre = 0
for i in range(N):
	if A[pre] in where_li:
		break
	where_li.append(A[pre])
	pre = A[pre]-1

len_w = len(where_li)
mod_s = len_w-where_li.index(A[pre])
if K<=len_w:
	print(where_li[K-1])
else:
	if (K-len_w)%mod_s==0:
		d = mod_s
	else:
		d = (K-len_w)%mod_s
	print(where_li[d-1+where_li.index(A[pre])])

Fixed submission:
N,K = [int(i) for i in input().split(' ')]
A = [int(i) for i in input().split(' ')]
 
where_li = []
pre = 0
for i in range(N):
	where_li.append(A[pre])
	pre = A[pre]-1

len_w = len(where_li)
a = where_li.index(A[pre])
mod_s = len_w-a
if K<=len_w:
	print(where_li[K-1])
else:
	if (K-len_w)%mod_s==0:
		d = mod_s
	else:
		d = (K-len_w)%mod_s
	print(where_li[d-1+a])
Buggy python submission (verdict: Time Limit Exceeded):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
X = int(input())
A = []
for i in factorization(X):
  for j in range(0,i[1]+1):
    a = i[0]**j
    b = X//a
    if(a<b):
      A.append([a,b])
    else:
      A.append([b,a])
 
A = list(map(list, set(map(tuple, A))))
flag = 0
for i in A:
  r = list(range(0,1000000+1))
  for a in r:
    b = a - i[0]
    if a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4 == i[1]:
      print(a,b)
      flag = 1
      break
  if flag==1:
    break

Fixed submission:

X = int(input())
flag = 0
for i in range(-150,150):
  for j in range(-150,150):
    if(i**5 - j**5 == X):
      print(i,j)
      flag = 1
      break
  if(flag==1):
    break

Buggy python submission (verdict: Time Limit Exceeded):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
X = int(input())
A = []
for i in factorization(X):
  for j in range(1,i[1]+1):
    a = i[0]**j
    b = X//a
    if(a<b):
      A.append([a,b])
    else:
      A.append([b,a])
 
A = list(map(list, set(map(tuple, A))))
flag = 0
for i in A:
  r = list(range(0,1000000+1))
  for a in r:
    b = a - i[0]
    if a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4 == i[1]:
      print(a,b)
      flag = 1
      break
  if flag==1:
    break
  r = list(range(0,1000000+1))
  for a in r:
    b = a - i[1]
    if a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4 == i[0]:
      print(a,b)
      flag = 1
      break
  if flag==1:
    break

Fixed submission:

X = int(input())
flag = 0
for i in range(-150,150):
  for j in range(-150,150):
    if(i**5 - j**5 == X):
      print(i,j)
      flag = 1
      break
  if(flag==1):
    break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
	S.append(input())
	S = list(set(S))
print(len(S))

Fixed submission:
N = int(input())
S = []
c = 0
for i in range(N):
	S.append(input())

S = list(set(S))
print(len(S))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
c = 0
for i in range(N):
	S.append(input())
    S = list(set(S))
print(len(S))

Fixed submission:
N = int(input())
S = []
c = 0
for i in range(N):
	S.append(input())

S = list(set(S))
print(len(S))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
c = 0
for i in range(N):
	j = input()
	if not j in S:
		S.append(j)
		c += 1
print(c)




Fixed submission:
N = int(input())
S = []
c = 0
for i in range(N):
	S.append(input())

S = list(set(S))
print(len(S))
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      c += math.gcd(math.gcd(i,j),k)
print(c)
      


Fixed submission:
import math
K = int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      c += math.gcd(math.gcd(i,j),k)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
a = list(map(int, input().split()))

s = 1
for i in range(k):
    s *= a[i]
last = s
for i in range(k, n):
    s = s * a[i] // a[i-k]
    if last >= s:
        print('No')
    else:
        print('Yes')
    last = s

Fixed submission:
n, k = map(int,input().split())
a = list(map(int, input().split()))

for i in range(k, n):
    if a[i] <= a[i-k]:
        print('No')
    else:
        print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
a = list(map(int, input().split()))

s = 1
for i in range(k):
    s *= a[i]
last = s
for i in range(k, n):
    s = s * a[i] // a[i-k]
    if last >= s:
        print('No')
    else:
        print('Yes')
    last = s

Fixed submission:
n, k = map(int,input().split())
a = list(map(int, input().split()))

for i in range(k, n):
    if a[i] <= a[i-k]:
        print('No')
    else:
        print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
a = list(map(int, input().split()))

s = 1
d = 1
last = 0
for i in range(n):
    s *= a[i]
    if i - k >= 0:
        d*=a[i-k]
    num = s // d

    #print(f'{num} {last}')
    if i-1 >= k-1:
        if last >= num:
            print('No')
        else:
            print('Yes')
    last = num

Fixed submission:
n, k = map(int,input().split())
a = list(map(int, input().split()))

for i in range(k, n):
    if a[i] <= a[i-k]:
        print('No')
    else:
        print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
a = list(map(int, input().split()))

s = 1
d = 1
last = 0
for i in range(n):
    s *= a[i]
    if i - k >= 0:
        d*=a[i-k]
    num = s // d

    #print(f'{num} {last}')
    if i-1 >= k-1:
        if last >= num:
            print('No')
        else:
            print('Yes')
    last = num

Fixed submission:
n, k = map(int,input().split())
a = list(map(int, input().split()))

for i in range(k, n):
    if a[i] <= a[i-k]:
        print('No')
    else:
        print('Yes')
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

# k分で読める本の累積
a_ruiseki = [0]*(k+10)
b_ruiseki = [0]*(k+10)
a_cnt = 1
b_cnt = 1
a_sum = a[0]
b_sum = b[0]
for i in range(k+1):
    if a_sum == i and a_cnt < len(a)+1:
        a_cnt += 1
        tmp = min(a_cnt-1, len(a)-1)
        a_sum+=a[tmp]
    if b_sum == i and b_cnt < len(b)+1:
        b_cnt += 1
        tmp = min(a_cnt-1, len(a)-1)
        b_sum+=b[tmp]
    a_ruiseki[i] = a_cnt-1
    b_ruiseki[i] = b_cnt-1

#    print(f'{i} {a_cnt-1}')
#
#print(a_ruiseki)
#print(b_ruiseki)

ans = 0
for i in range(k+1):
    ans = max(ans, a_ruiseki[i]+b_ruiseki[k-i])
print(ans)

Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]
for i in range(0, n):
    a.append(A[i] + a[i])
for i in range(0, m):
    b.append(B[i] + b[i])

ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k-a[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

# k分で読める本の累積
a_ruiseki = [0]*(k+10)
b_ruiseki = [0]*(k+10)
a_cnt = 1
b_cnt = 1
a_sum = a[0]
b_sum = b[0]
for i in range(k+1):
    if a_sum == i and a_cnt < len(a)+1:
        a_cnt += 1
        tmp = min(a_cnt-1, len(a)-1)
        a_sum+=a[tmp]
    if b_sum == i and b_cnt < len(b)+1:
        b_cnt += 1
        tmp = min(a_cnt-1, len(a)-1)
        b_sum+=b[tmp]
    a_ruiseki[i] = a_cnt-1
    b_ruiseki[i] = b_cnt-1

#    print(f'{i} {a_cnt-1}')
#
#print(a_ruiseki)
#print(b_ruiseki)

ans = 0
for i in range(k+1):
    ans = max(ans, a_ruiseki[i]+b_ruiseki[k-i])
print(ans)

Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]
for i in range(0, n):
    a.append(A[i] + a[i])
for i in range(0, m):
    b.append(B[i] + b[i])

ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k-a[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
t = input()
ques_num = t.count('?')
t = list(t)

# PDの2通りを計算する
ans = ""
score = 0
for bit in range(2**ques_num):
    tmp_t = list(t)
    tmp_ques_num = 0
    for i in range(len(t)):
        if tmp_t[i] != '?':
            continue
        if bit >> tmp_ques_num & 1:
            tmp_t[i] = 'P'
        else:
            tmp_t[i] = 'D'
        tmp_ques_num += 1
    if score < "".join(tmp_t).count('D') + "".join(tmp_t).count('PD'):
        score = "".join(tmp_t).count('D') + "".join(tmp_t).count('PD')
        ans = "".join(tmp_t)

print(ans)

Fixed submission:
t = list(input())

for i in range(len(t)):
    if t[i] == '?':
        t[i] = 'D'
print("".join(t))

Buggy python submission (verdict: Time Limit Exceeded):
t = input()
ques_num = t.count('?')
t = list(t)

# PDの2通りを計算する
ans = ""
score = 0
for bit in range(2**ques_num):
    tmp_t = list(t)
    tmp_ques_num = 0
    for i in range(len(t)):
        if tmp_t[i] != '?':
            continue
        if bit >> tmp_ques_num & 1:
            tmp_t[i] = 'P'
        else:
            tmp_t[i] = 'D'
        tmp_ques_num += 1
    if score < "".join(tmp_t).count('D') + "".join(tmp_t).count('PD'):
        score = "".join(tmp_t).count('D') + "".join(tmp_t).count('PD')
        ans = "".join(tmp_t)

print(ans)

Fixed submission:
t = list(input())

for i in range(len(t)):
    if t[i] == '?':
        t[i] = 'D'
print("".join(t))
Buggy python submission (verdict: Runtime Error):
n,x = map(int, input().split())
l = int(input())

d = 0
cnt = 0
for i in range(0, n):
  if i == 0:
    d = 0
  else:
    d = d + l
  if d <= x:
    cnt += 1
  if i != 0:
    l = int(input())

print (cnt)

Fixed submission:
n,x = map(int, input().split())
l = [int(i) for i in input().split()]

d = 0
cnt = 0
for i in range(0, n + 1):
  if i == 0:
    d = 0
  else:
    d = d + l[i-1]
  if d <= x:
    cnt += 1

print (cnt)
Buggy python submission (verdict: Runtime Error):
aa = list(map(int, input().split()))

bb = sorted(aa)

print(bb[0]+bb[1])

Fixed submission:
aa =  [int(i) for i in input().split()]

bb = sorted(aa)

print(bb[0]+bb[1])
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())

if a <= 5:
  print(0)
elif 6 <= a and a <= 12:
  print(b/2)
elif 13 <= a:
  print(b)

Fixed submission:
a,b = map(int, input().split())

if a <= 5:
  print(0)
elif 6 <= a and a <= 12:
  print(int(b/2))
elif 13 <= a:
  print(b)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w = map(int, input().split())

m = [list(input()) for _ in range(h)]

def get_start_points(m):
    start_points = []
    for y in range(h):
        for x in range(w):
            if m[y][x] == '#':
                start_points.append((y,x))
    return start_points

def bfs(start_points):
    que = deque(start_points)
    step = 0
    count_flag = False
    while len(que):
        for q in range(len(que)):
            y,x = que.popleft()
            for dy,dx in [(1,0),(-1,0),(0,1),(0,-1)]:
                ny = y + dy
                nx = x + dx
                if not (0<=ny<h and 0<=nx<w) or m[ny][nx] != '.':
                    continue
                m[ny][nx] = '#'
                count_flag = True
                que.append((ny,nx))

        if count_flag:
            step += 1
            count_flag = False
        else:
            break
    return step

print(bfs(get_start_points(m)))

Fixed submission:
from collections import deque
h,w = map(int, input().split())

m = [list(input()) for _ in range(h)]

def get_start_points(m):
    start_points = []
    for y in range(h):
        for x in range(w):
            if m[y][x] == '#':
                start_points.append((y,x))
    return start_points

def bfs(start_points):
    que = deque(start_points)
    step = 0
    count_flag = False
    while len(que):
        for q in range(len(que)):
            y,x = que.popleft()
            for dy,dx in [(1,0),(-1,0),(0,1),(0,-1)]:
                ny = y + dy
                nx = x + dx
                if not (0<=ny<h and 0<=nx<w) or m[ny][nx] != '.':
                    continue
                m[ny][nx] = '#'
                count_flag = True
                que.append((ny,nx))

        if count_flag:
            step += 1
            count_flag = False
        else:
            break
    return step

print(bfs(get_start_points(m)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = map(int, input().split())
c = map(int, input().split())

ans = 0
for i in range(n):
  if v[i] - c[i] > 0:
    ans += v[i] - c[i]

print(ans)

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
  if v[i] - c[i] > 0:
    ans += v[i] - c[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(long, input().split()))

ans = 0
for i in a:
   ans += abs(i)

print (ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans = 0
minus_cnt = 0
min_num = 10000000000000
for i in a:
  if i < 0:
    minus_cnt += 1
  if abs(i) < min_num:
    min_num = abs(i)

case = minus_cnt % 2

for i in a:
   ans += abs(i)

if case == 1:
  ans -= 2 * min_num

print (ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = list(input())

# 部分文字列の和を算出
array = []
now_num = 1
count = 0
for i in s:
  if now_num == int(i):
    count += 1
  else:
    array.append(count)
    count = 1
    now_num = 1 - now_num

if count != 0:
  array.append(count)

if len(array) % 2 == 0:
  array.append(0)

res = 0
add = 2 * k + 1
ans = 0
left = 0
right = 0
tmp = 0

for i in range(len(array))[::2]:
    next_left = i
    next_right = min(i+add, len(array))
    # 尺取法
    while next_left > left:
        tmp -= array[left]
        left += 1
    while next_right > right:
        tmp += array[right]
        right += 1
    ans = max(tmp,ans)

print(ans)

Fixed submission:
a, b = map(int, input().split())

ans =0
if a>=b:
  ans += a
  a = a-1
else:
  ans +=b
  b =b-1
  
if a>=b:
  ans += a
  a = a-1
else:
  ans +=b
  b =b-1
  
print(ans)
Buggy python submission (verdict: Runtime Error):
aa

Fixed submission:
n, k = map(int, input().split())
s = list(input())

# 部分文字列の和を算出
array = []
now_num = 1
count = 0
for i in s:
  if now_num == int(i):
    count += 1
  else:
    array.append(count)
    count = 1
    now_num = 1 - now_num

if count != 0:
  array.append(count)

if len(array) % 2 == 0:
  array.append(0)

res = 0
add = 2 * k + 1
ans = 0
left = 0
right = 0
tmp = 0

for i in range(len(array))[::2]:
    next_left = i
    next_right = min(i+add, len(array))
    # 尺取法
    while next_left > left:
        tmp -= array[left]
        left += 1
    while next_right > right:
        tmp += array[right]
        right += 1
    ans = max(tmp,ans)

print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

s = list(str(input()))

first_index=0
last_index=0

res = 0
for f in range (first_index, n+1):
  for l in range (last_index, n+1):
    if f < l:
      continue
    check = 0
    for i in range(f, l+1):
      if s[i] == 0:
        check += 1
    if check <= k:
      if l-f > res:
        res = l-f

print(res)

Fixed submission:
n, k = map(int, input().split())
s = list(input())

# 部分文字列の和を算出
array = []
now_num = 1
count = 0
for i in s:
  if now_num == int(i):
    count += 1
  else:
    array.append(count)
    count = 1
    now_num = 1 - now_num

if count != 0:
  array.append(count)

if len(array) % 2 == 0:
  array.append(0)

res = 0
add = 2 * k + 1
ans = 0
left = 0
right = 0
tmp = 0

for i in range(len(array))[::2]:
    next_left = i
    next_right = min(i+add, len(array))
    # 尺取法
    while next_left > left:
        tmp -= array[left]
        left += 1
    while next_right > right:
        tmp += array[right]
        right += 1
    ans = max(tmp,ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input().split)
if s.count(s[0]) ==3:
  print('Yes')
else:
  print('No')

Fixed submission:
s = list(input().split())
if s.count(s[0]) == 3:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
s = list(input())

res = 0
max = 0
for i in s:
  if i == 'A' or i == 'T' or i == 'C' or i == 'G':
    res += 1
  elif max <res:
    max = res
    res = 0
  else:
    res = 0

if max < res:
  max = res
-
print(max)

Fixed submission:
s = list(input())

res = 0
max = 0
for i in s:
  if i == 'A' or i == 'T' or i == 'C' or i == 'G':
    res += 1
  elif max <res:
    max = res
    res = 0
  else:
    res = 0

if max < res:
  max = res

print(max)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = list(map(int , input().split()))
s = input()

for cnt in range(q):
  l, r = list(map(int , input().split()))
  print(s[l-1:r].count('AC'))

Fixed submission:
# 累積和の考え方
#   listに積み重ねた数値を出しておくことで特定範囲の数値を求める時間を短縮する
#   例：ABBBBAABBBBAB があるときに(l,r)にAがいくつ含まれるかを求める場合は以下のように(1長い)listを作る
#      BBABBBAABBBBAA
#      000111123333345
#   このリストの文字列のr-lで出せる(3,7)ならstr[7]-str[3]を出すと3-1で2となる

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

# 累積和のリストを作成
cumsum = [0]*(n+1)
for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        cumsum[i+1]+=cumsum[i]+1
    else:
        cumsum[i+1]=cumsum[i]

# 012345   index
# 123456   input
# ACACAC   s
# 0011223  cumsum
for left, right in lr:
    print(cumsum[right]-cumsum[left])

Buggy python submission (verdict: Runtime Error):
n, q = list(map(int , input()))
s = input()

for cnt in range(q):
  l, r = list(map(int , input()))
  print(s[l-1:r].count('AC'))

Fixed submission:
# 累積和の考え方
#   listに積み重ねた数値を出しておくことで特定範囲の数値を求める時間を短縮する
#   例：ABBBBAABBBBAB があるときに(l,r)にAがいくつ含まれるかを求める場合は以下のように(1長い)listを作る
#      BBABBBAABBBBAA
#      000111123333345
#   このリストの文字列のr-lで出せる(3,7)ならstr[7]-str[3]を出すと3-1で2となる

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

# 累積和のリストを作成
cumsum = [0]*(n+1)
for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        cumsum[i+1]+=cumsum[i]+1
    else:
        cumsum[i+1]=cumsum[i]

# 012345   index
# 123456   input
# ACACAC   s
# 0011223  cumsum
for left, right in lr:
    print(cumsum[right]-cumsum[left])