Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03695 (python)

Fixed submission:
def solve(N, As):
    colors = set()
    allcount = 0
    for a in As:
        a -= a % 400
        n = a // 400
        if n < 8:
            colors.add(n)
        else:
            allcount += 1
    return max(len(colors), 1), len(colors) + allcount


if __name__ == "__main__":
    N = int(input())
    As = map(int, input().split(" "))
    m1, m2 = solve(N, As)
    print(m1, m2)

Buggy submission (verdict: Runtime Error):
def solve(N, As):
    colors = set()
    allcount = 0
    for a in As:
        if a // 400 < 8:
            colors.add(n)
        else:
            allcount += 1
    return max(len(colors), 1), len(colors) + allcount


if __name__ == "__main__":
    N = int(input())
    As = map(int, input().split(" "))
    m1, m2 = solve(N, As)
    print(m1, m2)
Problem p03059 (python)

Fixed submission:
A, B, T = map(int, input().split())
print((T//A)*B)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
import fractions
from functools import reduce

N = int(input())
A = np.array(input().split()).astype(int)

def gcd(numbers):
    return reduce(fractions.gcd, numbers)
rt = 1
for i in range(N):
    ind = np.ones(N, dtype=bool)
    ind[i]=False
    A_tmp = A[ind]
    f = gcd(A_tmp)
    if rt < f:
        rt = f
print(rt)
Problem p03105 (python)

Fixed submission:
A_B_C = [int(x.strip()) for x in input().split()]
print(min(int(A_B_C[1]/A_B_C[0]), A_B_C[2]))

Buggy submission (verdict: Runtime Error):
A_B_C = [int(x.strip()) for x in input().split()]
print(A_B_C = [int(x.strip()) for x in input().split()])
Problem p03106 (python)

Fixed submission:
A,B,K=map(int,input().split())
l = []
for i in reversed(range(0, min(A, B)+1)):
    if (A%i==0)&(B%i==0):
        l.append(i)
    if len(l)==K:
        break        
print(l[-1])

Buggy submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
 l = []
for i in reversed(range(0, min(A, B)+1)):
    if (A%i==0)&(B%i==0):
        l.append(i)
    if len(l)==K:
        break        
print(l[-1])
Problem p03140 (python)

Fixed submission:
N = int(input())
A = input()
B = input()
C = input()
target_list = []
for a, b, c in zip(A, B, C):
    if a==b and b==c and c==a:
        target_list.append(3)
    elif a==b or b==c or c==a: 
        target_list.append(2)
    else:
        target_list.append(1)
print(N*3 - sum(target_list))

Buggy submission (verdict: Runtime Error):
target_list = []
for a, b, c in zip(A, B, C):
    if a==b and b==c:
        target_list.append(3)
    elif a==b or a==c:
        target_list.append(2)
    else:
        target_list.append(1)
print(N*3 - sum(target_list))
Problem p03146 (python)

Fixed submission:
s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

while (len(l)==len(set(l))):
  i+=1
  s = func(s)
  l.append(s)
print(i)

Buggy submission (verdict: Runtime Error):
s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

def Collatz(s):
  i+=1
  l.append(func(s))
  if not len(l) == len(set(l)):
    print(i)
    break
  else:
    continue

Collatz(s)

Buggy submission (verdict: Runtime Error):
s = map(int, input().split())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

def Collatz(s):
  i+=1
  l.append(func(s))
  if not len(l) == len(set(l)):
    print(i)
    break
  else:
    continue

Collatz(s)

Buggy submission (verdict: Runtime Error):
s = map(int, input().split())
l=[s]
i=1
def func(a):
  if a%2==0:
    return a/2
  else:
    return 3s+1

def Collatz(s):
    i+=1
	l.append(func(s))
	if not len(l) == len(set(l)):
        print(i)
        break
    else:
        continue
Collatz(s)

Buggy submission (verdict: Runtime Error):
s = map(int, input().split()
l=[s]
i=1
def func(a):
  if a%2==0:
    return a/2
  else:
    return 3s+1

def Collatz(s):
    i+=1
	l.append(func(s))
	if not len(l) == len(set(l)):
        print(i)
        break
    else:
        continue
Problem p03212 (python)

Fixed submission:
import itertools
import numpy as np
N = input()
digit = len(N)
ans = 0
if int(N) < 357:
    print(ans)
else:
    for i in range(3, len(N)):
        ans += 3**i - 3 * 2**i + 3
    for v in itertools.product('753', repeat=digit):
        if (len(set(list(v)))==3) & (int(''.join(list(v))) <= int(N)):
            ans +=1
    print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
N = input(N)
digit = len(N)
ans = 0
if int(N) < 357:
    print(ans)
else:
    for i in range(3, len(N)):
        ans += 3**i - 3 * 2**i + 3
    for v in itertools.product('753', repeat=digit):
        if (len(set(list(v)))==3) & (int(''.join(list(v))) <= int(N)):
            ans +=1
    print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
N = input(N)
digit = len(N)
ans = 0
if int(N) < 357:
    print(ans)
else:
    for i in range(3, len(N)):
        ans += 3**i - 3 * 2**i + 3
    print(ans)
    for v in itertools.product('753', repeat=digit):
        if (len(set(list(v)))==3) & (int(''.join(list(v))) <= int(N)):
            ans +=1
    print(ans)
Problem p03369 (python)

Fixed submission:
s = input()
count = 0
for i in range(3):
  if s[i] == 'o':
    count+=1
print(count*100 + 700)

Buggy submission (verdict: Runtime Error):
s = input()
count = 0
for i in range(3):
  if s[i] == 'o':
    count+=1
pront(count*100 + 700)
Problem p03457 (python)

Fixed submission:
import numpy as np
N = int(input())
travels = np.array([input().split() for _ in range(N)], dtype=int)
travels = np.insert(travels, 0, [0, 0, 0], axis=0)
travels = travels[travels[:,0].argsort(), :]
able = True
for i in range(0, N):
    dist = travels[i+1,:] - travels[i,:]
    x_dist = abs(dist[1])
    y_dist = abs(dist[2])
    time_dist = dist[0]
    x = travels[i+1,1]
    y = travels[i+1,2]
    time = travels[i+1,0]
    if x_dist+y_dist>time_dist:
        able = False
        break
    elif (x+y)%2==0 and time%2!=0:
        able = False
        break
    elif (x+y)%2!=0 and time%2==0:
        able = False
        break
if able:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
travels = np.array([input().split() for _ in range(N)], dtype=int)
travels = np.insert(travels, 0, [0, 0, 0], axis=0)
travels = travels[travels[:,0].argsort(), :]
able = True
for i in range(np.shape(travels)[1]-1):
    dist = travels[i+1,:] - travels[i,:]
    time = dist[0]
    x = abs(dist[1])
    y = abs(dist[2])
    if x+y>time:
        able = False
        break
    elif x+y%2==0 and time%2!=0:
        able = False
        break
    elif x+y%2!=0 and time%2==0:
        able = False
        break
if able:
    print('Yes')
else:
    print('No')
Problem p03469 (python)

Fixed submission:
S = input().split('/')
S[0] = '2018'
print('/'.join(S))

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
# i: man, j: gosen, k: sen
output_flag=0
for i in range(0, N+1):
    while output_flag==0:
        for j in range(0, N+1-i):
            k = N-i-j
            if 10000*i+5000*j+1000*k==Y:
                print(i, j, k)
                output_flag=1
                break
    if output_flag==1:
        break
if output_flag==0:
    print(-1, -1, -1)
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split())
man = -1
gosen = -1
sen = -1
for i in range(0, N+1):
    for j in range(0, N+1-i):
        k = N-i-j
        total = 10000*i+5000*j+1000*k
        if total==Y:
            man = i
            gosen = j
            sen = k
print(man, gosen, sen)

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
man = -1
gosen = -1
sen = -1
flag=0
for i in range(0, N+1):
    if output_flag==1:
        break
    for j in range(0, N+1-i):
        k = N-i-j
        total = 10000*i+5000*j+1000*k
        if total==Y:
            output_flag=1
            man = i
            gosen = j
            sen = k
            break
print(man, gosen, sen)

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
# i: man, j: gosen, k: sen
output_flag=0
for i in range(0, N+1):
    if output_flag==0:
        for j in range(0, N+1-i):
            k = N-i-j
            if 10000*i+5000*j+1000*k==Y:
                print(i, j, k)
                not_output_flag=1
                break
    else:
        break
if not_output_flag==0:
    print(-1, -1, -1)
Problem p02696 (python)

Fixed submission:
import math

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

solved_flag = False
if B==1:
    ans = 0
    solved_flag = True
else:
    if B <= N:
        x = B-1
    else:
        x = N

if not solved_flag:
    ans = math.floor(A*x/B) - A*math.floor(x/B)
print(ans)

Buggy submission (verdict: Runtime Error):
solved_flag = False
if B==1:
    ans = 0
    solved_flag = True
else:
    if B <= N:
        x = B-1
    else:
        x = N

if not solved_flag:
    ans = math.floor(A*x/B) - A*math.floor(x/B)
print(ans)
Problem p02706 (python)

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

play_days = N
for i in A:
  play_days -= i
if play_days < 0:
  print(-1)
else:
  print(play_days)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
A = map(int, input().split()) 

play_days = copy.copy(N)
for i in A:
  play_days -= i
if play_days < 0:
  print(-1)
else:
  print(play_days)
Problem p02717 (python)

Fixed submission:
from copy import copy

A,B,C = map(int, input().split())

# A <--> B
temp = copy(A)
A = copy(B)
B = copy(temp)

# A <--> C
temp = copy(A)
A = copy(C)
C = copy(temp)

print("%d %d %d" %(A,B,C))

Buggy submission (verdict: Runtime Error):
K = int(input())

if K < 10:
  print(K)
else:
  count = 9

queue = [1,2,3,4,5,6,7,8,9]

while count != K:
  for x in queue:
    if x%10 != 0:
      queue.append(10*x + (x%10) - 1)
      count += 1
      if count == K:
        break

    queue.append(10*x + (x%10))
    count += 1
    if count == K:
      break

    if x%10 != 9:
      queue.append(10*x + (x%10) + 1)
      count += 1
      if count == K:
        break

print(queue[-1])
Problem p02720 (python)

Fixed submission:
K = int(input())

if K < 10:
  queue = range(1,K+1)
  count = K
else:
  count = 9
  queue = [1,2,3,4,5,6,7,8,9]

while count != K:
  for x in queue:
    if x%10 != 0:
      queue.append(10*x + (x%10) - 1)
      count += 1
      if count == K:
        break

    queue.append(10*x + (x%10))
    count += 1
    if count == K:
      break

    if x%10 != 9:
      queue.append(10*x + (x%10) + 1)
      count += 1
      if count == K:
        break

print(queue[-1])

Buggy submission (verdict: Runtime Error):
K = int(input())

if K < 10:
  print(K)
else:
  count = 9

queue = [1,2,3,4,5,6,7,8,9]

while count != K:
  for x in queue:
    if x%10 != 0:
      queue.append(10*x + (x%10) - 1)
      count += 1
      if count == K:
        break

    queue.append(10*x + (x%10))
    count += 1
    if count == K:
      break

    if x%10 != 9:
      queue.append(10*x + (x%10) + 1)
      count += 1
      if count == K:
        break

print(queue[-1])
Problem p02760 (python)

Fixed submission:
import numpy as np
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())

for n in range(N):
    called_num = int(input())
    exist_list = [called_num in A[i] for i in range(3)]
    if True in exist_list:
        called_row = exist_list.index(True)
        A[called_row] = [0 if x==called_num else x for x in A[called_row]]
        
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] #良い実装が思いつかなかった

