Problem:
 Score : 300 points    Problem Statement You've come to your favorite store Infinitesco to buy some ice tea.  The store sells ice tea in bottles of different volumes at different costs.
Specifically, a 0.25 -liter bottle costs Q yen, a 0.5 -liter bottle costs H yen, a 1 -liter bottle costs S yen, and a 2 -liter bottle costs D yen.
The store has an infinite supply of bottles of each type.  You want to buy exactly N liters of ice tea. How many yen do you have to spend?      Constraints  1 \leq Q, H, S, D \leq 10^8  1 \leq N \leq 10^9  All input values are integers.         Input Input is given from Standard Input in the following format:  Q  H  S  D  N       Output Print the smallest number of yen you have to spend to buy exactly N liters of ice tea.        Sample Input 1 20 30 70 90
3      Sample Output 1 150  Buy one 2 -liter bottle and two 0.5 -liter bottles. You'll get 3 liters for 90 + 30 + 30 = 150 yen.       Sample Input 2 10000 1000 100 10
1      Sample Output 2 100  Even though a 2 -liter bottle costs just 10 yen, you need only 1 liter.
Thus, you have to buy a 1 -liter bottle for 100 yen.       Sample Input 3 10 100 1000 10000
1      Sample Output 3 40  Now it's better to buy four 0.25 -liter bottles for 10 + 10 + 10 + 10 = 40 yen.       Sample Input 4 12345678 87654321 12345678 87654321
123456789      Sample Output 4 1524157763907942

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
n *= 4

lst = [[1, q, q*4], [2, h, h*2], [4, s, s], [8, d, d/2]]
lst.sort(key=lambda x: x[2])

