Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = input()
a = []
for i in range(N):
        a.append(input())

b = a.sort()
c = a.reverse()
 
for i in range(N):
        if a[i]!=c[0] :
                print(c[0])
        else:
                print(c[1])


Fixed submission:
N = input()
a = []
for i in range(N):
        a.append(input())
b = sorted(a)
b0,b1 = b[-1],b[-2]
for i in range(N):
        if a[i]!=b0 :
                print(b0)
        else:
                print(b1)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
a = []
for i in range(N):
        a.append(input())
B = max(a)
for i in range(N):
        if a[i] != B:
                print(B)
        else:
                b = a.pop(i)
                print(max(a))
                a.insert(i,b)


Fixed submission:
N = input()
a = []
for i in range(N):
        a.append(input())
b = sorted(a)
b0,b1 = b[-1],b[-2]
for i in range(N):
        if a[i]!=b0 :
                print(b0)
        else:
                print(b1)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
a = []
for i in range(N):
        a.append(input())
B = max(a)
for i in range(N):
        if B == max(a):
                b = a.pop(i)
                print(max(a))
                a.insert(i,b)
        else:
                print(B)

Fixed submission:
N = input()
a = []
for i in range(N):
        a.append(input())
b = sorted(a)
b0,b1 = b[-1],b[-2]
for i in range(N):
        if a[i]!=b0 :
                print(b0)
        else:
                print(b1)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
a = []
for i in range(N):
        a.append(input())
for i in range(N):
        b = a.pop(i)
        print(max(a))
        a.insert(i,b)


Fixed submission:
N = input()
a = []
for i in range(N):
        a.append(input())
b = sorted(a)
b0,b1 = b[-1],b[-2]
for i in range(N):
        if a[i]!=b0 :
                print(b0)
        else:
                print(b1)

Buggy python submission (verdict: Runtime Error):
N = input()
a = []
for i in range(N):
    a.append(input())
for i in range(N):
  	del a[i]
    print(max(a))
	

Fixed submission:
N = input()
a = []
for i in range(N):
        a.append(input())
b = sorted(a)
b0,b1 = b[-1],b[-2]
for i in range(N):
        if a[i]!=b0 :
                print(b0)
        else:
                print(b1)

Buggy python submission (verdict: Runtime Error):
N = input()
a = []
for i in range(N):
    a.append(input())
for i in range(N):
  	del b=a[i+1]
    print(max(b))
	

Fixed submission:
N = input()
a = []
for i in range(N):
        a.append(input())
b = sorted(a)
b0,b1 = b[-1],b[-2]
for i in range(N):
        if a[i]!=b0 :
                print(b0)
        else:
                print(b1)
