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):
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""

def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
a,b,c,x,y = ips()
c*=2
z = 0
sum = x*a+b*y
cm = sum
while x and y:
    x-=1
    y-=1
    z+=1
    sum-=(a+b)
    sum+=c
    cm = min(cm,sum)
if x:
    while x>0:
        x-=1
        sum-=a
        sum+=c
        cm = min(cm,sum)
elif y:
    while y>0:
        y -= 1
        sum -= b
        sum += c
        cm = min(cm, sum)
print(cm)

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

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

Solution (Python):
def smaller(x, y):
	if x < y: return x
	return y

A, B, AB, X, Y = map(int, input().split())
sum = 0
if A + B <= 2 * AB:
	sum += A * X + B * Y
else:
	pizzaset = 2 * smaller(X, Y)
	sum += pizzaset * AB
	X -= pizzaset // 2
	Y -= pizzaset // 2
	if X == 0:
		if B <= 2 * AB:
			sum += B * Y
		else:
			sum += 2 * Y * AB
	else:
		if A <= 2 * AB:
			sum += A * X
		else:
			sum += 2 * X * AB
print(sum)

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

cost_a = a * x
w_x = x

cost_b = b * y
w_y = y

if c * 2 < a + b:
    w_c = min(x, y) * 2
    w_x = x - min(x, y)
    w_y = y - min(x, y)

    if w_x > 0:
        if a > c * 2:
            w_c += w_x * 2
            w_x = 0

    if w_y > 0:
        if b > c * 2:
            w_c += w_y * 2
            w_y = 0

    print(w_x * a + w_y * b + w_c * c)
else:
    print(cost_a + cost_b)

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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

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


a1 = A * X + B * Y

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

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

print(min(a1, a2, a3))

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

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

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

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