if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: #書き方イマイチ
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
 
for n in range(N):
    called_num = int(input())
    exist_list = [called_num in A[i] for i in range(3)]
    if True in exist_list:
      	called_row = exist_list.index(True)
       	A[called_row] = [0 if x==called_num else x for x in A[called_row]]
    
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] #良い実装が思いつかなかった
 
if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: #書き方イマイチ
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
 
for n in range(N):
    called_num = int(input())
    exist_list = [called_num in A[i] for i in range(3)]
    if True in exist_list:
      	called_row = exist_list.index(True)
    
    A[called_row] = [0 if x==called_num else x for x in A[called_row]]
    
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] #良い実装が思いつかなかった
 
if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: #書き方イマイチ
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
A = np.array([])
for i in range(3):
    A.append(list(map(int, input().split())))

N = int(input())

for n in range(N):
    called_num = int(input())
    called_row = [called_num in A[i] for i in range(3)].index(True)
    
    A[called_row] = [0 if x==called_num else x for x in A[called_row]]
    
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] #良い実装が思いつかなかった

if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: #書き方イマイチ
    print('Yes')
else:
    print('No')
Problem p02982 (python)

Fixed submission:
import numpy as np
N, D = map(int, input().split())
X = np.zeros((N,D))
for i in range(N):
  X[i][:] = list(map(int, input().split()))