Buggy python submission (verdict: Runtime Error):
    N, A, B = map(int, input().split())
    sa = B - A
    if sa % 2 == 0:
      print(int(sa/2))
    else:
      print(int(min(A -1,N -B) + 1 + (B- A)//2))

Fixed submission:
N, A, B = map(int, input().split())
sa = B - A
if sa % 2 == 0:
   print(int(sa//2))
else:
   print(int(min(A -1,N -B) + 1 + (B- A)//2))

Buggy python submission (verdict: Runtime Error):
    N, A, B = map(int, input().split())
    sa = B - A
    if sa % 2 == 0:
      print(int(sa/2))
    else:
      print(int(min(A -1,N -B) + 1 + (B- A -1)//2))

Fixed submission:
N, A, B = map(int, input().split())
sa = B - A
if sa % 2 == 0:
   print(int(sa//2))
else:
   print(int(min(A -1,N -B) + 1 + (B- A)//2))
Buggy python submission (verdict: Runtime Error):
k, x = (int(x) for x in input().split())

if k*500 >= x :
	print('Yes')
else:
	Print('No')

Fixed submission:
k, x = (int(x) for x in input().split())

if k*500 >= x :
	print('Yes')	
else:
	print('No')

Buggy python submission (verdict: Runtime Error):
k, x = (int(x) for x in input().split())

if k*500 >= x :
	print(Yes)
else:
	Print(No)

Fixed submission:
k, x = (int(x) for x in input().split())

if k*500 >= x :
	print('Yes')	
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
x = int(input())
 
for val in range(x, x**1000) :
	if x ==2 :
		print(x)
		break
	elif ((10** (val-1)) % val) == 1 :
		print (val)
		break
	else :
		continue

Fixed submission:
S, T = (str(i) for i in input().split())

U = T + S
print(U)

Buggy python submission (verdict: Runtime Error):
x = int(input())
 
for val in range(x, x**1000) :
	if x ==2 :
		print(x)
		break
	elif ((10** val) % val) == 10 :
		print (val)
		break
	else :
		continue

Fixed submission:
S, T = (str(i) for i in input().split())

U = T + S
print(U)

Buggy python submission (verdict: Runtime Error):
x = int(input())
 
for val in range(x, x**100) :
	if x ==2 :
		print(x)
		break
	elif ((10** val) % val) == 10 :
		print (val)
		break
	else :
		continue

Fixed submission:
S, T = (str(i) for i in input().split())

U = T + S
print(U)

Buggy python submission (verdict: Runtime Error):
x = int(input())
 
for val in range(x+1, x**100) :
	if x ==2 :
		print(x)
		break
	elif ((2** val) % val) == 2 :
		print (val)
		break
	else :
		continue

Fixed submission:
S, T = (str(i) for i in input().split())

U = T + S
print(U)

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

U = T + S
print(U)

Fixed submission:
S, T = (str(i) for i in input().split())

U = T + S
print(U)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
 
for val in range(x, x**1000000000) :
	if x ==2 :
		print(x)
		break
	elif ((2** val) % val) == 2 :
		print (val)
		break
	else :
		continue

Fixed submission:
import math
x = int(input())
i = 0
flag = True
while flag:
  for k in range(2, int(math.sqrt(x+i)) + 1):
    if (x+i) % k == 0:
      i += 1
      break
  else:
      flag = False

print(x+i)
Buggy python submission (verdict: Runtime Error):
a,b = (int(i) for i in input().split())

import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))


Fixed submission:
a,b = (int(i) for i in input().split())

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

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

u = 0

for val in range(n):
	u += t_list[n]*(sum(t_list) - t_list[n])

u /= 2
m = int(u)
print(m)

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

u = 0

for val in range(n):
	u += t_list[val]*(sum(t_list) - t_list[val])

u /= 2
m = int(u)
print(m)
Buggy python submission (verdict: Runtime Error):
today_weather = input('')

if today_weather = 'Sunny' :
	print('Cloudy')
elif today_weather = 'Cloudy' :
	print('Rainy')
else :
	print('Sunny')

Fixed submission:
today_weather = input()

if today_weather == 'Sunny' :
	print('Cloudy')
elif today_weather == 'Cloudy' :
	print('Rainy')
else :
	print('Sunny')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val-1]]
	else:
		pass

print(score)

Fixed submission:
n = int(input())

m = n**3

print(m)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val-1]]
	else:
		pass

print(score)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val]-1]
	else:
		pass

print(score)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val-1]]
	else:
		pass

print(score)


Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val]-1]
	else:
		pass

print(score)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[val]
	else:
		pass

print(score)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val]-1]
	else:
		pass

print(score)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

num_of_coins, border = (int(n) for n in input().split)
if 500 * num_of_coins >= border:
  print("Yes")
else:
  print("No")

Fixed submission:
# coding: utf-8

num_of_coins, border = (int(n) for n in input().split())
if 500 * num_of_coins >= border:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

Tak, Ao, K = (int(n) for n in input().split())
for i in range(K):
  if Tak > 0:
    Tak -= 1
  elif Ao > 0:
    Ao -= 1
print(Tak, Ao)

Fixed submission:
# coding: utf-8
A, B, K = (int(n) for n in input().split())

if A <= K:
  K = K - A
  A = 0
else:
  A = A - K
  print(A, B)
  exit()
if B <= K:
  K = K - B
  B = 0
else:
  B = B - K
  print(A, B)
  exit()
print(A, B)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

def is_prime2(q,k=100):
  q = abs(q)
  if q == 2: return True
  if q < 2 or q&1 == 0: return False
  for i in xrange(3,k):
    x,y = q,i
    while y:
      x, y =  y, x % y
    if x != 1: continue
    if pow(i, q-1, q) != 1:
      return False
  return True

X = int(input())

for i in range(X,10**5+4):
  if is_prime(i):
    print(i)
    exit()

Fixed submission:
# coding: utf-8
 
