Problem:
 Score : 300 points    Problem Statement "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.      Constraints  1 ≤ A, B, C ≤ 5000  1 ≤ X, Y ≤ 10^5  All values in input are integers.         Input Input is given from Standard Input in the following format:  A  B  C  X  Y       Output Print the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.        Sample Input 1 1500 2000 1600 3 2      Sample Output 1 7900  It is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.       Sample Input 2 1500 2000 1900 3 2      Sample Output 2 8500  It is optimal to directly buy three A-pizzas and two B-pizzas.       Sample Input 3 1500 2000 500 90000 100000      Sample Output 3 100000000  It is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.

Solution (Python):
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C, X, Y] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2]), int(input_raw[3]), int(input_raw[4])]

    min_cost = sys.maxint
    for c in range(max(X, Y) * 2 + 1):
        a = max(int((X - 0.5 * c) + 0.5), 0)
        b = max(int((Y - 0.5 * c) + 0.5), 0)
        cost = a * A + b * B + c * C
        if cost < min_cost:
            min_cost = cost
    print min_cost

if __name__ == '__main__':
    main()

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


max_num = max(x,y)
cost_1 = max_num*2*c

min_num = min(x,y)
cost_2 = (x-min_num)*a + (y-min_num)*b + c*2*min_num

cost_3 = (x*a + y*b)

print(min(cost_3,min(cost_1,cost_2)))

Solution (Python):
def c_half_and_half(A, B, C, X, Y):
    if X <= Y:
        tmp = X * 2 * C + (Y - X) * B
    else:
        tmp = Y * 2 * C + (X - Y) * A
    ans = min(tmp, max(X, Y) * 2 * C, X * A + Y * B)
    return ans

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

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

c = c * 2

total = 0

minimum = min(x,y)

if a + b > c:
  total += minimum * c
  x -= minimum
  y -= minimum

if x > 0:
  if a > c:
    total += x * c
  else:
    total += x * a

if y > 0:
  if b > c:
    total += y * c
  else:
    total += y * b

print(total)

Solution (Python):
A, B, C, X, Y = map(int, input().split())

m = min([X,Y])
M = max([X,Y])
d = abs(X-Y)
if A+B < 2*C:
  res = X*A + Y*B
elif X < Y:
  if 2*C*X + B*(Y-X) < 2*C*Y:
    res = 2*C*X + B*(Y-X)
  else:
    res = 2*C*Y
else:
  if 2*C*Y + A*(X-Y) < 2*C*X:
    res = 2*C*Y + A*(X-Y)
  else:
    res = 2*C*X

print(res)

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

ans1 = 2 * min(x, y) * c
if x >= y:
  ans1 += (x - y) * a
else:
  ans1 += (y - x) * b

ans2 = x * a + y * b

ans3 = 2 * max(x, y) * c

print(min(ans1, ans2, ans3))

Solution (Python):
a, b, ab, x, y = (int(i) for i in input().split())  
if a + b <= (ab * 2):
    print(a*x+b*y)
