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):









import sys
input = sys.stdin.readline

Price = list(map(int, input().split()))
Volume = [0.25, 0.5, 1, 2]
Pper = [p/v for (p, v) in zip(Price, Volume)]
N = int(input())

ans = 0
n = Pper.index(min(Pper))
if n != 3:
    ans = int(N/Volume[n]) * Price[n]
else:
    ans = N//2 * Price[3]
    m = Pper.index(min(Pper[:3]))
    nokori = N % 2
    ans += int(nokori/Volume[m]) * Price[m]

print(ans)

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

ans = 0

s = min(s, 2*min(h, 2*q))

if s*2 <= d:
    ans = s*n
elif s*2 > d:
    ans = n//2*d + n%2*s

print(ans)

Solution (Python):
s = list(map(int, input().split()))
n = int(input()) * 100
ss = [s[0] * 4, s[1] * 2, s[2], s[3] // 2]
ll = [25, 50, 100, 200]
cost = 0
while n > 0:
    if n >= 200:
        pass
    elif n >= 100:
        ss = ss[:3]
        ll = ll[:3]
    elif n >= 50:
        ss = ss[:2]
        ll = ll[:2]
    else:
        ss = ss[:1]
        ll = ll[:1]
    ssm = ss.index(min(ss))
    cnt = n // ll[ssm]
    cost += s[ssm] * cnt
    n -= ll[ssm] * cnt
print(cost)

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

print(min(n*min_1l, (n//2)*min_2l + (n%2)*min_1l))

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input()) * 4
L = [[8*Q, 1, Q], [4*H, 2, H], [2*S, 4, S], [D, 8, D]]
L.sort()
ans = 0
for l in L:
  s, t = N // l[1], N % l[1]
  ans += s * l[2]
  N = t
print(ans)

Solution (Python):
from math import inf

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

L=inf
M=inf
for a in range(8+1):
    for b in range(4+1):
        for c in range(2+1):
            for d in range(1+1):
                if a+2*b+4*c+8*d==8:
                    L=min(L,a*Q+b*H+c*S+d*D)
                    
            if a+2*b+4*c==4:
                M=min(M,a*Q+b*H+c*S)

if N%2:
    print(L*(N//2)+M)
else:
    print(L*(N//2))

Solution (Python):
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    min_1 = min(q*4, h*2, q*2+h, s)
    min_2 = min(min_1*2, d)

    print((n % 2)*min_1 + (n // 2)*min_2)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    min_1 = min(q*4, h*2, q*2+h, s)
    min_2 = min(min_1*2, d)

    print((n % 2)*min_1 + (n // 2)*min_2)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    min_1 = min(q*4, h*2, q*2+h, s)
    min_2 = min(min_1*2, d)

    print((n % 2)*min_1 + (n // 2)*min_2)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

Q,H,S,D = I()
N = i()

a = N // 2
b = N // 1
c = N // 0.5
d = N // 0.25

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

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

Solution (Python):
Q, H, S, D = [int(_) for _ in input().split()]
N = int(input())

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

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

Solution (Python):
price = [int(x) for x in input().split()];
N = int(input());
price_d = price[3];
price_s = 2*price[2];
price_h = 4*price[1];
price_q = 8*price[0];
p = min([price_q,price_h,price_s]);
if price_d < p :
    if N%2 == 1 :
        ans = (N-1)//2*price_d + p//2;
    else :
        ans = N//2*price_d;
else :
    ans = N*p//2;

print(ans);

Solution (Python):
Q,H,S,D=list(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)

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

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

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

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

Solution (Python):
a, b, c, d = map(int, input().split())
n = int(input())
 
b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)
 
q, r = divmod(n, 2)
x = q * d + r * c
print(x)

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



Q *= 4
H *= 2

one_litter = min(Q, H, S)  

if 2 * one_litter < D:  
    ans = N * one_litter
else:  
    ans = N // 2 * D + (N % 2) * one_litter

print(ans)

Solution (Python):
a, b, c, d = map(int, input().split())
num = int(input())
 
if num % 2 == 0:
    Min = min(num*a*4, num*b*2, num*c, num//2*d)
else:
    Min = min((num-1)*a*4, (num-1)*b*2, (num-1)*c, num//2*d) + min(4*a, 2*b, c)
print(Min)

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

Solution (Python):
a = list(map(int, input().split()))
n = int(input())
if n >= 2:
    if n % 2 == 0:
        print(int((n//2)*min(a[0]*8, a[1]*4, a[2]*2, a[3])))
    else:
        print(int((n//2)*min(a[0]*8, a[1]*4, a[2]*2, a[3])+min(a[0]*4, a[1]*2, a[2])))
else:
    print(min(a[0]*4, a[1]*2, a[2]))

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

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

Solution (Python):
Q,H,S,D=map(int,input().split())
N=int(input())
N2,N1=divmod(N,2)
tmp2=min(8*Q,4*H,2*S,D)
tmp1=min(4*Q,2*H,S)
ans2=N2*tmp2
ans1=N1*tmp1
ans=ans1+ans2
print(ans)

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

L=min(4*Q, 2*H,S)
if 2*L<=D:
    ans=N*L
else:
    m=N//2
    ans=m*D+L*(N-2*m)
    
print(ans)

Solution (Python):
def resolve():
    Q, H, S, D = list(map(int, input().split()))
    N = int(input())
    ans = 0

    ls = [[0.25, Q, 8*Q, 0], [0.5, H, 4*H, 0], [1, S, 2*S, 0], [2, D, D, 0]]
    ls.sort(key=lambda x: x[2])

    for i in range(4):
        if N < ls[i][0]:
            continue

        ls[i][3] += int(N // ls[i][0])
        N -= ls[i][0] * ls[i][3]

        ans += ls[i][1] * ls[i][3]

    ans = int(ans)
    print(ans)
    return


resolve()

Solution (Python):
from collections import defaultdict
import bisect

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

q,h,s,d = readInts()
n = readInt()

reasonable = [-1,-1]
value = {"0.25":q,"0.5":h,"1":s,"2":d}
t = min(8*q,4*h,2*s,d)
if t==8*q:
  reasonable = [0.25,q]
  ans = (n//reasonable[0])*reasonable[1]
  print(int(ans))
elif t==4*h:
  reasonable = [0.5,h]
  ans = (n//reasonable[0])*reasonable[1]
  print(int(ans))
elif t==2*s:
  reasonable = [1,s]
  ans = (n//reasonable[0])*reasonable[1]
  print(ans)
else:
  reasonable = [2,d]
  remain = n%2
  money = 0
  if remain==1:
    money = min(4*q,2*h,1*s)
  print(int(money)+(n//reasonable[0])*reasonable[1])

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

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

Solution (Python):
q, h, s, d = [int(i) for i in input().split()]
n = int(input())
d = min(min(d, s*2), min(h*4, q*8))
s = min(s, min(h*2, q*4))
h = min(h, q*2)
ans = (n // 2) * d
n %= 2
while n > 0:
    if n >= 1:
        n -= 1
        ans += s
    elif n >= 0.5:
        n -= 0.5
        ans += h
    else:
        n -= 0.25
        ans += q

print(ans)

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

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

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

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

l = min(4*q, 2*h, s)
l_2 = min(2*l, d)

print((n//2) * l_2 + (n%2) * l)

Solution (Python):
def resolve():
    
    
    Q, H, S, D = [int(i) for i in input().split()]
    N = int(input())
    a = []
    a.append(N * S)
    a.append(N * H * 2)
    a.append(N * Q * 4)
    if N > 1:
        if N % 2 == 0:
            a.append((N // 2) * D)
        else:
            a.append((N // 2) * D + S)
            a.append((N // 2) * D + H * 2)
            a.append((N // 2) * D + Q * 4)
    print(min(a))


resolve()

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
a = N // 2
b = N % 2

money = a * min(8*Q, 4*H, 2*S, D) \
        + b * min(4*Q, 2*H, S)

print(money)

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

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

b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)

q, r = divmod(N, 2)
x = q * d + r * c
print(x)

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, d, N = map(int, read().split())

b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)

q, r = divmod(N, 2)
x = q * d + r * c
print(x)

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):
q,h,s,d = map(int,input().split())
n = int(input())
s = min(s,min(q*2,h)*2)
if s*2<d:
    print(n*s)
else:
    if n%2==0:
        print((n//2)*d)
    else:
        print((n//2)*d+s)

Solution (Python):
y=list(map(int, input().split()))
N=int(input())
ans=0

if N>=2:
  tmp=min(y[0]*8, y[1]*4, y[2]*2, y[3])
  rep=N//2
  ans+=rep*tmp
  N-=rep*2

if N==1:
  ans+=min(y[0]*4, y[1]*2, y[2])

print(ans)

Solution (Python):
Q, H, S, D = map(int, input().split())
M = min(2 * Q, H)

N = int(input())

if N % 2 == 0:
  print(min(M * 2 * N, S * N, D * N // 2))
else:
  print(min((M * 2 * (N-1)) + M * 2, S * (N-1) + S, D * (N-1) // 2 + M * 2, D * (N-1) // 2 + S))

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

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

print(ans)

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

    H = min(H, 2*Q)
    S = min(S, 2*H, 4*Q)
    D = min(D, 2*S, 4*H, 8*Q)

    cost = [
        [0.25, Q],
        [0.5, H],
        [1, S],
        [2, D]
    ]

    cost.sort(reverse = True, key = lambda x : x[0])

    ans = 0
    for c in cost:
        if N <= 0:
            break

        r, m = divmod(N, c[0])
        ans += r*c[1]
        N -= r*c[0]

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

Q,H,S,D = I()
N = i()
A = [[Q*8,0.25,Q],[H*4,0.5,H],[S*2,1,S],[D,2,D]]
A.sort()
ans = 0
for i in range(4):
    a,b,c = A.pop(0)
    if b <= N:
        ans += int((N//b)*c)
        N -= (N//b)*b
    if N == 0:
        print(ans)
        break

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())*4
arr = [[Q, Q, 1], [H/2, H, 2], [S/4, S, 4], [D/8, D, 8]]
arr.sort()
ans = 0
for _, cost, size in arr:
    ans += (N//size)*cost
    N %= size
    if N == 0: break
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

Q, H, S, D = MAP()
N = INT()

ans1 = 4*Q*N
ans2 = 2*H*N
ans3 = S*N
ans4 = D*(N//2) + min(4*Q, 2*H, S)*(N%2)

print(min(ans1, ans2, ans3, ans4))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

Q, H, S, D = MAP()
N = INT()

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

print(ans)

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

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

l = min(Q*4, H*2, S)
ll = min(l*2, D)
res = N//2*ll
if N % 2 == 1:
    res += l

print(res)

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


cost_per_1L=min(q*4, h*2, s)

cost_per_2L=min(cost_per_1L*2, d)

q,r = divmod(n, 2)

print(cost_per_2L*q + cost_per_1L*r)

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

if n%2==0:
    print(min(unit*n,d*(n//2)))
else:
    print(min(unit*n,d*(n//2)+unit))

Solution (Python):
t=list(map(int,input().split()))
s=[t[i]*(2**(3-i)) for i in range(4)]
n=int(input())
p,d=divmod(n,2)
print(p*min(s)+d*min([i//2 for i in s[:3]]))

Solution (Python):
ans=0
q,h,s,d=map(int,input().split())
n=int(input())
l=[(q,q*8,0.25),(h,h*4,0.5),(s,s*2,1),(d,d,2)]
l.sort(key=lambda x:-x[1])
while n>0:
    c=l.pop()
    ans+=c[0]*int(n//c[2])
    n-=c[2]*int(n//c[2])
    
print(ans)

Solution (Python):
sizePrice = list(map(int, input().split()))
N = int(input())
oneLMin = min([sizePrice[0] * 4, sizePrice[1] * 2, sizePrice[2]])
twoLMin = min([oneLMin*2, sizePrice[3]])
ans = 0
if N % 2 == 0:
    ans = twoLMin * (N//2)
else:
    ans = twoLMin * ((N - 1)//2) + oneLMin
print(ans)

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


L2 = min(D,2*S,4*H,8*Q)
L1 = min(S,2*H,4*Q)

ans = 0

ans+= (N//2)*L2
ans+= (N%2) *L1
ans=int(ans)
print(ans)

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

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

a = min(A[0]*4, A[1]*2, A[2])
b = A[3]

ans = min(N * a, N//2*b + (N%2)*a)
print(ans)

Solution (Python):
q, h, s, d = [int(x) for x in input().split()]
n = int(input())
per_l = min(4 * q, 2 * h, s)   
per_2l = min(2 * per_l, d) 

print(per_2l * (n // 2) + per_l * (n % 2))

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

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

yen = 0

yen += (n//2)*d
yen += (n%2)*s

print(yen)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

Q, H, S, D = MAP()
N = INT()

ans1 = 4*Q*N
ans2 = 2*H*N
ans3 = S*N
ans4 = D*(N//2) + min(4*Q, 2*H, S)*(N%2)

print(min(ans1, ans2, ans3, ans4))

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    Q, H, S, D = map(int, input().split())
    N = int(input())
    Double = [Q * 8, H * 4, S * 2, D]
    Single = [Q * 4, H * 2, S]
    if N % 2 == 0: print(min(Double) * N // 2)
    else: print(min(Double) * (N - 1) // 2 + min(Single))

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
 
q,h,s,d=map(int,input().split())
n=int(input())

a=min(d,s*2,h*4,q*8) 
b=min(s,h*2,q*4) 
ans=0
ans+=(n//2)*a
n-=2*(n//2)
ans+=n*b
print(ans)

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    q,h,s,d=map(int,readline().split())
    n=int(readline())

    if n%2==0:
        print(min(4*q*n,2*h*n,s*n,d*n//2))
    else:
        tmp1=min(4*q*(n-1),2*h*(n-1),s*(n-1),d*(n-1)//2)
        tmp2=min(4*q,2*h,s)
        print(tmp1+tmp2)
        
if __name__=="__main__":
    main()

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

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

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

Solution (Python):






from collections import defaultdict











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

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
q,h,s,d = readInts()
n = I()

Q = 4*q;H = 2*h
print(min(d * (n//2) + n%2 * min(Q,H,s), min(Q,H,s)*n))

Solution (Python):
Q,H,S,D = map(int,input().split())
N = int(input())
a2 = min(Q*8,H*4,S*2,D)
ans = (N//2)*a2
a1 = min(Q*4,H*2,S)
ans += (N%2)*a1
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
print(n//2*d + n%2*s)

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

a = (N//2)*D + (N%2)*min(4*Q,2*H,S)
b = N*S
c = H*2*N
d = Q*4*N

print(min(a,b,c,d))

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

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

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

N = int(input())



o = min(q*4,h*2,s)

if o*2 <= d:
	print(o*N)
else:
	print(d*(N//2) + o*(N%2))

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


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 make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




Q,H,S,D = IL()
N = I()

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

Solution (Python):


import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

Q, H, S, D, N = map(int, read().split())
H = min(Q * 2, H)
S = min(H *2 , S)

if S * 2 < D:
    print(N * S)
else:
    print(N // 2 * D + N % 2 * S)

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

cost = [Q, min(Q*2, H), min(Q*4, H*2, S), min(Q*8, H*4, S*2, D)]

print(N//2*cost[3] + N%2*cost[2])

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


x = a*4
y = b*2
z = min(x,y,c)
if z == x:
    e = x
elif z == y:
    e = y
else:
    e = c

if e*2 <= d:
    print(e*n)
else:
    if n%2 == 0:
        print(d*n//2)
    else:
        print(d*(n//2)+e)

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

Solution (Python):
q,h,s,d=map(int,input().split())
n=int(input())
num1=n%2
num2=n//2
num10=min(q*4,h*2,s)
num20=min(q*8,h*4,s*2,d)
ans=0
if num1==1:
    ans+=num10
ans+=num2*num20
print(ans)

Solution (Python):



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

one=min(cost[0]*4,cost[1]*2,cost[2])

n=int(input())

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

if n%2==0:
    print(n//2*min(one*2,cost[3]))
else:
    print(n//2*min(one*2,cost[3])+one)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    Q, H, S, D = [int(x) for x in input().split()]
    N = int(input())

    ans = 0
    if Q * 8 > D and H * 4 > D and S * 2 > D:
        X, N = divmod(N, 2)
        ans += X * D

    if Q * 4 > S and H * 2 > S:
        print(ans + S * N)
    elif Q * 2 > H:
        print(ans + H * 2 * N)
    else:
        print(ans + Q * 4 * N)


    
    

if __name__ == '__main__':
    main()

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

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

Solution (Python):
q,h,s,d = map(int,input().split())
n = int(input())
q1 = q*4
h1 = h*2
q2 = q*8
h2 = h*4
s2 = s*2
b1 = 0
b2 = 0

if q1 <= h1 and q1 <= s:
    b1 = q1
elif h1 <= q1 and h1 <= s:
    b1 = h1
else:
    b1 = s


if  q2 <= h2 and q2 <= s2 and q2 <= d:
    b2 = q2
elif h2 <= q2 and h2 <= s2 and h2 <= d:
    b2 = h2
elif s2 <= q2 and s2 <= h2 and s2 <= d:
    b2 = s2
else:
    b2 = d

cnt1 = 0
cnt2 = 0

if b1*2 > b2:
    cnt1 = n//2
    cnt2 = n%2
    print((b2*cnt1)+(b1*cnt2))
else:
    print(b1*n)

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

q = Q * 8
h = H * 4
s = S * 2
d = D

rlt = 0

lst1 = [Q, H, S, D]
lst2 = [q, h, s, d]
lst3 = [q, h, s]

while N > 0:
  if N >= 2:
    a = lst2.index(min(lst2))
  else:
    a = lst3.index(min(lst3))
  if a == 0:
    rlt += lst1[0] * N * 4
    N = 0
  elif a == 1:
    rlt += lst1[1] * N * 2
    N = 0
  elif a == 2:
    rlt += lst1[2] *N
    N = 0
  else:
    rlt += lst1[3] * (N // 2)
    N = N % 2

print(rlt)

Solution (Python):
T = list(map(int,input().split()))
n = int(input())*4
q_s = 1
h_s = 2
s_s = 4
d_s = 8

L = []
temp = 1
for i in range(4):
    s = temp
    v = T[i] / s
    L.append([T[i],s,v])
    temp *= 2

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

ans = 0
for l in L:
    ans += (n // l[1])*l[0]
    n = n % l[1]

print(ans)

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

r1=[4*Q,2*H,S,D/2]

if N%2==0:
    print(round(min(r1)*2)*N//2)
else:
    if r1.index(min(r1))<=2:
        print(round(min(r1)*N))
    else:
        print(N//2*D+min(r1[:3]))

Solution (Python):
Q, H, S, D = [int(x) for x in input().strip().split()]
N = int(input())
min_QHS = min(Q * 4, H * 2, S)
if min_QHS * 2 <= D:
  print(N * min_QHS)
else:
  print(D * (N // 2) + (N % 2) * min_QHS)

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

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

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

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

Solution (Python):
def solve(Q, H, S, D, N):
    prices =[(int(0.25 * 4), Q),
             (int(0.5 * 4), H),
             (int(1.0 * 4), S),
             (int(2.0 * 4), D)]
    prices.sort(key=lambda x: x[1] / x[0])
    ans = 0
    N *= 4
    for p in prices:
        L = N // p[0]
        ans += L * p[1]
        N -= L * p[0]
    return ans


if __name__ == "__main__":
    Q, H, S, D = tuple(map(int, input().split(" ")))
    N = int(input())
    print(solve(Q, H, S, D, N))

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

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

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

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

ans = n//2 * d + n%2 * s

print(ans)

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

Solution (Python):
a,b,c,d=map(int,input().split())
n=int(input())
if n == 1:
  print(min(a*4,b*2,c))
elif n%2 == 0:
  print(min(a*4*n,b*2*n,c*n,d*n//2))
else:
  print(min(a*4*n,b*2*n,c*n,n//2*d+min(a*4,b*2,c)))

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

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

if j==5 or j==7:
  if q*8<d:
    print(q*n)
  else:
    print(d*(n//8)+q*(n%8))