def is_prime2(q,k=100):
  q = abs(q)
  if q == 2: return True
  if q < 2 or q&1 == 0: return False
  for i in range(3,k):
    x,y = q,i
    while y:
      x, y =  y, x % y
    if x != 1: continue
    if pow(i, q-1, q) != 1:
      return False
  return True
 
X = int(input())
 
for i in range(X,10**5+4):
  if is_prime2(i):
    print(i)
    exit()
Buggy python submission (verdict: Runtime Error):
def main():
    num = input()
    num_list = list(map(int, input().split(" ")))
    # result = sum([sum([num_list[i]^num_list[j] for j in range(i)]) for i in range(int(num))])
    result = 0
    for i in range(int(num)):
        for j in range(i):
            result += num_list[i]^num_list[j]
    print(result%(10**9+7))    

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def main():
    input_list = input().split(" ")
    a1, a2, a3 = int(input_list[0]), int(input_list[1]), int(input_list[2])
    if a1 + a2 + a3 >= 22:
        print('bust')
    else:
        print('win')

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    num = input()
    num_list = list(map(int, input().split(" ")))
    result = sum([sum([num_list[i]^num_list[j] for j in range(i)]) for i in range(int(num))])
    print(result%(10**9+7))    

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def main():
    input_list = input().split(" ")
    a1, a2, a3 = int(input_list[0]), int(input_list[1]), int(input_list[2])
    if a1 + a2 + a3 >= 22:
        print('bust')
    else:
        print('win')

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K=(int(x) for x in input().split())

for i in range(K):
    if(A>0):
        A-=1
    elif(B>0):
        B-=1
    
print(A,B)

Fixed submission:
A,B,K=(int(x) for x in input().split())

if(A>K):
    A-=K
    print(A,B)
elif(A+B>K):
    B-=K-A
    print(0,B)
else:
    print("0 0")
Buggy python submission (verdict: Runtime Error):
a,b=(int(x) for x in input().split())
gcc=1
i=2
while True:
    if(a<i or b<i):
        break
    elif (a%i==0 and b%i==0):
        gcc*=i
        a/=i
        b/=i
        i=2
    else:
        i+=1

print(int(a*b*gcc))


Fixed submission:
N=int(input())
number=input().split(' ')
number_list=[]
for i in number:
    number_list.append(int(i))
index=1
flag=0
count=0
for i in number_list:
    if(i==1 and flag==0):
        flag=1
        index+=1
    elif (i==index):
        index+=1
    else:
        count+=1

if(flag==0):
    print(-1)
else:
    print(count)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
number=[]
for i in S:
    number.append(i)

numberlist=[]
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            candidate=number[i]+number[j]+number[k]
            if candidate not in numberlist:
                numberlist.append(candidate)

print(len(numberlist))

Fixed submission:
a,b=(int(x) for x in input().split())
c,d=(int(x) for x in input().split())

if(a!=c):
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N=float(input())
count=0
for i in range(N):
    if(i%2==0):
        count+=1

print(count/N)

Fixed submission:
N=int(input())
count=0.0
for i in range(1,N+1):
    if(i%2!=0):
        count+=1

print(count/N)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
come=input()
come=come.split()
come_list=[]
for i in come:
    come_list.append(int(i)) 
rank=[]
for i in range(N):
    rank.append(0)
count=1

for i in come_list:
    rank[i-1]=count
    count+=1


out_put=str(rank[0])

for i in rank[1:]:
    out_put+=" "+str(i)

print(out_put)

Fixed submission:
N=int(input())
come=input()
come=come.split()
come_list=[]
for i in come:
    come_list.append(int(i)) 
rank=[]
for i in range(N):
    rank.append(0)
count=1

for i in come_list:
    rank[i-1]=count
    count+=1


out_put=str(rank[0])

for i in rank[1:]:
    out_put+=" "+str(i)

print(out_put)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
count_list=[]
i=0
while(i<N):
    a=int(input())
    count_list.append(a)
    i+=1

i=0
while(i<N):
    b=[]
    for j in count_list:
        b.append(j)
    b[i]=0
    print(max(b))
    i+=1

Fixed submission:
N=int(input())

max_index=-1
max_number=-1
second_number=-1
max_count=0
i=0
while(i<N):
    a=int(input())
    if(max_number<a):
        second_number=max_number
        
        max_number=a
        max_index=i
        max_count=0
    elif(max_number==a):
        max_count+=1
        max_index=-1
    elif(second_number<a):
        second_number=a
    i+=1

