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

COMMON = min(X, Y)
P1 = (A * X) + (B * Y)
P2 = (COMMON * (C * 2) + (X - COMMON) * A + (Y - COMMON) * B)
P3 = (COMMON * (C * 2) + (X - COMMON) * (C*2) + (Y - COMMON) * B)
P4 = (COMMON * (C * 2) + (X - COMMON) * A + (Y - COMMON) * (C*2))
print(min(P1, P2, P3, P4))

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



ans1 = a*x + b*y

ans2 = a*x + 2*y*c

ans3 = b*y + 2*x*c

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

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

print(min(ans1,ans2,ans3,ans4,ans5))

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

D=min(A+B,2*C)

price=min(X,Y)*D

Z=max(X,Y)-min(X,Y)

if X>Y:
   price+=Z*min(A,2*C)
elif X<Y:
   price+=Z*min(B,2*C)

print(price)

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

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

min = float('inf')
for k in range(10**5+1):
    temp = 2*C*k+max(X-k,0)*A+max(Y-k,0)*B

    if min > temp:
        min = temp
print(min)

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

n = min(X,Y)

sum = 0

sum = min(n*2*C, A*n+B*n)

if X>Y:
    n = X-n
    sum = sum + n*A
else:
    n = Y - n
    sum = sum + n*B

sum_ab = X*A + Y*B

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


print(min(sum,sum_ab,sum_a_b))

Solution (Python):

import sys


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

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

print(ans)

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

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

Solution (Python):
from sys import exit

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

if a+b<2*c:
    print(x*a+y*b)
    exit()

ans = 0
if x>y:
    a,b = b,a
    x,y = y,x

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

Solution (Python):
import sys

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

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

def main():

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

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

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

