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())
yasui=False
yasuia=False
yasuib=False
ans=0
sa=max([x,y])-abs(x-y)
if a+b>2*c:
  yasui=True
if a>2*c:
  yasuia=True
if b>2*c:
  yasuib=True
if yasui:
  ans+=sa*2*c
else:
  ans+=sa*(a+b)
x-=sa
y-=sa

if x>0:
  if yasuia:
    ans+=2*c*x
  else:
    ans+=a*x
if y>0:
  if yasuib:
    ans+=2*c*y
  else:
    ans+=b*y
print(ans)

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

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

print(ans)

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

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

Solution (Python):
import numpy as np

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

m = min(X,Y)
p = np.abs(X-Y)

A_B_only = A*X+B*Y
A_B = A*m+B*m+p*2*C

if X<Y:
  AB = m*2*C+p*B
  AB_only = Y*2*C
elif Y<X:
  AB = m*2*C+p*A
  AB_only = X*2*C
elif X==Y:
  AB = m*2*C
  AB_only = X*2*C


print(min(A_B,AB,AB_only,A_B_only))

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

Solution (Python):
a,b,c,x,y=map(int,input().split())
ans=a*x+b*y
if x<y:
  ans=min(ans,x*2*c+(y-x)*b)
  ans=min(ans,y*2*c)
else:
  ans=min(ans,y*2*c+(x-y)*a)
  ans=min(ans,x*2*c)
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 :
    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=map(int,input().split())
price=0
if A+B>C+C:
    minXY=min(X,Y)
    price+=minXY*C*2
    X-=minXY
    Y-=minXY
if A>C+C:
    price+=X*2*C
    X=0
else:
    price+=A*X
    X=0
if B>C+C:
    price+=Y*2*C
    Y=0
else:
    price+=B*Y
    Y=0
print(price)

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

cmin=max([X,Y])
lis=[]
for i in range(cmin+1):
	i_c=i*2
	i_a, i_b=X-i,Y-i
	
	if i_a>=0 and i_b>=0:
		lis.append(i_c*C+i_b*B+i_a*A)
	if i_a<0:
		if i_b<0:
			lis.append(i_c*C)
		else:
			lis.append(i_c*C+i_b*B)
	elif i_b<0:
		lis.append(i_c*C+i_a*A)


print(min(lis))

Solution (Python):
import sys
INFTY=sys.maxsize

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

