Go: package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)
func main2(){
ans(10,3,50,4,60)
ans(10 ,3, 100, 5, 180)//360
ans(6, 2, 200, 3, 300)// 600

}

func main() {



    sc := bufio.NewScanner(os.Stdin)
     sc.Scan()
        args := strings.Split(sc.Text(), " ")
      

	var n, a, b, c, d int

	n, _ = strconv.Atoi(args[0])
	a, _ = strconv.Atoi(args[1])
	b, _ = strconv.Atoi(args[2])
	c, _ = strconv.Atoi(args[3])
	d, _ = strconv.Atoi(args[4])

        ans(n,a,b,c,d)
}

func ans(n,a,b,c,d int){

	ans2 := 0
	for i := 0; i < 1000; i++ {
		if i*a >= n {
			ans2 = i * b
			break
		}
	}

	for i := 0; i < 1000; i++ {
	
		if i*c >= n {
			if ans2 > i*d {


				ans2 = i *  d
			}
			break
		}
	}

	fmt.Printf("%d\n", ans2)
}

Python: 
N,A,B,C,D=(int(x) for x in input().split())

x=N//A
if N%A>0:
    x=x+1
    
y=N//C
if N%C>0:
    y=y+1

if x*B<=y*D:
    print(x*B)
else:
    print(y*D)

Python: s = list(map(int, input().strip().split(' ')))
a = s[0]
b = s[0]
i = 0
j = 0

while a >= 0:
    a -= s[1]
    i += 1

while b >= 0:
    b -= s[3]
    j += 1

c = s[2] * i
d = s[4] * j

if c > d:
    print(d)
else:
    print(c)

Python: n,a,b,c,d=map(int,input().split())

