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,N=map(int, open(0).read().split())
S=min(S,H*2,Q*4)
print(min(N//2*D+N%2*S, N*S))

Solution (Python):
q,h,s,d=map(int,input().split())
n=int(input())
x=min(s,2*h,4*q)
div,mod=divmod(n,2)
print(min(d*div+x*mod, x*n))

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

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

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

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

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

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

Solution (Python):

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

tmp = [4 * q, 2 * h, s, d / 2] 
tmp.sort()
if tmp[0] == d / 2:
    if n % 2 == 0:
        ans = d * (n // 2)
    elif tmp[1] == s:
        ans = d * (n // 2) + s
    elif tmp[1] == 2 * h:
        ans = d * (n // 2) + 2 * h
    elif tmp[1] == 4 * q:
        ans = d * (n // 2) + 4 * q
elif tmp[0] == s:
    ans = s * n
elif tmp[0] == 2 * h:
    ans = h * n * 2
elif tmp[0] == 4 * q:
    ans = q * n * 4
print(ans)

Solution (Python):
from itertools import permutations
Q, H, S, D = map(int, input().split())
N = int(input())*4

ans = 0
s = [(Q, 1), (H, 2), (S, 4), (D, 8)]

ans = float("inf")
for x in permutations(s):
    tmp = 0
    n = N
    for a, b in x:
        tmp += (n // b)*a
        n %= b
    ans = min(ans, tmp)
print(ans)

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

if __name__ == '__main__':
    main()

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

n=int(n/2)
ans+=n*min([2*q,2*h,2*s,d])
print(int(ans))

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

n//=2
ans+=n*min([2*q,2*h,2*s,d])
print(int(ans))

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

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

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

    
    value = list()
    value.append(q*4)
    value.append(h*2)
    value.append(s)
    value.append(d/2)

    ans = 0
    if min(value) == value[3]:
        if n % 2 == 1:
            ans += n // 2 * d
            ans += min(value[0:3])
        else:
            ans += n // 2 * d
    else:
        ans += min(value) * n

    print(ans)

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

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

ans+=(N%2)*min([4*Q,2*H,S])
print(ans)

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

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

d, m = divmod(N, 2)
ans = d * two + m * one
print(ans)

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

Solution (Python):
def main():
    Q, H, S, D = (int(i) for i in input().split())
    N = int(input())
    one = min(4*Q, 2*H, S)
    two = min(2*one, D)
    ans = 0
    if N & 1:
        ans += one
        N -= 1
    ans += two * (N // 2)
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
input = sys.stdin.readline
Q, H, S, D = map(int, input().split())
N = int(input()) * 4
res = 0

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

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(s*2,d)+n%2*s)

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

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

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

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

res = 0
res += (n//2)*ll
n %= 2



res += min(q*4, h*2, s)*n


print(res)

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

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

ans = min(u*n, d*(n//2) + u*(n%2))
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,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 operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]




q,h,c,d=mii()
n=ii()


ll05 = min(2*q,h)
ll1 = min(ll05*2,c)
ll2 = min(ll1*2,d)
ans=10**100
if n%2==1:
    ans = (n//2)*ll2 + ll1
else:
    ans = (n//2)*ll2

print(ans)

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

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

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

    N *= 4

    cost = [Q, H, S, D]
    
    
    
    
    

    for pow_i in range(3, 0, -1):
        cost[pow_i] = min(
            cost[pow_j] * (1 << (pow_i - pow_j))
            for pow_j in range(pow_i, -1, -1))

    ret = 0
    for pow in range(3, -1, -1):
        coef, N = divmod(N, 1 << pow)
        ret += coef * cost[pow]
    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
q,h,s,d = map(int, input().split())
n = int(input())
q_cp=q*4
h_cp=h*2
s_cp=s
d_cp=d/2

vals = [[q_cp,0.25],[h_cp,0.5],[s_cp,1],[d_cp,2]]
vals.sort()

if vals[0][1] <= 1:
        print(n * vals[0][0])
else:
        ans=d*(n//2)
        if n%2==0:
                print(ans)
        else:
                ans+=vals[1][0]
                print(ans)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    
    Q, H, S, D = Scanner.map_int()
    N = Scanner.int()
    ans = 0
    H = min(Q * 2, H)
    S = min(H * 2, S)
    if S * 2 <= D:
        ans = S * N
    else:
        ans += D * (N // 2)
        ans += (N % 2) * S
    print(ans)
    return


if __name__ == "__main__":
    main()

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

Solution (Python):
al = list(map(int,input().split()))
n = int(input())

bl = al[:]
bl[0] = bl[0] * 4
bl[1] = bl[1] * 2
bl[2] = bl[2] * 1
bl[3] = bl[3] / 2

idx = bl.index(min(bl))
idx2 = bl[:3].index(min(bl[:3]))
if idx == 3:
    print(n//2*al[idx] + (n%2) * bl[idx2])
else:
    print(bl[idx]*n)

Solution (Python):


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

n=N//2*2
ans=min(Q*4*n,H*2*n,S*n,D*n//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=[Q,H,S,D]

ans=10**18
for index,item in enumerate(cost):
    temp=item*(N*2**(2-index) if index!=3 else N//2)
    
    for jndex,jtem in enumerate(cost[:3]):
        ans=min(ans,temp+jtem*(0 if index!=3 else (N%2)*2**(2-jndex)))
    
print(ans)

Solution (Python):


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

for i in range(4):
    cost[i]/=2**(i-2)
    if i!=3:
        cost[i]=int(cost[i])
    
N=int(input())

if min(cost)==cost[3]:
    temp=int(cost[3]*2)
    print(((N//2)*temp+(N%2)*min(cost[:3])))
else:
    print((min(cost)*N))

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






P=[D,S,H,Q]
ans=10**18
for i in range(2**4):
  price=0
  amount=N
  for j in range(4):
    if (i>>j)&1:
      unit=2**(3-j)
      price+=(amount//unit)*P[j]
      amount%=unit
  if amount!=0:
    continue
  if price<ans:
    ans=price
print(ans)

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

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

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):
import sys
q, h, s, d = [int(i) for i in sys.stdin.readline().split()]
n = int(input())
if h > q * 2:
    h = q * 2
if s > h * 2:
    s = h * 2
if d > s * 2:
    d = s * 2
_sum = 0
ls = [(0.25, q), (0.5, h), (1, s), (2, d)]
ls.reverse()
ind = 0
while n:
    cur = ls[ind]
    _sum += cur[1] * (n // cur[0])
    n %= cur[0]
    ind += 1
print(_sum)

Solution (Python):
l=list(map(int,input().split()))
n=int(input())
a=[l[0]]
b=[2*l[0],l[1]]
c=[4*l[0],2*l[1],l[2]]
d=[8*l[0],4*l[1],2*l[2],l[3]]
ans=0
x=n//2
y=n%2
print(x*min(d)+y*min(c))

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

A[0]*=4
A[1]*=2
t1=10**10
for i in range(3):
   t1=min(t1,A[i])

A[0]*=2
A[1]*=2
A[2]*=2
t2=10**10
for i in range(4):
   t2=min(t2,A[i])

if(N%2==1):
    print(t2*(N//2)+t1)
else:
    print(t2*(N//2))

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
q,h,s,d=map(int,input().split())
n=int(input())
li=[[0.25,q],[0.5,h],[1,s]]
li.sort(key=lambda x: x[1]/x[0])
li=[[1,int(li[0][1]/li[0][0])],[2,d]]
li.sort(key=lambda x: x[1]/x[0])

ans=0
now=0
for i in range(2):
    ko=(n-now)//li[i][0]
    ans+=ko*li[i][1]
    now+=ko*li[i][0]
    now=int(now)
    
print(int(ans))

Solution (Python):


Q,H,S,D=map(int,input().split())
N=int(input())
temp=min(4*Q,2*H,S,D/2)

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

Solution (Python):

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

price = [d,s,h,q]

ans = 0
for i,p in enumerate(price):
    b = int(2**(3-i))
    
    ans += (n // b) * p
    n = n % b
print (ans)

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

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

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

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

Solution (Python):
a,b,c,d = map(int,input().split())
n = int(input())
INF = float("inf")
cost_1,cost_2 = INF,INF
for i in range(5):
	for j in range(3):
		for k in range(2):
			if 0.25*i + 0.5*j + 1*k == 1:
				cost_1 = min(cost_1,a*i+b*j+c*k)

for i in range(8):
	for j in range(5):
		for k in range(3):
			for l in range(2):
				if 0.25*i + 0.5*j + 1*k + 2*l == 2:
					cost_2 = min(cost_2, a*i+b*j+c*k+d*l)
ans = 0
if cost_2 <= cost_1 * 2:
	x,y = divmod(n,2)
	ans = x*cost_2 + y*cost_1
else:
	ans = n * cost_1

print(ans)

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

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

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

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

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

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

ans = (N//2) * min(8 * Q, 4 * H, S * 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())

PS = [[Q * 8, 0.25], [H * 4, 0.5], [S * 2, 1], [D, 2]]

PS.sort(key=lambda x: x[0])


R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += int(PS[i][0] * PS[i][1] // 2 * (R // PS[i][1]))
        R = R % PS[i][1]

print(ans)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    q, h, s, d = LI()
    n = II()
    q4 = q * 4
    h2 = h * 2
    l1 = min(q4, h2, s)
    l2 = min(l1 * 2, d)
    print((n >> 1) * l2 + (n & 1) * l1)
    
    return



if __name__ == '__main__':
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	Q, H, S, D = MAP()
	N = INT()

	
	A = [[Q/0.25, Q, 0.25], [H/0.5, H, 0.5], [S/1.0, S, 1.0], [D/2.0, D, 2.0]]
	A.sort()
	

	ans = 0
	for a in A:
		cost, price, amt = a
		if N >= amt:
			ans += int(N//amt) * price
			N -= int(N//amt) * amt
		
	
	print(int(ans))
	
	

if __name__ == '__main__':
	main()

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

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


if __name__ == "__main__":
    q, h, s, d = map(int, input().split())
    n = int(input())

    main(q, h, s, d, n)

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


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


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

Solution (Python):
import sys
input = sys.stdin.readline
Q, H, S, D = map(int, input().split())
N = int(input())
res = 0
for x in range(1, 3):
  q = Q * (8 // x)
  h = H * (4 // x)
  s = S * (2 // x)
  d = D
  if x == 1: res += (N // 2) * min(q, h, s, d)
  if x == 2: res += N * min(q, h, s)
  N = N % 2
print(res)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

if H > Q+Q:
    H = Q+Q
if S > H+H:
    S = H+H
if D > S+S:
    D = S+S

q,r = divmod(N,2)
answer = q * D + r * S
print(answer)

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

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

Solution (Python):

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

p3 = min([4 * Q, 2 * H, S])
p4 = min([2 * p3, D])


n4 = N // 2
n3 = N - n4 * 2

ans =  p3 * n3 + p4 * n4


print(int(ans))

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    q,h,s,d=map(int,input().split())
    n=int(input())

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

    if(n&1):
        print(d*(n//2)+s)
    else:
        print(d*(n//2))
resolve()

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(Q: int, H: int, S: int, D: int, N: int):
    h1 = min(2*Q, H)
    h1 = min(h1*2, S)
    d1 = D

    ans = 0
    if 2*h1 < d1:
        print(N*h1)
    else:
        if N%2 == 0:
            print((N//2)*d1)
        else:
            print((N//2)*d1 + h1)
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    Q = int(next(tokens))  
    H = int(next(tokens))  
    S = int(next(tokens))  
    D = int(next(tokens))  
    N = int(next(tokens))  
    solve(Q, H, S, D, N)

if __name__ == '__main__':
    main()

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

order = [(Q, 1), (H, 2), (S, 4), (D, 8)]
order.sort(key=lambda x: x[0] / x[1])

ret = 0
for i in range(4) :
  ret += (N // order[i][1]) * order[i][0]
  N %= order[i][1]
  
print(ret)

Solution (Python):
from decimal import Decimal, getcontext
getcontext().prec = 32

Q, H, S, D = map(int, input().split())
q = Decimal(Q * 4)
h = Decimal(H * 2)
s = Decimal(S)
d = Decimal(D / 2)

arr = [(q, Q, Decimal(0.25)), (h, H, Decimal(0.5)), (s, S, Decimal(1.0)), (d, D, Decimal(2.0))]
arr.sort()

N = int(input())

ans = 0
while N > 0:
    for _, cost, quantity in arr:
        if N >= quantity:
            ans += (N // quantity) * cost
            N -= (N // quantity) * quantity
print(int(ans))

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

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  


Q, H, S, D = rl()
N = ri()
if 2 * Q < H:
    H = 2 * Q
if 2 * H < S:
    S = 2 * H
if 2 * S < D:
    D = 2 * S
answer = N // 2 * D + N % 2 * S
print(answer)

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

d1 = min([8*q,4*h,2*s,d])
s1 = min([4*q,2*h,s])

ans = 0
if n >= 2:
    ans += n//2*d1
    n = n%2
    if n == 1:
        ans += s1
elif n == 1:
    ans = s1
    
print(ans)

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

L2 = [8*q,4*h,2*s,d]
L2.sort()
L1 = [4*q,2*h,s]
L1.sort()
L5 = [2*q,h]
L5.sort()
L25 = [q]

ans = 0
if n >= 2:
    ans += n//2*L2[0]
    n = n%2
    if n == 1:
        ans += L1[0]
elif n == 1:
    ans = L1[0]
elif n == 0:
    ans = 0
    
print(ans)

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    ls = list(map(int, readline().split()))
    n = int(readline())
    ls[1] = min(ls[1], ls[0] * 2)
    ls[2] = min(ls[2], ls[1] * 2)
    ls[3] = min(ls[3], ls[2] * 2)
    t = 0
    for i in range(3, -1, -1):
        if i == 3:
            t += n // 2 * ls[i]
            n -= n // 2 * 2
        elif i == 2:
            t += n // 1 * ls[i]
            n -= n // 1 * 1
        elif i == 1:
            t += n / 0.5 * ls[i]
            n -= n // 0.5 * 0.5
        else:
            t += n // 0.25 * ls[i]
            n -= n // 0.25 * 0.25
        if n == 0:
            break
    print(int(t))


if __name__ == '__main__':
    solve()

Solution (Python):
from sys import stdin

q,h,s,d = [int(x) for x in stdin.readline().rstrip().split()]
n = int(stdin.readline().rstrip())

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

if min(li) == q*4:
    print(n*q*4)
elif min(li) == h*2:
    print(n*h*2)
elif min(li) == s:
    print(n*s)
else:
    if n%2 == 1:
        li.pop()
        li.sort()
        print(n//2*d+li[0])
    else:
        print(n//2*d)

Solution (Python):
yen = list(map(int,input().split()))
N = int(input())
lista = [4*yen[0], 2*yen[1], yen[2]]

yen1 = min(lista)
if 2*yen1 <= yen[3]:
    print(N*yen1)
else:
    if N%2 == 0:
        print(int((N//2)*yen[3]))
    else:
        print(int( (N//2)*yen[3] + yen1))

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

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

ans = N//2 * p2 + N%2 * p1
print(ans)

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

Solution (Python):
def examA():
    Q, H, S, D = LI()
    N = I()
    economical2 = min(Q*8, H*4, S*2, D)
    economical1 = min(Q*4, H*2, S)
    ans = (N//2)*economical2 + (N%2)*economical1
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()

Solution (Python):

import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()



def main():
    Q, H, S, D = mi()
    N = ii()
    N *= 4
    dp = [10**10] * 9
    dp[0] = 0
    for i in range(1, 9):
        dp[i] = min(dp[i - 1] + Q, dp[i])
    for i in range(2, 9):
        dp[i] = min(dp[i - 2] + H, dp[i])
    for i in range(4, 9):
        dp[i] = min(dp[i - 4] + S, dp[i])
    for i in range(8, 9):
        dp[i] = min(dp[i - 8] + D, dp[i])
    
    m = min(8 * Q, 4 * H, 2 * S, D)
    print(m * (N // 8) + dp[N % 8])
    return


if __name__ == '__main__':
    main()

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

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

print(n // 2 * d + (n % 2) * s )

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

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

ans=0

ans+=N//2*D
N%=2
N*=2
ans+=N//2*S
N%=2
N*=2
ans+=N//2*H
N%=2
N*=2
ans+=N//2*Q

print(ans)

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

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

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

N = int(input())
answer = 0

if N&1:
  answer += S

answer += (N//2)*D
print(answer)

Solution (Python):
import sys,collections as cl,bisect as bs,copy
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

c = l()

n = onem()

cc = []

for i in range(4):
    cc.append([c[i],i])

cc[-1][0] /= 2

cc[0][0] *= 4
cc[1][0] *= 2



cc.sort()

su = 0

i = 0
while n:
    kkk = cc[i][1]
    if kkk == 0:
        su += 4 * c[kkk] * n
        n = 0
    elif kkk == 1:
        su += 2 * c[kkk] * n 
        n = 0
    elif kkk == 2:
        su += c[kkk]*n
        n = 0
    else:
        su += c[kkk] * (n//2)
        n %= 2
    i += 1
print(su)

Solution (Python):

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

N = int(input())

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

ans += N * min(S , H * 2,Q * 4)

print (ans)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input()) * 4
L = sorted([ [8*q, q, 1], [4*h, h, 2], [2*s, s, 4], [d, d, 8] ])
A = [ i[1:] for i in L ]
ans = 0
for p, a in A:
  ans += (n//a) * p
  n %= a
print(ans)

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

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

print(min(S*N,D*(N//2)+S*(N%2)))

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    q, h, s, d = list(map(int, readline().split()))
    n = int(readline())
    h = min(h, q * 2)
    s = min(s, h * 2, q * 4)
    d = min(d, s * 2, h * 4, q * 8)
    cnt = 0
    cnt += n // 2 * d
    n -= n // 2 * 2
    cnt += n // 1 * s
    n -= n // 1
    print(cnt)


if __name__ == '__main__':
    solve()

Solution (Python):
ps = []
l = 0.25
for p in map(int,input().split()):
  ps.append([p/l, l, p])
  l *= 2
ps.sort()

n = int(input())
ans = 0
for unitp, l, p in ps:
  num = int(n//l)
  ans += num*p
  n -= int(num*l)
  
print(ans)

Solution (Python):


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

ans = 0

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

if n == 1:
        
        ans = s
elif n%2 == 0:
        
        ans = n//2 * d
elif n%2 != 0:
        
        ans = (n-1)//2 * d + s
print(ans)

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


Q, H, S, D = list(map(int, sys.stdin.buffer.readline().split()))
N = int(sys.stdin.buffer.readline())

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