j=0
while(j<N):
    if(j==max_index and max_count==0):
        print(second_number)
    else:
        print(max_number)
    j+=1
Buggy python submission (verdict: Time Limit Exceeded):
L,R=(int(x) for x in input().split())

minimum=10000000000
for i in range(L,R):
    for j in range(i+1,R+1):
        candidate=(i*j)%2019
        if(minimum>candidate):
            minimum=candidate
print(minimum)

Fixed submission:
L,R=(int(x) for x in input().split())
mod_list=[]
minimum=10000000000
index=0
flag=0
for i in range(L,R):
    for j in range(i+1,R+1):
        if((i*j)%2019==0):
            minimum=0
            flag=1
            break
        else:
            candidate=(i*j)%2019
            if(minimum>candidate):
                minimum=candidate
    if(flag==1):
        break
print(minimum)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=(int(x) for x in input().split())
count=0
for r in range(0,N+1):
    if (r*R>N):
        break
    for g in range(0,N-r*R+1):
        if(r*R-g*G>N):
            break
        elif((N-r*R-g*G)%B==0 and (N-r*R-g*G)/B>=0):
            count+=1
print(count)

Fixed submission:
R,G,B,N=(int(x) for x in input().split())
count=0
for r in range(0,N+1):
    if (r*R>N):
        break
    for g in range(0,N-r*R+1):
        if(r*R-g*G>N):
            break
        elif((N-r*R-g*G)%B==0 and (N-r*R-g*G)/B>=0):
            count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=(int(x) for x in input().split())
count=0
for r in range(0,N+1):
    if (r*R>N):
        break
    for g in range(0,N-r*R+1):
        if((N-r*R-g*G)%B==0 and (N-r*R-g*G)/B>=0):
            count+=1
print(count)

Fixed submission:
R,G,B,N=(int(x) for x in input().split())
count=0
for r in range(0,N+1):
    if (r*R>N):
        break
    for g in range(0,N-r*R+1):
        if(r*R-g*G>N):
            break
        elif((N-r*R-g*G)%B==0 and (N-r*R-g*G)/B>=0):
            count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=(int(x) for x in input().split())
count=0
for r in range(0,N+1):
    for g in range(0,N-r*R+1):
        if((N-r*R-g*G)%B==0 and (N-r*R-g*G)/B>=0):
            count+=1
print(count)

Fixed submission:
R,G,B,N=(int(x) for x in input().split())
count=0
for r in range(0,N+1):
    if (r*R>N):
        break
    for g in range(0,N-r*R+1):
        if(r*R-g*G>N):
            break
        elif((N-r*R-g*G)%B==0 and (N-r*R-g*G)/B>=0):
            count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
A,B=input()
coin=0
for i in range(0,2):
    pre=max(A,B)
    coin+=pre
    if(pre==A):
        A-=1
    else:
        B-=1

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b)
sum=0
for i in range(1,3):
    sum += max(a,b)
    if (sum == a ):
        a -=1
    elif (sum==b):
        b -=1
print(sum)

Buggy python submission (verdict: Runtime Error):
A,B=input()
coin=0
for i in range(0,2):
    pre=max(A,B)
    coin+=pre
    if(pre==A):
        A-=1
    else:
        b-=1

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b)
sum=0
for i in range(1,3):
    sum += max(a,b)
    if (sum == a ):
        a -=1
    elif (sum==b):
        b -=1
print(sum)
Buggy python submission (verdict: Runtime Error):
import math
number = int(input())
if (number != 0):
    digit = int(math.log10(number))
else :
    digit=0

a=[]
while(True):
    if (number%10==0):
        a.append("0")
    elif (number%10!=0):
        a.append("1")
    
    number= int(number/10)
    if (number == 0):
        break
b= []
i = digit

while(i !=-1):
    b.append(a[i])
    i -= 1
print(b)

count1=0
count2=0
for j in range(0,digit+1):
    if (j % 2 ==0):
        if b[j]=="1":
            count1 +=1 
    elif (j %2 ==1):
        if b[j]=="0":
            count1 +=1
for j in range(0,digit):
    if (j % 2 ==0):
        if b[j]=="0":
            count2 +=1 
    elif (j %2 ==1):
        if b[j]=="1":
            count2 +=1
print(min(count1,count2))