if n%a==0:
    x=(n//a)*b
else:
    x=((n//a)+1)*b
if n%c==0:
    y=(n//c)*d
else:
    y=((n//c)+1)*d
    
if x>y:
    print(y)
else:
    print(x)

Python: try:
     (N,a,b,c,d)  =  map(int,input().split())
except:
    exit

cnt = 0
min_cost = 1000000

while ((cnt * a) <= (N + a-1)):
    a_setnum = cnt 
    zan = N - (a_setnum * a) 
    if (zan < 0):
        zan = 0
    c_setnum = zan // c
    if ( zan % c != 0):
        c_setnum += 1
    cnt += 1
    cost =a_setnum * b + c_setnum *d
    if (min_cost > cost):
        min_cost = cost
print (min_cost)

Python: N,A,B,C,D = map(int,input().split())

if N % A == 0:
    x_1 = N // A
else:
    x_1 = N // A + 1
x_2 = x_1 * B

if N % C == 0:
    y_1 = N // C
else:
    y_1 = N // C + 1
y_2 = y_1 * D

if x_2 > y_2:
    print(y_2)
else:
    print(x_2)

Python: N,A,B,C,D=map(int,input().split())

if N%A==0:
    X=N//A
else:
    X=N//A+1
    
if N%C==0:
    Y=N//C
else:
    Y=N//C+1
    
print(min(X*B,Y*D))

Python: import math
N,A,B,C,D = map(int,input().split())
x = math.ceil(N/A)*B
y = math.ceil(N/C)*D
if x < y:
    print(x)
else:
    print(y)

Python: n,a,b,c,d=map(int,input().split())
array=[]
if n%a!=0:
    array+=[(n//a+1)*b]
else:array+=[int((n/a)*b)]
if n%c!=0:
    array+=[(n//c+1)*d]
else:array+=[int((n/c)*d)]
print(min(array))

Python: n = input().split()

total = 0

min = 0
x = 0
y = 0
x_total = 0
y_total = 0


while(x < int(n[0])):
    #if(x <= int(n[0])):

    x += int(n[1])
    x_total += int(n[2])
    #print(x_total)
    #if(y <= int(n[0])):
while(y < int(n[0])):
    y += int(n[3])
    y_total += int(n[4])
    #print(y_total)

if(x_total < y_total):
    print(x_total)
else:
    print(y_total)

Python: N,A,B,C,D=map(int,input().split())

if N%A==0:
    x=N//A
else:
    x=N//A+1

if N%C==0:
    y=N//C
else:
    y=N//C+1
    
a=x*B
b=y*D

if a==b:
    print(a)
    
else:
    print(min(a,b))

Python: import math
N,A,B,C,D = map(int,input().split())
z=math.ceil(N/A)
w=math.ceil(N/C)
#print(z)
#print(w)
H=z*B
J=w*D
if H>J:
    print(J)
else:
    print(H)

Python: n,A,b,C,d=map(int,input().split())

if n%A==0:
    a=int(n/A)
else:
    a=int(n/A)+1
    
if n%C==0:
    c=int(n/C)
else:
    c=int(n/C)+1

if a*b>c*d:
    print(int(c*d))
else:
    print(int(a*b))

Python: import math
N, A, B, C, D = map(int, input().split())
print(min(math.ceil(N/A)*B, math.ceil(N/C)*D))

Python: import math
N, A, B, C, D = map(int, input().split(' '))
# 10 3 100 5 180


a_count = math.ceil(N/A)
c_count = math.ceil(N/C)

a_cost = a_count * B
c_cost = c_count * D

print(min([a_cost, c_cost]))

Python: import math

n,a,b,c,d = map(int,input().split())
print(min(math.ceil(n/a) * b , math.ceil(n/c) * d) )

Python: import math
N,A,B,C,D=map(int,input().split())
if (D*math.ceil((N/C)))>(B*math.ceil((N/A))) :
    print(B*math.ceil((N/A)))
else : 
    print(D*math.ceil((N/C)))

Python: # -*- coding: utf-8 -*-
"""
Pencils
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0641

"""
import sys


def solve(N, A, B, C, D):
    q1, r1 = divmod(N, A)
    ans1 = B * (q1 + (r1 > 0))
    q2, r2 = divmod(N, C)
    ans2 = D * (q2 + (r2 > 0))
    return min(ans1, ans2)


def main(args):
    N, A, B, C, D = map(int, input().split())
    ans = solve(N, A, B, C, D)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: # coding: utf-8
# Your code here!
N,A,B,C,D=map(int,input().split())

if N%A==0 and N%C==0:
    X=(N//A)*B
    Y=(N//C)*D
    
    X,Y=sorted([X,Y])
    print(X)

elif N%A==0 and N%C!=0:
    X=(N//A)*B
    Y=((N//C)+1)*D
    
    X,Y=sorted([X,Y])
    print(X)

elif N%A!=0 and N%C==0:
    X=((N//A)+1)*B
    Y=(N//C)*D
    
    X,Y=sorted([X,Y])
    print(X)

else:
    X=((N//A)+1)*B
    Y=((N//C)+1)*D
    
    X,Y=sorted([X,Y])
    print(X)

Python: #!/usr/bin/python3

import os
import sys


def main():
    N, A, B, C, D = read_ints()
    print(solve(N, A, B, C, D))


def solve(N, A, B, C, D):
    return min((N + A - 1) // A * B, (N + C - 1) // C * D)


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()

Python: n, a, b, c, d = map(int, input().split())

X = -1*(-1 * n // a) * b
Y = -1*(-1 * n // c) * d

print(min(X, Y))

Python: n,a,b,c,d = map(int,input().split())

x=int((n+a-1)/a)
y=int((n+c-1)/c)

if x*b < y*d:
    print(x*b)
else:
    print(y*d)

Python: N, A, B, C, D = map(int, input().split())
X = N//A + (N%A!=0)*1
Y = N//C + (N%C!=0)*1
print(min(X*B, Y*D))

Python: # AOJ Volume6 0652
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0641

import math

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

k1 = math.ceil(N / A)
k2 = math.ceil(N / C)

m1 = B * k1
m2 = D * k2
print(min(m1, m2))

Python: a,b,c,d,e=map(int,input().split())
f=a%b
g=a%d
if f==0:
    h=c*(a//b)
else:
    h=c*((a//b)+1)
if g==0:
    i=e*(a//d)
else:
    i=e*((a//d)+1)

print(min(h,i))

Python: import math
N, A, B, C, D=map(int,input().split())
x=math.ceil(N/A)
y=x*B
z=math.ceil(N/C)
r=z*D
print(min(y,r))

Python: n, a, b, c, d=map(int, input().split())

pricea = ((n+a-1)//a)*b
pricec = ((n+c-1)//c)*d
if pricea > pricec:
    print(pricec)
else:
    print(pricea)

Python: N,A,B,C,D=map(int,input().split())
print(min((N+A-1)//A*B,(N+C-1)//C*D))

Python: def find_cost(n, a, b):
    if n % a == 0:
        return b * (n // a)
    else:
        return b * ((n // a) + 1)

n, a, b, c, d = map(lambda x: int(x), input().split(" "))
ans = 1e9
ans = min(ans, find_cost(n, a, b))
ans = min(ans, find_cost(n, c, d))
print(ans)

Python: # -*- coding: utf-8 -*-
N,A,B,C,D = map(int,input().split())

pencilsX = 0
ansX = 0
while True:
    pencilsX += A
    ansX += B
    if pencilsX >= N:
        break

pencilsY = 0
ansY = 0
while True:
    pencilsY += C
    ansY += D
    if pencilsY >= N:
        break

print(min(ansX, ansY))

Python: N,A,B,C,D=map(int,input().split())
print(min((N+A-1)//A*B,(N+C-1)//C*D))

Python: N,a,b,c,d=map(int,input().split())

aa=int((N+a-1)/a)
bb=int((N+c-1)/c)

cc=aa*b
dd=bb*d

if cc>dd :
    print(dd)

else :
    print(cc)

Python: N,A,B,C,D=map(int,input().split())
x=N//A
y=N//C
if x==N/A:
    X=N//A
else:
    X=N//A+1

if y==N/C:
    Y=N//C
else:
    Y=N//C+1

if X*B > Y*D:
    print(Y*D)
else:
    print(X*B)

Python: n,a,b,c,d = map(int,input().split())

xpen=0
xmoney=0
ypen=0
ymoney=0

while(xpen<n):
    xpen=xpen+a
    xmoney=xmoney+b
while(ypen<n):
    ypen=ypen+c
    ymoney=ymoney+d

if(xmoney>ymoney):
    print(ymoney)
else:
    print(xmoney)