Problem:
Heat Stroke We have had record hot temperatures this summer. To avoid heat stroke, you decided to buy a quantity of drinking water at the nearby supermarket. Two types of bottled water, 1 and 0.5 liter, are on sale at respective prices there. You have a definite quantity in your mind, but are willing to buy a quantity larger than that if: no combination of these bottles meets the quantity, or, the total price becomes lower. Given the prices for each bottle of water and the total quantity needed, make a program to seek the lowest price to buy greater than or equal to the quantity required. Input The input is given in the following format. $A$ $B$ $X$ The first line provides the prices for a 1-liter bottle $A$ ($1\leq A \leq 1000$), 500-milliliter bottle $B$ ($1 \leq B \leq 1000$), and the total water quantity needed $X$ ($1 \leq X \leq 20000$). All these values are given as integers, and the quantity of water in milliliters. Output Output the total price. Sample Input 1 180 100 2400 Sample Output 1 460 Sample Input 2 200 90 2018 Sample Output 2 450

Solution (Python):
a,b,n=list(map(int,input().split()))
if n%500!=0:n=n+500-n%500
if a>=b*2:
    print((n//500)*b)
elif a<b:
    if n%1000!=0:n=n+1000-n%1000
    print((n//1000)*a)
else:
    print(((n//1000)*a)+((n%1000)//500)*b)

Solution (Python):
a, b, x = map(int, input().split())
c = 0
while x > 0:
    if x > 500:
        c += a if a < 2*b else 2*b
        x-=1000
    else:
        c += b if b < a else a
        x-=500
print(c)

Solution (Python):
a,b,x=map(int,input().split())
pay=0
if a//2<b:
    if x==1000:
        pay=a
    elif x==500:
        if b>a:
            pay=a
        else:
            pay=b
    else:        
        aa=x//1000
        aaa=x%1000
        if aaa>500:
            pay=(aa+1)*a
        elif aaa==0:
            pay=aa*a
        else:
            pay=aa*a+b
else:
    if x==500:
        pay=b
    else:
        bb=x//500
        bbb=x%500
        if bbb==0:
            pay=bb*b
        else:
            pay=(bb+1)*b
print(pay)

Solution (Python):
import math

A, B, X = map(int, input().split())
if A<B:
	print(A*(-(-X//1000)))
elif A<2*B:
	C = A*(X//1000)
	if X%1000==0:
		pass
	elif X%1000<=500:
		C += B
	else:
		C += A
	print(C)
else:
	print(B*(-(-X//500)))

Solution (Python):

a,b,c = map(int,input().split())


i = c // 500


if c % 500 != 0:i += 1


if a >= b * 2:print(b * i)
elif a < b and c <= 1000:print(a)
else:print((i // 2) * a + (i % 2) * b)

Solution (Python):
a,b,x = list(map(int, input().split()))
t = a * (x // 1000) + b * -(-(x % 1000) // 500)
print(min(a * -(-x // 1000), b * -(-x // 500), t))

Solution (Python):
a,b,x = map(int, input().split())
if a >= b*2:
    print(((x-1)//500+1)*b)
elif x%1000 > 500:
    print(((x-1)//1000+1)*a)
else:
    print(min(((x-1)//1000+1)*a, x//1000*a+b))

Solution (Python):
a, b, x = [int(i) for i in input().split()]

if x % 1000:
    max_a = x // 1000 + 1
else:
    max_a = x // 1000

if x % 500:
    max_b = x // 500 + 1
else:
    max_b = x // 500

min_cost = max_a*a + max_b*b

for i in range(max_a + 1):
    for j in range(max_b + 1):
        if 1000*i + 500*j >= x:
            if a*i + b*j < min_cost:
                min_cost = a*i + b*j
            break
        
print(min_cost)

Solution (Python):
import math

A, B, X = map(int, input().split())
ans = float('inf')

for a in range(math.ceil(X/1000)+1):
    if X-1000*a < 0: b = 0
    else: b = math.ceil((X-1000*a)/500)
    ans = min(ans, A*a+B*b)

print(ans)

Solution (Python):
a, b, x = map(int, input().split())
d, mo = divmod(x, 1000)
if mo>500: print(min(d*a+2*b, (d+1)*a, (d*2+2)*b))
elif mo!=0: print(min(d*a+b, (d+1)*a, (d*2+1)*b))
else: print(min(d*a, d*2*b))

Solution (Python):
a,b,x=map(int,input().split())
ans=10**9
for i in range(21):
    for j in range(41):
        if i*1000+j*500>=x:
            ans=min(ans,i*a+j*b)
print(ans)

Solution (Python):
A, B, X = map(int, input().split())
k = (X // 1000)
ans = k * min(A, 2*B)
r = X - 1000*k
if 0 < r <= 500:
    ans += min(A, B)
elif 500 < r:
    ans += min(A, 2*B)
print(ans)

Solution (Python):

import math

A,B,X = [int(i) for i in input().split()]

ans1 = math.ceil(X/1000) * A
ans2 = math.ceil(X/500) * B
ans3 = math.floor(X/1000) * A + math.ceil((X % 1000)/500) * B

print(min(ans1,ans2,ans3))

Solution (Python):
import math
a, b, x = map(int,input().split())
ans = 0

if a < b:
    ans = math.ceil(x/1000)* a
    print(ans)
elif a >= b*2:
    print(math.ceil(x/500)*b)
else:
    ans = (x // 1000)*a
    if (x % 1000) > 500:
        ans += a
    elif x % 1000 == 0:
        pass
    else:
        ans += b
    print(ans)

Solution (Python):
A, B, X = map(int, input().split())
if A > 2 * B:
    A = 2 * B
if A < B:
    B = A
ans = X // 1000 * A
X %= 1000

a, b, x = A, B, X
wa = ans + (0 if X == 0 else (B if X <= 500 else A))
print(wa)

Solution (Python):
x, y, z = map(int, input().split())

lit = z // 500
if z % 500 != 0:
    lit += 1

ans = min(y * lit, x * (lit // 2 + 1), x *(lit // 2) + y * (lit % 2))

print(ans)

Solution (Python):
a, b, x = map(int, input().split())
if a > b * 2:
    m = (x + 499) // 500 * b
elif a < b or ((x - 1) % 1000) >= 500:
    m = (x + 999) // 1000 * a
else:
    m = x // 1000 * a + b
print(m)

Solution (Python):
A,B,X = map(int, input().split())
ans = a = b = 0

if  X % 500 != 0:  X += 500 - X%500
if  A < B:
    a = X//1000 + (1 if (X%1000>0) else 0)
elif A > 2*B:
    b = X//500
else:
    a = X//1000; X %= 1000
    b = X//500

print(A*a + B*b)

Solution (Python):
a, b, x = map(int, input().split())
if b * 2 <= a:
  ans = b * (x // 500 + bool(x % 500))
else:
  ans = a * (x // 1000) + min(b * ((x % 1000) // 500 + bool((x % 1000) % 500)), a * bool(x % 1000))
print(ans)

Solution (Python):
a, b, x = map(int, input().split())
if a // 2 < b:
    if x % 1000 == 0:
        print(a*(x//1000))
    else:
        if (x % 1000) / 500 > 1:
            print(min(a*(x//1000 + 1), a*(x//1000) + b*2))
        else:
            print(min(a*(x//1000 + 1), a*(x//1000) + b))
else:
    if x % 500 == 0:
        print(b*(x//500))
    else:
        print(b*(x//500 + 1))

Solution (Python):

a, b, x = map(int, input().split())

if a // 2 < b:
    num_a = x // 1000
    if x % 1000 == 0:
        print(a * num_a)
    elif a < b:
        print(a * (num_a + 1))
    elif x % 1000 > 500:
        print(a * (num_a + 1))
    else:
        print(a * num_a + b)
else:
    num_b = x // 500
    if x % 500 == 0:
        print(b * num_b)
    else:
        print(b * (num_b + 1))

Solution (Python):
A, B, X = map(int, input().split())
A = min(A, B * 2)
B = min(A, B)
n = -(-X // 500)
print(n // 2 * A + n % 2 * B)

Solution (Python):
a,b,x = map(int,input().split())

ans = 10**10
for i in range(22):
    for j in range(44):
        if i*1000 + j*500 >= x:
            ans = min(ans, a*i+b*j)
print(ans)

Solution (Python):
import math
A, B, X = map(int, input().split())
C = X // 1000
D = X % 1000
print(min(A*C, B*C*2) + min(math.ceil(D/1000)*A, math.ceil(D/500)*B))