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())
price = A * X + B * Y
x = X
y = Y

for i in range(max(X, Y)):
    if x > 0 and y > 0:
        d = A + B - C * 2
    elif x <= 0:
        d = B - C * 2
    elif y <= 0:
        d = A - C * 2

    price = min(price, price - d)
    x -= 1
    y -= 1

print(price)

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

candidates = []
candidates.append(a * x + b * y)
candidates.append(c * max(x, y) * 2)
candidates.append(c * min(x, y) * 2 + (a if x > y else b) * abs(x - y))

print(min(candidates))

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

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


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

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

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

Solution (Python):
def solve():
    A,B,C,X,Y = map(int, input().split())
    ret = 0
    max_pizza = max(X,Y)
    min_pizza = min(X,Y)
    if A+B >= 2*C:
        ret += min_pizza*2*C
    else:
        ret += min_pizza*(A+B)
        
    max_price = B if X < Y else A
    if max_price <= 2*C:
        ret += (max_pizza - min_pizza)*max_price
    else:
        ret += 2*C*(max_pizza - min_pizza)
    
    print(ret)
    
solve()

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

    x1 = min(X, Y)
    price = min((A+B) * x1, 2 * C * x1)
    x2 = max(X, Y) - x1
    a = A if X > Y else B
    price += min(a * x2, 2 * C * x2)
    print(price)
solve()

Solution (Python):
def check():
    A, B, C, X, Y = [int(i) for i in input().split(' ')]
    if X > 0 and Y > 0:
        if 2*C < A+B:
            if X > Y:
                total = Y*2*C
                price = min(A, 2*C)
                total += (X-Y)*price
            else:
                total = X*2*C
                price = min(B, 2*C)
                total += (Y-X)*price
        else:
            total = A*X + B*Y
    elif X == 0:
        price = min(B, 2*C)
        total = price*Y
    else:
        price = min(A, 2*C)
        total = price*X
        
    print(total)
check()

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

x1 = min(X, Y)
price = min((A+B) * x1, 2 * C * x1)
x2 = max(X, Y) - x1
a = A if X > Y else B
price += min(a * x2, 2 * C * x2)
print(price)

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

n = max(int((x + 2 * c - 1) / (2 * c)),
        int((y + 2 * c - 1) / (2 * c)))
ret = float('inf')
for c_i in range(2 * (10 ** 5) + 1):
    a_i = max(x - c_i, 0)
    b_i = max(y - c_i, 0)
    cost = a_i * a + b_i * b + 2 * c_i * c
    ret = min(ret, cost)
print(ret)

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








max_r = max(X, Y) * 2 

cost = float('inf')

