Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline 
sys.setrecursionlimit(10 ** 6) 
N,Q = map(int, input().split())

tree = [[] for _ in range(N)]

for i in range(N - 1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  if a == b:
    continue
  tree[a].append(b)
  tree[b].append(a)

ans = [0] * N

for i in range(Q):
  p,x = map(int, input().split())
  ans[p - 1] += x
  
def dfs(cur, par):
  for chl in tree[cur]:
    ans[chl] += ans[cur]
    dfs(chl,cur)

dfs(0, -1)

print(*ans)



Fixed submission:
import sys
input = sys.stdin.readline 
sys.setrecursionlimit(10 ** 6) 
N,Q = map(int, input().split())

tree = [[] for _ in range(N)]

for i in range(N - 1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree[a].append(b)
  tree[b].append(a)

ans = [0] * N

for i in range(Q):
  p,x = map(int, input().split())
  ans[p - 1] += x
  
def dfs(cur, par):
  for chl in tree[cur]:
    if chl == par:
      continue
    ans[chl] += ans[cur]
    dfs(chl,cur)

dfs(0, -1)

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline 
sys.setrecursionlimit(10 ** 6) 
N,Q = map(int, input().split())

tree = [[] for _ in range(N)]

for i in range(N - 1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  if a > b:
    a,b = b,a
  elif a == b:
    continue
  tree[a].append(b)
  tree[b].append(a)

ans = [0] * N

for i in range(Q):
  p,x = map(int, input().split())
  ans[p - 1] += x
  
def dfs(cur, par):
  for chl in tree[cur]:
    ans[chl] += ans[cur]
    dfs(chl,cur)

dfs(0, -1)

print(*ans)



Fixed submission:
import sys
input = sys.stdin.readline 
sys.setrecursionlimit(10 ** 6) 
N,Q = map(int, input().split())

tree = [[] for _ in range(N)]

for i in range(N - 1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree[a].append(b)
  tree[b].append(a)

ans = [0] * N

for i in range(Q):
  p,x = map(int, input().split())
  ans[p - 1] += x
  
def dfs(cur, par):
  for chl in tree[cur]:
    if chl == par:
      continue
    ans[chl] += ans[cur]
    dfs(chl,cur)

dfs(0, -1)

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
H = int(input())
S = []
for _ in range(H):
	S.append(input()) 

L = []

for i in range(0,len(S)):
	L.append(sorted(S[i]))

for i in range(0,len(L)):
	L[i] = ",".join(L[i])

counter = 0
  
for i in range(0,len(L)):
	for j in range(i+1,len(L)):
		if L[i] == L[j]:
			counter += 1

print(counter)

Fixed submission:
H = int(input())
S = []
for _ in range(H):
	S.append(input()) 

L = []

for i in range(0,len(S)):
	L.append(sorted(S[i]))

for i in range(0,len(L)):
	L[i] = ",".join(L[i])

dicL = dict()
answer = 0

for l in L:
	if l in dicL:
		dicL[l] += 1
		answer += dicL[l]
	else:
		dicL[l] = 0
		
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):


H = int(input())
S = []
for _ in range(H):
	S.append(input()) 

L = []

for i in range(0,len(S)):
	L.append(sorted(S[i]))

counter = 0
  
for i in range(0,len(L)):
	for j in range(i+1,len(L)):
		if L[i] == L[j]:
			counter += 1

print(counter)

Fixed submission:
H = int(input())
S = []
for _ in range(H):
	S.append(input()) 

L = []

for i in range(0,len(S)):
	L.append(sorted(S[i]))

for i in range(0,len(L)):
	L[i] = ",".join(L[i])

dicL = dict()
answer = 0

for l in L:
	if l in dicL:
		dicL[l] += 1
		answer += dicL[l]
	else:
		dicL[l] = 0
		
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int,input().split()))

for i in range(N - 1):
  head = H[i]
  remains = min(H[i + 1:])
  if head - remains >= 2:
    print("No")
    break
else:
  print("Yes")

Fixed submission:
N = int(input())
H = list(map(int,input().split()))

head = 0

for i in range(N):
  if H[i] >= head:
    head = H[i]
  if head - H[i] >= 2:
    print("No")
    break
else:print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int,input().split()))