else:
    num_ab = min(x,y)*2
    price = 0
    price += num_ab*ab + (x-num_ab/2)*a + (y-num_ab/2)*b
    price2 = 0
    price2 += max(x,y)*ab*2
    print(int(min(price,price2)//1))

Solution (Python):
A,B,C,X,Y = map(int, input().split())
Z = X-Y
if Z<0:
  AB_least = min([X,Y])*2*C + abs(Z)*B
else:
  AB_least = min([X,Y])*2*C + Z*A
AB_all = max([X,Y])*2*C
AandB = A*X + B*Y
ans = min([AB_least,AB_all,AandB])
print(ans)

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

if 2*c<(a+b):
    if x>=y:
        if 2*c<a:
            print(2*c*x)
        else:
            print(2*c*y+(x-y)*a)
    else:
        if 2*c<b:
            print(2*c*y)
        else:
            print(2*c*x+(y-x)*b)
else:
    print(a*x+b*y)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
com = min(X, Y)
min_cost = min(A+B, C*2)

if min_cost * max(X, Y) < min_cost * com  + A * (X - com) + B * (Y - com):
    print(min_cost * max(X, Y))
else:
    print(min_cost * com  + A * (X - com) + B * (Y - com))

Solution (Python):
money_a, money_b, money_c, num_a, num_b = [int(x) for x in input().strip().split()]
sum_money = list()
temp = 0
for _ in range(num_a):
    temp += money_a
for _ in range(num_b):
    temp += money_b
sum_money.append(temp)
temp = 0
for _ in range(min(num_a, num_b)):
    temp += money_c*2
if num_a > num_b:
    temp += money_a * (num_a-num_b)
elif num_a < num_b:
    temp += money_b * (num_b-num_a)
sum_money.append(temp)
temp = 0
for _ in range(max(num_a, num_b)):
    temp += money_c*2
sum_money.append(temp)
print(min(sum_money))

Solution (Python):
import sys

A,B,C,X,Y = list(map(int,input().split()))

if A+B < 2*C:
    print(A*X+B*Y)
else:
    pre = []
    pre.append(max(X,Y)*2*C)
    if X>Y:
        
        pre.append(Y*2*C+(X-Y)*A)
    elif X<Y:
        
        pre.append(X*2*C+(Y-X)*B)
    else:

        pre.append(Y*2*C+(X-Y)*A)
        pre.append(X*2*C+(Y-X)*B)
    print(min(pre))

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = 0
if(2 * c < a + b):
    ans += min(x, y) * 2 * c
    z = x
    x -= min(x, y)
    y -= min(z, y)
    
    if(c * 2 < a):
        ans += c * 2 * x
        x = 0
    else:
        ans += a * x
       
        x = 0
    if(c * 2 < b):
        ans += c * 2 * y
        y = 0
    else:
        ans += b * y
        y = 0  
else:
    ans = x * a + b * y
print(ans)

Solution (Python):
a, b, c, x, y = list(map(int, input().split()))
ans = []
ans.append(a*x+b*y)
if(x>y):
    ans.append(c*2*x)
    ans.append(c*2*y+a*(x-y))
else:
    ans.append(c*2*y)
    ans.append(c*2*x+b*(y-x))
print(min(ans))

Solution (Python):
A,B,C,X,Y = map(int,input().split())
addition = 0
if X > Y:
    addition = A
elif X < Y:
    addition = B
    
print(min(A*X + B*Y, 2*C*min(X,Y) + abs(X-Y)*addition, 2*C*max(X,Y)))

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

price_a = int(input_conditions[0])
price_b = int(input_conditions[1])
price_ab = int(input_conditions[2])
required_a = int(input_conditions[3])
required_b = int(input_conditions[4])

price_1 = price_a * required_a + price_b * required_b

if required_a > required_b:
    price_2 = price_ab * required_b * 2 + price_a * (required_a - required_b)
else:
    price_2 = price_ab * required_a * 2 + price_b * (required_b - required_a)

price_3 = price_ab * max(required_a, required_b) * 2

print(min(price_1, price_2, price_3))

Solution (Python):
A,B,C,X,Y=map(int,input().split())
m=min(X,Y)
d=A+B
c=2*C
ans=0
if d>c:
    ans+=c*m
else:
    ans+=d*m
l=max(X,Y)
if X>Y:
    if A>c:
        ans+=c*(l-m)
    else:
        ans+=A*(l-m)
else:
    if B>c:
        ans+=c*(l-m)
    else:
        ans+=B*(l-m)
print(ans)

Solution (Python):
from math import ceil
A,B,C,X,Y=list(map(int,input().split()))


x=A*X+B*Y

if X>=Y:
    y=C*2*Y+A*ceil((2*X-2*Y)/2)
else:
    y=C*2*X+B*ceil((2*Y-2*X)/2)

z=C*2*max(X,Y)
    
print(min(x,y,z))

Solution (Python):
A, B, C, X, Y = list(map(int, input().split()))

if X>Y:
    A, B = B, A
    X, Y = Y, X
excessB = Y-X

ans = min(2*C, A+B)*X
ans += min(2*C, B)*excessB

print(ans)

Solution (Python):

def abc095C():
    a, b, c, x, y = map(int, input().split())

    diff = abs(x - y)
    price1 = [(a + b) * min(x, y), 2 * c * min(x, y)][a + b >= c * 2] + diff * [a, b][x < y]
    print(min(price1, max(x, y) * c * 2))


abc095C()

Solution (Python):
import math

A, B, C, X, Y = map(int, input().split())

if A + B < C * 2:
    p = A * X + B * Y
else:
    if X > Y:
        p = Y * C * 2
        if A > C * 2:
            p += math.ceil((X - Y) * 2) * C
        else:
            p += (X - Y) * A
    else:
        p = X * C * 2
        if B > C * 2:
            p += math.ceil((Y - X) * 2) * C
        else:
            p += (Y - X) * B

print(p)

Solution (Python):
a,b,c,x,y = map(int,input().split())
ans = 0
d = a+b
if d>2*c:
    while min(x,y)>0:
        ans += 2*c
        x -= 1
        y -= 1
else:
    while min(x,y)>0:
        ans += d
        x -= 1
        y -= 1
        

if x == 0:
    sus = min(2*c,b)
    while y>0:
        ans += sus
        y -= 1

        
else:
    sus = min(a,2*c)
    while x>0:
        ans += sus
        x -= 1
        
print(ans)

Solution (Python):
a, b, c, x, y = map(int, input().split())
out1 = a * x + b * y
if x > y:
    out2 = x*c*2
    out3 = y*c*2 + (x-y)*a
else:
    out2 = y*c*2
    out3 = x*c*2 + (y-x)*b
print(min([out1, out2, out3]))

Solution (Python):
def main():
    A, B, AB, X, Y = list(map(int, input().split()))

    min_price = 10**100

    for n_pizza_ab in range(0, 200001, 2):
        short_pizza_a = max(X - n_pizza_ab // 2, 0)
        short_pizza_b = max(Y - n_pizza_ab // 2, 0)

        price = short_pizza_a * A + short_pizza_b * B + n_pizza_ab * AB

        if price < min_price:
            min_price = price

    print(min_price)

main()

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

z = min(x, y)
total = 0

if (a+b) > c*2:
    total += c * 2 * z
else:
    total += a * z + b * z

if (a < c * 2):
    total += (x-z) * a
else:
    total += (x-z) * c * 2

if (b < c * 2):
    total += (y-z) * b
else:
    total += (y-z) * c * 2

print(total)

Solution (Python):
a, b, c, x, y = map(int, input().split())
m = 0
if a + b < 2 * c:
    m += (a * x) + (b * y)
else:
    m += 2*min([x, y])*c
    if x - y < 0:
        m += min([(abs(x-y) * b), 2*abs(x-y) * c])
    else :
        m += min([(abs(x-y) * a), 2*abs(x-y) * c])
print(m)

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


aprice = a*x + b*y

if x > y:
    amari = a*(x-y)
elif x < y:
    amari = b*(y-x)
else:
    amari = 0
bprice = min(x,y)*c*2 + amari

cprice = c*max(x, y)*2


print(min(aprice,bprice,cprice))

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

res = 0
tmp = 0
pair = False
if a // 2 + b // 2 < c:
    res = a+b
else:
    res = c*2

tmp = res * min(x, y)

if x > y:
    print(tmp + abs(x - y) * min(res, a))
else:
    print(tmp + abs(x - y) * min(res, b))

Solution (Python):
a,b,c,x,y = map(int, input().split(" "))
sum = 0
if a+b >= c*2:
    v = min(x, y)
    for i in range(v):
        sum += 2*c
    x -= v
    y -= v

if a < c*2:
    sum += a*x
if b < c*2:
    sum += b*y
if a >= c*2:
    sum += 2*c*x
if b >= c*2:
    sum += 2*c*y
print(sum)

Solution (Python):
A,B,C,X,Y = map(int,input().split())
if A+B <= 2*C:
    print(A*X+B*Y)
else:
    if X < Y:
        if B <= 2*C:
            print(X*2*C+(Y-X)*B)
        else:
            print(2*Y*C)
    elif X == Y:
        print(2*X*C)
    else:
        if A <= 2*C:
            print(Y*2*C+(X-Y)*A)
        else:
            print(2*X*C)

Solution (Python):

A,B,C,X,Y = map(int,input().split())

if A + B < 2*C:
	print(X*A+B*Y)
else:
	ans1 = 2*C*max(X,Y)
	if X > Y:
		ans2 = 2*C*Y + A*(X-Y)
	else:
		ans2 = 2*C*X + B*(Y-X)
	print(min(ans1,ans2))

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())

cost = 0
n_small = min(X, Y)

if A + B > 2*C:
    cost += n_small * (2*C)
else:
    cost += n_small * (A+B)

X -= n_small
Y -= n_small

if X == 0:
    if B > 2*C:
        cost += Y * (2*C)
    else:
        cost += Y * B
else:
    if A > 2*C:
        cost += X * (2*C)
    else:
        cost += X * A
        
print(cost)

Solution (Python):



def solve(A, B, C, X, Y):

  def cost(cnt):
    a, b, c = cnt
    return a * A + b * B + c * C

  def useAB(cnt):
    return [max(0, cnt[0] - 1),
            max(0, cnt[1] - 1),
            cnt[2] + 2]

  cnt = [X, Y, 0]
  while cost(cnt) > cost(useAB(cnt)):
    cnt = useAB(cnt)

  return cost(cnt)


if __name__ == '__main__':
  A, B, C, X, Y = map(int, input().split())
  print(solve(A, B, C, X, Y))

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

if x>=y:
    print( min(y*2*c+a*(x-y), x*a+y*b, 2*c*x) )

else:
    print( min(x*2*c+b*(y-x), x*a+y*b, 2*c*y) )

Solution (Python):
a,b,c,x,y=map(int,input().split())
price=0
z=min(x,y)
w=max(x,y)
if a+b>c*2:
    d=w*2*c
    e=z*c*2+(x-z)*a+(y-z)*b
    print(min(e,d))

else:
    print(a*x+b*y)

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

mincost=min(a+b,2*c)
ans=0
while (x>0 and y>0):
    ans+=mincost
    x-=1
    y-=1

ans+=min(a,2*c)*x+min(b,2*c)*y
print(ans)

Solution (Python):
import sys

A,B,C,X,Y=list(map(int,input().split()))


cost=0
if 2*C<A+B:
	mini=min([X,Y])
	cost+=mini*C*2
	X-=mini
	Y-=mini
	if not X==0:
		if 2*C<A:
			cost+=2*C*X
			X=0
	elif not Y==0:
		if 2*C<B:
			cost+=2*C*Y
			Y=0



cost+=X*A+Y*B

print(cost)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
C *= 2

ans1 = A*X + B*Y
ans2 = C*max(X,Y)

ans3 = C*min(X,Y)
if X < Y:
    ans3 += (Y-X)*B
else:
    ans3 += (X-Y)*A


print(min(ans1, ans2, ans3))

Solution (Python):
a,b,c,x,y = map(int,input().split(" "))
if x < y:
    a,b = b,a
    x,y = y,x
ans1 = a*x + b*y
ans2 = 2*c*max(x,y)
ans3 = 2*c*min(x,y)+(x-y)*a
print(min(ans1,ans2,ans3))

Solution (Python):
A, B, C, X, Y = list(map(int, input().split()))

m = min(X, Y)
X -= m
Y -= m

price = m * min(A + B, 2 * C)
price += min(A, 2 * C) * X + min(B, 2 * C) * Y
print(price)

Solution (Python):
A, B, C, X, Y = list(map(int, input().split()))

if A+B <= 2*C:
    cost = A*X + B*Y
else:
    if X >= Y:
        if A < 2*C:
            cost = Y*2*C + (X -Y)*A
        else:
            cost = X*2*C
    else:
        if B < 2*C:
            cost = X*2*C + (Y-X)*B
        else:
            cost = Y*2*C

print(cost)

Solution (Python):
A, B, C, X, Y = list(map(int, input().split()))

ans = 0
numab = min(X, Y)
if C * 2 < A + B:
    ans += numab * C * 2
else:
    ans += numab * (A + B)

if X < Y:
    if C * 2 < B:
        ans += (Y - X) * C * 2
    else:
        ans += (Y - X) * B
else:
    if C * 2 < A:
        ans += (Y - X) * C * 2
    else:
        ans += (X - Y) * A

print(ans)

Solution (Python):
a,b,c,x,y = map(int,input().split())
temp = 0
if x > y:
    temp = min(a*x+b*y,a * (x-y) + c * 2 * y,c * 2 * x)
else:
    temp = min(a*x+b*y,b * (y-x) + c * 2 * x,c * 2 * y)
print(temp)

Solution (Python):
A, B, C, X, Y = map(int, input().split())


if A + B >= 2 * C:
    if X >= Y:
        cnt = min((C * 2 * Y) + A * (X - Y), (C * 2 * X))
    else:
        cnt = min((C * 2 * X) + B * (Y - X), (C * 2 * Y))
    
else:
    cnt = (A * X) + (B * Y)
    
print(cnt)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
if A+B>C*2:
    ans = 2*C*min(X, Y)
    if X>Y:
        ans += (X-Y)*min(A, 2*C)
    elif X<Y:
        ans += (Y-X)*min(B, 2*C)
else:
    ans = X*A+Y*B
print(ans)

Solution (Python):
a, b, c, x, y = map(int, input().split())
num = float("inf")
for i in range(max(x, y) + 1):
    num = min(num, a * max(0, (x - i)) + b * max(0, (y - i)) + 2 * c * i)
print(num)

Solution (Python):
a,b,c,x,y = (int(i) for i in input().split())
if x<y:
	print(min(c*2*x+b*(y-x),c*2*y,a*x+b*y))
else:
	print(min(c*2*y+a*(x-y),c*2*x,a*x+b*y))

Solution (Python):
A,B,C,X,Y = map(int,input().split())
Ans = 0
Z = min(X,Y)
if A+B >= C*2:
    Ans = min(C*Z*2 + A*(X-Z) + B*(Y-Z), C*max(X,Y)*2)
else:
    Ans = A*X + B*Y
print(Ans)

Solution (Python):
a, b, c, x, y = map(int,input().split())
p = (a + b) / 2

if x == y:
    ans = min(a * x + b * y, c * x * 2)
elif x > y:
    ans = min(a * x + b * y, c * x * 2, c * y * 2 + a *(x-y))
else:
    ans = min(a * x + b * y, c * y * 2, c * x * 2 + b *(y-x))

print(ans)