n = 0
for i in range(N):
  for j in range(i+1, N):
    dist = np.linalg.norm(X[i]-X[j])
    if dist.is_integer():
      n += 1

print(n)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, D = map(int, input().split())
X = np.zeros((N,D))
for i in range(N):
  X[i][:] = list(map(int, input().split()))

n = 0
for i in range(N):
  for j in range(i+1, N):
    dist = linalg.norm(X[i]-X[j])
    if dist.is_integer():
      n += 1

print(n)
Problem p02999 (python)

Fixed submission:
X,A = map(int, input().split())
if X < A:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
N,X = map(int, input().split())
L_i = list(map(int, input().split()))

D=[0, 0]
count=1
for n in range(N+1):
  D[1] = D[0] + L_i[n]
  if D[1] <= X:
    count += 1
    D[0] = D[1]
  else:
    break

print(count)
Problem p03000 (python)

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

D=[0, 0]
count=1
for n in range(N):
  D[1] = D[0] + L_i[n]
  if D[1] <= X:
    count += 1
    D[0] = D[1]
  else:
    break

print(count)

Buggy submission (verdict: Runtime Error):
N,X = map(int, input().split())
L_i = list(map(int, input().split()))

D=[0, 0]
count=1
for n in range(N+1):
  D[1] = D[0] + L_i[n]
  if D[1] <= X:
    count += 1
    D[0] = D[1]
  else:
    break