for i in range(N - 1):
  head = H[i]
  remains = H[i + 1:]
  if head - min(remains) >= 2:
    print("No")
    break
else:
  print("Yes")

Fixed submission:
N = int(input())
H = list(map(int,input().split()))

head = 0

for i in range(N):
  if H[i] >= head:
    head = H[i]
  if head - H[i] >= 2:
    print("No")
    break
else:print("Yes")
Buggy python submission (verdict: Runtime Error):
A,B = int(input())

K = (A + B) 

if K % 2 == 0:
	print(int(K / 2))
else:print("IMPOSSIBLE")

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

K = (L[0] + L[1]) 

if K % 2 == 0:
	print(int(K / 2))
else:print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = []
for l in range(N):
	L.append(int(input()))

maxL = max(L)
num = ["n"] * N

if L.count(maxL) >= 2:
	for i in range(N):
		print(maxL)
		
else:
	L = L.remove(maxL)
	secL = max(L)
	
	for i in range(N):
		if i in num:
			print(secL)
		else:
			print(maxL)


Fixed submission:
N = int(input())
L = []
for l in range(N):
	L.append(int(input()))

maxL = max(L)
subL = L
num = ["n"] * N

if L.count(maxL) >= 2:
	for i in range(N):
		print(maxL)
		
else:	
	for i in range(N):
		if L[i] == maxL:
			L[i] = 0
			print(max(L))
		else:
			print(maxL)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = []
for l in range(N):
	L.append(int(input()))

maxL = max(L)
subL = L
num = ["n"] * N

if L.count(maxL) >= 2:
	for i in range(N):
		print(maxL)
		
else:
	for i in range(N):
		if L[i] == maxL:
			num[i] = i
			L[i] = 0
	
	if max(L) != 0:
		secL = max(L)
	else:
		secL = max(subL)
	
	for i in range(N):
		if i in num:
			print(secL)
		else:
			print(maxL)



Fixed submission:
N = int(input())
L = []
for l in range(N):
	L.append(int(input()))

maxL = max(L)
subL = L
num = ["n"] * N

if L.count(maxL) >= 2:
	for i in range(N):
		print(maxL)
		
else:	
	for i in range(N):
		if L[i] == maxL:
			L[i] = 0
			print(max(L))
		else:
			print(maxL)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = []
for l in range(N):
	L.append(int(input()))
	
maxL = [0] * N
	
for i in range(N):
	a = L[i]
	L[i] = 0
	maxL[i] = max(L)
	L[i] = a
	
for i in maxL:
	print(i)

Fixed submission:
N = int(input())
L = []
for l in range(N):
	L.append(int(input()))

maxL = max(L)
subL = L
num = ["n"] * N

if L.count(maxL) >= 2:
	for i in range(N):
		print(maxL)
		
else:	
	for i in range(N):
		if L[i] == maxL:
			L[i] = 0
			print(max(L))
		else:
			print(maxL)
Buggy python submission (verdict: Runtime Error):
L,R = map(int,input().split())

ans = 2019 ** 2

if R - L >= 2018:
  ans = 0
  print(ans)
else: 
  for i in range(L,R):
    for j in range(L + 1,R + 1):
      mod = (i * j) % 2019 
      if mod < ans:
        ans = mod
      elif mod == 0:
        ans = 0
        break
  print(ans)



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

N = L[0]
A = L[1]
B = L[2]


train = N * A

if train < B:
	print(train)
	
else:print(B)

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

#区間の両端を除いた数=2017より長ければ2019の倍数が含まれているので0が解

ans = 2019 ** 2

for i in range(L,R):
  for j in range(L + 1,R):
    mod = (i * j) % 2019 
    if mod < ans:
      ans = mod
    elif mod == 0:
      ans = 0
      break
print(ans)



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

