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):
A,B,C,X,Y = [int(i) for i in input().split()]
Sum = 0
if A+B<=2*C:
    Sum = A*X+B*Y
else:
    Min = min([X,Y])
    Sum+=Min*(2*C)
    Y-=Min;X-=Min
    if A*X+B*Y<=2*C*(X+Y):
        Sum+=A*X+B*Y
    else:
        Sum+=2*C*(X+Y)
print(Sum)

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

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

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

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

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

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

ans = 0

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

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

Solution (Python):
a,b,c,x,y = list(map(int,input().split()))
for i in range(100001):
    price_new = i*2*c + max(0, x-i)*a + max(0, y-i)*b
    if i==0:
        price = price_new
    else:
        price = min(price, price_new)

print(price)

Solution (Python):
import math

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


res = float('inf')
for i in range(max(x,y)*2+1):
    money = i * c
    if i/2<x:
        money += math.ceil(x-i/2) * a
    if i/2<y:
        money += math.ceil(y-i/2) * b
    res = min(res,money)

print(res)

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

Solution (Python):
A,B,C,X,Y = map(int, input().split())
ans = A*X+B*Y
for i in range(max(X,Y)+1):
  ans = min(ans, A*max(X-i,0)+B*max(Y-i,0)+C*i*2)
print(ans)

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def main():
    A, B, C, X, Y = map(int, input().split())
    
    ans = INF
    for c in range(0, max(X, Y) * 2 + 1, 2):
        p = c * C
        p += max(0, A * (X - (c // 2)))
        p += max(0, B * (Y - (c // 2)))
        ans = min(ans, p)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):

"""
Created on Thu Aug  9 23:51:35 2018

@author: Yuki
"""

A, B, AB, Acnt, Bcnt =map(int, input().split())

res = []

res.append(A*Acnt+B*Bcnt)


if Acnt >= Bcnt:
    res.append(Bcnt*2*AB+(Acnt-Bcnt)*A)
else:
    res.append(Acnt*2*AB+(Bcnt-Acnt)*B)


res.append(max(Acnt, Bcnt)*2*AB)
print(min(res))

Solution (Python):
def main():
  t = input().split(" ")
  A, B, C, X ,Y = int(t[0]), int(t[1]), int(t[2]), int(t[3]), int(t[4])
  a_p = min(A, 2*C)
  b_p = min(B, 2*C)
  set_p = min(A+B, 2*C)
  set_n = min(X, Y)
  a_n = X - set_n
  b_n = Y - set_n
  r = a_p * a_n + b_p * b_n + set_p * set_n
  print(r)
main()

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

print(min(A+B, C*2) * min(X,Y) + (X - min(X,Y)) * min(A, C*2) + (Y - min(X,Y)) * min(B, C*2))

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

A,B,C,X,Y = inpl()


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

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

print(ans)

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





cheapest = float("inf")

for i in range(max(X, Y) + 1):

    price = 2 * C * i + A * max(0, X - i) + B * max(0, Y - i)

    cheapest = min(cheapest, price)

print(cheapest)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
price = 0
min_num = min([X,Y])
if A/2 + B/2 > C:
    X -= min_num
    Y -= min_num
    if X == 0:
        print(min([min_num *2* C + B * Y, (Y+min_num)*2*C]))
    else:
        print(min([min_num *2* C + A * X, (X+min_num)*2*C]))
else:
    print(A*X+ B*Y)

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

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

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

print(min(a*x + b*y - (((a+b)-c*2)*min(x, y) if c*2 < a+b else 0), 2*c*max(x,y)))

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

C *= 2
ans1 = A*X + B*Y
ans2 = C*X + B*max(0,Y-X)
ans3 = C*Y + A*max(0,X-Y)
print(min(ans1,ans2,ans3))

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

cand1 = A*X + B*Y
cand2 = 2*C*min(X,Y) + A * max(0,X-Y) + B * max(0,Y-X) 
cand3 = 2*C*max(X,Y)

print(min(cand1,cand2,cand3))

Solution (Python):

a,b,c,x,y = map(int,input().split())
minv = a * x + b * y
c *= 2
big = max(x,y)
sml = min(x,y)
if a+b > c:
    minv = minv - (a+b) * sml + c * sml
if sml == x and b > c:
    minv = minv - (b-c) * (big - sml)
if sml == y and a > c:
    minv = minv - (a-c) * (big - sml)

print(minv)

Solution (Python):
A,B,C,X,Y=map(int,input().split())
l=[C*2*i+A*(X-i)+B*(Y-i) for i in range(min(X,Y)+1)]+[C*2*max(X,Y)]
print(min(l))

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

min_amt = 2*10**5*5001

for i in range(0, max(X, Y) * 2 + 1) :
    min_amt = min(min_amt, C*2*i + max(0, (X - i) * A) + max(0, (Y - i) * B))
    
print(min_amt)

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

ans=float("inf")
for i in range(max(x, y) + 1):
    if i <= min(x, y):
        temp = a * (x - i) + b *(y - i) + c * 2 * i
        ans = min(temp, ans)
    else:
        if x > y:
            temp = a * (x - i) + c * 2 * i
        else:
            temp = b * (y - i) + c * 2 * i
            ans = min(ans, temp)
print(ans)

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

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

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

Solution (Python):


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

    ABset = 2 * C
    min_price = 0

    
    if ABset <= A + B:
        if X >= Y:
            min_price += ABset * Y
            min_price += min(A * (X - Y), ABset * (X - Y))
        if X < Y:
            min_price += ABset * X
            min_price += min(B * (Y - X), ABset * (Y - X))
    else:
        min_price += A * X + B * Y

    print(min_price)

if __name__ == '__main__':
    main()

Solution (Python):
A, B, C, X, Y = [int(x) for x in input().split()]

def main():
    base = min(X, Y)
    rest = max(X, Y) - base
    is_x = X > Y

    base_price = min(A + B, 2 * C) * base
    rest_price = min((A if is_x else B), 2 * C) * rest

    print(base_price + rest_price)

if __name__ == "__main__":
    main()

Solution (Python):
A,B,C,X,Y=map(int,input().split())
price_sum_1=A*X+B*Y
if min(X,Y)==X:
    price_sum_2=C*X*2+(Y-X)*B
else:
    price_sum_2=C*Y*2+(X-Y)*A

if max(X,Y)==X:
    price_sum_3=C*X*2
else:
    price_sum_3=C*Y*2
    
print(min(price_sum_1,price_sum_2,price_sum_3))

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 and a<2*c:
    print(a*(x-y)+2*c*y)
  elif x<y and b<2*c:
    print(b*(y-x)+2*c*x)
  else:
    print(2*c*max(x,y))

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

ans = float("INF")
for i in range(max(x, y)+1):
  t = c*2*i
  if x>i:
    t += (x-i)*a
  if y>i:
    t += (y-i)*b
  ans = min(ans, t)
print(ans)

Solution (Python):
a,b,c,x,y = input().split()
A = int(a)
B = int(b)
C = int(c)
X = int(x)
Y = int(y)

min_yen = 0

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

		if(X!=0 and (C*2 < B)):
			min_yen += C*2*Y
		elif(X!=0 and(C*2 >= B)):
			min_yen += B*Y

	else:
		min_yen += A*X

		if(C*2 < B):
			min_yen += C*2*Y
		else:
			min_yen += B*Y


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

		if(X!=0 and (C*2 < A)):
			min_yen += C*2*X
		elif(X!=0 and(C*2 >= A)):
			min_yen += A*X
	else:
		min_yen += B*Y

		if(C*2 < A):
			min_yen += C*2*X

		else:
			min_yen += A*X

print(min_yen)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
mA = min(A,B)
MB = max(A,B)
mXY = min(X,Y)
if A != mA:
    AX = Y
    BY = X
else:
    AX = X
    BY = Y
A = mA
B = MB
X = AX
Y = BY
ans = 0
if A <= C and B <= C:
    ans = A*X + B*Y
else:
    if A + B <= 2*C:
        ans = mXY * (A+B)
        if X > Y:
            ans += A*(X - mXY)
        else:
            ans += B*(Y - mXY)
    else:
        ans = mXY * 2 * C
        if X > Y:
            ans += min(A,2*C)*(X-mXY)
        else:
            ans += min(B,2*C)*(Y-mXY)
print(ans)

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
s1 = A * X + B * Y
s2 = A * (X - min(X, Y)) + B * (Y - min(X, Y)) + C * 2 * min(X, Y)
s3 = C * 2 * max(X, Y)
print(min(s1, s2, s3))

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

if A+B<2*C:
    tmp=A+B
else:
    tmp=2*C

ans=tmp*min(X,Y)



X2=X-min(X,Y)
Y2=Y-min(X,Y)

a1=X2*A+Y2*B
a2=X2*2*C+Y2*2*C

if a1<a2:
    print(ans+a1)
else:
    print(ans+a2)

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

Solution (Python):
a_price, b_price, c_price, a_target, b_target = map(int, input().split())

i = 0
i_max = 0
ans = float("inf")

if a_target > b_target:
    i_max = a_target
else:
    i_max = b_target

for i in range(0, i_max + 1):
    sum = i * c_price * 2 + max(0, a_target - i) * a_price + max(0, b_target - i) * b_price
    if sum < ans:
        ans = sum

print(ans)

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

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

Solution (Python):


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

ooiXY=max(X,Y)
sukunaiXY=min(X,Y)
ans1=C*ooiXY*2
ans2=A*X+B*Y
ans3=C*sukunaiXY*2+A*(X-sukunaiXY)+B*(Y-sukunaiXY)

print(min(ans1,ans2,ans3))

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


def abs0(inp):
    if inp < 0:
        return 0
    else:
        return inp


for i in range(x+1):
    a_l.append(a*i + c*2*(x-i) + b*abs0(y-(x-i)))
b_l = []
for i in range(y+1):
    b_l.append(b*i + c*2*(y-i) + a*abs0(x-(y-i)))
print(min(a_l + b_l))

Solution (Python):
A, B, C, X, Y = map(int, input().split(" "))
p1 = A * X + B * Y
p2 = C * min(X, Y) * 2
if X > Y:
    p2 += (X - Y) * A
else:
    p2 += (Y - X) * B
p3 = C * max(X, Y) * 2
print(min(p1, p2, p3))

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

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

Solution (Python):

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

    y1 = a * x + b * y
    y2 = c * max(x, y) * 2
    if x >= y:
        y3 = c * y * 2
        y3 += a * (x - y)
    else:
        y3 = c * x * 2
        y3 += b * (y - x)
    print(min(y1, y2, y3))

if __name__ == '__main__':
    main()

Solution (Python):
A, B, C, X, Y = map(int, input().split())
sum1 = A * X + B * Y
sum2 = C * min(X, Y) * 2 + A * (X - min(X, Y)) + B * (Y - min(X , Y))
sum3 = C * max(X, Y) * 2
print(min(sum1, sum2, sum3))

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

if X>=Y:
    bigger = A
else:
    bigger = B


common = max(X,Y) - abs(X-Y)
if (A+B)/2 < C:
    total = A*common + B*common
else:
    total = C*common*2

difference = abs(X-Y)
if bigger < C*2:
    total = total + bigger*difference
else:
    total = total + difference*C*2


print(total)

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

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

print(kingaku)

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

money = 0
if A + B >= C*2:
    t = min(X,Y)
    money += t * 2 * C
    X -= t
    Y -= t
    if X > 0:
        if A > C*2:
            money += C * 2 * X
        else:
            money += A * X
    elif Y > 0:
        if B > C*2:
            money += C * 2 * Y
        else:
            money += B * Y
else:
    money += A * X + B * Y
print(money)

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

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

AB *= 2
result = [A*X+B*Y, AB*max(X,Y), AB*Y+A*(X-Y) if X>Y else AB*X+B*(Y-X)]

print(min(result))

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

AB *= 2
result = [A*X+B*Y, AB*max(X,Y), AB*Y+A*(X-Y) if X>Y else AB*X+B*(Y-X)]

print(min(result))

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

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

is_break = 0

for i in range(100000):
    if price >= A*max(0, X - i) + B*max(0, Y - i)+2*C*i:
        price = A*max(0, X - i) + B*max(0, Y - i)+2*C*i
print(price)

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

z = min(x, y)
total = z * min(a + b, 2 * c)
total += (x - z) * min(a, 2 * c)
total += (y - z) * min(b, 2 * c)

print(total)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
sum1 = A * X + B * Y
sum2 = A * (X - min(X, Y)) + B * (Y - min(X, Y)) + C * 2 * min(X, Y)
sum3 = C * 2 * max(X, Y)
print(min(sum1, sum2, sum3))

Solution (Python):
A,B,C,X,Y = (int(i) for i in input().split())
i = 0
a = []
while i <= 100000:
    p = i * 2*C + A*max(0,X-i)+B*max(0,Y-i)
    a.append(p)
    i += 1
print(min(a))

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

minValue = float('inf')

for i in range(0,100001):
    total = 2 * i * C + max([0,X-i]) * A + max([0,Y-i]) * B
    
    if minValue > total:
        minValue = total

print(minValue)

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

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

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

Solution (Python):
l = map(int, raw_input().split())
a = l[0]
b = l[1]
c = l[2]
x = l[3]
y = l[4]

if a+b <= 2*c:
	price = a*x + b*y
	tmp = 0
else:
	if x < y:
		price = 2*c*x
		tmp = y-x
	else:
		price = 2*c*y
		tmp = x-y

if tmp !=0:
	if x > y:
		if tmp*a > tmp*2*c:
			price += tmp*2*c
		else:
			price += tmp*a
	elif y > x:
		if tmp*b > tmp*2*c:
			price += tmp*2*c
		else:
			price += tmp*b

print price

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

Solution (Python):
a,b,c,x,y = map(int, input().split())
only = a * x + b * y 
ans = only
for i in range(1,x + 1):
    current = 0
    current = c * i * 2
    if y - i >= 0:
        current = current + a * ( x - i ) + b * (y - i)
    else:
        current = current + a * ( x - i )
    if ans > current:
        ans = current
for i in range(1,y + 1):
    current = 0
    current = c * i * 2
    if x - i >= 0:
        current = current + a * ( x - i ) + b * ( y - i )
    else:
        current = current + b * ( y - i )
    if ans > current:
        ans = current
print(ans)

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

A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)



value = 0

na = 0
nb = 0
nc = 0


if A+B <= 2*C:
  value = X * A + Y * B
else:
  if X > Y:
    if 2*C <= A:
      nc = 2*X
    else:
      na = X - Y
      nc = 2*Y
  else:
    if 2*C <= B:
      nc = 2*Y
    else:
      nb = Y - X
      nc = 2*X
  value = A * na + B * nb + C * nc

print(value)

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = 10**18
for i in range(500000):
    ans = min(ans, i*c + max(0,x - i//2)*a + max(0,y - i//2)*b)
print(ans)

Solution (Python):
(A,B,C,X,Y)=[int(i) for i in input().split()]

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

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

set_ga_otoku = c * 2 < a + b
nimai_ga_otoku_a = c * 2 < a
nimai_ga_otoku_b = c * 2 < b

dup = min(x, y)
cost = c * 2 * dup if set_ga_otoku else a * dup + b * dup

x, y = map(lambda x: x - dup, [x, y])

if x:
    cost += c * 2 * x if nimai_ga_otoku_a else a * x
else:
    cost += c * 2 * y if nimai_ga_otoku_b else b * y

print(cost)

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

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

Solution (Python):

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

ans = 0

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

print(ans)

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

else:
    yen += A*X + B*Y

print(yen)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
sum_1 = A * X + B * Y
sum_2 = C * min(X, Y) * 2 + A * (X - min(X, Y)) + B * (Y - min(X, Y))
sum_3 = C * max(X, Y) * 2
print(min(sum_1, sum_2, sum_3))

Solution (Python):
def main():

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

    num_a = 0
    num_b = 0
    num_c = 0

    if A >= C*2:
        num_c += X*2
    if B >= C*2:
        num_c += max(Y*2 - num_c, 0)

    left_X = max(X-num_c/2, 0)
    left_Y = max(Y-num_c/2, 0)

    
    if A + B >= C*2:
        num_c += min(left_X, left_Y)*2

    num_a = max(X-num_c/2, 0)
    num_b = max(Y-num_c/2, 0)

    

    print(int(A*num_a + B*num_b + C*num_c))


if __name__ == '__main__':
    main()

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

tmp = min(X, Y)
if tmp * A + tmp * B < tmp * C * 2:
    a += tmp
    b += tmp
else:
    c += tmp * 2
X -= tmp
Y -= tmp
if X:
    if C * 2 < A:
        c += X * 2
    else:
        a += X
if Y:
    if C * 2 < B:
        c += Y * 2
    else:
        b += Y
print(a * A + b * B + c * C)

Solution (Python):
import builtins
import functools
import sys
import textwrap
from io import StringIO


def solve(input, print):
    A, B, C, X, Y = map(int, input().split())

    cost_min = sys.maxsize
    for c in range(max([X, Y]) + 1):
        cost = c * 2 * C
        a = X - c
        b = Y - c
        if a > 0:
            cost += a * A
        if b > 0:
            cost += b * B
        cost_min = min([cost_min, cost])
    print(cost_min)


if __name__ == '__main__':
    solve(builtins.input, functools.partial(builtins.print, flush=True))


def make_input(s):
    ss = textwrap.dedent(s).splitlines()
    it = iter(ss)
    return functools.partial(next, it)


def execute_solve(input_text):
    result = StringIO()
    solve(make_input(input_text),
          functools.partial(print, file=result, flush=True))
    return result.getvalue()


def test_solve():
    assert execute_solve('1500 2000 1600 3 2') == '7900\n'
    assert execute_solve('1500 2000 1900 3 2') == '8500\n'
    assert execute_solve('1500 2000 500 90000 100000') == '100000000\n'

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

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

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

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

if X<Y:
        t = X
        X = Y
        Y = t
        t = A
        A = B
        B = t

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

print(ans)

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

Solution (Python):
a,b,c,x,y = map(int,input().split())
if a + b >= 2*c:
	if x >= y:
		ans = 2*y*c + (x-y)*min(a,2*c)
	else:
		ans = 2*x*c + (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())
ans = a*x + b*y
for i in range(max(x,y) + 1):
	money = max(0,(x-i)*a) + max(0,(y-i)*b) + 2*i*c
	if money <= ans:
		ans = money
print(ans)

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

Solution (Python):


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

min = float('inf')
for i in range(max(x, y) + 1):
    pa = (x - i) * a
    if pa < 0:
        pa = 0
    pb = (y - i) * b
    if pb < 0:
        pb = 0
    pc = c * 2 * i
    sum = pa + pb + pc
    if min > sum:
        min = sum

print(min)

Solution (Python):
A, B, C, X, Y = [int(i) for i in input().split()]
price = 0
if A + B <= C*2:
    price += A*X+B*Y
else:
    price += C*2*min(X, Y)
    if A <= C*2 and X > Y:
        price += A*(X-Y)
    elif B <= C*2 and X < Y:
        price += B*(Y-X)
    else:
        price += C*2*abs(X-Y)
print(price)

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

    if m == X:
        if B > 2 * C:
            result += 2 * max(X, Y) * C
        else:
            result += 2 * m * C + (Y - m) * B
    else:
        if A > 2 * C:
            result += 2 * max(X, Y) * C
        else:
            result += 2 * m * C + (X - m) * A

print(result)

Solution (Python):
A,B,C,X,Y = map(int, raw_input().split())
  
m = min(X,Y)
M = max(X,Y)
result = 0
if A + B >= 2 * C:
    result += C * m * 2
    if m == X:
        result += (Y - X) * min(B, 2*C)
    else:
        result += (X - Y) * min(A, 2*C)
else:
    result =  A * X + B * Y

print(result)

Solution (Python):
a,b,c,x,y = map(int,input().split())
cheap = min(a+b,c*2)

if x>y:
    result = min(x,y)*cheap+(x-y)*a
elif x<y:
    result = min(x,y)*cheap+(y-x)*b
else:
    result = min(x,y)*cheap
    
print(min(result,c*max(x,y)*2))

Solution (Python):


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

ans = 9999999999
for z in range(0, 1000001, 2):
    result = A * max(0, int(X - (z / 2))) + B * max(0, int(Y - (z / 2))) + C * z
    ans = min(ans, result)
print(ans)

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


ans = float('inf')
for nc in range(0, max(x, y) * 2 + 1, 2):
    na = x - math.floor(nc / 2)
    if na < 0:
        na = 0
    nb = y - math.floor(nc / 2)
    if nb < 0:
        nb = 0
    total = a * na + b * nb + c * nc
    if total < ans:
        ans = total
    
print(ans)

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

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

if x < y:
    pizza = [(x, a), (y, b)]
else:
    pizza = [(y, b), (x, a)]

values = list()
values.append(c * 2 * pizza[0][0] + pizza[1][1] * (pizza[1][0] - pizza[0][0]))
values.append(c * 2 * pizza[1][0])
values.append(a * x + b * y)

print(min(values))

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

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

Solution (Python):



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


Yen = []
for i in range(max(X+1,Y+1)):
	Yen.append(A*max(0,X-i) + B*max(0,Y-i) + 2*C*i)


print(min(Yen))

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

money = 0
if a + b > c * 2 :

	c_num = y * 2 if x > y else x * 2 
	money += c * c_num

	rest_money = a if x > y else b 
	rest_num = x-y if x > y else y-x 
	
	money += c * 2 * rest_num if rest_money > c*2 else rest_money * rest_num

else :
	money += a * x + b * y

print money

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

pay = []

for i in range(max(X,Y)+1):
    pay.append(i*2*C + max(0,X-i)*A + max(0,Y-i)*B)
    
print(min(pay))

Solution (Python):

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

if A < B:
    A, B = B, A
    X, Y = Y, X    
    
if A > C*2 and B > C*2:
    print(C*2*max(X,Y))

elif A > C*2 and B < C*2:
    print(2*C*X + B*max(0,(Y-X)))

elif A + B > C*2 :
    print(2*C*min(X,Y) + A*max(0,(X-Y)) + B*max(0,(Y-X)))

else:
    print(A*X+B*Y)

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
 
cost_temp = float('inf')
 
for i in range(max(X,Y)+1):
    cost = i * 2 * C + A * max(0, X-i) + B * max(0, Y-i)
    if cost < cost_temp:
        cost_temp = cost
 
print(cost_temp)

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

cost_temp = float('inf')

for i in range(max(X,Y)+1):
    cost = i * 2 * C + A * max(0, X-i) + B * max(0, Y-i)
    if cost < cost_temp:
        cost_temp = cost

print(cost_temp)

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

na = 0
nb = 0
nab = 0

if a+b >= 2*ab:
  nab += 2*min(x, y)
  if x > y:
    if ab*2 >= a:
      na += x - int(nab/2)
    else:
      nab += 2*(x - int(nab/2))
  else:
    if ab*2 >= b:
      nb += y - int(nab/2)
    else:
      nab += 2*(y - int(nab/2))
else:
  na += x
  nb += y

print(na*a + nb*b + nab * ab)

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








bose = min(x,y)

bose_cost = 0
if a+b > 2*c:
    bose_cost = 2*c
else:
    bose_cost = a+b


remain = max(x,y) - min(x,y)
remain_cost = 0


remain_one_cost = 0
if x> y:
    remain_one_cost = a
else:
    remain_one_cost = b

remain_cost = 0
if remain_one_cost > 2*c:
    remain_cost = 2*c
else:
    remain_cost = remain_one_cost

result = bose * bose_cost + remain_cost * remain
print(result)

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):
        print(min(x * 2 * c, y * 2 * c + (x - y) * a))
    else:
        print(min(y * 2 * c, x * 2 * c + (y - x) * b))

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