Solution (Python):
from sys import stdin
A,B,C,X,Y = [int(x) for x in stdin.readline().rstrip().split()]
ans = 10**9
for i in range(0,2*(max(X,Y)+1)):
    total = A*max((X-(i//2)),0) + B*max((Y-(i//2),0)) + i*C
    
    if total > 0 and total < ans:
        ans = total
print(ans)

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

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

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

ans_3 = X * A + Y * B

print(min(ans_1, ans_2, ans_3))

Solution (Python):
A,B,C,X,Y = (int(_) for _ in input().split())
all_ab =max(X,Y)*C*2
no_ab = A*X + B*Y
if X>=Y:
    ab = Y*2*C + (X-Y)*A
else:
    ab = X*2*C + (Y-X)*B
print(min(all_ab,no_ab,ab))

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

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	A,B,C,X,Y = map(int, input().split(" "))
	
	if C >= A and C >= B:
		
		print(A*X + B*Y)
		sys.exit()
	
	base = A*X + B*Y
	
	if X == Y:
		tmp = C * 2 * Y
		
		print(min(base, tmp))
		sys.exit()
	

	part1 = A*X
	part21 = C*2*Y
	part22 = B*Y
	tmp = min(part21,part22)
	tmp = part1 + tmp
	ans = min(base, tmp)
	
			
	part1 = C*2*X
	Y_tmp = Y-X
	if Y_tmp > 0:	
		part21 = C*2*Y_tmp
		part22 = B*Y_tmp
		tmp = min(part21,part22)
		tmp = part1 + tmp
	else:
		tmp = part1
	ans = min(ans, tmp)
	
	
	part1 = B*Y
	part21 = C*2*X
	part22 = A*X
	tmp = min(part21,part22)
	tmp = part1 + tmp
	ans = min(ans, tmp)
	
		
	part1 = C*2*Y
	X -= Y
	if X > 0:
		part21 = C*2*X
		part22 = A*X
		tmp = min(part21,part22)
		tmp = part1 + tmp
	else:
		tmp = part1
	ans = min(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:
        if a <= 2*c:
            print(2*c*y + a*(x-y))
        else:
            print(2*c*x)
    else:
        if b <= 2*c:
            print(2*c*x + b*(y-x))
        else:
            print(2*c*y)

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

sum_ab = a + b
double_c = c * 2
cheaper = sum_ab if sum_ab <= double_c else double_c
lesser = x if x < y else y
moreer = x if x >= y else y
base_cost = cheaper * lesser
additional = 0
if x - y > 0:
  additional = (x-y) * a
else:
  additional = (y-x) * b
total_p1 = base_cost + additional
total_p2 = moreer * double_c
print(min(total_p1, total_p2))

Solution (Python):

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


if __name__ == "__main__":
    main()

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


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


print(ans)

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


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


print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
def calc(x, y):
    return A*x+B*y

mi = min(X, Y)
ma = max(X, Y)
print(min(calc(X,Y), calc(X-mi, Y-mi) + C*mi*2, C*ma*2))

Solution (Python):
A, B, C, X, Y = map(int, input().split())
def calc(x, y):
    return A*x+B*y

mi = min(X, Y)
ma = max(X, Y)
print(min(calc(X,Y), calc(X-mi, Y-mi) + C*mi*2, C*ma*2))

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

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

Solution (Python):
import math

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

cost = []
cost.append(A*X + B*Y)

for i in range(2*min(X,Y), 2*max(X,Y)+1):
    cost.append(C*i + max(0, math.ceil(X-i/2)*A) + max(0, math.ceil(Y-i/2)*B))

print(min(cost))

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

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

print(ans)

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

Solution (Python):

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


ans = X * A + Y * B

bul = True

while bul:

    bul = False

    if X > 0 and Y > 0 and A + B > 2*C:

        bul = True
        X -= 1
        Y -= 1

        ans = ans - (A+B) + 2*C

    elif X > 0 and A > 2*C:

        bul = True
        X -= 1

        ans = ans - A + 2*C

    elif Y > 0 and B > 2*C:

        bul = True
        Y -= 1

        ans = ans - B + 2*C

print (ans)

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

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

print(ans)

Solution (Python):


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

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

ans = 10**9
for i in range(max(x,y)+1):
    cnt = 2*c*i
    if x > i:
        cnt += a*(x-i)
    if y >i:
        cnt += b*(y-i)
    ans = min(ans,cnt)

print(ans)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(4100000)

a,b,c,x,y = [int(i) for i in input().split()]
cost = x * a
while y != 0:
    if x > 0:
        if c * 2 < a + b:
            cost += -a + c*2
            y -= 1
            x -= 1
        else:
            cost += b
            y -= 1
    else:
        if b < c * 2:
            cost += b
            y -= 1
        else:
            cost += c*2
            y -= 1
print(cost)

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

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

ab = c * 2

if ab < a and ab < b:
    print(max(x, y) * ab)
else:
    answer = min(a+b, ab) * min(x, y)

    if x > y:
        answer += min(a, ab) * (x - y)
    else:
        answer += min(b, ab) * (y - x)
    print(answer)

Solution (Python):
a,b,c,x,y = list(map(int,input().split()))
cost = []
tmp = 0
i = 0

while i <= max(x,y) :
    tmp += i * 2 * c
    tmp += max(x-i,0)*a + max(y-i,0) * b
    cost.append(tmp)
    i += 1
    tmp = 0

print(min(cost))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a,b,c,x,y=LI()

  p=a*x+b*y
  q=c*2*max(x,y)

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

  return min(p,q,r)

print(main())

Solution (Python):
a, b, ab, xa, yb = map(int, input().split())
price = []
for i in range(100001):
    price.append(i * 2 * ab + max(xa - i, 0) * a + max(yb - i, 0) * b)

idx = price.index(min(price))

print(min(price))

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

mn_ABC = min(A+B, C*2)
mn_xy = min(X, Y)
money_1 = mn_ABC * mn_xy

money_2 = 0
if X > Y:
  mn_AC = min(A, C*2)
  money_2 = mn_AC * (X-Y)
elif X < Y:
  mn_BC = min(B, C*2)
  money_2 = mn_BC * (Y-X)

ans = money_1 + money_2
print(ans)

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

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

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

    ans = min(C*i*2 + A*X_i + B*Y_i, ans)
print(ans)

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

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

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

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

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

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

print (ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
AB = [A, B]
XY = [X, Y]
ans = []
minXY = min(X, Y)
maxXY = max(X, Y)
maxid = XY.index(max(X, Y))

ans.append(A*X+B*Y)
print(min(A*X+B*Y, 2*C*minXY+(maxXY-minXY)*AB[maxid], maxXY*2*C))

Solution (Python):

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

print(ans)

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

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

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

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

if a + b < c*2:
    res = a*x + b*y
else:
    min_c = min(x, y)
    ab_cost = min_c * 2 * c
    rem = max(x-min_c, y-min_c)
    if x > y:
        rem_cost = min(rem * a, rem*2*c)
    else:
        rem_cost = min(rem*b, rem*2*c)
    res = ab_cost + rem_cost
print(res)

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

ans = a*x + b*y

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

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

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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a,b,c,x,y=LI()

  l=[]
  l.append(a*x+b*y)
  l.append(c*x*2+b*max(0,y-x))
  l.append(c*y*2+a*max(0,x-y))
  l.append(c*max(x,y)*2)
  return min(l)

print(main())

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

Solution (Python):


def solve(A, B, C, X, Y):
    if A + B < C*2:
        return A * X + B * Y

    paid = 0
    if A > C * 2:
        
        
        paid += X * 2 * C
        Y -= X
        X = 0
    
    if Y > 0:
        if B > C * 2:
            
            paid += Y * 2 * C
            X -= Y
            Y = 0
        
    if X <= 0 and Y <= 0:
        return paid

    Z = min(X, Y)
    paid += Z * 2 * C
    X -= Z
    Y -= Z

    if X > 0:
        paid += X * A
    if Y > 0:
        paid += Y * B

    return paid

    



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



print(solve(A, B, C, X, Y))

Solution (Python):


def solve(A, B, C, X, Y):
    if A + B < C*2:
        return A * X + B * Y

    paid = 0
    if A > C * 2:
        
        
        paid += X * 2 * C
        Y -= X
        X = 0
    
    if Y > 0:
        if B > C * 2:
            
            paid += Y * 2 * C
            X -= Y
            Y = 0
        
    if X <= 0 and Y <= 0:
        return paid

    Z = min(X, Y)
    paid += Z * 2 * C
    X -= Z
    Y -= Z

    if X > 0:
        paid += X * A
    if Y > 0:
        paid += Y * B

    return paid

    



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



print(solve(A, B, C, X, Y))

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

min_cost = float("inf")

for ab_pizza in range(0, max(x, y)*2+1, 2):
    cost = a * max(x - ab_pizza // 2, 0) + b * max(y - ab_pizza // 2, 0) + c * ab_pizza
    if cost < min_cost:
        min_cost = cost

print(min_cost)

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

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

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


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

print(ans)

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

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

if (a + b) <= c * 2:
  cost_over = 10 ** 100
  cost = a * x + b * y 
else: 
  if x <= y:
    cost_over = c * 2 * y
    cost = c * 2 * x + b * (y - x)
  else: 
    cost_over = c * 2 * x
    cost = c * 2 * y + a * (x - y)

min = min(cost, cost_over)
print(min)

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

answer = 10**18
for c in range(10**5+1):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a,0)*A
  cost += max(b,0)*B
  if answer > cost:
    answer = cost
print(answer)

Solution (Python):

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

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

Solution (Python):

import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    cost = float("inf")

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

    print(cost)




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=list(map(int,input().split()))
ans=0
if (A+B)/2>=C:
    ans+=2*C*min(X,Y)
else:
    ans+=(A+B)*min(X,Y)

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

Solution (Python):
def smaller(x, y):
	if x < y: return x
	return y
A, B, C, X, Y = map(int, raw_input().split())
sum = 0
if A+B > 2 * C:
	c = smaller(X, Y)
	sum += c * 2 * C
	X -= c
	Y -= c
	if A > 2 * C: sum += X * 2 * C
	else: sum += X * A
	if B > 2 * C: sum += Y * 2 * C
	else: sum += Y * B
else:
	sum = A * X + B * Y
print sum

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

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

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

a_pizza = a * x
b_pizza = b * y
ans_1 = a_pizza + b_pizza

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

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

print(min(ans_1, ans_2, ans_3))

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

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

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

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

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

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

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

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

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

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

print (ans)

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

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

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

Solution (Python):

import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    ret = 0
    if C * 2 <= A + B:
        ret += min(X, Y) * 2 * C
        if X > Y:
            if C * 2 <= A:
                ret += C * 2 * (X - Y)
            else:
                ret += A * (X - Y)
        else:
            if C * 2 <= B:
                ret += C * 2 * (Y - X)
            else:
                ret += B * (Y - X)

    else:
        ret += A * X + B * Y
    print(ret)
    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())
cost=0
pizza_rem=0


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


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


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

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

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b,c,x,y=IL()
c=c*2
if c<=a:
    if c<=b:
        print(c*max(x,y))
    else:
        print(c*x+max(0,(y-x)*b))
elif c<=b:
    print(c*y+max(0,(x-y)*a))
elif c<=a+b:
    if x>=y:
        print(c*y+a*(x-y))
    else:
        print(c*x+b*(y-x))
else:
    print(a*x+b*y)

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

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

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

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

print(total)

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    a, b, c, x, y = intin()

    if c * 2 >= a + b:
        print(a * x + b * y)
        return

    xy = min(x, y)

    if a <= c * 2 and b <= c * 2:
        print((x - xy) * a + (y - xy) * b + xy * c * 2)
        return

    if b <= c * 2:
        print((x - xy) * c * 2 + (y - xy) * b + xy * c * 2)
        return

    if a <= c * 2:
        print((x - xy) * a + (y - xy) * c * 2 + xy * c * 2)
        return

    xy = max(x, y)
    print(xy * c * 2)


if __name__ == '__main__':
    main()

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

min_cost = 10000000000
for i in range(max(x, y) + 1):
    cost = 2 * c * i + max(0, a * (x - i)) + max(0, b * (y - i))

    if min_cost > cost:
        min_cost = cost
print(min_cost)