def main(a,b,c,x,y):
    minPrice=INFTY
    for nab in range(0,max(x,y)*2+1,2):
        na=max(0,x-nab//2)
        nb=max(0,y-nab//2)
        price=nab*c+na*a+nb*b
        
        minPrice=min(minPrice,price)  
    return minPrice  

if __name__=='__main__':
    a,b,c,x,y=readinput()
    ans=main(a,b,c,x,y)
    print(ans)

Solution (Python):
def calc(s, l, c, x, y):
    pat1 = s*x + l*y
    pat2 = 2*c*y
    pat3 = 2*c*x + l*(y-x)
    return min(pat1,pat2,pat3)

A,B,C,X,Y = map(int, input().split())
if X < Y:
    print(calc(A,B,C,X,Y))
else:
    print(calc(B,A,C,Y,X))

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

fee = 0

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

print(fee)

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

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

print(ans)

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

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

print(ans)

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

Solution (Python):

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

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

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

ans=10**10

for i in range(10**5+1):
    a_cnt=max(0,x-i)
    b_cnt=max(0,y-i)
    
    total=i*2*c+a_cnt*a+b_cnt*b
    ans=min(ans,total)

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A,B,C,X,Y = map(int,readline().split())
AB = 2*max(X,Y)
price = float('inf')
for i in range(0,AB+1,2):
  total = A * max(0,X-i//2)+ B * max(0,Y-i//2) + C * i 
  price = min(price,total)
print(price)

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

Solution (Python):
input = input()
split = input.split()
pliceA = int(split[0])
pliceB = int(split[1])
pliceC = int(split[2])
neededA = int(split[3])
neededB = int(split[4])

maxC = neededA * 2 if neededA > neededB else neededB * 2
minPlice = 10 ** 10
for c in range(0, maxC + 1, 1):
    leftA = neededA - int(c / 2) if neededA - int(c / 2) > 0 else 0
    leftB = neededB - int(c / 2) if neededB - int(c / 2) > 0 else 0
    plice = leftA * pliceA + leftB * pliceB + pliceC * c
    minPlice = plice if plice < minPlice else minPlice

print(minPlice)

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


ans = a * x + b * y


ans = min(ans, c * 2 * max(x,y))

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

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

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

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

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

print(min(k1, k2, k3))

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

ans=10**9
for i in range(2*max(x,y)+1):
  s=max(x-i//2,0)
  t=max(y-i//2,0)
  t_ans=s*a+t*b+i*c
  ans=min(ans,t_ans)

print(ans)

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

    ans = 1 << 30
    c = 0  
    while True:
        j = c // 2
        t = A * max(0, X - j) + B * max(0, Y - j) + C * c
        if ans <= t: break
        ans = t
        c += 2

    print(ans)


if __name__ == '__main__':
    main()

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

d = c * 2


ans = 1 << 30

for i in range(max(x, y) + 1):
    rx = max(x - i, 0)
    ry = max(y - i, 0)
    ans = min(ans,  i * d + rx * a + ry * b)
print(ans)

Solution (Python):

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

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

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

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

d = c * 2


ans = 1 << 30

for i in range(max(x, y) + 1):
    rx = max(x - i, 0)
    ry = max(y - i, 0)
    ans = min(ans,  i * d + rx * a + ry * b)
print(ans)

Solution (Python):
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, x, y = map(int, input().split())

ab = math.floor((x+y)/2)

p1 = a*x+b*y
max_x = max(x, y)
p2 = c*max_x+c*max_x
min_x = min(x, y)
p3 = a*(x-min_x)+b*(y-min_x)+c*((min_x)*2)
ans = min(p1, p2, p3)
print(ans)

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

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

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

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

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

print(total)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

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

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

a,b,c,x,y = map(int,stdin.readline().rstrip().split())
mi = 10**10

mi = min(mi,max(x,y)*2*c)
mi = min(mi,a*x+b*y)

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

print(mi)

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

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

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

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

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

print(ans)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, x, y = map(int, input().split())
    c *= 2
    if a + b > c:
        cost1 = max(x, y) * c
        cost2 = min(x, y) * c
        plus = ((y - x) * b) if x < y else (x - y) * a
        res = min(cost1, cost2 + plus)
    else:
        res = x * a + y * b
    print(res)

if __name__ == '__main__':
    resolve()

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

  print(ans)
  return

if __name__ == "__main__":
  resolve()

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = 10 ** 18
for i in range(10 ** 5 * 2):
    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())

cost = 0

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

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

print(cost)

Solution (Python):
def examA():
    C1 = SI()
    C2 = SI()
    ans = "YES"
    if C1[0]!=C2[2] or C1[1]!=C2[1] or C1[2]!=C2[0]:
        ans = "NO"
    print(ans)
    return

def examB():
    A, B, C, X, Y = LI()
    loop = max(X,Y)
    ans = inf
    for i in range(loop+1):
        cost = i*2*C
        if X>i:
            cost += A*(X-i)
        if Y>i:
            cost += B*(Y-i)
        ans = min(ans,cost)
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

Solution (Python):

def main():
    import sys
    A,B,C,X,Y = map(int, sys.stdin.readline().split())
    
    ans = -1
    for i in range(0, 2*10**5+1, 2):
        tmp = max((X-i//2)*A, 0) + i*C + max((Y-i//2)*B, 0)
        if ans ==-1 or ans > tmp:
            ans = tmp
    print(ans)
    
   
    
if __name__=='__main__':
    main()

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


price_a_b = 0
price_mix = 0
price_c = 0


price_a_b = a*x + b*y


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


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

print(min(price_a_b, price_mix, price_c))

Solution (Python):

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

minp=10**9+1
for i in range(X+1):
    p=0
    p+=A*i
    numab=(X-i)*2
    p+=numab*C
    p+=max(0,(Y-X+i))*B
    minp=min(minp,p)
for i in range(Y+1):
    p=0
    p+=B*i
    numab=(Y-i)*2
    p+=numab*C
    p+=max(0,(X-Y+i))*A
    minp=min(minp,p)
    
print(minp)

Solution (Python):

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





price_min = 1000000000




for i in range(X+1):
    
    
    if Y <= X-i:
        price = i*A + 2*(X-i)*C
    
    
    else:
        price = i*A + 2*(X-i)*C + min((Y-(X-i))*B,2*(Y-(X-i))*C)
    
    if price_min > price:
            
            price_min = price
            
print(price_min)

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

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

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

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

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

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

Solution (Python):
a, b, ab, x, y = (int(x) for x in input().split())
if x>y:
    tmp = x
    x = y
    y = tmp
    tmp = a
    a = b
    b = tmp

if a+b < 2*ab:
    print(a*x+b*y)
elif b < 2*ab:
    print(b*(y-x)+ab*2*x)
else:
    print(2*ab*y)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

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

ans = 0
if A+B > 2*C:
	ans += 2*C*min(X,Y)
	idx = (X, Y).index(max(X, Y))
	left = abs(X-Y)
	if 2 * C < (A, B)[idx]: 
		ans += 2*C*left
	else:
		ans += (A, B)[idx] * left
else:
	ans = A*X + B*Y
print(ans)

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

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

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

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

ans = 0

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

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

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

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


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

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


print(min(ans))

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

ab_n = 2 * (max(x, y))
ans = float("inf")

for i in range(0, ab_n + 1, 2):
    a_n = x - i // 2
    b_n = y - i // 2
    if a_n < 0:
        a_n = 0
    if b_n < 0:
        b_n = 0
    ans = min(ans, a * a_n + b * b_n + c * i)
print(ans)

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

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

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

print(min(tmp, a*x+b*y))

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

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

    print(min(A*X+B*Y, tmp))


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
def main():
    a, b, c, x, y = map(int, input().split())
    
    t1 = a * x + b * y
    t2 = c * max(x, y) * 2
    if x >= y:
        t3 = c * y * 2 + a * (x - y)
    else:
        t3 = c * x * 2 + b * (y - x)
        
    print(min(t1, t2, t3))
    
    
if __name__ == '__main__':
    main()

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

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

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

atob = x*a + y*b

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

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

Solution (Python):
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq

a, b, c, x, y = map(int, sys.stdin.readline().split())



n = max(x, y)
ans = 10 ** 10
for i in range(n+1):
    p = max(x - i, 0)
    q = max(y - i, 0)
    r = 2 * i * c + p * a + q * b
    if r < ans:
        ans = r

print(ans)

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

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

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

Solution (Python):
import sys
from collections import deque
import copy
def main():
    A, B, C, X, Y = map(int, input().split())
    C *= 2
    ans = 0
    if A + B >= C:
        if X > Y:
            ans = C * Y + min(A, C) * (X - Y)
        else:
            ans = C * X + min(B, C) * (Y - X)
    else:
        if X > Y:
            ans = min(A, C) * (X - Y) + A * Y + B * Y
        else:
            ans = A * X + B * X + min(B, C) * (Y - X)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from collections import deque

from bisect import bisect_left, bisect_right









def main():
    A, B, C, X, Y = map(int,input().split())
    max_C_num = 2 * max(X, Y)
    left_x = X
    left_y = Y
    min_price = 10 ** 10
    for c in range(0, max_C_num + 1, 2):
        left_x = X - c // 2
        left_y = Y - c // 2
        price = C * c
        if price > min_price:
            continue
        if left_x > 0:
            price += A * left_x
        if left_y > 0:
            price += B * left_y
        min_price = min(price, min_price)
    print(min_price)


if __name__ == '__main__':
    main()

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

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

ans = min([a*x+b*y,
           c*2*y+a*(x-y),
           2*c*x,])

print(ans)

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

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

Solution (Python):

A,B,C,X,Y = list(map(int,input().split()))
max_pizza=max(X,Y)
ans=10E+10  

for i in range(0,max_pizza*2+2,2):
    
    

    if (X-i/2)<=0 and (Y-i/2)>0:
        ans_kouho = B*(Y-i/2)+C*(i)
    elif (X-i/2)>0 and(Y-i/2)<=0:
        ans_kouho = A*(X-i/2)+C*(i)
    elif (X-i/2)<=0 and(Y-i/2)<=0:
         ans_kouho = C*(i)
    else:
        ans_kouho = A*(X-i/2)+B*(Y-i/2)+C*(i)

    
    if(ans_kouho<ans):
        ans = ans_kouho

print(int(ans))

Solution (Python):

A,B,C,X,Y = list(map(int,input().split()))
max_pizza=max(X,Y)
ans=10E+10  

for i in range(0,max_pizza*2+2,2):
    
    if (X-i/2)<=0 and (Y-i/2)>0:
        ans_kouho = B*(Y-i/2)+C*(i)
    elif (X-i/2)>0 and(Y-i/2)<=0:
        ans_kouho = A*(X-i/2)+C*(i)
    elif (X-i/2)<=0 and(Y-i/2)<=0:
         ans_kouho = C*(i)
    else:
        ans_kouho = A*(X-i/2)+B*(Y-i/2)+C*(i)

    
    if(ans_kouho<ans):
        ans = ans_kouho

print(int(ans))

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    A, B, C, X, Y = map(int, input().split())
    M = max(X, Y)
    ans = INF
    for i in range(0, 2 * M + 1, 2):
        tmp = i * C
        rest_a = max(X - i // 2, 0)
        rest_b = max(Y - i // 2, 0)
        tmp += rest_a * A + rest_b * B
        if tmp < ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    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:
        A, B, X, Y = B, A, Y, X
    print(2 * X * C + (Y - X) * min(B, 2 * C))

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

cost_min = 1000000 * 5000
for i in range(2 * max(x, y) + 1):
    cost = c * i
    if x - i // 2 > 0:
        cost += a * (x - i // 2)
    if y - i // 2 > 0:
        cost += b * (y - i // 2)
    cost_min = min(cost, cost_min)
print(cost_min)

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

Solution (Python):
a,b,c,x,y = map(int,input().split())
l = min(x,y)
m = max(x,y)
M = a * x + b * y
for i in range(1,l+1):
  K = a * (x-i) + b * (y-i) + 2 * c * i 
  M = min(M,K)
for i in range(l+1,m+1):
  if x == l:
    K = b * (y-i) + 2 * c * i
  else:
    K = a * (x-i) + 2 * c * i
  M = min(M,K)
print(M)

Solution (Python):
a,b,c,x,y = map(int,input().split())
l = min(x,y)
m = max(x,y)
M = a * x + b * y
for i in range(1,l+1):
  K = a * (x-i) + b * (y-i) + 2 * c * i 
  M = min(M,K)
for i in range(l+1,m+1):
  if x == l:
    K = b * (y-i) + 2 * c * i
  else:
    K = a * (x-i) + 2 * c * i
  M = min(M,K)
print(M)

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

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

ans = float('inf')

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

print(ans)

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

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

print(ans)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

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


cost1 = a*x + b*y

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

cost3 = c*y*2 + abs(x - y)*a

cost4 = c*x*2 + abs(y-x)*b
ans = min(cost1,cost2)
ans = min(ans,cost3)
ans = min(ans,cost4)
print(ans)