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 = list(map(int,input().split()))
A = a[0]
B = a[1]
C = a[2]
X = a[3]
Y = a[4]
if A + B <= 2*C:
    print(str(A*X + B*Y))
else:
    if X <= Y:
        
        if B <= 2*C:
            print(str(2*X*C + (Y-X)*B))
        else:
            print(str(2*Y*C))
    else:
        if A <= 2*C:
            print(str(2*Y*C + (X-Y)*A))
        else:
            print(str(2*X*C))

Solution (Python):
a = list(map(int,input().split()))
A = a[0]
B = a[1]
C = a[2]
X = a[3]
Y = a[4]
if A + B <= 2*C:
    print(str(A*X + B*Y))
else:
    if X <= Y:
        
        if B <= 2*C:
            print(str(2*X*C + (Y-X)*B))
        else:
            print(str(2*Y*C))
    else:
        if A <= 2*C:
            print(str(2*Y*C + (X-Y)*A))
        else:
            print(str(2*X*C))

Solution (Python):
from functools import reduce
from operator import add

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

print(min([C*i + A*max(0,X - i//2) + B*max(0,Y-i//2) for i in range(max(2*X, 2*Y)+1)]))

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

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

print(Ans)

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

s = 0

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

print(s)

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

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

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


"""
A+BよりもCのほうがお得な場合、XまたはYを買い切るまでCを買う
その後は、AかBで残っているものとAB*2で安い方を買う
"""
result = 0
if A+B >= C*2:
    
    reduce_amount = min(X,Y)
    X -= reduce_amount
    Y -= reduce_amount
    result += C*2*reduce_amount

if X > 0:
    result += min(C*2*X, A*X)

if Y > 0:
    result += min(C*2*Y, B*Y)


print(result)

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

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

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

def f(x,y):
    return x-y if x>y else 0

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

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

def f(x,y):
    return x-y if x>y else 0

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

print(ans)

Solution (Python):
A,B,C,X,Y=map(int,input().split())
ans=[]
if X>=Y:
    X,Y=Y,X
    A,B=B,A

ans.append(A*X+B*Y)
ans.append(2*C*X+B*(Y-X))
ans.append(2*C*max(X,Y))

print(min(ans))

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

M=max(2*X,2*Y)
ans=10**9
for i in range(0,M+2,2):
    temp=i*C+max(0,X-(i//2))*A+max(0,Y-(i//2))*B
    ans=min(ans,temp)
print(ans)

Solution (Python):
def solve(string):
    a, b, c, x, y = map(int, string.split())
    if a + b <= 2 * c:
        return str(a * x + b * y)
    if 2 * c <= a and 2 * c <= b:
        return str(2 * c * max(x, y))
    base = 2 * c * min(x, y)
    diff = abs(x - y)
    cost = min(a, 2 * c) if x >= y else min(b, 2 * c)
    return str(base + cost * diff)


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

Solution (Python):
def solve(string):
    a, b, c, x, y = map(int, string.split())
    if a + b <= 2 * c:
        return str(a * x + b * y)
    if 2 * c <= a and 2 * c <= b:
        return str(2 * c * max(x, y))
    base = 2 * c * min(x, y)
    diff = abs(x - y)
    return str(base + min(a, 2 * c) * diff if x >= y else base + min(b, 2 * c) * diff)


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

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

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

print(ans)

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

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

ans = 0
judge = 0 
if(X < Y):
  judge = 0
else:
  judge = 1
  


if((A+B) > C*2 ):
  if(judge == 0):
   ans += C*2*X
   
   if( B < 2*C):
    ans += B*(Y-X) 
   else:
    ans += C*2*(Y-X)    
  elif(judge == 1):
   ans += C*2*Y 
   
   if( A < 2*C):
    ans += A*(X-Y) 
   else:
    ans += C*2*(X-Y)

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

print(ans)

Solution (Python):
A,B,C,X,Y = map(int,input().split())
ans = 0
if A+B >= 2*C:
    sub = min(X,Y)
    ans += 2*C * sub
    X -= sub
    Y -= sub
    left = max(X,Y)
    yen = [A,B][X<Y]
    if yen >= 2*C:
        ans += 2*C*left
        X=Y=0
ans += A*X+B*Y
print(ans)

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

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

print(res)

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


A = 0
B = 0
res = 0

if c*2 <= a+b:
    res += min(x,y)*2*c
    A = min(x,y)
    B = min(x,y)

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

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

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

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

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

print(price)

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
INF = 10 ** 9
cost = INF
if x < y:
    x, y = y, x
    a, b = b, a
for i in range(x + 1):
    cost = min(cost, 2 * c * i + a * max(x - i, 0) + b * max(y - i, 0))

print(cost)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
 
totalA1 = A * X
totalA2 = C * X * 2
totalB1 = B * Y
totalB2 = C * Y * 2
 
totalAB = A * X + B * Y
 
totalAC = C * Y * 2
if X > Y:
    totalAC += (X - Y) * A
 
totalCB = C * X * 2
if Y > X:
    totalCB += (Y - X) * B
 
totalCC = max(X, Y) * C * 2
 
print(min(totalAB, totalAC, totalCB, totalCC))

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

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

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

if x >= y:
	answer = (minab * y) + (mina * (x-y))
else:
	answer = (minab * x) + (minb * (y-x))
	
print(answer)

Solution (Python):


"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""






def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n 

def getIntMat(n, m):  
    
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    A, B, C, X, Y = getIntList()
    d.dmp((A, B, C, X, Y),'A, B, C, X, Y')
    pt1 = A*X + B*Y
    pt2 = A*X + C*2*Y
    pt3 = C*2*X + B*Y
    pt4 = C*2*min(X, Y)+ C*2*(max(X, Y)-min(X, Y))
    if X > Y:
        pt5 = C*2*min(X, Y)+ A*(X-min(X, Y))
    else:
        pt5 = C*2*min(X, Y)+ B*(Y-min(X, Y))

    yen = min(pt1, pt2, pt3, pt4, pt5)
    d.dmp((pt1, pt2, pt3, pt4, pt5), 'pt1, pt2, pt3, pt4, p5')
    d.dmp(yen, 'yen')
    return yen


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Solution (Python):


import sys
import math

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

ans = 0
if A+B > 2*C:
  mn = min(X,Y)
  ans += 2*C*int(mn)
  X -= mn
  Y -= mn

if A > 2*C and X > 0:
  ans += 2*C*math.ceil(X)
  X = 0

if B > 2*C and Y > 0:
  ans += 2*C*math.ceil(Y)
  Y = 0

if X > 0:
  ans += A*math.ceil(X)

if Y > 0:
  ans += B*math.ceil(Y)

print(ans)

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


def main():
    print(
        min(A * X + B * Y,
            2 * max(X, Y) * C,
            2 * min(X, Y) * C + (B if X < Y else A) * abs(X - Y)))
    return


main()

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

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

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

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

print(cost)

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

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

Solution (Python):
import math
a, b, c, x, y=map(int, input().split())
ans=10**9
for i in range(2*max(x, y)+1):
    if 2*x-i>0:
        aa=math.ceil((2*x-i)/2)*a
    else:
        aa=0
    if 2*y-i>0:
        bb=math.ceil((2*y-i)/2)*b
    else:
        bb=0
    res=aa+bb+i*c
    ans=min(ans, res)
print(ans)

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





AB = max(X, Y) * 2 * C
ABandAorB = min(X,Y)* 2 * C + ( ((X-Y)* A  ) if  X > Y else ((Y -X) *B))
AorB = X * A + Y * B
print(min(AB,ABandAorB ,AorB ))

Solution (Python):
def half_and_half(
        A: int, B: int, C: int, X: int, Y: int) -> int:
    """
    :param A: A ピザの値段
    :param B: B ピザの値段
    :param C: AB ピザの値段
    :param X: A ピザの必要数
    :param Y: B ピザの必要数
    """
    min_price = float('inf')
    for num_ab in range(max(X, Y)+1):
        num_a, num_b = max(0, X-num_ab), max(0, Y-num_ab)
        price = num_a*A + num_b*B + 2*num_ab*C
        min_price = min(min_price, price)

    return min_price


if __name__ == "__main__":
    A, B, C, X, Y = map(int, input().split())
    ans = half_and_half(A, B, C, X, Y)
    print(ans)

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

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

Solution (Python):

import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    
    val_min = 5001 * (X+Y)
    for z in range(0, 2*max(X, Y)+1, 2):
        x = max(0, X - z//2)
        y = max(0, Y - z//2) 
        val_min_cond = A*x + B*y + C*z
        
        val_min = val_min_cond if val_min_cond < val_min else val_min
    print(val_min)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    X = int(next(tokens))  
    Y = int(next(tokens))  
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()

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

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

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

print(ans)

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

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

Solution (Python):
a,b,c,x,y=map(int,input().split())
p1=a*x+b*y
min=10**9
for i in range(10**5+1):
    p2=2*i*c+max(0,x-i)*a+max(0,y-i)*b
    if p2<min:
        min=p2
if min<p1:
    print(min)
else:
    print(p1)

Solution (Python):
def main():
    A, B, C, X, Y = map(int, input().split())
    ans = min(X, Y) * min(A+B, 2*C) + max(X-Y, 0) * \
        min(A, 2*C) + max(Y-X, 0) * min(B, 2*C)
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
cost1 = a * x + b * y
cost2 = max(x, y) * c * 2
cost3 = min(x, y) * c * 2
if x == y:
    pass
elif x > y:
    cost3 += (x - y) * a
else:
    cost3 += (y - x) * b
print(min(cost1, cost2, cost3))

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
center = (a + b) / 2
res = 0
if center >= c:
    buy = min(x, y)
    res += buy * 2 * c
    x -= buy
    y -= buy
if x > 0 and a >= c * 2:
    res += x * 2 * c
    x = 0
if y > 0 and b >= c * 2:
    res += y * 2 * c
    y = 0
res += a * x
res += b * y
print(res)

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

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

print(answer)

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  A, B, C, X, Y = map(int, input().split())
  ans = float('INF')
  for i in range(max(X, Y)+1):
    cur = C * 2 * i + max(0, X - i) * A + max(0, Y - i) * B
    ans = min(ans, cur)
  print(ans)


if __name__ == '__main__':
  main()

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  A, B, C, X, Y = map(int, input().split())
  n = max(X, Y)
  ans = float('INF')
  for i in range(max(X, Y)+1):
    cur = C * 2 * i + max(0, X - i) * A + max(0, Y - i) * B
    ans = min(ans, cur)
  print(ans)


if __name__ == '__main__':
  main()

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

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

Solution (Python):
from sys import stdin
a, b, c, x, y = [int(x) for x in stdin.readline().rstrip().split()]
print(min([i*2*c+max(0, x-i)*a+max(0, y-i)*b for i in range(10**5+1)]))

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

money = [A*X+B*Y, 2*C*max(X,Y)]
n = min(X, Y)
x, y = X - n, Y - n
money.append(A*x+B*y+2*C*n)
money.append(A*n+B*n+2*C*(max(X,Y)-n))
print(min(money))

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

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

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

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

Solution (Python):

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

Solution (Python):

import sys



def solve(lines):
    A,B,C,X,Y = map(int, lines.pop(0).split(' '))
    res = 0
    AB = (A + B)/2
    res = min(AB, C) * min(X, Y) * 2

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

    print(int(res))

lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

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

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

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

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

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

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

Solution (Python):

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


AandB = a*x + b*y

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

if x > y:
    AB = 2*c*x
else:
    AB = 2*c*y
print(min(AandB,ABandAorB,AB))

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

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

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

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

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

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

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

d = min(a+b,2*c)

a = min(a,2*c)
b = min(b,2*c)
s=min(x,y)*d + max(0,x-y)*a + max(0,y-x)*b
print(s)

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

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

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

Solution (Python):
def solve(A, B, C, X, Y):
    ans = X * A + B * Y
    ans = min(ans, 2 * C * X + B * max(Y - X, 0))
    ans = min(ans, A * max(X - Y, 0) + 2 * C * Y)
    return ans

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

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

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


main()

Solution (Python):
import math
a,b,c,x,y=map(int,input().split())
cost=float('inf')
if 2*c>=a+b:
    cost=a*x+b*y
else:
    least=min(x*2,y*2)
    most=max(x*2,y*2)
    r=least
    while r<=most:
        p=max(0,math.ceil(x-r/2))
        q=max(0,math.ceil(y-r/2))
        tmp=a*p+b*q+c*r
        cost=min(cost,tmp)
        r+=1
print(cost)

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

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

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

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

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

print(ans)

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

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

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

ab1 = A + B
ab1c = C*2
ans = 0
if ab1 > ab1c:
    mi = min(X,Y)
    for i in range(mi):
        ans += C*2

    if X > Y:
        for i in range(X-Y):
            ans += A
    else:
        for i in range(Y-X):
            ans += B
else:
    for i in range(X):
        ans += A
    for i in range(Y):
        ans += B

t = 0
ma = max(X,Y)
for i in range(ma):
    t +=C*2

if t < ans:
    print(t)
    exit()

print(ans)

Solution (Python):
a,b,c,x,y = map(int,input().split())
res = 10**10
for i in range(0,2*max(x,y)+1,2):
    if x-i//2<0:
        na=0
    else:
        na=x-i//2
    if y-i//2<0:
        nb=0
    else:
        nb=y-i//2
    cost = a*na+b*nb+c*i
    if cost < res:
        res = cost
    else:
        break
print(res)

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

print(Ans)

Solution (Python):
A, B, C, X, Y = map(int,input().split())
value = 0
ans = []
ans.append(max(X,Y) * 2*C)
if X > 0 and Y > 0 and A + B > 2*C:
    m = min(X, Y)
    value += m * 2*C
    X = X - m
    Y = Y - m
value += (X * A + Y * B)
ans.append(value)
print(min(ans))

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

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

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

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

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

s = a * x + b * y
t = c * max(x, y) * 2
u = c * min(x, y) * 2 + a * (x - min(x, y)) + b * (y - min(x, y))

print(min(s, t, u))

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

if average <= ab:
    ans = a * x + b * y
else:
    temp1 = ab * min(x, y) * 2 + a * (x - min(x, y)) + b * (y - min(x, y))
    temp2 = ab * max(x, y) * 2
    ans = min(temp1, temp2)
    
print(ans)

Solution (Python):
A,B,C,X,Y = map(int,input().split())
minS = float('inf')
for i in range(0,2*max(X,Y)+2,2):
    minS = min(minS,C*i + B*max(0,Y-i/2) + A*max(0,X-i/2))

print(int(minS))

Solution (Python):
A,B,C,X,Y=(int(i) for i in input().split())
A = min(A,2*C)
B = min(B,2*C)
AB = min(A+B,2*C)
print(AB*min(X,Y)+A*(X-min(X,Y))+B*(Y-min(X,Y)))

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

Solution (Python):


def main():
    na = list(map(int, input().split()))
    A, B, C, X, Y = na[0], na[1], na[2], na[3], na[4]

    r = 0
    if A + B <= C * 2:
        r = A * X + B * Y
    elif C * 2 < A and C * 2 < B:
        r = C * 2 * max(X, Y)
    elif C * 2 < A:
        r = C * 2 * X
        if X < Y:
            r += B * (Y - X)
    elif C * 2 < B:
        r = C * 2 * Y
        if Y < X:
            r += A * (X - Y)
    else:
        r = C * 2 * min(X, Y)
        if X < Y:
            r += B * (Y - X)
        else:
            r += A * (X - Y)

    print(r)


if __name__ == '__main__':
    main()

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

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

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