print(count)
Problem p03030 (python)

Fixed submission:
N = int(input())
data = [{}]*N

for i in range(N):
  tempS, tempP = input().split()
  data[i] = {'ID': i+1, 'Name': tempS, 'Point': int(tempP)}

data_sort = sorted(
  data,
  key = lambda x: (x['Name'], -x['Point'])
)

for i in range(N):
  print(data_sort[i]['ID'])

Buggy submission (verdict: Runtime Error):
_N, *_SP = open(0).read().split()
N = int(_N)

S = {}
P = {}

for i in range(N):
    S[i+1] = _SP[2*i]
    P[i+1] = int(_SP[2*i+1])
    
import pandas as pd

S_df = pd.DataFrame(S.values(), index=S.keys(), columns=["name"])
P_df = pd.DataFrame(P.values(), index=P.keys(), columns=["point"])

df = pd.concat([S_df, P_df], axis=1)
print(*list(df.sort_values(['name', 'point'], ascending=[True, False]).index), sep="\n")
Problem p03031 (python)

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

s = []
for i in range(M):
    _, *tmp_s = map(int, input().split())
    s.append(tmp_s)
    
p = list(map(int, input().split()))

import numpy as np

s_matrix = []

for i in range(M):
    s_matrix.append([1 if x+1 in s[i] else 0 for x in range(N)])
    
s_matrix = np.array(s_matrix)

ans = 0

for i in range(2**N):
    on_off_pattern = list(format(i, '0%db' %N))
    on_nums = np.dot(s_matrix, np.array(list(map(int, on_off_pattern))))
    on_nums_mod2 = on_nums % 2

    if not False in (on_nums_mod2 == p):
        ans += 1
        
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

s = []
for i in range(M):
    _, *tmp_s = map(int, input().split())
    s.append(tmp_s)
    
p = list(map(int, input().split()))

import numpy as np

s_matrix = []

for i in range(M):
    s_matrix.append([1 if x+1 in s[i] else 0 for x in range(N)])
    
s_matrix = np.array(s_matrix)

ans = 0

for i in range(2**N):
    on_off_pattern = list(format(i, '0%db' %N))
    on_nums = s_matrix @ np.array(list(map(int, on_off_pattern)))
    on_nums_mod2 = on_nums % 2

    if not False in (on_nums_mod2 == p):
        ans += 1
        
print(ans)
Problem p03035 (python)

Fixed submission:
A,B = map(int, input().split())
if A <= 5:
  print(0)
elif A <= 12:
  print(int(B/2))
else:
  print(B)

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())

if A => 13:
  print(B)
elif A =< 5:
  print(0)
else:
  print(int(B/2))
Problem p03061 (python)

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

import fractions

L = [A[0]]
R = [A[-1]]

for i in range(1, N):
    L.append(fractions.gcd(L[i-1], A[i]))
    R.append(fractions.gcd(R[i-1], A[-(i+1)]))

R.reverse()


ans = 0

for i in range(N):
    if i == 0:
        ans = max(ans, R[1])
    elif i == N-1:
        ans = max(ans, L[-2])
    else:
        ans = max(ans, fractions.gcd(L[i-1], R[i+1]))
    
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

ans = 0

for i in range(N):
    if ans == 0:
        ans = gcd_list([*A[:i], *A[i+1:]])
        
    elif gcd_list([*A[:i], *A[i+1:]]) > ans:
        ans = gcd_list([*A[:i], *A[i+1:]])
        break
        
