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())

ans = 10 ** 18
for i in range(0, 2 * max(X, Y) + 1, 2):
    tmpx = X - (i // 2)
    if tmpx <= 0:
        tmpx = 0
    tmpy = Y - (i // 2)
    if tmpy <= 0:
        tmpy = 0
    ans = min(ans, (i * C) + (tmpx * A) + (tmpy * B))

print(ans)

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

ans = 10 ** 18
for i in range(0, 2 * max(X, Y) + 1, 2):
    tmpx = X - (i // 2)
    if tmpx <= 0:
        tmpx = 0
    tmpy = Y - (i // 2)
    if tmpy <= 0:
        tmpy = 0
    ans = min(ans, (i * C) + (tmpx * A) + (tmpy * B))

print(ans)

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

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

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

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

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

ans = 0

for i in range(max(x, y)):
    if x != 0 and y != 0:
        if c*2 < a + b:
            ans += c*2
            x -= 1
            y -= 1
        else:
            ans = ans + a + b
            x -= 1
            y -= 1
    else:
        if x == 0:
            if c*2 < b:
                ans += c*2
                y -= 1
            else:
                ans += b
                y -= 1
        else:
            if c*2 < a:
                ans += c*2
                x -= 1
            else:
                ans += a
                x -= 1

print(ans)

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

ans = 0

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

print(ans)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

from functools import lru_cache

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

ans = INF
for i in range((10**5)+1):
    tmp = i * 2 * C
    if X - i > 0:
        tmp += (X - i) * A
    if Y - i > 0:
        tmp += (Y - i) * B
    ans = min(ans, tmp)
print(ans)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

from functools import lru_cache

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




ans = A * X + B * Y


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


ans = min(ans, max(X, Y) * (2 * C))

print(ans)

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

c2 = c * 2
itr_end = max(x, y) + 1
results = []

for i in range(0, itr_end):
    
    result = c2 * i
    if (x - i) > 0:
        result += a * (x - i)
    if (y - i) > 0:
        result += b * (y - i)

    results.append(result)

print(min(results))

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

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

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

d = (a + b) - 2 * c

sep = a * x + b * y

ab_x = 2 * x * c
ab_y = 2 * y * c
sum = 0

if d < 0:
    print(sep)
    exit()
elif x > y:
    sum = a * (x - y) + ab_y
    if sum > ab_x:
        print(ab_x)
    else:
        print(sum)
else:
    sum = b * (y - x) + ab_x
    if sum > ab_y:
        print(ab_y)
    else:
        print(sum)

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

Solution (Python):


from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    A, B, C, X, Y = mulinputs()

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

    
    print(cost)

Solution (Python):
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

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

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

print(cost)

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

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

if x > 0: ans += x*a
if y > 0: ans += y*b
print(ans)

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

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

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

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

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

Solution (Python):
a, b, c, x, y =map(int, input().split())
ab = 2*c
i = 0
cost = 0
minCost = 10**10
while i < 10**6:
    cost = i*ab
    cost += a *(max(0, (x-i)))
    cost += b *(max(0, (y-i)))
    if minCost >= cost:
        minCost = cost
    i += 1
print(minCost)

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

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

print(min(price))

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

price=0
if X>Y:    
  N_same=Y
  flag='A'
else:
  N_same=X
  flag='B'
  
if A+B >2*C:
  price+=2*C*N_same
else:
  price+=(A+B)*N_same

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

print(price)

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

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

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

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

ans1 = A * X + 2 * C * Y

ans2 = 2 * C * X + B * Y

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


t = abs(X - Y)

ans4 = 2 * C * min(X, Y)
ans5 = 10 ** 18
ans6 = 10 ** 18
if X > Y:
    temp1 = A * t
    temp2 = 2 * C * t
    ans5 = ans4 + min(temp1, temp2)
else:
    temp1 = B * t
    temp2 = 2 * C * t
    ans6 = ans4 + min(temp1, temp2)

print(min(ans0,ans1, ans2, ans3, ans5, ans6))

Solution (Python):
import copy
import math


def get_int():
    return int(input())

def get_string():
    return input()

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

def get_string_list():
    return input().split()

def get_int_multi():
    return map(int, input().split())

def get_string_char_list():
    return list(str(input()))




'''
while (idx < n) and ():

    idx += 1
'''

def main():

    a, b, c, x, y = get_int_multi()
    ans = 100000 * 5000 * 2

    for i in range(0,x+1):

        for ii in (max(0,(x - i) * 2), max(0,(y - i) * 2, (x - i) * 2)):
            price = i * a

            price += ii * c
            cnt_b = max(0, y - (ii // 2))
            price += cnt_b * b
            ans = min(ans, price)

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def solve():
    A_yen, B_yen, AB_yen, A_mai, B_mai = list(map(int, input().split()))
    AB_average = (A_yen + B_yen)/2
    if (AB_average > AB_yen):
        if(2*AB_yen >= A_yen and 2*AB_yen >= B_yen):
            kakaku = AB_yen*2*min(A_mai, B_mai)
            if(A_mai > B_mai):
                kakaku += A_yen * (A_mai - min(A_mai, B_mai))
            else:
                kakaku += B_yen * (B_mai - min(A_mai, B_mai))
            print(kakaku)
        elif(2*AB_yen < A_yen and 2*AB_yen >= B_yen):
            kakaku = AB_yen*2*min(A_mai, B_mai)
            if(A_mai > B_mai):
                kakaku += 2*AB_yen * (A_mai - min(A_mai, B_mai))
            else:
                kakaku += B_yen * (B_mai - min(A_mai, B_mai))
            print(kakaku)
        elif(2*AB_yen >= A_yen and 2*AB_yen < B_yen):
            kakaku = AB_yen*2*min(A_mai, B_mai)
            if(A_mai > B_mai):
                kakaku += A_yen * (A_mai - min(A_mai, B_mai))
            else:
                kakaku += 2*AB_yen * (B_mai - min(A_mai, B_mai))
            print(kakaku)
        elif(2*AB_yen < A_yen and 2*AB_yen < B_yen):
            kakaku = AB_yen*2*min(A_mai, B_mai)
            if(A_mai > B_mai):
                kakaku += 2*AB_yen * (A_mai - min(A_mai, B_mai))
            else:
                kakaku += 2*AB_yen * (B_mai - min(A_mai, B_mai))
            print(kakaku)
    else:
        kakaku = A_yen * A_mai + B_yen * B_mai
        print(kakaku)


if __name__ == "__main__":
    solve()

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

l = []


price1 = A * X + B * Y
l.append(price1)


if X > Y:
    if A < 2*C:
        price2 = 2 * Y * C + A * abs(X-Y)
        l.append(price2)
    else:
        price3 = 2 * Y * C + C * abs(X-Y) * 2
        l.append(price3)
elif X < Y:
    if B < 2*C:
        price4 = 2 * X * C + B * abs(Y-X)
        l.append(price4)
    else:
        price5 = 2 * X * C + C * abs(Y-X) * 2
        l.append(price5)

else:
    price6 = 2 * X * C
    l.append(price6)


print(min(l))

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

Solution (Python):
if __name__ == '__main__':
    A, B, C, X, Y = map(int, input().split())
    min_cost = 2*max(X, Y)*C
    for c in range(0, 2*pow(10, 5)+2, 2):
        a = X-c//2
        b = Y-c//2
        if a>=0 and b>=0:
            cost = A*a+b*B+C*c
            min_cost = min(cost, min_cost)
    print(min_cost)

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

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

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

ans=[(A*X+B*Y),
    C*2*X+B*max(0,(Y-X)),
    C*2*Y+A*max(0,(X-Y))]
print(min(ans))

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


limit = max(X,Y)*2
Min = 10**10

for i in range(limit+1):
    a=0
    b=0
    c=0
    
    if i/2 < X:
        a = (X-int(i/2)) *A
    if i/2 < Y:
        b= (Y-int(i/2))*B    
        
    c = i*C
    
    Min = min(Min,a+b+c)
    
    
    
print(Min)

Solution (Python):

import sys
input = sys.stdin.readline


def RD(): return input().rstrip()
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))

def main():
    A, B, C, X, Y = MI()
    result = float('inf')
    result = min(result,int(A*X+B*Y))
    temp = min(X,Y)
    result = min(result,int(C*temp*2+(X-temp)*A+(Y-temp)*B))
    result = min(result, int(max(X, Y)*C*2))
    print(result)
    
    
if __name__ == "__main__":
    main()

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


if __name__ == '__main__':
    main()

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

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

print(ans)

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

res = 0

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

else:
    res = A * X + B * Y

print(res)

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

total_AtoC = C * 2 * X + max((Y - X) * B, 0)
total_BtoC = C * 2 * Y + max((X - Y) * A, 0)
total_AB = A * X + B * Y

ans = min(total_AtoC, total_BtoC, total_AB)

print(ans)

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

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

Solution (Python):
A,B,C,X,Y=list(map(int, input().split()))
mini=1*10**10
Z=max(X,Y)
for i in range(Z+1):
  sum=A*(max(X-i,0))+B*max(Y-i,0)+C*2*i
  if sum<mini:
    mini=sum
print(mini)

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

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

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

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

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

Solution (Python):
a,b,c,x,y=[int(x) for x in input().split()]
p=0
if a>=c and b>=c:
  p_1=c*min(x,y)*2
  if x>y:
    p_1+=a*(x-y)
  elif y>x:
    p_1+=b*(y-x)
  p_2=c*max(x,y)*2
  p=min(p_1,p_2)
elif a<=c and b<=c:
  p=a*x+b*y
elif a<=c and c<=b:
  p_1=a*x+b*y
  p_2=c*min(x,y)*2
  if x>y:
    p_2+=a*(x-y)
  elif y>x:
    p_2+=b*(y-x)
  p_3=c*max(x,y)*2
  p=min(p_1,p_2,p_3)
elif b<=c and c<=a:
  p_1=a*x+b*y
  p_2=c*min(x,y)*2
  if x>y:
    p_2+=a*(x-y)
  elif y>x:
    p_2+=b*(y-x)
  p_3=c*max(x,y)*2
  p=min(p_1,p_2,p_3)
print(p)

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

c *= 2

MIN=10**9

tmp = a*x + b*y
if tmp < MIN: MIN=tmp
  
if x <= y:
  tmp = c*x + (y-x)*b
  if tmp < MIN: MIN=tmp

else:
  tmp = c*y + (x - y)*a
  if tmp < MIN: MIN=tmp

tmp = c*max(x,y)
if tmp < MIN: MIN=tmp
  
print(MIN)

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

print(ans)

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

ans = float('inf')
for i in range(0,2*max(x,y)+1,2):
    ab = i
    x_tmp = x - i//2
    y_tmp = y - i//2
    tmp = max(0,a*x_tmp) + max(0,b*y_tmp) + c*i
    if tmp < ans:
        ans = tmp
print (ans)

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

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

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

Solution (Python):



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


nomal=X*A+Y*B
buyCuntilX=2*X*C+(Y-X)*B
allC=2*X*C+(Y-X)*2*C

print(min(nomal,buyCuntilX,allC))

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

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

p = []
for i in range(0,100001):
    p.append(i * 2 * c + max(0,x-i) * a + max(0,y-i) * b)

print(min(p))

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

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

XY = 0
ans = 10 ** 9
while XY // 2 <= max(X,Y):
  price = XY * C
  price += max(X - (XY // 2), 0) * A + max(Y - (XY // 2), 0) * B
  if ans > price:
    ans = price
  XY += 1
    
print(ans)

Solution (Python):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    a,b,c,x,y = map(int, input().split())
    num = max(x,y)
    ans = INF
    for i in range(0,num*2+1,2): 
        half = i//2
        c_cst = i*c
        a_cst = max(x-half,0)*a
        b_cst = max(y-half,0)*b
        ans = min(ans,(c_cst+a_cst+b_cst))
    print(ans)



if __name__=="__main__":
    main()

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

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

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

min_cost = float('inf')
for ab in range(max(X + 1, Y + 1)):
    cost = ab * C
    cost += A * max(0, X - ab)
    cost += B * max(0, Y - ab)
    if min_cost > cost:
        min_cost = cost
print(min_cost)

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

Solution (Python):
from numba import njit


@njit
def solve(a, b, c, x, y):
    ans = 10000000000000000
    for i in range(100000 + 1):
        X = i * (2 * c) + max(0, x - i) * a + max(0, y - i) * b
        ans = min(ans, X)
    return ans


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

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

print(ans)

Solution (Python):
def resolve():
    import math
    a, b, c, x, y = map(int, input().split())
    ans = a*x + b*y
    
    for i in range(1, max(x, y)+1):
        ab = i*2 
        total = ab*c + a*max(0, x-i) + b*max(0, y-i) 
        ans = min(ans, total)
    print(ans)
resolve()

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

lst = []

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

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


if __name__ == '__main__':
    main()

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

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

while x > 0 or y > 0:
    if x>0 and y>0:
        if 2*c<a+b:
            ans += 2*c
            x -= 1
            y -= 1
        else:
            ans = ans+a+b
            x -= 1
            y -= 1
    elif x>0:
        if 2*c<a:
            ans += 2*c
            x -= 1
        else:
            ans += a
            x -= 1
    else:
        if 2*c < b:
            ans += 2*c
            y -= 1
        else:
            ans += b
            y -= 1


print(ans)

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


import math
max_money = A*X + B*Y


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



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

print(max_money)

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

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

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

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

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

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

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

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

print(ans)

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

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

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

print(ans)

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

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

print(ans)

Solution (Python):
price_A, price_B, price_AB, num_A, num_B = map(int,input().split())
AandB = price_A * num_A + price_B * num_B
if num_A >= num_B:
    minAB = price_AB*num_B*2 + price_A*(num_A-num_B)
else:
    minAB = price_AB*num_A*2 + price_B*(num_B-num_A)
maxAB = price_AB * max(num_A, num_B) * 2
print(min(AandB, minAB, maxAB))

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

m=max(x,y)
ans=10**9+7
for e in range(m+1):
  ans=min(ans,2*e*c+a*max(0,x-e)+b*max(0,y-e))
  
print(ans)

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

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

print(ans)

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
max_count = max(x, y)
ans = 10**18

for i in range(max_count+1):
    tmp = i*2*c
    if x-i > 0:
        tmp += (x-i)*a
    if y-i > 0:
        tmp += (y-i)*b
    ans = min(ans, tmp)

print(ans)

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


def main():
    a, b, c, x, y = map(int, input().split())
    c *= 2
    res1 = a * x + b * y
    res2 = c * max(x, y)
    res3 = c * x + max(0, y-x) * b
    res4 = c * y + max(0, x-y) * a
    print(min([res1, res2, res3, res4]))


if __name__ == "__main__":
    main()

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

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

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

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