def foo(z):
    res = a*max(x-z//2, 0) + b*max(y-z//2, 0) + c*z
    
    return res
candid = []
for z in range(max(x, y)*2+1):
    candid.append(foo(z))
print (min(candid))

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

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

DR = [1, -1, 0, 0]
DC = [0, 0, 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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    A, B, C, X, Y = LI()
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    money_a_b = X * A + Y * B
    money_b_c = (Y - X) * B + (2 * X) * C
    money_c = Y * 2 * C
    ans = min(money_a_b, money_b_c, money_c)
    print(ans)

main()

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

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

count = 0

ans1 = a*x + b*y
ans2 = 2*c*(min(x,y))
ans3 = 2*c*(max(x,y))

if x > y:
  ans2 += a*(x-y)
elif x < y:
  ans2 += b*(y-x)

print(min(ans1,ans2,ans3))

Solution (Python):
import sys
a, b, c, x, y = [int(i) for i in sys.stdin.readline().split()]
if a + b < 2 * c:
    print(x * a + y * b)
else:
    if x > y:
        if a <= c * 2:
            print(c * y * 2 + a * (x - y))
        else:
            print(c * x * 2)
    else:
        if b <= c * 2:
            print(c * x * 2 + b * (y - x))
        else:
            print(c * y * 2)

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

D = C * 2
p = []

if X > Y:
    p.append(D * Y + A * (X - Y))
else:
    p.append(D * X + B * (Y - X))

p.append(A * X + B * Y)
p.append(D * max(X, Y))

ans = min(p)

print(ans)

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

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

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

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

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

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

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

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

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

print(ans)

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

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

ans = 0
for i in range(1, max(X,Y)+1):
    x = 1
    y = 1
    if X <= 0: x = 0
    if Y <= 0: y = 0
    ab_price = A * x + B * y
    c_price = C * 2

    if ab_price >= c_price:
        ans += C * 2
    else:
        _x = 0
        if x > 0:
          _x = 1
        _y = 0
        if y > 0:
          _y = 1
        ans += A * _x + B * _y
    X -= 1
    Y -= 1
print(ans)

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

Solution (Python):

import sys
input = sys.stdin.readline

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

min_cost = 5000 * 100000 * 2


for i in range(100001):
    zan_a = max(x-i,0)
    zan_b = max(y-i,0)
    min_cost = min((a*zan_a+b*zan_b+c*i*2),min_cost)
print(min_cost)

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

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

main()

Solution (Python):


def main():
    (A,B,C,X,Y) = map(int,input().split())
    lim = max(X, Y)
    vmin = min(X, Y)
    minCost = 5000 * 10**5 * 2
    for t in range(lim+1):
        if t <= vmin:
            cost = (X - t) * A + (Y - t) * B + t * 2 * C
        elif X <= Y:
            cost = (Y - t) * B + t * 2 * C
        else:
            cost = (X - t) * A + t * 2 * C
        minCost = min(minCost, cost)
    print(minCost)
    

main()

Solution (Python):
import sys
input = sys.stdin.readline
A, B, C, X, Y = [int(x) for x in input().split()]
ans_notAB = A * X + B * Y
temp = min(X,Y)
ans_AB = 2 * temp * C
if X > Y:
    X -= Y
    ans_AB += min([X * A, 2 * X * C])
elif Y > X:
    Y -= X
    ans_AB += min([Y * B, 2 * Y * C])
print(min(ans_AB,ans_notAB))

Solution (Python):
import sys
input = sys.stdin.readline
A, B, C, X, Y = [int(x) for x in input().split()]
ans_notAB = A * X + B * Y
temp = min(X,Y)
ans_AB = 2 * temp * C
if X > Y:
    X -= Y
    ans_AB += min([X * A, 2 * X * C])
elif Y > X:
    Y -= X
    ans_AB += min([Y * B, 2 * Y * C])
print(min(ans_AB,ans_notAB))

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

cost = 0
if A + B > 2 * C:
    n_purchase_surplus = 2 * max(X, Y)
    cost_surplus = n_purchase_surplus * C
    if X >= Y:
        n_purchase = 2 * Y
        cost = n_purchase * C
        n_remaining = X - Y
        cost += n_remaining * A
    else:
        n_purchase = 2 * X
        cost = n_purchase * C
        n_remaining = Y - X
        cost += n_remaining * B
    
    cost = min(cost_surplus, cost)
else:
    cost = (X * A) + (Y * B)
print(cost)

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

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

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

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

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

Solution (Python):


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if A + B < 2 * C:
        ans = A*X + B*Y
    else:
        
        if (A-2*C)*X + B*max(Y-X, 0) > (B-2*C)*Y + A*max(X-Y, 0):
            
            ans = 2*C*X + max(Y-X, 0)*B
        else:
            ans = 2*C*Y + max(X-Y, 0)*A
        if 2*C < A and 2*C < B:
            ans = min(ans, 2*C*max(X,Y))
    print(ans)

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

if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if A + B < 2 * C:
        ans = A*X + B*Y
    else:
        
        if (A-2*C)*X + B*max(Y-X, 0) > (B-2*C)*Y + A*max(X-Y, 0):
            
            ans = 2*C*X + max(Y-X, 0)*B
        else:
            ans = 2*C*Y + max(X-Y, 0)*A
        if 2*C < A and 2*C < B:
            ans = min(ans, 2*C*max(X,Y))
    print(ans)


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

import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if Y > X:
        bigger_y = 1
        bigger_x = 0
    elif Y == X:
        bigger_y = 1
        bigger_x = 1
    else:
        bigger_y = 0
        bigger_x = 1

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

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


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 = [int(i) for i in input().split()]
ans = (a + b + c) * (x + y)
for i in range(max(x, y) + 1):
  ans = min(2 * c * i + a * max(x - i, 0) + b * max(y - i, 0), ans)
print(ans)

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

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

Solution (Python):

import sys
A,B,C,x,y = map(int, sys.stdin.readline().split())

ans = float('inf')
for i in range(0, 2*max(x, y)+1, 2):
    tmp = A*max(x-i//2, 0) + C*i + B*max(y-i//2, 0)
    
    if ans > tmp:
        ans = tmp
print(ans)

Solution (Python):
import sys
A, B, C, x, y = map(int, sys.stdin.readline().split())

ans = float('inf')
for i in range(0, 2*max(x, y)+1, 2):
    tmp = A*max(x-i//2, 0) + C*i + B*max(y-i//2, 0)
    if tmp < ans:
        ans = tmp
print(ans)

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

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

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

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

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

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

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

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

print(cost)

Solution (Python):

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

















minimum_cost = X*A + Y*B + (X+Y)*C

if X>Y:
    for A_pizza in range(0,X+1):
        AB_pizza = (X-A_pizza)*2 

        if Y - AB_pizza//2 > 0:
            B_pizza = Y - AB_pizza//2 
        else:
            B_pizza = 0

        cost = A*A_pizza + B*B_pizza + C*AB_pizza 

        

        if minimum_cost > cost:
            minimum_cost = cost
            
else:
    for B_pizza in range(0,Y+1):
        AB_pizza = (Y-B_pizza)*2 

        if X - AB_pizza//2 > 0:
            A_pizza = X - AB_pizza//2 
        else:
            A_pizza = 0

        cost = A*A_pizza + B*B_pizza + C*AB_pizza 

        

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

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










ans_1 = a*x + b*y

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

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

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

ans = min(ans_1, ans_2, ans_3, ans_4)
print(ans)

Solution (Python):
A , B , C , X ,Y = map(int,input().split())
C_val = C * 2
ans = 0
if A + B >= C_val:
    if X >= Y:
        XYmax , XYmin = X , Y
        cmp = A
    else:
        XYmax , XYmin = Y , X
        cmp = B
    ans += XYmin * C_val
    remain = XYmax - XYmin
    if cmp >= C_val:
        ans += C_val * remain
    else:
        ans += cmp * remain
    print(ans)
else:
    print(A * X + B * Y)

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

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

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

ANS = []

ans = c*max(x,y)*2
ANS.append(ans)


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


ans = a*x+b*y
ANS.append(ans)

print(min(ANS))

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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


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

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

N = max(X,Y)
ans = 10**10

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

print(ans)

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

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

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

print(min(case1,case2,case3))

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

print(ans)

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

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

print(ans)

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

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

print(ans)

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

Ans=float('inf')

for i in range(0,10**5+1):
    price=2*C*i+A*max(0,X-i)+B*max(0,Y-i)
    if price<Ans:
        Ans=price

print(Ans)

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

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

print(price)

Solution (Python):
def examC():
    A, B, C, X, Y = LI()
    ans = 0
    if A+B<=C*2:
        ans = A*X + B*Y
    else:
        Z = min(X,Y)
        ans = min(A,C*2)*max(X-Z,0) + min(B,C*2)*max(Y-Z,0) + C*Z*2
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

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

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


price = 0
num_c = x * 2
price += c * num_c
if x < y:
  price += (y - x) * b
min_cost = min(min_cost, price)


price = 0
num_c = y * 2
price += c * num_c
if x > y:
  price += (x - y) * a
min_cost = min(min_cost, price)


min_cost = min(min_cost, a * x + b * y)

print(min_cost)

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

ans = float("inf")
ab_max = max(x*2, y*2) 
for ab in range(ab_max+1):
    a_buy = max(x - (ab // 2),0)
    b_buy = max(y - (ab // 2),0)
    tmp = a * a_buy + b * b_buy + ab * c
    if ans > tmp:
        ans = tmp

print(ans)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import bisect
from logging import getLogger, StreamHandler, DEBUG, WARNING
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)


logger.addHandler(handler)












def main():
    ans = 0
    a,b,c,x,y = getList()


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

    ans2 = (a * x + b * y)

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

    print(min(ans1, ans2, ans3))
    return

if __name__ == "__main__":
    main()

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

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

print(money)

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b,c,x,y=map(int,input().split())
    ans=0

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

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

    
    if(a>=2*c):
        ans+=x*2*c
    else:
        ans+=x*a

    print(ans)
resolve()

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

ans = 10**10

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

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

print(ans)

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

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

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

Solution (Python):
from sys import stdin
import numpy as np
a,b,c,x,y= [int(x) for x in stdin.readline().rstrip().split()]

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

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

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

ans = 0

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

Solution (Python):

import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0
f=g=h=0
a,b,c,x,y=map(int,input().split())
if a+b>2*c:
    f=1
if a>2*c:
    g=1
if b>2*c:
    h=1

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

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


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

print(ans)

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

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

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

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

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

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

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

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

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