ans = 0
for i in range(4):
    volume = lst[i][0]
    price = lst[i][1]
    ans += price * (n//volume)
    n = n % volume

print(ans)

Solution (Python):
q,h,s,d = map(int,input().split())
N = int(input())
one = min(q*4,h*2,s)
print(min(one*N,d*(N//2)+one*(N%2)))

Solution (Python):
q,h,s,d = map(int, input().split())
n = int(input())

print((n//2 * min(q*8,h*4,s*2,d)) + (n%2 * min(q*4,h*2,s)))

Solution (Python):
Q,H,S,D = map(int,input().split())
N = int(input())
cnt = (N//2)*min(8*Q,4*H,2*S,D)
if N%2==1:
    cnt += min(4*Q,2*H,S)
print(cnt)

Solution (Python):
q, h, s, d = map(int, input().split())
n =int(input())
ans = min([4*n*q, 2*n*h, n*s, (n//2)*d+(n%2)*min(4*q, 2*h, s)])
print(ans)

Solution (Python):
q,h,s,d = map(int, input().split())
n = int(input())

if q*2 < h: h = q*2
if h*2 < s: s = h*2
if s*2 < d: d = s*2

ans = n//2*d
n -= n//2 * 2
ans += n*s
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

Q, H, S, D = map(int, input().split())
N = int(input())
S = min(S, 4*Q, 2*H)
D = min(D, 8*Q, 4*H, 2*S)
print(N//2*D+N%2*S)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    Q, H, S, D = map(int,input().split())
    N = int(input())
    print((N//2)*min(Q*8,H*4,S*2,D)+(N%2)*min(Q*4,H*2,S))
    
if __name__ == '__main__':
    main()

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
Q1 = Q * 4
H1 = H * 2
D1 = D / 2
if min(Q1, H1, S) > D1:
  ans = D * (N // 2) + min(Q1, H1, S) * (N % 2)
else:
  ans = min(Q1, H1, S) * N
  
print(ans)

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
l_1 = min((Q * 4), (H * 2), (S * 1))
l_2 = min((Q * 8), (H * 4), (S * 2), (D * 1))
ans = 0

if N == 1:
    ans = int(l_1)
elif N % 2 == 0:
    ans = int(l_2 * (N // 2))
else:
    ans = int(((N - 1) // 2) * l_2 + l_1)
print(ans)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
o = min(4*q, 2*h, s)
if 2*o <= d:
	print(o * n)
else:
	print(d*(n//2) + o*(n%2))

Solution (Python):
import math
q,h,s,d = map(int,input().split())
n = int(input())
value = [0]*4
value[0] = q*4
value[1] = h*2
value[2] = s
value[3] = d/2
dum = min(value)
ind = value.index(dum)
if ind == 0:
    print(value[0]*n)
elif ind == 1:
    print(value[1]*n)
elif ind == 2:
    print(value[2]*n)
else:
    if n == 1:
        value.sort()
        print(value[1])
    elif n%2 == 0:
        print(math.floor(d*n//2))
    else:
        dum1 = (n//2)*d
        value.sort()
        print(math.floor(value[1]+dum1))

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())

price = [(8 * Q, 0.25), (4 * H, 0.5), (2 * S, 1.0), (D, 2.0)]
price.sort()

res = 0
if N % 2 == 0:
    res += N // 2 * price[0][0]
else:
    res += (N - 1) // 2 * price[0][0]
    for p in price:
        if p[1] == 2.0:
            continue
        res += p[0] // 2
        break

print(int(res))

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())

l1 = min(h*2, q*4, s)
l2 = min(8*q, h*4, s*2, d)

ans = n//2 * l2 + n%2 * l1
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())
    ans = N//2*min(8*Q, 4*H, 2*S, D) + N%2*min(4*Q, 2*H, S)

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    q, h, s, d = map(int, input().split())
    N = int(input())

    one = min([4*q, 2*h, s])
    print(min((N//2)*d+one*(N % 2), N*one))


resolve()

Solution (Python):
q, h, s, d = list(map(int, input().split()))
n = int(input())
qpl = 4 * q
hpl = 2 * h
spl = s
dpl = d / 2
s_min = min(qpl, hpl, spl)
if dpl >= s_min:
    print(s_min * n)
elif n % 2 == 0:
    print(d * (n // 2))
else:
    print(d * (n // 2) + s_min)

Solution (Python):
q,h,s,d = [int(x) for x in input().split()]
n = int(input())

print((n//2) * min(8*q, 4*h, 2*s, d) + (n%2) * min(4*q, 2*h, s))

Solution (Python):
q,h,s,d = map(int, input().split())
n = int(input())
q*=4
h*=2
one = min(q,h,s)
c1 = n//2*d + n%2*one
c2 = n*one
print(min(c1,c2))

Solution (Python):
q,h,s,d=map(int,input().split())
n=int(input())
Q=4*q
H=2*h
S=s
D=d/2
b=[Q,H,S,D]
a=sorted(b)
if a[0]==D and n%2==1:
    ans=(n//2)*d+a[1]
elif a[0]==D:
    ans=(n//2)*d
else:
    ans=n*a[0]
print(ans)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True




def warshall_floyd(d, n):
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d



def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


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


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


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


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






def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



q, h, s, d = map(int, input().split())
n = int(input())
ans = 0
while n > 0:
    if n >= 2:
        ans += min(8 * q, 4 * h, 2 * s, d) * (n // 2)
        n = n % 2
    elif n == 1:
        ans += min(4 * q, 2 * h, s)
        break
print(ans)

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())

new_S = min(2 * min(2 * Q, H), S)
if 2 * new_S >= D:
    q, r = divmod(N, 2)
    print(q * D + r * new_S)
else:
    print(N * new_S)

Solution (Python):
Q,H,S,D = map(int, input().split())
N = int(input())

onelit = min((4*Q),(2*H),(S))

pattern1 = N * onelit
pattern2 = ((N//2)*D) + ((N%2) * onelit)

print(min(pattern1, pattern2))

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
m = 0
l = [q, min(q*2, h), min(q*4, h*2, s), min(q*8, h*4, s*2, d)]

m += (n // 2) * l[3] + (n % 2) * l[2]

print(int(m))

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    Q,H,S,D = MI()
    N = I()
    if(Q*2<H):
        H=2*Q
    if(H*2<S):
        S=H*2
    if(S*2<D):
        D=S*2
    print(N//2*D + ((N&1)*S))
if __name__ == '__main__':
    main()

Solution (Python):
q,h,s,d = map(int, input().split())
n = int(input())
l1 = min(min(4*q,2*h),s)
l2 = min(2*l1, d)
print(n//2*l2 + n%2*l1)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
s = min(4*q, 2*h, s)
ans = n//2*min(2*s, d)
ans += s*(n%2)
print(ans)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
Q,H,S,D = LI()
N = I()
min_1 = min(Q*4,H*2,S)
if 2*min_1<=D:
    ans = min_1*N
else:
    ans = N//2*D+(min_1 if N%2==1 else 0)
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())

    ans = 0
    price_of_1_L = min(4 * Q, 2 * H, S)
    if D < 2 * price_of_1_L:
        n_D = N // 2
        ans += D * n_D
        N -= 2 * n_D
    ans += N * price_of_1_L

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
p = list(map(int, input().split()))
n = int(input())
eff = [p[0], p[1] / 2, p[2] / 4, p[3] / 8]
g = [0.25, 0.5, 1, 2]
total = 0
ans = 0
def calc(i):
    global total, ans
    k = eff.index(min(eff[: i + 1]))
    ans += int((n - total) // g[k] * p[k])
    total += (n - total) // g[k] * g[k]


while total != n:
    if n - total >= 2:
        calc(3)
    elif n - total >= 1:
        calc(2)
    elif n - total >= 0.5:
        calc(1)
    else:
        total += 0.25
        ans += p[0]
print(ans)

Solution (Python):
Q,H,S,D = list(map(int,input().split()))
N = int(input())*100
TL = sorted([(25,Q,8*Q),(50,H,4*H),(100,S,2*S),(200,D,D)],key=lambda x: x[2])
ans = 0
if N >= TL[0][0]:
    ans += (N//TL[0][0])*TL[0][1]
    N %= TL[0][0]
if N >= TL[1][0]:
    ans += (N//TL[1][0])*TL[1][1]
    N %= TL[1][0]
if N >= TL[2][0]:
    ans += (N//TL[2][0])*TL[2][1]
    N %= TL[2][0]
if N >= TL[3][0]:
    ans += (N//TL[3][0])*TL[3][1]
    N %= TL[3][0]
print(ans)

Solution (Python):
Q,H,S,D=map(int, input().split())
N=int(input())
a=min(8*Q,4*H,2*S,D)
b=min(4*Q,2*H,S)
if N%2==0:
  print(a*(N//2))
else:
  print(a*(N//2)+b)

Solution (Python):
from decimal import Decimal

Q, H, S, D = map(int, input().split())
N = int(input())


s = min([Q*4, H*2, S])
d = Decimal(D)/2


if N%2==0:
    print(int(N*min(s, d)))


else:
    print(int((N-1)*min(s, d) + s))

Solution (Python):
Q, T, S, D = map(int, input().split())
N = int(input())

for_1L = min(4*Q, 2*T, S)
for_2L = min(2*for_1L, D)

print((N//2)*for_2L + (N%2)*for_1L)

Solution (Python):


Q, T, S, D = map(int, input().split())
N = int(input())

for_1L = min(4*Q, 2*T, S)
for_2L = min(2*for_1L, D)

print((N//2)*for_2L + (N%2)*for_1L)

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
n = N // 2 * 2
ans =  min(n * Q * 4, n * H * 2, n * S, n * D // 2)
if N % 2 == 1:
    ans += min(Q * 4, H * 2, S)
print(ans)

Solution (Python):



































q, h, s, d = map(int, input().split())
n = int(input())
 
cost_per_2l = min(q*8, h*4, s*2, d)
cost_per_1l = min(q*4, h*2, s)
 
a = n // 2
b = n % 2
 
print(a*cost_per_2l + b*cost_per_1l)

Solution (Python):
q , h , s , d = map(int,input().split())
n = int(input())
qb = q*8
hb = h*4
sb = s*2
db = d

if min(qb,hb,db,sb) != db:
    print(n*min(q*4,h*2,s))
elif min(qb,hb,db,sb) == db:
    if n % 2 == 0:
        print((n//2)*d)
    elif n % 2 == 1:
        ans = (n//2) * d
        ans += min(q*4,h*2,s)
        print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    q,h,s,d=map(int, input().split())
    n=int(input())
    s=min(4*q,2*h,s)
    if 2*s<=d:
        print(n*s)
    else:
        a,b=divmod(n,2)
        print(a*d+b*s)
resolve()

Solution (Python):
q,h,s,d = map(int,input().split())

n = int(input())

price = [q,h,s,d]
base = [8,4,2,1]
quant = [1,2,4,8]

comp = []
for i in range(4):
    comp.append([price[i]*base[i],i])

comp.sort()


ans = 0
n *= 4

for ind in range(4):
    tag = comp[ind][1]
    p = price[tag]
    q = quant[tag]
    pos = n//q
    
    if pos >= 0:
        ans += p*pos
        n -= q*pos
    else:
        continue

print(ans)

Solution (Python):

q, h, s, d = map(int, input().split())
n = int(input())

ans = (n // 2) * min(d, 2 * s, 4 * h, 8 * q) + (n % 2) * min(s, 2 * h, 4 * q)

print(ans)

Solution (Python):
Q,H,S,D=list(map(int,input().split()))
N=int(input())
ans=0
min_tea=min(Q*8,H*4,S*2,D)
ans+= (N//2) * min_tea
N-=(N//2)*2
min_tea=min(Q*4,H*2,S*1)
ans+= (N//1) * min_tea
print(ans)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())

cost_per_2l = min(q*8, h*4, s*2, d)
cost_per_1l = min(q*4, h*2, s)

a = n // 2
b = n % 2

print(a*cost_per_2l + b*cost_per_1l)

Solution (Python):
Q,H,S,D=map(int,input().split())
N=int(input())
if H > 2*Q:
    H=2*Q
if S > 2*H:
    S=2*H
if D < 2*S:
    ans = N//2*(D)+(N%2)*S
else:
    ans = N*S
print(ans)

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from collections import Counter
def resolve():
    Q,H,S,D=pin()
    N=int(input())
    Q*=4
    H*=2
    s=min(Q,H,S)
    t=N%2
    ans=0
    if s*2>D:
        ans+=D*(N//2)
        
        N=t
    ans+=N*s
    print(ans)

resolve()

Solution (Python):
q, h, s, d = map(int, input().strip().split())
n = int(input())

sorted_list = sorted([(q, 4), (h, 2), (s, 1), (d, 0.5)],
                     key=lambda t: t[0] * t[1])

cheapest = sorted_list[0]
if cheapest[1] == 0.5:
    
    second = sorted_list[1]
    cost = cheapest[0] * (n // 2) + second[0] * (n % 2) * second[1]
else:
    cost = cheapest[0] * cheapest[1] * n

print(cost)

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())

c_05 = min(2*Q, H)
c_1 = min(2*c_05, S)

if 2*c_1 <= D:
    print(c_1 * N)
else:
    if N % 2 == 0:
        print(D * (N//2))
    else:
        print(D * (N//2) + c_1)

Solution (Python):
q,h,s,d=map(int, input().split( ))
n=int(input())
n*=4
lst=[(q*4,q,1),(h*2,h,2),(s,s,4),(d/2,d,8)]
lst.sort()
ans=0
for _,t,x in lst:
    ans+=(n//x)*t
    n-=(n//x)*x
print(ans)

Solution (Python):
q,h,s,d=map(int, input().split())
n = int(input())
q*=4
h*=2
t = min(q, h, s)
ans=0
while n!=0:
    if n==1:
        ans+=t
        break
    if n%2==1:
        if 2*t < d:
            ans+=2*t*(n-1)//2
            n=1
        else:
            ans+=d*(n-1)//2
            n=1
    else:
        if 2*t < d:
            ans+=t*(n)
            n=0
        else:
            ans+=d*(n)//2
            n=0

print(ans)

Solution (Python):
q,h,s,d = map(int,input().split())
n = int(input())
print(min(q*n*4,h*n*2,s*n,(n//2)*d+(n%2)*s,(n//2)*d+(n%2)*h*2,(n//2)*d+(n%2)*q*4))

Solution (Python):

"""
Created on Sat May  9 23:33:40 2020

@author: shinba
"""

q,h,s,d = map(int,input().split())

n = int(input())

a = [4*q,2*h,s,d/2]

a.sort()

if a[0] != d/2:
    print(int(n*a[0]))

else:
    if n % 2 == 0:
        print(d*int(n/2))
    else:
        print(d*int(n/2)+int(a[1]))

Solution (Python):
Q,H,S,D = map(int,input().split())
N = int(input())

S = min(S,2*H,4*Q)
if N != 1:
  if 2*S <= D:
    print(S*N)
  else:
    print(D*(N//2) +(N%2)*S)
else:
  print(S)

Solution (Python):
def main():
    Q,H,S,D=map(int,input().split())
    N=int(input())
    S=min(S,2*(min(H,2*Q))) 
    print(S*N if 2*S<=D else (N//2)*D+(N%2)*S)

main()

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
q_cp = q*8
h_cp = h*4
s_cp = s*2
d_cp = d
ans = 0
if min(q_cp,h_cp,s_cp,d_cp)==q_cp:
    ans+=n*q*4
elif min(q_cp,h_cp,s_cp,d_cp)==h_cp:
    ans+=n*h*2
elif min(q_cp,h_cp,s_cp,d_cp)==s_cp:
    ans+=n*s
else:
    ans += n//2*d
    amari = n%2
    if min(q_cp, h_cp, s_cp) == q_cp:
        ans += amari*q*4
    elif min(q_cp, h_cp, s_cp) == h_cp:
        ans += amari*h*2
    elif min(q_cp, h_cp, s_cp) == s_cp:
        ans += amari*s
print(int(ans))

Solution (Python):


q, h, s, d = map(int, input().split())
n = int(input())
ans = (n // 2) * min([q * 8, h * 4, s * 2, d]) + (n % 2) * min([q * 4, h * 2, s])
print(ans)

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
q, h, s, d = map(int, sys.stdin.readline().rstrip().split())
N = I()
D = d
qh = min(2*q, h)
S = min(2*qh, s)
x = min(2*S, D)
if N%2 == 0:
    print(N//2*x)
else:
    print(N//2*x + S)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())

q *= 4
h *= 2
d_ = d / 2

tmp = min(q, h, s)
ans = 0
if d_ < tmp:
    ans += d * (n // 2)
    ans += tmp * (n % 2)
else:
    ans += n * tmp

print(ans)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
min_2l = min(8*q, 4*h, 2*s, d)
min_1l = min(4*q, 2*h, s)
if n % 2 == 0:
  cost = (n // 2) * min_2l
else:
  cost = (n // 2) * min_2l + min_1l
print(cost)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
s = min(q*4, h*2, s)
if s*2 <= d: print(s*n)
else: print(d*(n//2) + s*(n%2))

Solution (Python):
q,h,s,d=map(int,input().split());n=int(input());print(n//2*min(8*q,4*h,2*s,d)+n%2*min(4*q,2*h,s))

Solution (Python):
q,h,s,d=map(int,input().split())
n=int(input())
m=n//2*min(8*q,4*h,2*s,d)+n%2*min(4*q,2*h,s)
print(m)

Solution (Python):
q,h,s,d = map(int,input().split())
n = int(input())
m = min(8*q,4*h,2*s,d)*(n//2) + min(4*q,2*h,s)*(n%2)
print(m)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())

L = min(4*q, 2*h, s)
L2 = min(2*L, d)

print((n//2)*L2 + (n%2)*L)

Solution (Python):
Q,H,S,D = map(int,input().split())
N = int(input())

ans = min(8 * Q,4 * H,2 * S ,D) * (N // 2) + min(4 * Q,2 * H,S) * (N % 2)

print(ans)

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
Q *= 4
H *= 2
if(N == 1): print(min(Q, H, S))
elif(N == 2): print(min(Q * 2, H * 2, S * 2, D))
else:
    ans = 0
    if(N % 2):
        N = N - 1
        ans += min(N * Q, N * H, N * S, (N // 2) * D)
        ans += min(Q, H, S)
    else:
        ans += min(N * Q, N * H, N * S, (N // 2) * D)
    print(ans)

Solution (Python):
q,h,s,d = map(int,input().split())
n = int(input())

d1 = min(q*4, h*2, s)
if d1*2 < d:
    print(n*d1)
else:
    print(n//2*d + n%2*d1)

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
l = min(4*Q, 2*H, S)
if 2*l > D:
  print(D*(N//2) + N%2 * l)
else:
  print(l*N)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
if min(q*8, h*4, s*2)<=d:
    print(min(q*4, h*2, s)*n)
else:
    print(n//2*d+min(q*4, h*2, s)*(n%2))

Solution (Python):
import sys
input = sys.stdin.readline


prices = list(map(int, input().split()))
n = int(input())

stores = []
units = [1, 2, 4, 8]
magnifications = list(reversed(units))

for i in range(4):
	compared_price = prices[i] * magnifications[i]
	store = [units[i], prices[i], compared_price]
	stores.append(store)


stores.sort(key=lambda x:x[2])

amount = n * 4
ans = 0

for i in range(4):
	unit = stores[i][0]
	price = stores[i][1]

	ans += price * (amount//unit)
	amount %= unit

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline
MOD = 1000000007

Q,H,S,D = map(int,input().split())
N = int(input())


min_1L = min(min(4*Q,2*H),S)

min_2L = min(D,2*min_1L)


print(N//2*min_2L + N%2*min_1L)

Solution (Python):
q,h,s,d,n=map(int,open(0).read().split())
if n%2==0:
  print(min(8*q,4*h,2*s,d)*(n//2))
else:
  print(min(8*q,4*h,2*s,d)*(n//2)+min(4*q,2*h,s))

Solution (Python):
q,h,s,d = map(int,input().split())
n = int(input())

ans = 0

if n>=2:
    amount = n//2
    n-=amount*2
    ans+=min(q*8,h*4,s*2,d*1)*amount
if n==1:
    ans+=min(q*4,h*2,s*1)
print(ans)

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    q,h,s,d = MII()
    n = II()
    print(int((n//2)*min(8*q, 4*h, 2*s, d) + (n%2)*min(4*q, 2*h, s)))

if __name__ == '__main__':
    main()

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    q,h,s,d = MII()
    n = II()
    pay = [q*4,h*2,s,d/2]
    pay_sorted = sorted(pay)
    min1 = pay_sorted[0]
    min1_index = pay.index(min1)
    min2 = pay_sorted[1]
    min2_index = pay.index(min2)

    if min1_index == 0:
        print(int((n//0.25)*q))
    elif min1_index == 1:
        print(int((n//0.5)*h))
    elif min1_index == 2:
        print(int(n)*s)
    else:
        res = int(n//2)*d
        if n%2 == 1:
            res += pay[min2_index]
        print(res)

if __name__ == '__main__':
    main()

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
single = min(Q * 4, H * 2, S)
div, mod = divmod(N, 2)
print(min(single * N, int(D * div) + int(single * mod)))

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
single = min(Q * 4, H * 2, S)
print(min(single * N, N // 2 * D + N % 2 * single))

Solution (Python):
Q, H, S, D = map(int, input().split())
prices = {0.25: Q, 0.5: H, 1: S, 2: D}
n = int(input())
costs = {0.25: Q * 8, 0.5: H * 4, 1: S * 2, 2: D}
costs_sorted = sorted(costs.items(), key=lambda x: x[1])
ans = 0
for cost in costs_sorted:
    quantity = cost[0]
    div, n = divmod(n, quantity)
    ans += int(prices[quantity] * div)
    if n == 0:
        break

print(ans)

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())

H = min(H, 2 * Q)
S = min(S, 2 * H)

res = 0
if 2 * S <= D:
	res = N * S
elif 2 * S > D:
	if N % 2 == 0:
		res = D * (N // 2)
	else:
		res = D * (N // 2) + S

print(res)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

q, h,s,d, = map(int, input().split())

n = int(input())
ans = 0

qqqq = q*4
hh = h*2

best1 = min(qqqq,hh,s)

if n ==1:
    print(best1)
    exit()

if d >= best1*2:
    print(n*best1)
    exit()


else:
    d_ = n//2
    n -= d_*2
    ans += d*d_
    ans += n*best1
    print(ans)

Solution (Python):
q,h,s,d = map(int,input().split())
n = int(input())
s = min(q*4, h*2,s)
print(min(s*n, n//2*d + (n%2)*s))

Solution (Python):
from itertools import permutations
def main():
    C = list(map( int, input().split()))
    S = [1, 2, 4,8]
    N = 4*int( input())
    ans = 10**20
    for P in permutations( range(4)):
        cost = 0
        left = N
        for i in P:
            cost += left//S[i]*C[i]
            left -= left//S[i]*S[i]
        if cost < ans:
            ans = cost
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
a,b,c,d= map(int,input().split())
A=min(min(4*a,2*b),c)
B=min(2*A,d)

n=int(input())
if n %2==0:
    print(n*B//2)
else:
    print((n//2)*B + A)

Solution (Python):
A = list(map(int,input().split()))
n = int(input())
base = {}
for i in range(4):
    tmp = 2**(i)
    base.update({i:A[i]/tmp})
dict = sorted(base.items(), key=lambda x: x[1])
m = n*4
ans = 0
for x in dict:
    y = 2**(x[0])
    kosuu = m // y
    m -= y*kosuu
    ans += kosuu*A[x[0]]
print(ans)

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
kouho = []
mv = int(1e9)

if N % 2 == 0:
    for i, j in zip([Q, H, S, D], [0.25, 0.5, 1, 2]):
        kouho.append(int((N // j)*i))
else:
    for i, j in zip([Q, H, S, D], [0.25, 0.5, 1, 2]):
        kouho.append(int((N // j)*i))

    for i, j in zip([Q, H, S], [0.25, 0.5, 1]):
        mv = int(min(i // j, mv))
    kouho[-1] += mv
print(min(kouho))

Solution (Python):
from decimal import Decimal as de
q,h,s,d=map(de,input().split())
n=de(input())
ans=0

if n%2:
    ans+=min(4*q,2*h,s)
    n-=1
print(int((ans+n*min(4*q,2*h,s,d/2))//1))

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())

h = min(q*2,h)
s = min(h*2,s)
if 2*s >= d:
    a,b = n//2, n%2
    print(a*d+b*s)
else:
    print(n*s)

Solution (Python):
Q,H,S,D = list(map(int, input().split()))
N = int(input())
minone = min(4*Q, 2*H, S)
mintwo = min(minone*2, D)
print(N//2 * mintwo + N%2 * minone)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())

qq = 4 * q
hh = 2 * h

one = min(qq, min(hh, s))

if one < d / 2:
    print(n * one)
else:
    print((n // 2) * d + (n % 2) * one)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
cost = 0

q_ef = q*8
h_ef = h*4
s_ef = s*2

if min(q_ef, h_ef, s_ef, d) == d:
    cost += d * (n//2)
    n %= 2

if min(q_ef, h_ef, s_ef) == q_ef:
    cost += q * (n*4)
elif h_ef <= s_ef:
    cost += h * (n*2)
else:
    cost += s * n

print(cost)

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    q,h,s,d = readInts()
    n = int(input())
    
    
    
    
    one = min(q*4, h*2, s)
    
    
    print(min(one*n, d*(n//2) + one * (n%2)))

if __name__ == '__main__':
  main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    q, h, s, d = map(int, input().split())
    n = int(input())
    t = min(q * 4, h * 2, s)

    if n == 1:
        print(int(t))
    else:
        if n % 2 == 0:
            print(int(min(t * n, d * n // 2)))
        else:
            print(int(min(t * n, d * ((n - 1) // 2) + t)))


if __name__ == '__main__':
    resolve()