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=map(int,input().split())
result=0
if A+B>=C*2:
  min_pizza=min(X,Y)
  min_pizza//2*2
  X-=min_pizza
  Y-=min_pizza
  result+=C*2*min_pizza
for i,j in zip((A,B),(X,Y)):
  if i>=C*2:
    result+=C*2*(max(0,j-2))
  else:
    result+=i*(max(0,j-2))
X-=max(0,X-2)
Y-=max(0,Y-2)
cnd=[C*2*2]
for i in range(3):
  for j in range(3):
    if X<=i and Y<=j:
      cnd.append(A*i+B*j)
result+=min(cnd)
print(result)

Solution (Python):



import sys

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

ans = 10 ** 18

for m in range(max(x, y) + 1):
    tmp = a * max(0, (x - m)) + b * max(0, (y - m)) + 2 * m * c
    ans = min(ans, tmp)

print(ans)

Solution (Python):



import sys


import pprint as pp

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]



MAXSIZE = ( 1 << 31 ) -1
MINSIZE = -( 1 << 31) + 1
MAXSHEET = 10**5

def solver(a_price, b_price, ab_price, x_sheet , y_sheet):
    result = MAXSHEET*a_price+MAXSHEET*b_price
    for j in range(0, 2*MAXSHEET+1, 2):
        a_buy_sheet = max(x_sheet-j//2,0)
        b_buy_sheet = max(y_sheet - j//2, 0 )
        total = ( a_buy_sheet*a_price + b_buy_sheet*b_price +
                                         j*ab_price )

        check = ( total < result )
        if check:

            result = total
    return result


if __name__ == "__main__":
    a_price, b_price, ab_price, x_sheet , y_sheet = MI()
    print("{}".format(solver(a_price, b_price,
                             ab_price, x_sheet, y_sheet)))

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

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(2*C*X,2*C*Y+A*(X-Y)))
  else:
    print(min(2*C*Y,2*C*X+B*(Y-X)))

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


if A+B > C*2:
    Z = min(X,Y)
    ans += 2*C*Z
    X -= Z
    Y -= Z
a = min(A,2*C)
b = min(B,2*C)

ans += a*X
ans += b*Y

print(ans)

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

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

Solution (Python):


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

ans = 10000 * 10**5
for z in range(10**5+1):
    x = max(X-z, 0)
    y = max(Y-z, 0)
    yen = A*x + B*y + 2*C*z
    if ans > yen:
        ans = yen

print(ans)

Solution (Python):


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


yen1 = max(X,Y) * 2 * C


yen2 = (max(X-Y, 0) * A) + (Y * 2 * C)


yen3 = (X * 2 * C) + (max(Y-X, 0) * B)


yen4 = X * A + Y * B

ans = min(yen1, yen2, yen3, yen4)
print(ans)

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

max = max(x,y)

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

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

Solution (Python):



def main():
    a, b, c, x, y = map(int, input().split())
    ans = float("inf")
    for i in range(0, max(x, y) * 2 + 1, 2):
        p = x - i // 2
        p = max(0, p)
        q = y - i // 2
        q = max(0, q)
        sum = a * p + b * q + c * i
        if ans > sum:
            ans = sum
    print(ans)


if __name__ == "__main__":
    main()

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

INF = float("inf")
b = 0
for a in range(X + 1):
    sum = A * a
    ab_a = (X - a) * 2
    ab_b = ab_a
    sum += C * ab_a
    if ab_b / 2 < Y:
        if B < C * 2:
            b = round(Y - ab_b / 2)
            sum += B * b
        else:
            sum += C * int(Y - (ab_b / 2)) * 2
    if sum < INF:
        INF = sum
print(INF)

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

AB_flag = C * 2 <= A + B

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

print(total)

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


cmax=max(x,y)

t_list=[]


for i in range(cmax+1):
   total=i*2*c+max(0,x-i)*a+max(0,y-i)*b
   t_list.append(total)
    
print(min(t_list))

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


cmax=max(x,y)

t_list=[]


for i in range(cmax+1):
    if x>=i and y>=i:
        total=c*2*i+a*(x-i)+b*(y-i)
        
    elif x>=i and y<i:
        total=c*2*i+a*(x-i)
        
    else:
        total=c*2*i+b*(y-i)
        
    t_list.append(total)
    
print(min(t_list))

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

a, b, c, x, y = inm()
first = a*x + b*y
second = min(x, y) * c * 2 + abs(x-y) * (a if x > y else b)
third = max(x, y) * c * 2
print(min(first, second, third))

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = 0
flag = 0
if a + b < 2*c:
    ans = a*x + b*y
elif a + b >= 2*c:
    if x > y:
        if a > 2*c:
            ans = 2*c*x
            flag = 1
        elif a <= 2*c:
            ans = 2*c*y + a*(x-y)
            flag = 2
    elif x < y:
        if b > 2*c:
            ans = 2*c*y
            flag  = 3
        elif b <= 2*c:
            ans = 2*c*x + b*(y-x)
            flag = 4
    elif x == y :
        ans = 2*c*x
        flag = 5


print(ans)

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

num_A = 0
num_B = 0
num_AB = 0
if A + B <= 2 * C:
    num_A = X
    num_B = Y
else: 
    Z = min(X, Y)
    X = X - Z
    Y = Y - Z
    num_AB = 2 * Z

    if A >= 2 * C:
        num_AB += 2 * X
    else: 

        num_A = X
    if B >= 2 * C:
        num_AB += 2 * Y
    else: 
        num_B = Y

ans = A * num_A + B * num_B + C * num_AB
print(ans)

Solution (Python):

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

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

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

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

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

Solution (Python):
a, b, c, x, y = list(map(int, input().split(" ")))
print(min(map(lambda i: max(0, x-(i//2))*a + max(0, y-(i//2))*b + i*c, range(0, max(x, y)*2+2, 2))))

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1500 2000 1600 3 2"""
        output = """7900"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1500 2000 1900 3 2"""
        output = """8500"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1500 2000 500 90000 100000"""
        output = """100000000"""
        self.assertIO(input, output)


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

    ans = float("inf")
    for i in range(2*max(X, Y)+1):
        t = A*max(X-i//2, 0) + B*max(Y-i//2, 0) + C*i
        ans = min(ans, t)
    print(ans)


if __name__ == "__main__":
    
    resolve()

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

Solution (Python):








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

ans = []

c_max_num = max(x,y)*2

for c_num in range(c_max_num+1):
    a_num = max(0, x - c_num//2)
    b_num = max(0, y - c_num//2)

    tmp = a*a_num + b*b_num + c*c_num
    ans.append(tmp)


print(min(ans))

Solution (Python):
def main():
	A, B, C, X, Y = map(int, input().split())
	lst = [0] * (10 ** 5 + 1)

	for i in range(10 ** 5 + 1):
		lst[i] = 2 * C * i + max(X - i, 0) * A + max(Y - i, 0) * B

	print(min(lst))


  
if __name__ == "__main__":
  	main()

Solution (Python):
a, b, c, x, y = list(map(int, input().split(" ")))
print(min(map(lambda i: max(0, x-(i//2))*a + max(0, y-(i//2))*b + i*c, range(0, max(x, y)*2+2, 2))))

Solution (Python):

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

res = 10**10
for i in range(0, max(x, y)*2+2, 2):
    a_piza = max(0, x - (i // 2))
    b_piza = max(0, y - (i // 2))
    res = min(res, a_piza*a + b_piza*b + i*c)

print(res)

Solution (Python):



import sys


import pprint as pp

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]



MAXSIZE = ( 1 << 31 ) -1
MINSIZE = -( 1 << 31) + 1

def solver(a_price, b_price, c_price, target_x, target_y):
    result = MAXSIZE
    for mix_i in range(0, 2 * 10**5+1, +1):
        a_i = target_x - mix_i//2
        b_i = target_y - mix_i//2
        totalPrice = max(a_i, 0) * a_price + max(b_i,0) * b_price + mix_i * c_price
        if totalPrice < result:
            
            result = totalPrice
    return result


if __name__ == "__main__":
    A, B, C, X, Y = MI()
    print("{}".format(solver(A, B, C, X, Y)))

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

sum = 0

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

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

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


ans1 = A * X + B * Y


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

ans3 = C * max(X, Y) * 2

print(min(ans1,ans2,ans3))

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

print(sm)

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

Solution (Python):
A,B,C,X,Y=map(int,input().split())
if A+B<=2*C:
    print(A*X+B*Y)
elif X==Y or (X>Y and A>=2*C) or (X<Y and B>=2*C):
    print(2*max([X,Y])*C)
elif X>Y and A<2*C:
    print(2*Y*C+A*(X-Y))
elif X<Y and B<2*C:
    print(2*X*C+B*(Y-X))

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


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

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, x, y = map(int, input().split())
    r = a * x + b * y
    for i1 in range(1, min(x, y) + 1):
        r1 = r - a - b + c * 2
        r = min(r, r1)
    if x > y:
        for j1 in range(y + 1, x + 1):
            r1 = r - a + c * 2
            r = min(r, r1)
    else:
        for j1 in range(x + 1, y + 1):
            r1 = r - b + c * 2
            r = min(r, r1)
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, x, y = map(int, input().split())
    p1 = a * x + b * y
    p2 = max(x, y) * 2 * c
    p3 = min(x, y) * 2 * c + ((x - y) * a if x > y else (y - x) * b)
    r = min(p1, p2, p3)
    print(r)

if __name__ == '__main__':
    main()

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

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

cc = c * 2 * max(x, y)
print(min(ab, abc, cc))

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

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

print(ans)

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

sum_l.append(a*x+b*y)

sum_l.append(max(x,y)*2*c)

sum_n = min(x,y)*2*c
if(x>y):
    sum_n +=(x-y)*a
else:
    sum_n += (y-x)*b
sum_l.append(sum_n)
print(min(sum_l))

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

ans = A * X + B * Y

t = max(X, Y)

for i in range(2, (t+1)*2, 2):
    if (X - i//2) < 0:
        ans = min(ans, C * i + B * (Y - i//2))
    elif (Y - i//2) < 0:
        ans = min(ans, C * i + A * (X - i//2))
    else:
        ans = min(ans, C * i + A * (X - i//2) + B * (Y - i//2))

print(ans)

Solution (Python):
a, b, c, x, y = map(int,input().split())
c = 2 * c
money = 0
apizza = 0
bpizza = 0
ans = 0
for i in range(max(x,y) + 1):
    apizza = x - i
    if apizza < 0:
        apizza = 0
    bpizza = y - i
    if bpizza < 0:
        bpizza = 0
    ans = apizza * a + bpizza * b + c * i
    if money > ans or i == 0:
        money = ans
print(money)

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

sum_list=[]


max_c=max(x,y)


for i in range(max_c+1):
    
    
    if i>=x and i>=y:
        sum=2*c*i
        
    
    elif i<x and i>=y:
        sum=2*c*i+a*(x-i)
    
    
    elif i>=x and i<y:
        sum=2*c*i+b*(y-i)
    
    
    else:
        sum=2*c*i+a*(x-i)+b*(y-i)
        
    sum_list.append(sum)
    
    
print(min(sum_list))

Solution (Python):









import sys
input = sys.stdin.readline

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

ans = 0
if Y < X:
    Y, X = X, Y
    B, A = A, B

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

print(ans)

Solution (Python):

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

ab = a * x + b * y

cc = 0
if x >= y:
    cab = c * 2 * y + (a * (x - y))
else:
    cab = c * 2 * x + (b * (y - x))

if x >= y:
    cc = c * 2 * x
else:
    cc = c * 2 * y


print(min(ab, cab,cc))

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




case1 = A * X + B * Y


case2 = 2*C * X + B * max(Y - X, 0)


case3 = 2*C * Y + A * max(X - Y, 0)


case4 = 2*C * max(X, Y)


print(min(case1, case2, case3, case4))

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

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

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

if X!=0:
    if A>2*C:
        ans+=2*C*X
    else:
        ans+=A*X
else:
    if B>2*C:
        ans+=2*C*Y
    else:
        ans+=B*Y

print(ans)

Solution (Python):
a, b, c, x, y = map(int, input().split())
PRC = []
for i in range(max(x,y) + 1):
    PRC.append(max((x - i), 0) * a + max((y - i), 0) * b + i * 2 * c)
print(min(PRC))

Solution (Python):
a,b,c,x,y = list(map(int,input().split()))
m = a*x + b*y
n = max(x, y) * 2*c
d = {x: b, y: a}
v = 2*c*min(x, y) + d[min(x, y)]*abs(x-y)
print(min(m, n, v))

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
D = {X:B, Y:A}
P = [A*X+B*Y, C*2*min(X, Y)+D[min(X,Y)]*abs(X-Y), C*2*max(X, Y)]

print(min(P))

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

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

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

budget = A* X+ B* Y
i = 1

while True:
  if(max(A* (X- i), 0)+ max(B* (Y- i), 0)+ C* 2* i< budget):
    budget = max(A* (X- i), 0)+ max(B* (Y- i), 0)+ C* 2* i
  else:
    break
  i+= 1

print(budget)

Solution (Python):
a, b, c, x, y = map(int, open(0).read().split())
c *= 2
xy = min(x, y)
res = xy * min(a + b, c) + (x - xy) * min(a, c) + (y - xy) * min(b, c)
print(res)

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

    judge = 0
    price = 0

    same_num = X - Y
    if same_num < 0:
        judge = -1
        same_num = -same_num
    elif same_num > 0:
        judge = 1

    if 2*C > (A + B):
        price += (max(X,Y)-same_num)*(A + B)
    elif 2*C < (A + B):
        price += (max(X,Y)-same_num)*C*2
    elif 2*C == (A + B):
        price += (max(X,Y)-same_num)*C*2

    if judge == 1:
        if 2*C > A:
            price += A*same_num
        elif 2*C < A:
            price += 2*C*same_num
        elif 2*C == A:
            price += A*same_num

    elif judge == -1:
        if 2*C > B:
            price += B*same_num
        elif 2*C < B:
            price += 2*C*same_num
        elif 2*C == B:
            price += B*same_num
    return price

print(main())

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

p1 = a*x + b*y
p2 = 2*c*max(x, y)
p3 = 2*c*y + a*(x-y) if x > y else 2*c*x + b*(y-x)

print(min(p1, p2, p3))

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

if A+B >= 2*C:
    priceA = 2*C*max(X,Y)
    priceB = 2*C*min(X,Y)
    if X > Y:
        priceB += A * (X-Y)
    elif Y > X:
        priceB += B * (Y-X)

    print(min(priceA,priceB))

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
p1 = a * x + b * y
p2 = 2 * c * (min(x, y))
p3 = 2 * c * (max(x, y))
if x > y:
    p2 += a * (x - y)
elif x < y:
    p2 += b * (y - x)

print(min(p1, p2, p3))

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

min_sum = A*X + B*Y
for c in range(0, 100000+1):
    sum = 2*C*c
    if X - c > 0:
        sum += A * (X - c)
    if Y - c > 0:
        sum += B * (Y - c)
    if sum < min_sum:
        min_sum = sum
print(min_sum)

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

res = a*x + b*y 
for i in range(1, max(x, y)+1): 
    ab = i*2 
    cand = ab*c + a*max(0, x-i) + b*max(0, y-i) 

    res = min(res, cand) 

print(res)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
cost = A*X + B*Y
new_cost = cost
plus = 0
for i in range(1, max(X, Y)+1):
  if i <= min(X, Y):
    plus = - A - B + 2*C
  else:
    plus = -A + 2*C if X > Y else -B + 2*C
  if plus < 0:
    new_cost += plus
  else:
    break
print(new_cost)

Solution (Python):
a,b,c,x,y=list(map(int,input().split()))
temp=0
ans=float("Inf")
import math
while temp<=max(x,y)*2:
  xt=math.ceil(x-0.5*temp)
  yt=math.ceil(y-0.5*temp)
  ans=min(ans,max(0,xt)*a+max(0,yt)*b+temp*c)
  temp=temp+1
print(ans)

Solution (Python):
import math

__DEUBG__ = 0

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

minimum = a * x + b * y

if x > y:
    for i in range(x+1):
        N_a = i
        N_c = 2 * (x - i)
        if (y-N_c/2) < 0:
            N_b = 0
        else:
            N_b = y - int(N_c/2)
        tmp = a * N_a + b * N_b + c * N_c
        if tmp < minimum:
            minimum = tmp
            if __DEUBG__:
                print(tmp, N_a, N_b, N_c)
else:
    for i in range(y+1):
        N_b = i
        N_c = 2 * (y - i)
        if (x-N_c/2) < 0:
            N_a = 0
        else:
            N_a = x - int(N_c/2)
        tmp = a * N_a + b * N_b + c * N_c
        if tmp < minimum:
            minimum = tmp
            if __DEUBG__:
                print(tmp, N_a, N_b, N_c)

print(minimum)

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

x = y = z = 0

if 2 * C >= A + B:
    x = min(X, Y)
    y = x
else:
    z = min(X, Y) * 2

if X > Y :
    if A > 2 * C :
        z += (X - Y) * 2
    else :
        x += X - Y

elif X < Y :
    if B > 2 * C :
        z += (Y - X) * 2
    else :
        y += Y - X

print(A*x + B*y + C*z)

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

if x<y:
    x,y=y,x
    a,b=b,a

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

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

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

Solution (Python):
"""
O(1)解法
以下の3つから一番安いものを選ぶ
1. AピザとBピザをそれぞれ必要数買う場合
2. ABピザを必要数の多いピザ基準で買う場合 (2倍必要になることを忘れない)
3. ABピザを必要数の少ないピザ基準で買い、不足分のピザを買い足す場合
"""
A, B, C, X, Y = map(int, input().split())

if X < Y:
    X, Y = Y, X
    A, B = B, A
p1 = A * X + B * Y  
p2 = 2 * C * X  
p3 = 2 * C * Y + (X - Y) * A  
print(min(p1, p2, p3))

Solution (Python):
A, B, C, X, Y = map(int, input().split())
m_value = float('inf')
for ab in range(max(X, Y) + 1):
    ab2 = 2 * ab
    a = X - ab
    b = Y - ab
    tmp = C * ab2
    if a > 0:
        tmp += a * A
    if b > 0:
        tmp += b * B
    m_value = min(m_value, tmp)
print(m_value)

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

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

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

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

hantei=0


result=A*X+B*Y

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

    result=int(min(result,hantei))

print(result)

Solution (Python):
a_price, b_price, ab_price, a_num, b_num = map(int, input().split())
if a_num >= b_num:
  amari_price = a_price
else:
  amari_price = b_price
min_price = float('inf')
price1 = a_price*a_num+b_price*b_num
price2 = min(a_num,b_num)*ab_price*2 + abs(a_num-b_num)*amari_price
price3 = max(a_num,b_num)*ab_price*2
print(min(price1,price2,price3))

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

price = a * x + b * y

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

    else:
        price = min(2 * x * c + (y - x) * b,  2 * y * c)

print(price)

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

if (a + b) // 2 >= c:
    min_price = 'c'
else:
    min_price = 'other'

if min_price == 'c':
    if x >= y:
        price = min(2 * x * c, 2 * y * c + (x - y) * a)

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

print(price)

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

    minPrice = 10**20

    for i in range(2 * (x + y) + 1):
        pizzaC = i * c
        pizzaB = max(0, y - i // 2) * b
        pizzaA = max(0, x - i // 2) * a

        price = pizzaA + pizzaB + pizzaC
        
        if price < minPrice:
            minPrice = price

    print(minPrice)

if __name__ == '__main__':
    main()

Solution (Python):
A, B, C, X, Y = list(map(int, input().split()))
for num_c in range(0, 2 * max(X, Y) + 1, 2):
    num_a = X - num_c // 2 if X - num_c // 2 > 0 else 0
    num_b = Y - num_c // 2 if Y - num_c // 2 > 0 else 0
    if num_c == 0:
        min_money = A * num_a + B * num_b
    else:
        if (A * num_a + B * num_b + C * num_c) < min_money:
            min_money = A * num_a + B * num_b + C * num_c
print(min_money)

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

INF = (10**5)*a + (10**5)*b + 1
ans = INF

c = 2*c

m = max(x, y)

for num in range(m+1):
    num_x = max(0, x - num)
    num_y = max(0, y - num)
    ans = min(num_x*a + num_y*b + num*c, ans)

print(ans)

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

    paymin = max(a, b, c) * (x + y) *2
    for ab in range(max(x, y)+1):
        if paymin > (2 * ab * c) + (max((x - ab), 0) * a) + (max((y - ab), 0) * b):
            paymin = (2 * ab * c) + (max((x - ab), 0) * a) + (max((y - ab), 0) * b)

    print(paymin)
resolve()

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

m = 5000 * 200001
for k in range(200001):
    i = max(0, X - int(k / 2))
    j = max(0, Y - int(k / 2))
    m = min(m, A * i + B * j + C * k)
print(m)

Solution (Python):
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

a,b,c,x,y = readInts()

ans = 1000000000000000000


for i in range(0,max(x,y)*2+1,2):
	A = max(x - i//2,0)
	B = max(y - i//2,0)
	money = A*a+B*b+i*c
	ans = min(ans,money)

print(ans)