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

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

Solution (Python):

import sys
input=sys.stdin.readline

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

if __name__=="__main__":
    main()

Solution (Python):

import sys
input=sys.stdin.readline

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

    if n%2==0:
        c=n//2
        print(c*dp2)
    
    else:
        c=n//2
        print(c*dp2+sp1)
    
    
    

if __name__=="__main__":
    main()

Solution (Python):

import sys
input=sys.stdin.readline

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

    if n%2==0:
        c=n//2
        print(c*dp2)
    elif n%2!=0:
        c=n//2
        print(c*dp2+sp1)
    else:
        print(n*sp1)
    

if __name__=="__main__":
    main()

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

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

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

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





Q, H, S, D = getNM()
N = getN()


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

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

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

if __name__ == "__main__":
    main()

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

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

Solution (Python):



def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())
    ans = 0
    Q *= 4
    H *= 2
    min_price = min([Q, H, S])
    if N % 2 == 1:
        ans += min_price
    ans += N // 2 * min(min_price * 2, D)

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
Q, H, S, D = map(int, input().split())
L = int(input())
quantities = [(8*Q, 'Q'), (4*H, 'H'), (2*S, 'S'), (D, 'D')]
rest = {'Q': 4*Q, 'H': 2*H, 'S': S, 'D': D//2}
quantities.sort()
if quantities[0][1] == 'D' and L%2 != 0:
  print(L//2*D + rest[quantities[1][1]])
elif quantities[0][1] == 'D' and L%2 == 0:
  print(L//2*D)
else:
  print(L*rest[quantities[0][1]])

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

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

print(n//2*cst2+n%2*cst1)

Solution (Python):
*A,N  = map(int,open(0).read().split())
ans = 0
ans += (N//2)*min(A[0]*8,A[1]*4,A[2]*2,A[3])
ans += (N%2)*min(A[0]*4,A[1]*2,A[2])

print(ans)

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

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, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

Q, H, S, D = mi()
N = ii()

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

if N%2 == 0:
    print(x*(N//2))
else:
    print(x*(N//2)+y)

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

Solution (Python):
def solve():
    Q, H, S, D = [int(i) for i in input().split()]
    P = [(250, Q), (500, H), (1000, S), (2000, D)]
    P.sort(key=lambda t: t[1] / t[0])
    N = int(input()) * 1000
    ans = 0
    for p in P:
        if N == 0:
            break
        x, y = p
        n = int(N / x)
        ans += n * y
        N -= n * x
    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):




def resolve():
    import sys
    input = sys.stdin.readline

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

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

    ans = 0

    ans += (n // 2) * d
    n = n % 2

    ans += n * s

    print(ans)


if __name__ == "__main__":
    resolve()

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

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

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

print(calc)

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

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

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


if __name__ == "__main__":
    main()

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

Solution (Python):
Q,H,S,D=map(int,input().split())
Q*=4
H*=2
a=Q*2
b=H*2
c=S*2
d=D
s=min([a,b,c,d])
p=int(input())
if p%2==0:
  print(((p//2)*s))
else:
  print((p//2)*s+min([Q,H,S]))

Solution (Python):
Q, H, S, D = map(int, input().split())
n = int(input())
coffee = [[Q*4, 0.25, Q], [H*2, 0.5, H], [S, 1, S], [D/2, 2, D]]
coffee_cost = sorted(coffee)
cost = 0
Qt = n
for i in range(4):
    cost += (round(Qt // coffee_cost[i][1]) * coffee_cost[i][2])
    Qt = round(Qt % coffee_cost[i][1])
    if Qt == 0:
        print(int(cost))
        exit()

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
one = [q*4, h*2, s]
one.sort()
cost = 0
if one[0]*2>d:
    cost += d*(n//2)
    n %= 2
cost += one[0]*int(n)
n -= int(n)
if n==0:
    print(cost)
else:
    n *= 100
    x = []
    x.append(q*(n//25))
    x.append(s*(n//50)+q*((n%50)//25))
    print(min(x)+cost)

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
one = [q*4, h*2, s]
one.sort()
cost = 0
if one[0]*2>d:
    cost += d*(n//2)
    n %= 2
cost += one[0]*int(n)
n -= int(n)
if n==0:
    print(cost)
else:
    n *= 100
    x = []
    x.append(q*(n//25))
    x.append(s*(n//50)+q*((n%50)//25))
    print(min(x)+cost)

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
x = N % 2
y = N // 2
arr = [4*Q*x, 2*H*x, S*x]
arr1 = [8*Q*y, 4*H*y, 2*S*y, D*y]




   
print(min(arr) + min(arr1))

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

price = min(a) * (n // 2) + min(b) * (n % 2)

print(price)

Solution (Python):
q,h,s,d=map(int,input().split())
n=int(input())
h=min(2*q,h)
s=min(2*h,s)
d=min(2*s,d)
ans=0
data=[[2,d],[1,s],[float(0.5),h],[float(0.25),q]]
for i in range(4):
  ans+=(int(n/data[i][0]))*data[i][1]
  n-=(int(n/data[i][0]))*data[i][0]
print(int(ans))

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

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

Solution (Python):
from sys import stdin

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

min_for_one = min([q*4, h*2, s])
min_for_two = min([min_for_one*2, d])

print(n//2*min_for_two + n%2*min_for_one)

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

Solution (Python):

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

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

if 2*S>D:
    cnt_2 = N//2
    cnt_1 = N%2
    pay = D*cnt_2 + S*cnt_1
else:
    pay = N * S
print(pay)

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

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

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

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

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

Solution (Python):
a = input().split()
q = int(a[0]) * 4
h = int(a[1]) * 2
s = int(a[2])
t = int(min([q,h,s]))
d = int(a[3])
b = int(input())

if min([t,d/2]) == t:
  print(int(b * t))
else:
  print(int((b // 2) * d + (b % 2) * t))

Solution (Python):

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)


mod = 998244353
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(n*q,n*h,n*s,(n//2)*d + (n-(n//2)*2)*min(q,h,s)))

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())
R = N%2
M = N//2

print(min([Q*8,H*4,S*2,D])*M+min([Q*4,H*2,S])*R)

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

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

q = 4*q
h = 2*h

min_1 = min(q,h,s)
if n == 1:
    print(min_1)
else:
    if min_1*2 < d:
        print(n*min_1)
    else:
        double = n//2
        v = double*d
        if n%2 == 1:
            v += min_1
        print(v)

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

if 2*q < h: h = 2*q
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())

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

ans = (n // 2) * two + (n % 2) * one
print(ans)

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

ans=0
p=min(Q*8,H*4,S*2,D)
q=N
ans=p*(q//2)

p=min(Q*4,H*2,S)
q=q%2
ans+=p*(q//1)

print(int(ans))

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    0.25 0.5 1 2
    Q H S D
    N
    """
    Q, H, S, D = read_ints()
    N = read_int()
    min_cost_per_liter = min(4*Q, 2*H, S)
    return min(N*min_cost_per_liter, (N//2)*D+(N%2)*min_cost_per_liter)


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

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

ans=min(one*N, D*(N//2)+one*(N%2))
print(ans)

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

a,b,c=q*8,h*4,s*2

x=n//2

ans=0

ans+=x*min(a,b,c,d)

if n%2==1:
  ans+=min(a//2,b//2,c//2)
  
print(ans)

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

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

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

print(ans)

Solution (Python):
from operator import itemgetter
Q, H, S, D = map(int, input().split())
p = sorted([(1,Q,Q*8),(2,H,H*4),(4,S,S*2),(8,D,D)], key=itemgetter(2))
N = int(input()) * 4
ans = 0
for i in range(4):
    ans += N // p[i][0] * p[i][1]
    N -= N // p[i][0] * p[i][0]
print(ans)

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

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

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

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

Solution (Python):
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))

for i in range(4):
    l[i].append(tmp[i])

for i in range(4):
    l[i].append(l[i][1]*4/(l[i][0]*4))

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = 4*int(input())
for i in range(4):
    tmp = n//int(l[i][0]*4)
    if tmp >= 1:
        ans += tmp * l[i][1]
        n -= tmp*int(l[i][0]*4)

print(int(ans))

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Solution (Python):
Q, H, S, D = map(int, input().split())
N = int(input())
r = 0
if D*1<=Q*8 and D*1<=H*4 and D*1<=S*2:
    r += (N//2)*D
    N = N % 2

if S*2 <= H*4 and S*2 <= Q*8:
    r += N*S
    N = 0
if H*4 <= S*2 and H*4 <= Q*8:
    r += N*H*2
    N = 0
if Q*8 <= S*2 and Q*8 <= H*4:
    r += N*Q*4
    N = 0

print(r)

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

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

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 = float(input())

N = int(N * 4)

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

res = 0

while N > 0:
    if q > d and h > d and s > d:
        res += N // 8 * D
        N %= 8
        d = 10 ** 9
        
    elif q > s and h > s:
        res += N // 4 * S
        N %= 4
        s = 10 ** 9
        
    elif q > h:
        res += N // 2 * H
        N %= 2
        h = 10 ** 9

    else:
        res += N * Q
        N = 0

print(res)

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

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

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

tmp = n//2
tmp2 = n % 2
ans1 = tmp * d + tmp2 *m
ans2 = m * n

print(min(ans1, ans2))

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

q4 = 4*q
h2 = 2*h

minimum = min(q4, h2, s)

ans = 0
tmp = n//2
tmp2 = n % 2

ans += tmp * d
ans += tmp2 *minimum

ans2 = minimum * n

print(min(ans, ans2))

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

min_1l = min([4 * Q, 2 * H, 1 * S])
min_2l = min([8 * Q, 4 * H, 2 * S, D])

ans = 0
if min_2l == D:
  ans = D * (N // 2) + (N % 2) * min_1l
else:
  ans = N * min_1l

print(ans)

Solution (Python):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

q,h,s,d = map(int,input().split())
n = int(input())
h = min(q*2,h)
s = min(h*2,s)
if n == 1:
    print(s)
    sys.exit()

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

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

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

Solution (Python):



def f(Q,H,S,D,N,M):
    QQ=Q
    QH=H/2
    QS=S/4
    QD=D/8

    if N==0:
        return M

    if N==1:
        if QQ==min(QQ,QH,QS):
            return M+(4*Q)

        if QH==min(QQ,QH,QS):
            return M+(2*H)
        
        if QS==min(QQ,QH,QS):
            return M+(S)
    else:
        if QQ==min(QQ,QH,QS,QD):
            return M+4*Q*N
            
        if QH==min(QQ,QH,QS,QD):
            return M+2*H*N
        
        if QS==min(QQ,QH,QS,QD):
            return M+S*N
        
        if QD==min(QQ,QH,QS,QD):
            if N%2==0:
                return M+(N//2)*D
            else:
                return f(Q,H,S,D,1,M+(N//2)*D)




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

print(f(Q,H,S,D,N,0))

Solution (Python):
def solve():
  Q, H, S, D = map(int, input().split())
  N = int(input())
  two = min([Q*8,H*4,S*2,D])
  one = min([Q*4,H*2,S])
  ans = two*(N//2)+one*(N%2)
  return ans
print(solve())

Solution (Python):
*aa,n = map(int, open(0).read().split())

n *= 1000

bb = [250,500,1000,2000]

for i in range(1,4):
    aa[i] = min(aa[i], aa[i-1]*2)

ans = 0
for b,a in zip(bb[::-1], aa[::-1]):
    ans += n // b * a
    n %= b

print(ans)

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

Solution (Python):
Q, H, S, D = map(int, input().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

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

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

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

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

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

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

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

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

p = min([Q*4,H*2,S])

p1 = p*N
p2 = D*(N//2) + p*(N%2)
print(min([p1,p2]))

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

cQ = Q*8
cH = H*4
cS = S*2
cD = D 

m = min(cQ, cH, cS, cD)

if m == cQ:
    print(Q * N * 4)
elif m == cH:
    print(H * N * 2)
elif m == cS:
    print(S * N)
else:
    if N % 2 == 0:
        print(D * N // 2)
    elif N == 1:
        print(min(Q * 4, H * 2, S))
    else:
        c = (N-1) // 2 * D
        print(c + min(Q * 4, H * 2, S))

Solution (Python):

import sys
input=sys.stdin.readline

def main():
    quota,half,single,double = map(int,input().split())
    want_icetea=int(input())
    cost_list = [4 * quota, 2 * half, single, double / 2]
    ans=0
    if want_icetea >= 2:
        idx1 = cost_list.index(min(cost_list))
        if idx1 == 0:
            ans = 4 * quota * want_icetea
        elif idx1 == 1:
            ans = 2 * half * want_icetea
        elif idx1 == 2:
            ans = single * want_icetea
        elif idx1 == 3:
            if want_icetea % 2 == 0:
                ans = want_icetea // 2 * double
            elif want_icetea % 2 == 1:
                ans = want_icetea // 2 * double
                idx2 = cost_list.index(min(cost_list[:3]))
                if idx2 == 0:
                    ans += 4 * quota
                elif idx2 == 1:
                    ans += 2 * half
                elif idx2 == 2:
                    ans += single
    else:
        idx2 = cost_list.index(min(cost_list[:3]))
        if idx2 == 0:
            ans = 4 * quota * want_icetea
        elif idx2 == 1:
            ans = 2 * half * want_icetea
        elif idx2 == 2:
            ans = single * want_icetea
    print(ans)
if __name__=="__main__":
    main()

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

Solution (Python):
prices = [ int(p) for p in input().split(" ") ]
N = int(input())

total_price = 0

p1 = {"0.25": prices[0],  "0.5": prices[1], "1": prices[2], "2": prices[3]}
p2 = {"0.25": prices[0] * 8,  "0.5":prices[1] * 4, "1":prices[2] * 2, "2":prices[3]}
min_price = sorted(p2.items(), key=lambda x:x[1])

for item in min_price:
  if N >= float(item[0]):
    buy_num = int(N / float(item[0]))
    total_price += p1[item[0]] * buy_num
    N -= int(float(item[0]) * buy_num)
    
    
  if N == 0:
    break

print(total_price)

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

def main():
    """
    q:0.25l
    h:0.5l
    s:1l
    d:2l
    """
    q, h, s, d = [int(i) for i in input().strip().split()]
    n = int(input().strip())
    
    prices = list()
    heapq.heappush(prices, (q * 4, q, 0.25))
    heapq.heappush(prices, (h * 2, h, 0.5))
    heapq.heappush(prices, (s, s, 1))
    heapq.heappush(prices, (d / 2, d, 2))

    ans = 0
    _,price,size = heapq.heappop(prices)
    
    while n != 0:
        if size > n:
            _, price, size = heapq.heappop(prices)
            continue
        else:
            if size >= 1:
                ammount = n // size
                n = n % size
                ans += price * ammount
                continue
            else:
                ammount = int(n / size)
                ans += price * ammount
                break
    print(ans)
    return



if __name__ == "__main__":
    main()

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

Solution (Python):


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

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

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

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

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

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

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

if 2*min1 < min2 or n == 1:
    print(n*min1)
else:
    if n%2:
        print((n//2)*min2+min1)
    else:
        print((n//2)*min2)

Solution (Python):
def resolve():
    A,B,C,D = map(int,input().split())
    N = int(input())*4
    cc = [(8*A,A,1),(4*B,B,2),(2*C,C,4),(D,D,8)]
    cc.sort()
    ans = 0

    for _,cost,vol in cc:
         enable = N//vol
         ans += enable*cost
         N %= vol
    print(ans)
resolve()

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

Solution (Python):
c=list(map(int,input().split()))
n=int(input())
for i in range(4):
  for j in range(4-i):
    c[i+j]=min(c[i+j],c[i]*2**j)
print(n//2*c[3]+n%2*c[2])

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    q, h, s, d = map(int, readline().split())
    n = int(readline())
    ans = min(8 * q, 4 * h, 2 * s, d) * (n // 2) + min(4 * q, 2 * h, s) * (n % 2)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
q, h, s, d = map(int, input().split())
n = int(input())
ans = 0
q_per = q / 0.25
h_per = h / 0.5
s_per = s
d_per = d / 2
list = [q_per,h_per,s_per,d_per]
if min(list) == d_per :
    if n%2 == 0:
        ans += d * (n //2)
    else :
        ans += n//2 * d
        n -= n//2
        list.remove(d_per)
        if min(list) == s_per :
            ans += s_per
        elif min(list) == h_per :
            ans += h * 2
        else :
            ans += q * 4
elif min(list) == s_per :
    ans += n * s
elif min(list) == h_per :
    ans += n * 2 * h
else :
    ans += n * 4 * q

print(int(ans))

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

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

Solution (Python):
from decimal import Decimal
Q,H,S,D = [int(i) for i in input().split()]
costs = [[Q,Decimal("0.25")], [H,Decimal("0.5")], [S,Decimal("1")], [D,Decimal("2")]]
costs.sort(key=lambda x: Decimal(x[0]) / x[1])
N = int(input())
tc = 0
for c, a in costs:
    tc += c * (N // a)
    N %= a
print(int(tc))

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

print((n%2)*a+(n//2)*b)

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

Solution (Python):
price = [int(w) for w in input().split()]
n = int(input())
price[0]*=4
price[1]*=2
cheap = min(price[:3])

ans = n // 2 * min(cheap * 2, price[3])
ans += n % 2 * cheap


print(ans)

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

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


q,h,s,d = list(map(int, input().split()))
n = int(input())
vals = [q*4, h*2, s, d/2]
v = min(vals)
if v==q*4:
    ans = n*4*q
elif v==h*2:
    ans = n*2*h
elif v==s:
    ans = n*s
else:
    ans = (n//2)*d
    vv = min(vals[:-1])
    if n%2!=0:
        ans += vv
print(ans)

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

Solution (Python):

(*p, ) = map(int, input().split())
n = int(input())

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

if m == p[3]:
    print(n // 2 * m + n % 2 * m2)
else:
    print(n * m // 2)