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 = list(map(lambda x: int(x), input().split(' ')))

ans = pow(10, 5) * max(A, B, C) * 3
ab_max = (max(X, Y)+1) * 2
for ab in range(0, ab_max + 1, 2):
    x = max(0, X - ab//2)
    y = max(0, Y - ab//2)
    price = x * A + y * B + ab * C
    
    ans = min(ans, price)

print(ans)

Solution (Python):


import sys










def main():
    a, b, c, x, y = (int(i) for i in sys.stdin.readline().split())
    if a + b <= c * 2:
        cost = a * x + b * y
    elif x >= y:
        atleast = y
        cost = c * atleast * 2
        remainder = x - atleast
        if a <= c * 2:
            cost += a * remainder
        else:
            cost += c * remainder * 2
    else:
        atleast = x
        cost = c * atleast * 2
        remainder = y - atleast
        if b <= c * 2:
            cost += b * remainder
        else:
            cost += c * remainder * 2 
    
    print(cost)
    
if __name__ == "__main__":
    
    main()

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

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

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

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

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

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

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

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

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

Solution (Python):
a,b,c,x,y=map(int,input().split())
ans=10000000000
for i in range(0,max(x,y)*2+1,1):
    if x-i/2<=0 and y-i/2<=0:
        aa=0
        bb=0
    elif x-i/2<=0 and y-i/2>0:
        aa=0
        bb=y-i/2
    elif y-i/2<=0 and x-i/2>0:
        aa=x-i/2
        bb=0
    else:
        aa=x-i/2
        bb=y-i/2
    ab=aa*a+bb*b+i*c
    ans=min(ans,ab)
print(int(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:
    z = min(x,y)
    ans = min(max(x,y)*c*2,z * 2 * c + a*(x-z) + b*(y-z))

print(ans)

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

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

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

C = c*2
ans = []
if C<a+b:
    if x>y:
        ans.append(C*x)
        ans.append(C*y+a*(x-y))
    else:
        ans.append(C*y)
        ans.append(C*x+b*(y-x))
else:
    ans.append(a*x+b*y)
print(min(ans))

Solution (Python):
a,b,c,x,y=map(int,input().split())
lo=0 
hi=10**19
def check(mi): 
    m=max(x,y)
    if m*2*c<=mi:
        
        return 1 
    if a<c and b<c: 
        cost=a*x+b*y 
        
        return cost<=mi 
    if a>c and b>c:
        cost=0 
        mini=min(x,y)
        
        return mini*c*2+(-mini+x)*a+(-mini+y)*b<=mi 

    if a*x+b*y<=mi:
        return 1 
    mini=min(x,y)
    if mini*c*2+(x-mini)*a+(y-mini)*b<=mi:
      
        return 1 
    return 0 



while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1 
    else:
        lo=mi+1 
print(ans)

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

Solution (Python):
A,B,C,X,Y=map(int,input().split())
ans= min(A+B,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())
ans=A*X+B*Y
for i in range(max(X,Y)+1):
	ans=min(ans,2*C*i+A*max((X-i),0)+B*max((Y-i),0))

print(ans)

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


def main():
    import math
    import collections
    import itertools

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



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

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

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

ans = a * n_a + b * n_b
while ans > a * max(n_a - 1, 0) + b * max(n_b - 1, 0) + c * n_c:
    ans = a * max(n_a - 1, 0) + b * max(n_b - 1, 0) + c * n_c
    n_a -= 1
    n_b -= 1
    n_c += 2
    
print(ans)

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

res=0

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






if X > 0: 
        if A > 2 * C: 
                res += C * 2*X
                Y -= X
        else: 
                res += X * A

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

print(res)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c, x, y = list(map(int, input().rstrip('\n').split()))
    t = a * x + b * y
    t = min(t, max(x, y) * 2 * c)
    m = min(x, y)
    x -= m
    y -= m
    m = min(t, a * x + b * y + c * 2 * m)
    print(m)


if __name__ == '__main__':
    slove()

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

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

print(ans)

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

r = []


t1 = A * X + B * Y
r.append(t1)


x = min(X, Y)
ab = 2 * x
t2 = ab * C + (X - x) * A + (Y - x) * B
r.append(t2)


x = max(X, Y)
ab = 2 * x
t3 = ab * C
r.append(t3)

print(min(r))

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

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

print(ans)

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

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

if a+b<2*ab:
  print(a*x+b*y)
else:
  amount = min(min(x,y)*2*ab+ (abs(x-y))*(a if x>y else b),max(x,y)*2*ab)
  print(amount)

Solution (Python):
s, t, c, x, y = list(map(int, input().split()))
a = [s, x]
b = [t, y]
if x > y:
    large = a
    least = b
else:
    large = b
    least = a
ans = 0
if s + t >= c * 2:
    ans += c * 2 * least[1]
    if large[0] > c * 2:
        ans += c * 2 * (large[1] - least[1])
    else:
        ans += large[0] * (large[1] - least[1])
else:
    ans += s * x + t * y
print(ans)

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

sum1 = a * x + b * y

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

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

print(min(sum1, sum2, sum3))

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

Solution (Python):

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

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

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

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

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

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

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


if __name__ == "__main__":
    test()

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


if __name__ == "__main__":
    test()

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

Solution (Python):



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


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

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

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

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

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

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

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

Solution (Python):


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

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

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



cost = set()
for n_AB in range(0, max(X,Y)*2 + 1, 2):
    n_A = max(0, X - n_AB//2)
    n_B = max(0, Y - n_AB//2)
    cost.add(n_A*A + n_B*B + n_AB*C)

print(min(cost))

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

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

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

Solution (Python):
a,b,c,x,y = map(int,input().split())
pizza = [(x,a),(y,b)]
pizza.sort()
sp,sq = pizza[0][1],pizza[0][0]
lp,lq = pizza[1][1],pizza[1][0]


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

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

tmp1 = c * min(x, y) * 2
tmp2 = 0
if x < y:
    tmp2 = b * abs(x - y)

elif x > y:
    tmp2 = a * abs(x - y)

else:
    tmp2 = float("INF")

pattern1 = (a * x + b * y)
pattern2 = tmp1 + tmp2
pattern3 = c * max(x, y) * 2

print(min(pattern1, pattern2, pattern3))

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

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

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

a_cnt = 0
b_cnt = 0
c_cnt = 0

if A + B > C * 2:
    c_cnt += min(X,Y) * 2
else:
    a_cnt = b_cnt = min(X,Y)

if X > Y:
    if A < C * 2:
        a_cnt += X-Y
    else:
        c_cnt += (X-Y) * 2
elif Y > X:
    if B < C * 2:
        b_cnt += Y-X
    else:
        c_cnt += (Y-X) * 2
print(a_cnt * A + b_cnt * B + c_cnt * C)

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

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

Solution (Python):
a,b,c,x,y=[int(s) for s in input().split()]
if x<=y:
  A=a
  B=b
  C=c
  X=x
  Y=y
else:
  A=b
  B=a
  C=c
  X=y
  Y=x

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

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

minprice = 10 ** 10
XY_max = max(X,Y)

for i in range(XY_max + 1):
    nokori_X = max(X - i,0)
    nokori_Y = max(Y - i,0)

    tmp = i * 2 * C + nokori_X * A + nokori_Y * B
    minprice = min(tmp,minprice)

if minprice == 10 ** 10:
    minprice = 0

print(minprice)

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

min_xy=min(X,Y)
Max_xy=max(X,Y)
d=A*X+B*Y
e=C*2*Max_xy
if X>=Y:
    print(min(C*2*min_xy+(Max_xy-min_xy)*A,d,e))
else:
    print(min(C*2*min_xy+(Max_xy-min_xy)*B,d,e))

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B, C, x, y] = string_to_int(inputs[0])
    cost = 0
    if A + B > C * 2:
        while x >= 1 and y >= 1:
            cost += C * 2
            x -= 1
            y -= 1

    if A > C * 2:
        while x >= 1:
            cost += C * 2
            x -= 1
    else:
        while x >= 1:
            cost += A
            x -= 1

    if B > C * 2:
        while y >= 1:
            cost += C * 2
            y -= 1
    else:
        while y >= 1:
            cost += B
            y -= 1
    return cost


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

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

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

ret = float('inf')
for ab in range(0, max(X, Y) * 2 + 1, 2) :
    ret = min(ret, A * max(0, (X - ab // 2)) + B * max(0, (Y - ab // 2)) + C * ab)
    
print(ret)

Solution (Python):
A,B,C,X,Y = [int(x) for x in input().split()]
mi = min(X,Y)
ans = 0
if mi*C*2<A*mi+B*mi:
  X = X-mi
  Y = Y-mi
  ans = mi*C*2
else:
  print(A*X+B*Y)
  exit()
if X>0:
  if X*C*2<X*A:
    ans += X*C*2
    print(ans)
    exit()
  else:
    ans += X*A
    print(ans)
    exit()
if Y>0:
  if Y*C*2<Y*B:
    ans += Y*C*2
    print(ans)
    exit()
  else:
    ans += Y*B
    print(ans)
    exit()
print(ans)

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

    prs = [a*x + b*y] 
    
    ac = x*2*c
    if y > x:
        z = y - x
        ac += min([b*z, z*2*c])
    prs.append(ac)

    
    bc = y*2*c
    if x > y:
        z = x - y
        bc += min([a*z, z*2*c])
    prs.append(bc)

    print(min(prs))

cc095()

Solution (Python):
a,b,ab,a_c,b_c=map(int,input().split())
ans=[]

ans.append(a*a_c+b*b_c)

ans.append(max(a_c,b_c)*ab*2)

c=min(a_c,b_c)
ans.append(c*ab*2+(a_c-c)*a+(b_c-c)*b)
print(min(ans))

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

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

if X > Y:
    temp = X
    X = Y
    Y = temp
    temp = A
    A = B
    B = temp

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

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

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

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

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

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

print(ans)

Solution (Python):
def main():
    A, B, C, X, Y = (int(i) for i in input().split())
    ans1 = A * X + B * Y
    ans2 = 0
    ans3 = 0
    if X < Y:
        ans2 += 2 * C * X
        ans2 += B * (Y-X)
        ans3 += 2 * C * Y
    else:
        ans2 += 2 * C * Y
        ans2 += A * (X-Y)
        ans3 += 2 * C * X

    print(min(ans1,ans2,ans3))

if __name__ == '__main__':
    main()

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

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:
    pass
  elif X > Y:
    if A > C*2:
      ans += C*2*(X-Y)
    else:
      ans += A*(X-Y)
  else:
    if B > C*2:
      ans += C*2*(Y-X)
    else:
      ans += B*(Y-X)
else:
  ans = A*X + B*Y
print(ans)

Solution (Python):
def solve():
    a,b,c,x,y = map(int, input().split())
    z = [a*x + b*y, c*2*x + b*max(0,y-x), c*2*y + a*max(0,x-y), c*2*max(x,y)]
    return min(z)
        
if __name__ == '__main__':
    print(solve())

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

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

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

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

print(min(P))

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

res = (
    c * max(x, y) * 2,
    a*x + b*y,
    c*x*2 + b*max(y-x, 0),
    c*y*2 + a*max(x-y, 0)
)

print(min(res))

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

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

  ans = min(ans, p)
print (ans)

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

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

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

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

ans1 = min(x,y) * min(a + b,c*2) + abs(x-y) * z
ans2 = c * max(x,y) * 2
print(min(ans1,ans2))

Solution (Python):
A, B, AB, X, Y = map(int, input().split())
res = 0
if A + B > 2 * AB:
  res += min(X, Y) * AB * 2
  m = min(X, Y)
  X -= m
  Y -= m
if A > 2 * AB and X > 0:
  res += X * AB * 2
  X -= X
  Y -= X
if B > 2 * AB and Y > 0:
  res += Y * AB * 2
  X -= Y
  Y -= Y
print(res + max(0, X * A) + max(0, Y * B))

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

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

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

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

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

answer = 10**18
n = 2*10**6+1
for c in range(n):
  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 = map(int, input().split())

answer = 10**18
for c in range(10**6+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 = map(int, input().split())

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

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

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

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
p0 = a * x + b * y
p1 = 2 * c * max(x, y)
a0 = 2 * c * min(x, y) + a * (max(x, y) - min(x, y))
b0 = 2 * c * min(x, y) + b * (max(x, y) - min(x, y))

if x <= y:
    print(min(p0, p1, b0))
else:
    print(min(p0, p1, a0))

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

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

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

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

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




def main():

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

    if X == Y:
        price = min(cSet*X, A*X+B*Y)
    elif X > Y:
        price = min(cSet*X, cSet*Y+A*(X-Y), A*X+B*Y)
    else:
        price = min(cSet*Y, cSet*X+B*(Y-X), A*X+B*Y)
    
    print(price)



 





if __name__ == "__main__":
    main()

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

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

print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


a, b, c, x, y = LI()
a = min(2 * c, a)
b = min(2 * c, b)

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

Solution (Python):

a,b,c,x,y = map(float,input().split())
ans = 0
if a+b > 2*c:
    while x != 0.0 and y != 0.0:
        ans += 2*c
        x -= 1.0
        y -= 1.0
        if y == 0.0:
            while x != 0.0:
                if a > 2*c:
                    ans += 2*c
                    x -= 1.0
                else:
                    ans += a
                    x -= 1.0
        if x == 0.0:
            while y != 0.0:
                if b > 2*c:
                    ans += 2*c
                    y -= 1.0
                else:
                    ans += b
                    y -= 1.0
else:
    ans += a*x + b*y
print(int(ans))

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