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

Solution (Python):
def inpl(): return [int(i) for i in input().split()]

Q, H, S, D = inpl()
N = int(input())
mini2 = min(8*Q, 4*H, 2*S, D)
mini1 = min(4*Q, 2*H, S)
print(N//2*mini2 + N%2*mini1)

Solution (Python):
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    q, h, s, d = [next_int() for _ in range(4)]
    n = next_int()
    s = min(4 * q, 2 * h, s)
    
    print(s * (n % 2) + min(2 * s, d) * (n // 2))


if __name__ == '__main__':
    main()

Solution (Python):
Q,H,S,D = map(int,input().split())
N = int(input())
Q_l = [8*Q,0.25,Q]
H_l = [4*H,0.5,H]
S_l = [2*S,1,S]
D_l = [D,2,D]
L = [Q_l,H_l,S_l,D_l]
L.sort()
cost = 0
for e in L:
    num = int(N // e[1])
    N -= (num) * e[1]
    cost += num * e[2]
print(cost)

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

Solution (Python):

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

q = 4*q
h = 2*h

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

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

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

half = min(Q*2,H)
one = min(half*2,S)
doub = min(one*2,D)

ans = (N//2)*doub + (N%2)*one
print(ans)

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

Solution (Python):
a,b,c,d = map(int,input().split())
n = int(input())
a1 = a*8
b1 = b*4
c1 = c*2
d1 = d
g = n//2
n %= 2
ans = 0
ans += g*(min(a1,b1,c1,d1))
g = n//1
g = int(g)
n = n%1
a1 = a*4
b1 = b*2
c1 = c
ans += g*(min(a1,b1,c1))
g = n//0.5
g = int(g)
n = n%0.5
a1 = a*2
b1 = b*1
ans += g*(min(a1,b1))
g = n//0.25
g = int(g)
n = n%0.25
a1 = a
ans += g*a1
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(S * N)
else:
    print(D * (N//2) + (N % 2) * S)

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

Solution (Python):
A,B,C,Q = map(int,input().split())
N = int(input())
P = min(4*A,2*B,C)

if N % 2 == 0 :
    ans = min(P*N,Q*N//2)
else :
    ans = min(P*(N-1), Q*(N-1)//2) + P
print(ans)

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

A = min(4*L[0],2*L[1],L[2])
B = L[3]
if N % 2 == 0 :
    ans = min(A*N,B*N//2)
else :
    ans = min(A*(N-1),B*(N-1)//2) + A
print(ans)

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

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

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

Solution (Python):
a = list(map(int, input().split()))
n = int(input())
a[0] *= 4
a[1] *= 2
a[3] /= 2
m = min(a)
i = a.index(m)
if i != 3:
    print(n*a[i])
else:
    k = min(a[:-1])
    j = a.index(k)
    print((n//2)*int(2*a[3])+(n%2)*a[j])

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=min(q*4,h*2,s)
M=min(m*2,d)
print((n//2)*M+(n%2)*m)

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 = list(map(int, input().split()))
N = int(input())

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

if N == 1:
	print(x)
elif N == 2:
	print(y)
else:
	if N % 2 == 0:
		print(min(N * x, int(N // 2) * y))
	else:
		print(min(N * x, int(N // 2) * y + x))

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

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

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

Solution (Python):
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

[q,h,s,d] = getlist()
N = getN()

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

ans = 0

ans += tanka_ni * (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())
if 2*q < h:
    h = 2*q
if 2*h < s:
    s = 2*h
if 2*s < d:
    d = 2*s

n = int(input())
if n%2==0:
    kosu = n//2
    print(d*kosu)
else:
    kosu = n//2
    print(d*kosu + s)

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())
q_perf = q / 0.25
h_perf = h / 0.5
s_perf = s
d_perf = d / 2
list_amo = [0.25,0.5,1,2]
list_price = [q,h,s,d]
list_perf = [q_perf,h_perf,s_perf,d_perf]
cost = 0
ind4 = list_perf.index(min(list_perf))
ind3 = list_perf.index(min(list_perf[0:3]))
ind2 = list_perf.index(min(list_perf[0:2]))
ind1 = list_perf.index(min(list_perf[0:1]))

while n >= 2:
    cost += int((n//list_amo[ind4]) *  int(list_price[ind4]))
    n -= (n//list_amo[ind4]) * list_amo[ind4]
while n >= 1:
    cost += int((n//list_amo[ind3]) *  int(list_price[ind3]))
    n -= (n//list_amo[ind3]) * list_amo[ind3]
while n >= 0.5:
    cost += int((n//list_amo[ind2]) *  list_price[ind2])
    n -= (n//list_amo[ind2]) * list_amo[ind2]

while n >= 0.25:
    cost += int((n//list_amo[ind1]) *  list_price[ind1])
    n -= (n//list_amo[ind1]) * list_amo[ind1]

print(int(cost))

Solution (Python):
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)
print((N // 2) * D + (N % 2) * S)

Solution (Python):
cup_cost = list(map(int, input().split()))
l = int(input())


cost = [cup_cost[0]*8, cup_cost[1]*4, cup_cost[2]*2, cup_cost[3]]


cost_2 = min(cost)


cost_1 = int(min(cost[:-1]) / 2)


cup_2 = l // 2


cup_1 = l % 2


print(cup_2*cost_2 + cup_1*cost_1)

Solution (Python):
cup_cost = list(map(int, input().split()))
cost = [cup_cost[0]*8, cup_cost[1]*4, cup_cost[2]*2, cup_cost[3]]
l = [250, 500, 1000, 2000]
A = int(input())*1000

price = 0
while True:
  if A == 0:
    break;

  if A >= 2000:
      ind = cost.index(min(cost[:]))
  elif A >= 1000:
      ind = cost.index(min(cost[:-1]))
  elif A >= 500:
      ind = cost.index(min(cost[:-2]))
  else:
      ind = cost.index(min(cost[:-3]))
      
  cup_cnt = int(A/l[ind])
  price += cup_cnt * cup_cost[ind]
  A -= l[ind] * cup_cnt
    

print(price)

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

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

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

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

q2 = q*8
h2 = h*4
s2 = s*2

k = min([q2,h2,s2,d])

q1 = q*4
h1 = h*2
r = min([q1,h1,s])

if n % 2 == 0:
    print((n//2)*k)
else:
    print((n//2)*k+r)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

Q,H,S,D = inpl()
N = int(input())
L0_5 = min(Q*2,H)
L1   = min(L0_5*2,S)
L2 = min(L1*2,D)
ans = N//2 * L2 + (N%2) * L1
print(ans)

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

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

p = sorted([(q, 8), (h, 4), (s, 2), (d, 1)], key=lambda x: x[0] * x[1])
ans = 0
for v, i in p:
    ans += n // (8 // i) * v
    n = n % (8 // i)
print(ans)

Solution (Python):
money = list(map(int, input().split()))
if money[0] * 2 < money[1]:
    money[0] *= 4
    del money[1]
else:
    money[1] *= 2
    del money[0]
if money[0] < money[1]:
    del money[1]
else:
    del money[0]
if money[0] * 2 < money[1]:
    money[1] = money[0] * 2
N = int(input())
print(N // 2 * money[1] + N % 2 * money[0])

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

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

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

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

print(n//2 * two_liter + n%2 * one_liter)

Solution (Python):
def greedy():
    global qhsd, n
    ret = 0
    ret += (n//2)*qhsd[-1]
    ret += (n % 2)*qhsd[-2]
    return ret


qhsd = [int(x) for x in input().split()]
n = int(input())
for i in range(1, 4):
    qhsd[i] = min(qhsd[i-1]*2, qhsd[i])
print(greedy())

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

half = min(2 * q, h)
one = min(2 * half, s)
two = min(2 * one, d)

l = zip([2, 1, 0.5, 0.25], [two, one, half, q])

ans = 0
rest = n
for vol, cost in l:
    ans += (rest // vol) * cost
    rest %= vol
    if rest == 0:
        print(ans)
        break

Solution (Python):
def a_ice_tea_store(Q, H, S, D, N):
    record_low_1liter = min(4 * Q, 2 * H, S)  
    if record_low_1liter * 2 <= D:  
        ans = N * record_low_1liter
    else:
        buy_2liter = N // 2
        buy_1liter = N % 2
        ans = buy_1liter * record_low_1liter + buy_2liter * D
    return ans

Q, H, S, D = [int(i) for i in input().split()]
N = int(input())
print(a_ice_tea_store(Q, H, S, D, N))

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

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

Solution (Python):
def main():
    qhsd=list(map(int,input().split(" ")))
    n=int(input())
    for i in range(3):
        if qhsd[i+1]>qhsd[i]*2: qhsd[i+1]=qhsd[i]*2
    res=(n%2)*qhsd[2]+(n//2)*qhsd[3]
    print(int(res))

main()

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

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

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

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

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

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

if n % 2 == 1:
    qua = 4 * q * n
    hal = 2 * h * n
    one = s * n
    two_1 = d * (n//2) + s
    two_2 = d * (n//2) + 2*h
    two_3 = d * (n//2) + 4*q
    
    print(min(qua, hal, one, two_1, two_2, two_3))
    
else:
    qua = 4 * q * n
    hal = 2 * h * n
    one = s * n
    two = d * (n//2)
    
    print(min(qua, hal, one, two))

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

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


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


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

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

h=min(h,q+q)
s=min(s,h+h)
d=min(d,s+s)

n=int(input())

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

Solution (Python):
def main():
  t = input().split(" ")
  Q, H, S, D = int(t[0]), int(t[1]), int(t[2]), int(t[3])
  N = int(input())
  if Q*4 < S:
    S = Q*4
  if H*2 < S:
    S = H*2
  if S*2 < D:
    D = S*2
  ans = (N//2) * D
  ans += (N%2) * S
  print(ans)
main()

Solution (Python):



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

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


if __name__ == '__main__':
    main()

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

t2=min([a*8,b*4,c*2,d*1])

ans=(n//2)*t2
n=n%2

t1=min([a*4,b*2,c*1])
ans+=n*t1

print(ans)

Solution (Python):



def main():
    weight = 8,4,2,1

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

    

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




    div = n//2
    mod = n%2

    sum = 0
    if mod == 1:
        sum = sum + s


    sum = sum + div * min(s*2 , d)

    print(sum)
main()

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

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

ans = 0
if N % 2 == 0:
    ans = min(8*Q, 4*H, 2*S, D)*N//2
else:
    ans = min(8*Q, 4*H, 2*S, 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 

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

Solution (Python):

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

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

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

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



r = (N // 2) * l2 + (N % 2) * l

print(r)

Solution (Python):
arr = map(int,raw_input().split())

l1 = min(arr[0]*4,arr[1]*2,arr[2])
l2 = min(l1*2,arr[3])
n = int(input())

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

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

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

if min(q,h,s,d)==d:
    if N%2 == 0:
        money = D*(N//2)
    else:
        money = (N//2)*D + min(q,h,s)
else:
    money = min(q,h,s)*N

print(int(money))

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

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

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

cost_per_two_liters = [8*Q,4*H,2*S,D]
res = int(N/2) * min(cost_per_two_liters)
if N % 2 == 0:
    print(res)
else:
    res += min([4*Q,2*H,S])
    print(res)

Solution (Python):
Q, H, S, D = list(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())
litter = [q*4,h*2,s]
litter.sort()
twolitter = [q*8,h*4,s*2,d]
twolitter.sort()
total = 0
if n%2 == 0:
	total = (n//2)*twolitter[0]
else:
	total = (n//2)*twolitter[0]+litter[0]

print(total)

Solution (Python):
Q,H,S,D=map(int,raw_input().split())
N=input()
a=min([Q*4,H*2,S])
b=float(D)/2

ans=0
if b<a:
	ans+=N/2*D
	amari=N%2
	ans+=amari*a
else:
	ans=N*a
print ans

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

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

one_litter = [4*q,2*h,s]
ans += n * min(one_litter)
print(ans)

Solution (Python):

def main():
    q, h, s, d = map(int, input().split())
    n = int(input()) * 100
    h = min(h, 2*q)
    s = min(s, 2*h)
    d = min(d, 2*s)
    ans = 0
    vals = [(200, d), (100, s), (50, h), (25, q)]
    for m, val in vals:
        c = n // m
        n -= m * c
        ans += val*c
    print(int(ans))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    
    x, y = n // 2, n % 2
    p_x = min(8*q, 4*h, 2*s, d) * x
    p_y = min(4*q, 2*h, s) * y
    
    print(p_x+p_y)
    
    
if __name__ == "__main__":
    main()

Solution (Python):
Q, H, S, D=map(int,input().split())
N=int(input())
Q_1liter=4*Q
H_1liter=2*H
S_1liter=S
min_QHS=min(Q_1liter,H_1liter,S_1liter)
min_QHS2=min(min_QHS*2,D)
if N%2==0:
    output=min_QHS2*int(N/2)
    print(int(output))
else:
    output=(int(N/2)*min_QHS2+min_QHS)
    print(int(output))

Solution (Python):
Q, H, S, D=map(int,input().split())
N=int(input())
Q_1liter=4*Q
H_1liter=2*H
S_1liter=S
min_QHS=min(Q_1liter,H_1liter,S_1liter)
min_QHS2=min(min_QHS*2,D)
if N%2==0:
    output=min_QHS2*(N//2)
    print(int(output))
else:
    output=((N//2)*min_QHS2+min_QHS)
    print(int(output))

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

N = int(input())

if Q*2<H: H=2*Q
if H*2<S: S=2*H
if S*2<D: D=2*S
    
ans = (N//2)*D
if N%2==1: ans += S
    
print(ans)

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

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

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

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:
    cnt=n%2
    cnt_2=n//2
    print(cnt_2*d+cnt*s)

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

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

print(A)

Solution (Python):
def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))


def readmap():
    return map(int, input().split())


Q, H, S, D = readmap()
N = read()

ls = [4 * Q, 2 * H, S]
idx = ls.index(min(ls))

if idx == 0:
    S = 4 * Q
elif idx == 1:
    S = 2 * H

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

Solution (Python):
def getinputdata():

    
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()


q = int(arr_data[0][0])


h = int(arr_data[0][1])


s = int(arr_data[0][2])


d = int(arr_data[0][3])


n = int(arr_data[1][0])

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


if n == 1:
    
    kingaku = min(arr[0:3])
    
else:
    
    if arr.index(min(arr)) == 3:
        
        kingaku = d * (n // 2)
        n -= 2 * (n // 2)
        kingaku += n * min(arr[0:3])
    else:
        kingaku = n * min(arr)
        
    
print(kingaku)

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

ans = int(0)
if d < 2*s and d < 4*h and d < 8*q and n >= 2 :
    ans += int(n/2)*d
    n %= 2

if s < 2*h and s < 4*q:
    ans += n*s
elif h < 2*q:
    ans += n*2*h
else:
    ans += n*4*q

print(ans)

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

    yen = 0
    A = [4*Q, 2*H, S]
    if D/2 < min(A):
        if N%2==0:
            return D * N//2
        else:
            return D*(N-1)//2 + min(A)
    else:
        return N * min(A)

if __name__ == '__main__':
    print(main())

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

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

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

Solution (Python):
q,h,s,d=map(int,input().split())
n=int(input())
cospa=[[q/0.25,0.25,q],[h/0.5,0.5,h],[s,1.0,s],[d/2,2.0,d]]
cospa.sort()
money=0
for i in range(4):
  if(n>=cospa[i][1]):
    x=int(n//cospa[i][1])
    money+=int(x*cospa[i][2])
    n%=cospa[i][1]
print(int(money))

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

l05 = min(2*Q, H)
l10 = min(l05*2, S)
l20 = min(l10*2, D)

print(N//2*l20 + N%2*l10)

Solution (Python):


import sys, math, copy




HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    l = min(4 * q, 2 * h, s)
    if 2 * l > d:
        print((n // 2) * d + (n % 2) * l)
    else:
        print(n * l)

main()

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

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

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

l05 = min(Q*2, H)
l10 = min(l05*2, S)
l20 = min(l10*2, D)

print(int((N//2*l20) + (N%2*l10)))

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
Q_S, H_S, D_S = Q*4, H*2, D/2

if min(Q_S,H_S,S,D_S) == Q_S:
    print(Q_S*N)
elif min(Q_S,H_S,S,D_S) == H_S:
    print(H_S*N)
elif min(Q_S,H_S,S,D_S) == S:
    print(S*N)
else:
     if min(Q_S,H_S,S) == Q_S:
         print(D*(N//2)+Q_S*(N%2))
     elif min(Q_S,H_S,S) == H_S:
         print(D*(N//2)+H_S*(N%2))
     elif min(Q_S,H_S,S) == S:
         print(D*(N//2)+S*(N%2))

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

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



print(ans)

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

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



print(ans)

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

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

print(ans)

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

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

print(ans)

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

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

l2=[Q*8,H*4,S*2,D]
l1=[Q*4,H*2,S]
l2min=l2.index(min(l2))
l1min=l1.index(min(l1))

ans,rest=divmod(N,2)
ans=ans*l2[l2min]+rest*l1[l1min]
print(ans)

Solution (Python):
inputstr = input().split()

QHSD = [[250,int(inputstr[0])],[500,int(inputstr[1])],[1000,int(inputstr[2])],[2000,int(inputstr[3])]]
N = int(input()) * 1000

QHSDs = sorted(QHSD, key=lambda x: x[1]/x[0])

amari = N
ans = 0
for row in QHSDs:
    ans += (amari // row[0]) * row[1]
    amari %= row[0]
    
print(ans)

Solution (Python):
a = input().split(" ")
b = list(map(int, a))
c = int(input())
ans = 0
r = min([b[0] * 4, b[1] * 2, b[2]])
r2 = min([r * 2, b[3]])
if c % 2 == 1:
    ans += r
    c -= 1
ans += r2 * (c // 2)
print(int(ans))

Solution (Python):
b=list(map(int,input().split()))
c = int(input())
ans = 0
r = min([b[0]*4, b[1]*2, b[2]])
r2 = min([r*2, b[3]])
if c % 2 == 1:
	ans += r
	c -= 1
ans += r2 * (c // 2)
print(ans)

Solution (Python):
b=list(map(int,input().split()))
c = int(input())
ans = 0
r = min([b[0]*4, b[1]*2, b[2]])
r2 = min([r*2, b[3]])






if c%2==1:
	print(((c-1)//2)*r2+r)
else :
	print((c//2)*r2)

Solution (Python):
b=list(map(int,input().split()))
c = int(input())
ans = 0
r = min([b[0]*4, b[1]*2, b[2]])
r2 = min([b[0]*8,b[1]*4,b[2]*2, b[3]])






if c%2==1:
	print(((c-1)//2)*r2+r)
else :
	print((c//2)*r2)

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

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

qr,hr,sr,dr=q*4,h*2,s,d/2
a=[[qr,q,0.25],[hr,h,0.5],[sr,s,1],[dr,d,2]]

a.sort()
k=0
if a[0][2]<2:
  k = n * a[0][0]
else:
  k=  (n//2) * a[0][1] + (n%2) *a[1][0]
  
print(round(k))

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

Solution (Python):
def main():
    rt = 0
    Q,H,S,D = map(int,input().split(" "))
    N = float(input())
    count_1 = N//2
    count_2 = (N-count_1*2)//1
    count_3 = (N-count_1*2-count_2)*100//50
    count_4 = (((N-count_1*2-count_2)*100)-50*count_3)//25
    if count_1:
        rt+=int(count_1)*min(2*S,D,4*H,8*Q)
    if count_2:
        rt+=int(count_2)*min(S,2*H,4*Q)
    if count_3:
        rt+=min(H,2*Q)*int(count_3)
    if count_4:
        rt+=Q*int(count_4)
    print(int(rt))

if __name__=="__main__":
    main()

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

Solution (Python):
import math

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(math.floor(n/2)*d + n%2*s)

Solution (Python):

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

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

cost1 = N * one
cost2 = N//2 * two + (N %2) * one










print(min(cost1, cost2))

Solution (Python):
money=list(map(int,input().split()))
N=int(input())
best_over2=int(min(8*money[0],4*money[1],2*money[2],money[3]))
best_under1=int(min(4*money[0],2*money[1],money[2]))
if(N==1):
    print(best_under1)
elif(N%2==0):
    print((N//2)*best_over2)
elif(N%2!=0):
    print((N//2)*best_over2+best_under1)

Solution (Python):
line = map(int, raw_input().split())
n = int(raw_input()) * 4 

for i in range(3):
    line[i+1] = min(line[i+1], 2*line[i])

res = 0 
while n > 0:
    for i in range(3, -1, -1):
        k = n // (2**i)
        if k > 0:
            res += k * line[i]
            n -= k*(2**i)
            break

print(res)

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

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

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

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

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

print(s*n if d>s*2 else d*(n//2)+s*(n%2))

Solution (Python):
import numpy as np

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




N = int(input())













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

Solution (Python):
Q, H, S, D,= map(int, raw_input().split())
N = int(input())
if Q*2 > H:
    M1 = H
else:
    M1 = Q*2

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
 
sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
def main():
    a = sorted(list(zip(LI(),[0.25,0.5,1.0,2.0])), key=lambda x: x[0]/x[1])
    n = I() * 4
    r = 0
    for i in range(4):
        k,t = a[i]
        t = int(t*4)
        if n >= t:
            r += k * (n//t)
            n %= t
 
    return r
 
print(main())

Solution (Python):
value = list(map(int,input().split()))
l = int(input())
l *= 100
rittoru = [25, 50, 100, 200]
m = value[0] * 2
total = 0

for i in range(1, 4):
    if m < value[i]:
        value[i] = m
        m *= 2
    else :
        m = value[i] * 2

for i in range(4)[::-1]:
    hon = l // rittoru[i]
    l %= rittoru[i]
    total += hon * value[i]

print (total)

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

N = int(input())
N = N*100
res = 0
l = [25,50,100,200]

for i in range(3):
    if Value[i]*2 < Value[i+1]:
        Value[i+1] = Value[i]*2

for i in range(4)[::-1]:
    n = N//l[i]
    N = N%l[i]
    res += Value[i]*n

print(res)

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

Solution (Python):
p = list(map(int, input().split()))
N = 4 * int(input())

p[1] = min(p[1], p[0] * 2)
p[2] = min(p[2], p[1] * 2, p[0] * 4)
p[3] = min(p[3], p[2] * 2, p[1] * 4, p[0] * 8)

k = 8
ret = 0
for m in p[::-1]:
    ret += N // k * m
    N %= k
    k //= 2

print(ret)