Fixed submission:
def case_1 (S,size):
    count=0
    for i in range(0,size):
        if (i%2==0):
            if(int(S[i])==0):
                count+=1
        else:
            if(int(S[i])==1):
                count+=1
    return count

def case_2 (S,size):
    count=0
    for i in range(0,size):
        if (i%2==1):
            if(int(S[i])==0):
                count+=1
        else:
            if(int(S[i])==1):
                count+=1
    return count

S=str(input())
size=len(S)
can_1=case_1(S,size)
can_2=case_2(S,size)
print(min(can_1,can_2))
Buggy python submission (verdict: Runtime Error):
ref=imput()

if (ref=="A"):
  print("T")
elif (ref=="T"):
  print("A")
elif (ref=="G"):
  print("C")
elif (ref=="C"):
  print("G")

Fixed submission:
ref=input()

if (ref=="A"):
  print("T")
elif (ref=="T"):
  print("A")
elif (ref=="G"):
  print("C")
elif (ref=="C"):
  print("G")
Buggy python submission (verdict: Runtime Error):
ref=input()
count_list=[]
count=0
seq=["A","T","G","C"]
for base in ref:
    if base in seq:
        count +=1
    else:
        count_list.append(count)
        count =0

print(max(count_list))


Fixed submission:
ref=input()
count=0
count_list=[]
seq=["A","T","G","C"]
for base in ref:
    if base in seq:
        count +=1
       
    else:
        count_list.append(count)
        count =0
    count_list.append(count)

print(max(count_list))

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

count=0
seq=["A","T","G,","C"]
for base in ref:
    if base in ref:
        count +=1
    else count =0

print(count)

Fixed submission:
ref=input()
count=0
count_list=[]
seq=["A","T","G","C"]
for base in ref:
    if base in seq:
        count +=1
       
    else:
        count_list.append(count)
        count =0
    count_list.append(count)

print(max(count_list))
Buggy python submission (verdict: Runtime Error):
A,B,K=(int(x) for x in input().split())
GC_list=[]
for i in range(1,max(A,B)):
    if(A%i==0 and B%i==0):
        GC_list.append(i)

print(GC_list[len(GC_list)-K])

Fixed submission:
A,B,K=(int(x) for x in input().split())
GC_list=[]
for i in range(1,max(A,B)+1):
    if(A%i==0 and B%i==0):
        GC_list.append(i)

print(GC_list[len(GC_list)-K])
Buggy python submission (verdict: Runtime Error):
def main():
    antenna = []
    for i in range(5):
        antenna.append(int(raw_input()))
    k = int(raw_input())
    if (antenna[-1] - antenna[0]) < k:
        print("yes")
    else:
        print("no")



if __name__ == "__main__":
    main()


Fixed submission:
def main():
    antenna = []
    for i in range(5):
        antenna.append(int(raw_input()))
    k = int(raw_input())
    if (antenna[-1] - antenna[0]) <= k:
        print("Yay!")
    else:
        print(":(")



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():

    capa = []
    n = int(raw_input())
    ans = 0

    for i in range(5):
        capa.append(int(raw_input()))
    if n % sorted_capa[0] == 0:
        ans = 4 + n//sorted_capa[0]
    else:
        ans = 4 + n//sorted_capa[0] + 1
        print(ans)
    """
    people = [n]
    for i in range(5):
        people.append(0)
    print(capa,people)
    while people[-1] < n:
        for i in reversed(range(0,6)):
            if i != 0:
                people[i] += min(people[i-1],capa[i-1])
                people[i-1] -= min(people[i-1],capa[i-1])
        time += 1
        print(people,time)
    print(time)

    """
if __name__ == "__main__":
    main()


Fixed submission:
def main():

    capa = []
    n = int(raw_input())
    ans = 0

    for i in range(5):
        capa.append(int(raw_input()))
    sorted_capa = sorted(capa)
    if n % sorted_capa[0] == 0:
        ans = 4 + n//sorted_capa[0]
    else:
        ans = 4 + n//sorted_capa[0] + 1
    print(ans)
    """
    people = [n]
    for i in range(5):
        people.append(0)
    print(capa,people)
    while people[-1] < n:
        for i in reversed(range(0,6)):
            if i != 0:
                people[i] += min(people[i-1],capa[i-1])
                people[i-1] -= min(people[i-1],capa[i-1])
        time += 1
        print(people,time)
    print(time)

    """
if __name__ == "__main__":
    main()