print(ans)
Problem p03076 (python)

Fixed submission:
import math
cookT = {}
lastOrder = 0

for i in range(5):
  cookT[i] = int(input())
  
lastOrder = max(cookT.items(), key=lambda x:(10-x[1]%10)%10)[0]

totalT = 0
for i in range(5):
  if i == lastOrder:
    totalT += cookT[lastOrder]
  else:
    tempX = cookT[i]
    tempY = math.ceil(tempX%10 / 10)*10
    totalT += tempX//10 *10 + tempY
print(totalT)

Buggy submission (verdict: Runtime Error):
A = list(map(int, open(0).read().split()))

last_order = A[min([(x%10, i) for i,x in enumerate(A) if x%10!=0])[1]]
import numpy as np
print(sum(A) + sum(10 - np.array([x%10 for x in A if x%10!=0])) - (10 - min([x%10 for x in A if x%10!=0])))
Problem p03106 (python)

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

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

print(sorted(list(set(divisor(A)) & set(divisor(B))), reverse=True)[K-1])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

def cf(x1,x2):
    cf=[]
    
    if 1 in [x1, x2]:
        cf.append(1)
    else:
        count = 0
        for i in range(2,min(x1,x2)+1):
            if count== K:
                break
            else:
                if x1 % i == 0 and x2 % i == 0:
                    cf.append(i)
            count += 1
    return cf

print(cf(A, B)[-1])
Problem p03324 (python)

Fixed submission:
D, N = map(int, input().split())
print([100 ** D * i for i in range(102) if i%100 != 0][N-1])

Buggy submission (verdict: Runtime Error):
D, N = map(int, input().split())

print([100 ** D * i for i in range(101) if i%100 != 0][N-1])
Problem p03386 (python)

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

L = list(range(A, min(B, A+K))) + list(range(max(A, B-K+1), B+1))
L_no_duplication = set(L)
print(*sorted(L_no_duplication), sep="\n")

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

L = list(range(A, B+1))
ans = set(L[:K] + L[-K:])
print(*sorted(ans), sep="\n")

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

L = list(range(A, B+1))
ans = L[:K] or L[-K:]
print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

L = list(range(A, B+1))
ans = L[:K] + L[-K:]
print(*ans, sep="\n")
Problem p02603 (python)

Fixed submission:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

n = I()
a = LI()
ans = 1000
for i in range(n - 1):
    kabu = 0
    if a[i] < a[i+1]:
        # 出来るだけ買う
        kabu = ans // a[i]
    # 買った株があれば i + 1日目 に売る
    if kabu > 0:
        ans += (a[i + 1] - a[i]) * kabu
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

n = I()
a = LI()
ans = 1000
kabu = 0
vs = list(Counter(a).keys())
i = 0
m = len(vs)
# 極小値で売る、極大値で買う
while i < m:
    if 0 < i < m - 1:
        if vs[i-1] > vs[i] < vs[i+1]:
            # 買う
            ans, kabu = ans % vs[i], ans // vs[i]
            # print(i, ans, kabu)

        elif vs[i-1] < vs[i] > vs[i+1]:
            # 売る
            ans, kabu = ans + vs[i] * kabu, 0
            # print(i, ans, kabu)
    else:
        if i == 0:
            if vs[i] < vs[i+1]:
                # 買う
                ans, kabu = ans % vs[i], ans // vs[i]
                # print(i, ans, kabu)
        else:
            if vs[i - 1] < vs[i]:
                # 売る
                ans, kabu = ans + vs[i] * kabu, 0
                # print(i, ans, kabu)
    i += 1
# print(i)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

n = I()
a = LI()
ans = 1000
kabu = 0
vs = list(Counter(a).keys())
i = 0
m = len(vs)
# 極小値で売る、極大値で買う
while i < m:
    if 0 < i < m - 1:
        if vs[i-1] > vs[i] < vs[i+1]:
            # 買う
            ans, kabu = ans % vs[i], ans // vs[i]
            print(i, ans, kabu)

        elif vs[i-1] < vs[i] > vs[i+1]:
            # 売る
            ans, kabu = ans + vs[i] * kabu, 0
            # print(i, ans, kabu)
    else:
        if i == 0:
            if vs[i] < vs[i+1]:
                # 買う
                ans, kabu = ans % vs[i], ans // vs[i]
                # print(i, ans, kabu)
        else:
            if vs[i - 1] < vs[i]:
                # 売る
                ans, kabu = ans + vs[i] * kabu, 0
                # print(i, ans, kabu)
    i += 1
# print(i)

print(ans)