N = L[0]
A = L[1]
B = L[2]


train = N * A

if train < B:
	print(train)
	
else:print(B)
Buggy python submission (verdict: Runtime Error):
L,R = map(int,input().split())

#区間の両端を除いた数=2017より長ければ2019の倍数が含まれているので0が解
if R - L >= 2018:
  print(0)
else:
  ans = 2018 ** 2
  for i in range(L,R):
    for j in range(L + 1,R):
      mod = (i * j) % 2019 
      if mod < ans:
        ans = mod
      elif mod == 0:
        ans = 0
        break
print(ans)



Fixed submission:
L,R = map(int,input().split())

ans = 2019 ** 2

if R - L >= 2018:
  ans = 0
  print(ans)
else: 
  for i in range(L,R):
    for j in range(L + 1,R + 1):
      mod = (i * j) % 2019 
      if mod < ans:
        ans = mod
      elif mod == 0:
        ans = 0
        break
  print(ans)

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

ans = 2020

for i in range(L,R + 1):
  l = i % 2019
  r = (i + 1) % 2019
  if l * r < ans:
    ans = l * r
  if r = 0:
    ans = 0
    break
    
print(ans)

Fixed submission:
L,R = map(int,input().split())

ans = 2019 ** 2

if R - L >= 2018:
  ans = 0
  print(ans)
else: 
  for i in range(L,R):
    for j in range(L + 1,R + 1):
      mod = (i * j) % 2019 
      if mod < ans:
        ans = mod
      elif mod == 0:
        ans = 0
        break
  print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))

def sort(L):
  if len(L) < 2:
    return(L)
  p = L[0]
  X,Y = divide(p,L[1:])
  return sort(X) + [p] + sort(Y)

def divide(p,L):
  if len(L) < 1:
    return([],[])
  X,Y = divide(p,L[1:])
  l = L[0]
  if l < p:
    return([l] + X,Y)
  else:
    return(X,[l]+Y)
  
L = sort(L)
cut = L[int(N/2)] - L[int((N/2))-1]
print(cut)

Fixed submission:
N = int(input())
L = sorted(list(map(int, input().split())))
  
print(L[int(N/2)] - L[int((N/2))-1])
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
 
cList = []
 
dList = []
 
numList = []
 