for r in range(0, max_r+2, 2):
  p = max(X - r // 2, 0)
  q = max(Y - r // 2, 0)
  tmp_cost = A * p + B * q + C * r  
  cost = min(cost, tmp_cost)
  
print(cost)

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

ans = float("inf")

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

print(ans)

Solution (Python):
def main():
    A, B, AB, x, y = map(int, input().split())
    ans = []
    ans.append(A*x + B*y)
    if x < y:
        ans.append(AB*x*2 + B*(y-x))
        ans.append(AB*y*2)
    elif y < x:
        ans.append(AB*y*2 + A*(x-y))
        ans.append(AB*x*2)
    else:
        ans.append(AB*x*2)
    print(min(ans))


if __name__ == "__main__":
    main()

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 = map(int, input().split())

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

print(ans)

Solution (Python):
(a, b, c, wanted_a, wanted_b) = (int(tok) for tok in input().split())

res = wanted_a * a + wanted_b * b
for both in range(max(wanted_a, wanted_b) * 2 + 1):
  left_a = wanted_a - both // 2
  left_b = wanted_b - both // 2
  cost = both * c + max(0, left_a) * a + max(0, left_b) * b
  res = min(res, cost)

print(res)

Solution (Python):
import sys

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

if A+B <= 2*C:
	print(A*X + B*Y)
	sys.exit()

else:
	ans = 0
	temp = min(X,Y)
	ans = 2*C*temp
	X -= temp
	Y -= temp

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

	print(ans)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

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

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

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



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

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

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

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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

ans = float('inf')
for i in range(max(x, y)+1 ):
    price = i * 2 * ab + max(0, x-i)*a + max(0, y-i)*b
    ans = min(ans, price)

print(ans)

Solution (Python):
a,b,c,x,y = map(int,input().split())
if x < y:
    big = b
    dd = y-x
else:
    big = a
    dd = x-y


sol_1 = a*x + b*y
sol_2 = c*min(x,y)*2 + big*dd
sol_3 = c*max(x,y)*2
print(min(sol_1,sol_2,sol_3))

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

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

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

print(ans)

Solution (Python):
def resolve():
    a, b, c, x, y = list(map(int, input().split()))
    p1 = a * x + b * y
    p2 = y * 2 * c + abs(x - y) * a
    p3 = x * 2 * c + abs(y - x) * b
    p4 = max(x, y) * 2 * c
    print(min(p1, p2, p3, p4))


if __name__ == "__main__":
    resolve()

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

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

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

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

ans += min(B * Y, Y * C)
print(ans)

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

Solution (Python):
def main():
    A, B, C, X, Y = map(int, input().split())
    AB = A+B
    cost = 0
    if 2*C <= AB:
        if X <= Y:
            return X * 2 * C + (Y-X) * min(2*C, B)
        else:
            return Y * 2 * C + (X-Y) * min(2*C, A)
    else:
        return X * A + Y * B

if __name__ == '__main__':
    print(main())

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

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

    
    fee+=x*min(a, 2*c)

    
    fee+=y*min(b, 2*c)

    return fee
    
print(makeAccount())

Solution (Python):

a, b, c, x, y = [ int(v) for v in input().split() ]
ans = 10**10
for i in range(max(x,y)*2+2):
    x_i, y_i = x - i // 2, y - i // 2
    if x_i < 0:
        x_i = 0
    if y_i < 0:
        y_i = 0
    total = x_i * a + y_i * b + c * i
    ans = min(ans,total)

print(ans)

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = 50000 * 10 ** 5
for i in range(max(x, y) + 1):
  ansa = max(x - i, 0)
  ansb = max(y - i, 0)
  sm = a * ansa + b * ansb + 2 * c * i 
  if ans > sm:
    ans = sm
print(ans)

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

z = max(x,y) * 2
min_sum = c * z

for i in range(z):
    r = max(0, y - i) * b
    t = max(0, x - i) * a
    sum = c * i * 2 + r + t
    if sum < min_sum:
        min_sum = sum

print(min_sum)

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

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

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

Solution (Python):

A, B, C, X, Y = [int(el) for el in input().split(' ')]
min_total = 10**9
for c in range(max(X, Y) * 2, -1, -2):
    a = max(X - c // 2, 0)
    b = max(Y - c // 2, 0)
    min_total = min(A*a + B*b + C*c, min_total)
print(min_total)

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

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

ans = a * x + b * y

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

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

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

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

ans = 10000000000
for i in range(2 * max(X, Y) + 1):
    A_half = i
    B_half = i
    cur_cost = i * C
    
    left_A_half = 2 * X - A_half
    left_B_half = 2 * Y - B_half
    if left_A_half > 0 :
        if left_A_half % 2 == 0:
            cur_cost += left_A_half // 2 * A
        else:
            cur_cost += (left_A_half // 2 + 1) * A
    
    if left_B_half >= 0:
        if left_B_half % 2 == 0:
            cur_cost += left_B_half // 2 * B
        else:
            cur_cost += (left_B_half // 2 + 1) * B
    
    ans = min(ans, cur_cost)
    
print(ans)

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

if X<Y:
    if B<2*C:
        total+=(Y-X)*B
    else:
        total+=(Y-X)*C*2

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

print(total)

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

maxxy = max([x,y])
price = 0

prices=[]

for i in range(maxxy+1):
  amai = x-i
  bmai = y-i
  
  if amai<0:
    amai = 0
  if bmai<0:
    bmai = 0
  
  price = i*2*c + amai*a + bmai*b
  prices.append(price)
  
print(min(prices))

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

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



main()

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

ab = min(x, y)
c2 = c * 2
p = 0

if a + b >= c2:
  x -= ab
  y -= ab
  p += c2 * ab

if a >= c2:
  p += c2 * x
  x = 0
  y -= x

if b >= c2:
  p += c2 * y
  y = 0
  x -= y

if x > 0:
  p += a * x

if y > 0:
  p += b * y
  
print(p)

Solution (Python):
A, B, AB, A_NUM, B_NUM = map(int, input().split())


if AB * 2 > A + B:
    print(A * A_NUM + B * B_NUM)
    exit()

ans = 0
nikoichi = min([A_NUM, B_NUM])
ans += AB * nikoichi * 2

if A_NUM > B_NUM:
    if A > AB * 2:
        ans += (A_NUM-B_NUM) * AB * 2
    else:
        ans += (A_NUM-B_NUM) * A
elif A_NUM < B_NUM:
    if B > AB * 2:
        ans += (B_NUM-A_NUM) * AB * 2
    else:
        ans += (B_NUM-A_NUM) * B

print(ans)

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

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

AandB = X * A + Y * B
allAB = max(X, Y) * 2 * C  

comb = min(X, Y) * 2 * C  
minXY = min(X, Y)
X -= minXY
Y -= minXY
comb += X * A
comb += Y * B

print(min(AandB, allAB, comb))

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

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

x = 2*X
y = 2*Y
p = 0

if A+B >= 2*C:
    k = max(X,Y)-abs(X-Y)
    p += 2 * k * C
    X -= k
    Y -= k

while X>0:
    X -= 1
    if A > 2*C:
        p += 2*C
    else:
        p += A

while Y>0:
    Y -= 1
    if B > 2*C:
        p += 2*C
    else:
        p += B
        
print(p)

Solution (Python):

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

if a+b <= 2*c:
    print(a*x+b*y)
else:
    min_xy = min(x,y)
    max_xy = max(x,y)
    
    n_c = min_xy*2
    v = n_c*c + max(0,x-min_xy)*a+max(0,y-min_xy)*b
    
    
    N_c = max_xy*2
    V = N_c * c
    print(min(v,V))

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

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

res = INF
for AB in range(max(X,Y)*2+1):
    x = AB*C
    a = AB//2
    b = AB//2
    if a < X:
        x += (X-a)*A
    if b < Y:
        x += (Y-b)*B
    if res > x:
        res = x
print(res)

Solution (Python):
a, b, c, x, y = list(map(int, input().split()))
nokori_x, nokori_y = x, y
cost = 0
count_a, count_b, count_c = 0, 0, 0



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



nokori_n = max(x, y) - ab_set_n
if nokori_n:
    price = a if max(x, y) == x else b
    if c * 2 < price:
        cost += c * 2 * nokori_n
    else:
        cost += price * nokori_n

print(cost)

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c,x,y=LI()
  return min(max(x,y)*c*2,a*x+b*y,max(0,x-y)*a+y*c*2,max(0,y-x)*b+x*c*2)


print(main())

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

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

ans = 1e9
for c in range(max(X, Y)+1):
    a = max(X-c, 0)
    b = max(Y-c, 0)
    ans = min((A*a + B*b + 2*C*c), ans)

print(ans)

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

Solution (Python):

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

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

res = x*a + y*b
for c_count in range(0, max(x,y)*2 + 2, 2):
    x_need = max(0, x - c_count // 2)
    y_need = max(0, y - c_count // 2)
    tmp = x_need * a + y_need * b + c_count * c
    res = min(res, tmp)

print(res)

Solution (Python):
def getint(): return int(input())
def getints(): return list(map(int, input().split()))

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

res = 10 ** 10
for c_count in range(0, max(x,y)*2 + 2, 2):
    x_need = max(0, x - c_count // 2)
    y_need = max(0, y - c_count // 2)
    tmp = x_need * a + y_need * b + c_count * c
    res = min(res, tmp)

print(res)

Solution (Python):

import sys, math, fractions, itertools


def solve(A: int, B: int, C: int, X: int, Y: int):
    mn = 1e9
    for i in range(0, 2*(max(X, Y)+1), 2):
        mn = min(mn, C*i+A*max(X-i//2, 0)+B*max(Y-i//2, 0))
    print(int(mn))
    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())
INF = 10**9
upp = max(x,y)*2
ans = INF

for i in range(upp+1):
    money = i*c
    half = i // 2
    if x > half:
        money += (x-half)*a
    if y > half:
        money += (y-half)*b
    if money < ans:
        ans = money
print(ans)

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

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

print(ans)

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

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

Solution (Python):
a,b,c,d,e=map(int,input().split());m=min;C=2*c;print((a*d+b*e,C*m(d,e)+(m(a,C)*(d-e),m(b,C)*(e-d))[e>d])[a+b>C])

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

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

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

ans = a*x + b*y

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

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

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

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

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

ans1 = A*X + B*Y
ans2 = 0
ans3 = 0
if X >= Y:
  ans2 = A*(X-Y) + AB*Y*2
  ans3 = AB*X*2
else:
  ans2 = B*(Y-X) + AB*X*2
  ans3 = AB*Y*2
print(min(ans1, ans2, ans3))

Solution (Python):

import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    if(2*C >= A+B):
        print(A*X+B*Y)
        exit()

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

    print(ans)

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

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

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    s = S()
    s.append("o")
    a = s.count("o")-1
    print(700+a*100)
    return


def B():
    n, x = LI()
    m = IR(n)
    m.sort()
    msum = sum(m)
    print(n + (x - msum) // m[0])
    return


def C():
    a, b, c, x, y = LI()
    if c * 2 > a + b:
        print(x * a + y * b)
        return
    if x > y:
        if c * 2 > a:
            print(c * 2 * y + (x - y) * a)
            return
        print(c * 2 * x)
        return
    if c * 2 > b:
        print(c * 2 * x + (y - x) * b)
        return
    print(c * 2 * y)

    return


def D():
    return


if __name__ == '__main__':
    C()

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

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

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

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

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

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

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

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

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


Set = min(X, Y)

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

print(ans)

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

print(ans)

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

Solution (Python):

import math 

repo = list(map(int, input().split()))

a_kane = repo[0]
b_kane = repo[1]
c_kane = repo[2]
a_maisu = repo[3]
b_maisu = repo[4]
kingaku = 0

test_kane_tantai = 0
test_kane_harf = 0

tantai_kane = a_kane + b_kane
harf_kane = c_kane*2

kaburi_maisu = abs(a_maisu-b_maisu)


if(tantai_kane<harf_kane): 
    kingaku = a_kane*a_maisu + b_kane*b_maisu
else: 
    if(a_maisu>b_maisu):
        sabun_maisu = a_maisu-b_maisu
        kaburi_maisu = b_maisu
        kingaku += kaburi_maisu*c_kane*2
        test_kane_tantai = sabun_maisu*a_kane
        test_kane_harf = sabun_maisu*c_kane*2
        if(test_kane_tantai>test_kane_harf):
            kingaku += test_kane_harf
        else:
            kingaku += test_kane_tantai
    else:
        sabun_maisu = b_maisu-a_maisu
        kaburi_maisu = a_maisu
        kingaku += kaburi_maisu*c_kane*2
        test_kane_tantai = sabun_maisu*b_kane
        test_kane_harf = sabun_maisu*c_kane*2
        if(test_kane_tantai>test_kane_harf):
            kingaku += test_kane_harf
        else:
            kingaku += test_kane_tantai

print(kingaku)

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

ansa=0
ansb=0
ansc=0

f=0
ff=0

if c*2 < a+b:
    
    ansc=min(x,y)
    f=1
else:
    
    ansa=x
    ansb=y

if f:
    
    
    if c*2<a and x-ansc > 0:
        ansc+=x-ansc
        ff=1
        
    if c*2<b and y-ansc >0:
        ansc+=y-ansc
        ff=1
        
    if ff==0:
        ansa+=x-ansc
        ansb+=y-ansc
    


print(a*ansa + b*ansb + c*ansc*2)

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


total=[0,0,0]

total[0]=A*X+B*Y

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

total[2]=max(X,Y)*2*C

print(min(total))

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

kakaku = [[A, 'a'], [B, 'b'], [C, 'c']]
buff = [[X, 0], [Y, 1]]
huta = A+B

ab = C*2

if ab > huta:
    print(A*X+B*Y)
    exit()
else:
    buff.sort()
    
    ans = buff[0][0]*ab
    diff = buff[1][0]-buff[0][0]
    
    
    
    mn = kakaku[buff[1][1]][0]
    
    if mn > ab:
        print(ans+(diff*ab))
        
        exit()
    else:
        print(ans+(diff*mn))
        exit()

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

Solution (Python):
import sys


	



def main():
	a,b,c,x,y = map(int, input().split())
	
	get_price=lambda na,nb,nab:max(na,0) * a + max(nb,0) * b + max(nab,0) * c
	us=lambda x:max(0,x)
	
	r_min=get_price(x,y,0)
	
	for i in range(max(x,y)+1):
		r=get_price(us(x - i), us(y - i), 2*i)
		r_min=r if r<r_min else r_min
		
	
	print(r_min)
	
	


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
		
	ret = main()
	if ret is not None:
		print(ret)
		
	if sys.platform =='ios':
		sys.stdin.close()