supC = (B // C)
infC = (A // C)
 
supD = (B // D)
infD = (A // D)
 
for i in range(A,B+1):
	numList.append(i)
 
 
for i in range(infC,supC+1):
	cList.append(i * C)
 
for i in range(infD,supD+1):
	dList.append(i * D)
	
numList = len(set(numList) - set(cList) - set(dList))
 
print(numList)
A,B,C,D = map(int,input().split())

cList = []

dList = []

numList = []

supC = (B // C)
infC = (A // C)

supD = (B // D)
infD = (A // D)

for i in range(A,B+1):
	numList.append(i)


for i in range(infC,supC+1):
	cList.append(i * C)

for i in range(infD,supD+1):
	dList.append(i * D)
	
numList = len(set(numList) - set(cList) - set(dList))

print(numList)

Fixed submission:
L = input()

for i in range(0,len(L)-1):
	if L[i] == L[i+1]:
		print("Bad")
		break
else:print("Good")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split())

cList = []

dList = []

numList = []

supC = (B // C)
infC = (A // C)

supD = (B // D)
infD = (A // D)

for i in range(A,B+1):
	numList.append(i)


for i in range(infC,supC+1):
	cList.append(i * C)

for i in range(infD,supD+1):
	dList.append(i * D)
	
numList = len(set(numList) - set(cList) - set(dList))

print(numList)

Fixed submission:
A,B,C,D = map(int,input().split())

def gcd(m,n):
	while n!=0:
		m,n = n,m % n
	return m

def lcm(m,n):
	return m * n // gcd(m,n)

CD = lcm(C,D)

supC = B // C
supD = B // D
supCD = B // (CD)

infC = (A-1) // C
infD = (A-1) // D
infCD = (A-1) // (CD)

num = B - A + 1
num = num - supC - supD + supCD + infC + infD - infCD
print(num)
Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
L = list(map(int,input().split()))

D = [0] * (N + 1)

counter = 0

for i in range(1,len(L)):
	D[i] = D[i - 1] + L[i - 1]
	print(D)
	
	
for i in range(0,len(D)):
	if D[i] <= X:
	counter += 1
	
print(counter)

Fixed submission:
N,X = map(int,input().split())
L = list(map(int,input().split()))

D = [0] * (N + 1)

counter = 0

for i in range(1,len(L)+1):
	D[i] = D[i - 1] + L[i - 1]
	
	
for i in range(0,len(D)):
	if D[i] <= X:
		counter += 1
	
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
from collections import deque
from functools import lru_cache

N,K = map(int,input().split())
lim = min(N,K)
V = list(map(int,input().split()))
D = V.copy()
have = []
heapq.heapify(have)

#@lru_cache(maxsize = None)
def recur(d,h,n):
  if n == lim:
    #print(h)
    return sum(h)
  else:
    a = d[0]
    b = d[-1]
    ha = h.copy()
    hb = h.copy()
    heapq.heappush(ha,a)
    heapq.heappush(hb,b)
    reta = recur(d[1:],ha,n + 1)
    retb = recur(d[:-1],hb,n + 1)
    if len(h) == 0:
      return max(reta,retb)
    else:
      heapq.heappop(h)
      retc = recur(d,h,n + 1)
      return max(reta,retb,retc)
    
print(max(recur(D,have,0),0))

Fixed submission:
import heapq
from collections import deque
from functools import lru_cache

N,K = map(int,input().split())
V = list(map(int,input().split()))
ans = 0

for l in range(0,K + 1):
  for r in range(0,K - l + 1):
    d = K - r - l
    tmp = 0
    have = []
    if l + r > N:
      continue
    for i in range(0,l):
      tmp += V[i]
      have.append(V[i])
    for j in range(N - r,N):
      tmp += V[j]
      have.append(V[j])
    h = len(have)
    #print(have)
    have = sorted(have)
    for k in range(0,d):
      #print(have,sum(have))
      if k >= h:
        break
      if have[k] > 0:
        break
      tmp -= have[k]
    ans = max(tmp,ans)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
 
LR = [set([]) for i in range(M)]
 
for i in range(M):
	L,R = map(int, input().split())
	for j in range(L,R + 1):
		LR[i].add(j)

for i in range(M):
	LR[i] = LR[i] & LR[i-1]
    
 
print(len(LR[M-1]))

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

inf = []
sup = []

for i in range(0,M):
	L,R = map(int,input().split())
	inf.append(L)
	sup.append(R)
	
inf = max(inf)
sup = min(sup)

ran = sup - inf

if ran >= 0:
	print(ran + 1)
else:print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
 
LR = [[] for i in range(M)]
 
for i in range(M):
	L,R = map(int, input().split())
	for j in range(L,R + 1):
		LR[i].append(j)
	LR[i] = set(LR[i])
 
for i in range(M):
	LR[i] = LR[i] & LR[i-1]
    
 
print(len(LR[M-1]))

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

inf = []
sup = []

for i in range(0,M):
	L,R = map(int,input().split())
	inf.append(L)
	sup.append(R)
	
inf = max(inf)
sup = min(sup)

ran = sup - inf

if ran >= 0:
	print(ran + 1)
else:print(0)

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

LR = [[] for i in range(M)]

for i in range(M):
	L,R = map(int, input().split())
	for j in range(L,R + 1):
		LR[i].append(j)
	LR[i] = set(LR[i])

for i in range(M):
	LR[i] = LR[i] & LR[i-1]
    

print(len(LR[M-1]))

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

inf = []
sup = []

for i in range(0,M):
	L,R = map(int,input().split())
	inf.append(L)
	sup.append(R)
	
inf = max(inf)
sup = min(sup)

ran = sup - inf

if ran >= 0:
	print(ran + 1)
else:print(0)

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

LR = [[] for i in range(M)]

for i in range(M):
	L,R = map(int, input().split())
	for j in range(L,R + 1):
		LR[i].append(j)


for i in range(M):
	LR[i] = set(LR[i])

for i in range(M):
	LR[i] = LR[i] & LR[i-1]

print(len(LR[M-1]))

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

inf = []
sup = []

for i in range(0,M):
	L,R = map(int,input().split())
	inf.append(L)
	sup.append(R)
	
inf = max(inf)
sup = min(sup)

ran = sup - inf

if ran >= 0:
	print(ran + 1)
else:print(0)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()

#同じカードを書き換える操作は無駄なため、cが降順となるようにソート
BC.sort(key=lambda x:-x[1])

for B,C in BC:
  print(B,C)
  for j in range(i,min(N,i + B)):
    if A[j] < C:
      A[j] = C
  #B枚分先を飛ばす BCはCに関して降順のため問題ない
  i = i + B

print(sum(A))

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()

#同じカードを書き換える操作は無駄なため、cが降順となるようにソート
BC.sort(key=lambda x:-x[1])

i = 0

for B,C in BC:
  for j in range(i,min(N,i + B)):
    if A[j] < C:
      A[j] = C
  #B枚分先を飛ばす BCはCに関して降順のため問題ない
  i = i + B

print(sum(A))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = []
for _ in range(M):
  b,c = map(int,input().split())
  BC.append([b,c])

totals = [sum(A)]

for i in range(M):
  b = BC[i][0]
  part = A[:b]
  c = [BC[i][1]] * b
  print(part,c)
  if sum(part) < sum(c):
    left = c
    right = A[b:]
    total = sum(left) + sum(right)
    totals.append(total)
    
print(max(totals))

  

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()

#同じカードを書き換える操作は無駄なため、cが降順となるようにソート
BC.sort(key=lambda x:-x[1])

i = 0

for B,C in BC:
  for j in range(i,min(N,i + B)):
    if A[j] < C:
      A[j] = C
  #B枚分先を飛ばす BCはCに関して降順のため問題ない
  i = i + B

print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a % b)
  
N = int(input())

A = list(map(int,input().split()))

GCD = 0

for i in range(0,N):
  current = A[i]
  A[i] = A[i - 1]
  div = reduce(gcd,A)
  if div > GCD:
    GCD = div
  A[i] = current
  
print(GCD)

Fixed submission:
#最大公約数を求める関数を再帰的に定義
def gcd(x,y):
	if x < y:
		x,y = y,x
	if y == 0:
		return x
	#一方が0の時、他方を最大公約数として定義
	return gcd(y,x % y)
	
N = int(input())
A = list(map(int,input().split()))

L = [0]
R = [0]
gcdlist = []

#リストの前と後ろから値を取得し
#A[i]を除いてA[i]以前と以降の最大公約数を算出
for i in range(N):
	L.append(gcd(L[i],A[i]))
	R.append(gcd(R[i],A[N-i-1]))


#i毎にA[i]を除いた最大公約数のリストを作成
for i in range(N):
	gcdlist.append(gcd(L[i],R[N-i-1]))

print(max(gcdlist))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import functools

N = int(input())
A = list(map(int,input().split()))

gcdlist = []

def gcdpy(numbers):
	return functools.reduce(fractions.gcd, numbers)

for i in range(0,N):
	I = A[i]
	A[i] = A[i-1]
	gcdlist.append(gcdpy(A))
	A[i] = I
	
print(max(gcdlist))

Fixed submission:
#最大公約数を求める関数を再帰的に定義
def gcd(x,y):
	if x < y:
		x,y = y,x
	if y == 0:
		return x
	#一方が0の時、他方を最大公約数として定義
	return gcd(y,x % y)
	
N = int(input())
A = list(map(int,input().split()))

L = [0]
R = [0]
gcdlist = []

#リストの前と後ろから値を取得し
#A[i]を除いてA[i]以前と以降の最大公約数を算出
for i in range(N):
	L.append(gcd(L[i],A[i]))
	R.append(gcd(R[i],A[N-i-1]))


#i毎にA[i]を除いた最大公約数のリストを作成
for i in range(N):
	gcdlist.append(gcd(L[i],R[N-i-1]))

print(max(gcdlist))
Buggy python submission (verdict: Runtime Error):
from collections import deque
input = sys.stdin.readline

N,K = map(int,input().split())
S = input()

if N == 1:
  if S == "1" or K >= 1:
    print(1)
  else:
    print(0)
    
else:
  num = deque([])
  if S[0] == "0":
    num.append(0)
  cnt = 1
  ans = 0
  M = 2 * K + 1
  
  for i in range(1,N):
    if S[i] == S[i - 1]:
      cnt += 1
    else:
      num.append(cnt)
      cnt = 1
      
    if len(num) > M:
      num.popleft()

    if S[i - 1] == "1":
      ans = max(sum(num),ans)
    
    if i == N - 1:
      num.append(cnt)
      if len(num) > M:
        num.popleft()
      if S[i] == "1":
        ans = max(sum(num),ans)
  
  print(ans)

Fixed submission:
from operator import add
from collections import deque
from itertools import accumulate

N,K = map(int,input().split())
S = input()

if N == 1:
  if S == "1" or K >= 1:
    print(1)
  else:
    print(0)
    
else:
  num = []
  cnt = 1
  ans = 0
  M = 2 * K + 1

  for i in range(1,N):
    if S[i] == S[i - 1]:
      cnt += 1
    else:
      num.append(cnt)
      cnt = 1
  num.append(cnt)

  if S[0] == "0":
    num = [0] + num
  
  acc = list(accumulate(num,add))
  acc = [0] + acc
  A = len(acc)
  
  for left in range(0,A,2):
    right = min(A - 1,left + M)
    ans = max((acc[right] - acc[left]),ans)
    
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ride = [0] * 6
for i in range(5):
	ride[i] = int(input())

city = [0] * 6
city[0] = N

minuites = 0

while city[5] != N:
	for i in range(5)[::-1]:
		city[i + 1] = min(city[i],ride[i]) + city[i + 1]
		city[i] = city[i] - min(city[i],ride[i])
	minuites += 1

	
print(minuites)

Fixed submission:
import math

N = int(input())
ride = [0] * 5
for i in range(5):
	ride[i] = int(input())
 
narrow = min(ride)

minuites = math.ceil(N / narrow) + 4
  
print(minuites)
Buggy python submission (verdict: Runtime Error):
S = input()
 
partial = ""
 
conditions = ["A","T","G","C"]
 
conlist = []
 
con = 0
 
for i in range(0,len(S)):
	if S[i] in conditions:
		for j in range(0,i+1):
			if S[j] in conditions:
				con +=1
			if (S[j] not in conditions) or j == i:
				conlist.append(con)
				con = 0
				
 
print(max(conlist))

Fixed submission:
S = input()

partial = ""

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

conlist = []

con = 0

for i in range(0,len(S)):
	if S[i] in conditions:
		for j in range(0,i+1):
			if S[j] in conditions:
				con +=1
			if (S[j] not in conditions) or j == i:
				conlist.append(con)
				con = 0
				

if len(conlist) > 0:
	print(max(conlist))
else:print(0)

Buggy python submission (verdict: Runtime Error):
S = input()

partial = ""

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

conlist = []

con = 0

for i in range(0,len(S)):
	if S[i] in conditions:
		for j in range(0,i):
			if S[j] in conditions:
				con +=1
			if (S[j] not in conditions) or j == i:
				conlist.append(con)
				con = 0
				

print(max(conlist))

Fixed submission:
S = input()

partial = ""

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

conlist = []

con = 0

for i in range(0,len(S)):
	if S[i] in conditions:
		for j in range(0,i+1):
			if S[j] in conditions:
				con +=1
			if (S[j] not in conditions) or j == i:
				conlist.append(con)
				con = 0
				

if len(conlist) > 0:
	print(max(conlist))
else:print(0)

Buggy python submission (verdict: Runtime Error):
S = input()

partial = ""

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

conlist = []

con = 0

for i in range(0,len(S)):
	if S[i] in conditions:
		for j in range(0,i+1):
			if S[j] in conditions:
				con +=1
			if (S[j] not in conditions) or j == i:
				conlist.append(con)
				con = 0
				

print(max(conlist))

Fixed submission:
S = input()

partial = ""

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

conlist = []

con = 0

for i in range(0,len(S)):
	if S[i] in conditions:
		for j in range(0,i+1):
			if S[j] in conditions:
				con +=1
			if (S[j] not in conditions) or j == i:
				conlist.append(con)
				con = 0
				

if len(conlist) > 0:
	print(max(conlist))
else:print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()

for c in range(Q):
  con = 0
  l,r = map(int,input().split())
  l = l - 1
  part = S[l:r]
  for i in range(len(part) - 1):
    if part[i] + part[i + 1] == "AC":
      con += 1
  print(con)
  

Fixed submission:
N, Q = map(int, input().split())
S = input()
cons = [0] * (N + 1)

for i in range(N - 1):
  #隣り合う2文字(S[i] + S[i + 1])が"AC"である数の累積和を予め記録しておく
  #愚直に計算すると最悪でN * Q = 10 ** 6となるため、下準備をして再計算を防ぐ
  ##ACACTACGなら[0,1,1,2,2,2,3,3]
  cons[i + 1] = cons[i] + (1 if S[i] + S[i + 1] == 'AC' else 0)

for i in range(Q):
  l,r = map(int, input().split())
  #予め記録してあるACの累積数を引けば範囲内のACの数が求められる
  #ACと単位が2文字であるためrを1つ左にずらしておく(1引かないとCがはみ出てしまう)
  print(cons[r - 1] - cons[l - 1])

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

for c in range(Q):
  l,r = map(int,input().split())
  l = l - 1
  part = S[l:r]
  print(part.count("AC"))

Fixed submission:
N, Q = map(int, input().split())
S = input()
cons = [0] * (N + 1)

for i in range(N - 1):
  #隣り合う2文字(S[i] + S[i + 1])が"AC"である数の累積和を予め記録しておく
  #愚直に計算すると最悪でN * Q = 10 ** 6となるため、下準備をして再計算を防ぐ
  ##ACACTACGなら[0,1,1,2,2,2,3,3]
  cons[i + 1] = cons[i] + (1 if S[i] + S[i + 1] == 'AC' else 0)

for i in range(Q):
  l,r = map(int, input().split())
  #予め記録してあるACの累積数を引けば範囲内のACの数が求められる
  #ACと単位が2文字であるためrを1つ左にずらしておく(1引かないとCがはみ出てしまう)
  print(cons[r - 1] - cons[l - 1])

Buggy python submission (verdict: Runtime Error):
N , Q = map(int,input().split())
S = input()
L = [list(map(int,input().split())) for i in range(Q)]

cut = ""

conlist = []

for i in range(Q):
	cut = S[L[i][0]-1:L[i][1]]
	conlist.append(cut.count("AC"))
	print(cut)
print(max(conlist))

Fixed submission:
N, Q = map(int, input().split())
S = input()
cons = [0] * (N + 1)

for i in range(N - 1):
  #隣り合う2文字(S[i] + S[i + 1])が"AC"である数の累積和を予め記録しておく
  #愚直に計算すると最悪でN * Q = 10 ** 6となるため、下準備をして再計算を防ぐ
  ##ACACTACGなら[0,1,1,2,2,2,3,3]
  cons[i + 1] = cons[i] + (1 if S[i] + S[i + 1] == 'AC' else 0)

for i in range(Q):
  l,r = map(int, input().split())
  #予め記録してあるACの累積数を引けば範囲内のACの数が求められる
  #ACと単位が2文字であるためrを1つ左にずらしておく(1引かないとCがはみ出てしまう)
  print(cons[r - 1] - cons[l - 1])