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

"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""

"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    if X > Y :
        if A < 2 * C:
            ans = Y * C * 2 + abs(X-Y) * A
        else:
            ans = X * C * 2  
    else:
        if B < 2 * C:
            ans = X * C * 2 + abs(X-Y) * B
        else:
            ans = Y * C * 2 
else:
    ans = X * A + Y * B 
print(ans)
"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    ans1 = max(X,Y) * C * 2  
    if X > Y :
            ans2 = Y * C * 2 + abs(X-Y) * A           
    else:
            ans2 = X * C * 2 + abs(X-Y) * B  
    print(min(ans1,ans2)) 
else:   
    ans1 = X * A + Y * B 
    print(ans1)

Solution (Python):

"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""

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

Solution (Python):
def solve():
    a,b,c,x,y = map(int,input().split())
    ans = 10**12
    for i in range(max(x,y+1)):
        cost = c*2*i
        dx = max(0,x-i)
        dy = max(0,y-i)
        cost+=dx*a
        cost+=dy*b
        ans = min(ans,cost)
    print(ans)
if __name__ == "__main__":
    solve()

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

Solution (Python):


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

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

print(int(cost))

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

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

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

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

if __name__ == '__main__':
    resolve()

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

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

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

if __name__ == '__main__':
    resolve()

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

"""
ABピザの購入数(0~2 * max(X, Y)で全探索)
"""
min_price = 10 ** 10
for i in range(2 * max(X, Y) + 1):
    c_price = C * i
    a_price = A * max(0, (X - i//2))
    b_price = B * max(0, (Y - i//2))
    min_price = min(min_price, a_price+b_price+c_price)
print(min_price)

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

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

ret=10**10

for i in range(max(2*X,2*Y)+1):
    cx=X-i//2
    cy=Y-i//2

    price=max(0,cx)*A+max(0,cy)*B+i*C
    ret=min(ret,price)

print(ret)

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

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

print(min(ans1,ans2,ans3))

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

Solution (Python):
import math
import copy
from copy import deepcopy
import sys
import fractions

from functools import reduce

import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)







def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList




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

itr = max(x, y)*2+1

ans = sys.maxsize
for i in range(itr):
    tmpa = max(0, a*(x-i//2))
    tmpb = max(0, b*(y-i//2))
    tmpc = c*i
    tmp_cost = tmpa+tmpb+tmpc
    ans = min(ans, tmp_cost)

print(ans)

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

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

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

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    A,B,C,x,y = map(int, readline().split())

    ans = 0
    if A + B > C * 2:
        ans += min(x, y) * C * 2
        if x > y:
            ans += (x - y) * min(A, C*2)
        else:
            ans += (y - x) * min(B, C*2)
    
    else:
        ans += A * x + B * y
    
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):




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






easy = A * X + B * Y
maxnum = max(X, Y) * 2
for i in range(maxnum, 1, -2):
    tmp = 0
    if (i == maxnum): tmp = C * i
    elif (X - (i / 2) > 0 and Y - (i / 2) > 0): tmp = A * (X - (i / 2)) + B * (Y - (i / 2)) + C * i
    elif (X - (i / 2) > 0): tmp = A * (X - (i / 2)) + C * i
    elif (Y - (i / 2) > 0): tmp = B * (Y - (i / 2)) + C * i
    if (tmp < easy): easy = tmp
print(int(easy))

Solution (Python):
A,B,C,X,Y = map(int,input().split())
C *= 2
ax = 0
bx = 0
num = 0
while ax < X or bx < Y:
  if ax < X and bx < Y:
    if A+B < C:
      num += A+B
    else:
      num += C
    ax += 1
    bx += 1
  elif ax < X:
    if A < C:
      num += A
    else:
      num += C
    ax += 1
  else:
    if B < C:
      num += B
    else:
      num += C
    bx += 1
print(num)

Solution (Python):

















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

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




if a <= 2 * c:
    ans += x * a
else:
    ans += x * 2 * c

if b <= 2 * c:
    ans += y * b
else:
    ans += y * 2 * c
print(ans)

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

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

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

while s:
    tmp = 0
    tmp -= c*2
    s -= 1
    if x > s:
        tmp += a
    if y > s:
        tmp += b
    if tmp > 0:
        print(ans)
        exit()
    else:
        ans += tmp
        
print(ans)

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

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

cmx = max(x, y)*2

ans = 10**9+7
for cn in range(cmx+1):
    an = max(0, x - cn//2)
    bn = max(0, y - cn//2)
    total = an*a + bn*b + cn*c
    ans = min(ans, total)

print(ans)

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

res = float("inf")
if a + b <= ab:
    res = x * a + y * b
else:
    if x == y:
        res = x * ab
    elif x > y:
        for i in range(y, x + 1):
            cost = i * ab + (x - i) * a
            res = min(res, cost)
    else:
        for i in range(x, y + 1):
            cost = i * ab + (y - i) * b
            res = min(res, cost)
print(res)

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

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

if A >= 2 * C:
    A = 2 * C
if B >= 2 * C:
    B = 2 * C

while X != 0:
    ans += A
    X -= 1
while Y != 0:
    ans += B
    Y -= 1

print(ans)

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

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

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

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

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

    price_no_ab = A * X + B * Y

    if X < Y:
        price_use_ab = A * 0 + B * (Y - X) + C * 2 * X
    else:
        price_use_ab = A * (X - Y) + B * 0 + C * 2 * Y

    if X < Y:
        price_ab = C * 2 * Y
    else:
        price_ab = C * 2 * X

    
    return min([price_use_ab, price_no_ab, price_ab])


if __name__ == "__main__":
    result = solve()
    print(result)

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

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

Solution (Python):
def main():
    import math

    a, b, c, x, y = map(int, input().split())
    d = [a, b]
    i, j = min(x, y), max(x, y)
    n = math.ceil(i / 2)
    f = j == x
    if 2 * c > (a + b):
        ans = a * x + b * y
    else:
        ans = 2 * c * i + (j - i) * min(c * 2, d[not f])

    print(ans)


if __name__ == '__main__':
    main()

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

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

print(ans)

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

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

Solution (Python):

import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    c = 0
    if (A + B < 2 * C):
        c += min(X, Y) * (A + B)
    else:
        c += min(X, Y) * 2 * C
    if X > Y:
        c += (X - Y) * min(A, 2 * C)
    else:
        c += (Y - X) * min(B, 2 * C)
    print(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())

val=a*x+b*y
val2=2*c*x+b*(y-x) if y>x else 2*c*y+a*(x-y)
val3=2*c*max(x,y)
print(min(val,val2,val3))

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

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

    print(ans)

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

    total_min = a * x + b * y

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

if __name__ == "__main__":
    main()

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

    total_min = a * x + b * y

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

if __name__ == "__main__":
    main()

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

ans = a*x + b*y
ch = -a-b + 2*ab
for i in range(1,max(x,y)+1):
    if i <= min(x,y):
        ans = min(ans , ans + ch)
    else:
        if x < y:
            ans = min(ans , ans + ch + a)
        else:
            ans = min(ans , ans + ch + b)
print(ans)

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

    print(ans)

if __name__ == '__main__':
    resolve()

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

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

xn, yn = 0, 0
price = 0

if A >= 2*C and X > xn:
    ammount = X - xn
    price += C * X * 2
    xn += X
    yn += X

if B >= 2*C and Y > yn:
    ammount = Y - yn
    price += C * ammount * 2
    xn += ammount
    yn += ammount

if (A+B) >= 2*C and (X - xn) >= 1 and (Y - yn) >= 1:
    ammount = min(X, Y)
    price += C * ammount * 2
    xn += ammount
    yn += ammount


if X - xn >= 1:
    price += A * (X - xn)

if Y - yn >= 1:
    price += B * (Y - yn)

print(price)

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




























min_price = 1 << 32 
for i in range(max(X, Y)+1):
    xn, yn = i, i
    price = (2*C) * i
    price += (max(0, X - xn)) * A
    price += (max(0, Y - yn)) * B
    min_price = min(min_price, price)

print(min_price)

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


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

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

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

print(ans)

Solution (Python):
def HalfPizza(a , b , c , x , y):

    ans = 0

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

    return ans

def main():
    a , b , c , x , y = map(int, input().split())
    print(HalfPizza(a , b , c , x , y))

if __name__ == '__main__':
    main()

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



def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))




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











if __name__ == "__main__":
	main()

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

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):




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

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


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:
  Z = 2 * min(X, Y)
  X_rem = X - Z // 2
  Y_rem = Y - Z // 2
  
  if (X_rem != 0) and (A > 2*C):
    print(C*(2*X))
  elif (Y_rem != 0) and (B > 2*C):
    print(C*(2*Y))
  else:
    print(A*X_rem + B*Y_rem + C*Z)

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

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

for i in range(1,max(x,y)+1):
  if x-i < 0:
    ans1 = b*(y-i)+c*i
  elif y-i < 0:
    ans1 = a*(x-i)+c*i
  else:
    ans1 = a*(x-i)+b*(y-i)+c*i
  ans = min(ans,ans1)
print(ans)

Solution (Python):


MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

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

xy_min = 0
xy_max = 0
if X > Y:
    xy_min = Y
    xy_max = X
else:
    xy_min = X
    xy_max = Y

ans2 = xy_max*AB


ans = 0
if A+B > AB:
    ans += AB*xy_min
    X -= xy_min
    Y -= xy_min

    ans += A*X
    ans += B*Y
else:
    ans += A*X
    ans += B*Y

print(min(ans, ans2))

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


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

if __name__ == '__main__':
    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:
    if x>y:
        ans = min(2*c*y+(x-y)*a, 2*c*x)
    else:
        ans = min(2*c*x+(y-x)*b, 2*c*y)
print(ans)

Solution (Python):











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

mn = 10**10
for i in range(max(x,y) + 1):
    if x<=i<=y:
        total = 2*c*i + b*(y-i)
    elif y<=i<=x:
        total = 2*c*i + a*(x-i)

    else:
        total = 2*c*i + a*(x-i) + b*(y-i)

    mn = min(mn, total)

print(mn)

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

normal_price = a * x + b * y
min_price = float('inf')
minn = min(x, y)
maxx = max(x, y)

for mi in range(2, maxx * 2 + 1, 2):
    mix_price = c * mi
    xz = x - mi // 2
    yz = y - mi // 2
    if xz < 0: xz = 0
    if yz < 0: yz = 0
    x_price = xz * a
    y_price = yz * b
    total_price = mix_price + x_price + y_price
    min_price = min(min_price, total_price)

min_price = min(min_price, normal_price)
print(min_price)

Solution (Python):
def resolve():
    A, B, C, X, Y = map(int, input().split())
    C *= 2
    AB = A+B
    ans = 0
    while X > 0 or Y > 0:
        min_cnt = min(X, Y)
        if X and Y:
            if min_cnt*C <= (A*min_cnt) + (B*min_cnt):
                ans += min_cnt*C
                X -= min_cnt
                Y -= min_cnt
            else:
                ans += (A*min_cnt) + (B*min_cnt)
                X -= min_cnt
                Y -= min_cnt
        else:
            if max(X, Y)*C <= (A*X) + (B*Y):
                ans += max(X, Y)*C
                X -= max(X, 0)
                Y -= max(Y, 0)
            else:
                ans += (A*X) + (B*Y)
                X -= max(X, 0)
                Y -= max(Y, 0)
    return print(ans)

if __name__ == "__main__":
    resolve()

Solution (Python):
import numpy as np
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)

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


if a + b <= c*2:
  buy = a*x + b*y
elif a + b > c*2:
  num = [x,y]
  num.sort()
  buy = c*2*num[0]
  num_rest = num[1] - num[0]
  if num[1] == x:
    if a <= c*2:
      buy += a*num_rest
    else:
      buy += c*2*num_rest
  elif num[1] == y:
    if b <= c*2:
      buy += b*num_rest
    else:
      buy += c*2*num_rest
      
print(buy)

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

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

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

print(ans)

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

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

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

s = set()
s.add(a*x + b*y)
if x < y:
    s.add(2*x*c + b*(y-x))
    s.add(2*(x+1)*c + b*(y-x-1))
    s.add(2*y*c)
    print(min(s))
else:
    s.add(2*y*c + a*(x-y))
    s.add(2*(y+1)*c + a*(x-y-1))
    s.add(2*x*c)
    print(min(s))

Solution (Python):
a,b,c,x,y=map(int, input().split())
z = 0
l= []
l.append(a * x+b * y)
while x > 0 or y > 0:
    x -= 1
    y -= 1
    z += 2
    x1 = x
    if x1 < 0: x1 = 0
    y1 = y
    if y1 < 0: y1 = 0
    l.append(a * x1 + y1 * b + z * c)
print(min(l))

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

for i in range(big+1):
    x = X - i if X - i >= 0 else 0
    y = Y - i if Y - i >= 0 else 0 
    goukei = (A*x)+(B*y)+(C*i*2) 
    ans.append(goukei)
print(min(ans))

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

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

Z = abs(X - Y)
D = A if X >= Y else B
if D > 2 * C:
    ans += 2 * C * Z
else:
    ans += Z * D

print(ans)

Solution (Python):
cost_a,cost_b,cost_ab,num_a,num_b = map(int,input().split())
if num_a > num_b:
  num_ab = num_b * 2
  need_a = num_a - (num_ab // 2)
  cost1 = need_a * cost_a + num_ab * cost_ab
  
  num_ab = num_a * 2
  cost3 = num_ab * cost_ab
  cost1 = min(cost1,cost3)
elif num_a < num_b:
  num_ab = num_a * 2
  need_b = num_b - (num_ab // 2)
  cost1 = need_b * cost_b + num_ab * cost_ab

  num_ab = num_b * 2
  cost3 = num_ab * cost_ab
  cost1 = min(cost1,cost3)
else:
  num_ab = num_b * 2  
  cost1 = num_ab * cost_ab

cost2 = cost_a * num_a + cost_b * num_b
ans = min(cost1,cost2)
print(ans)

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

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

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

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

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

print(ans)

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

Solution (Python):
import sys

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

if a+b<=c*2:
  while x>0 and y>0:
    ans+=a+b
    x-=1
    y-=1

else:
  if (c*2>a and c*2>b) or (c>=a and x>=y) or (c>=b and y>x):
    while x>0 and y>0:
      ans+=c*2
      x-=1
      y-=1
  else:
    while x>0 or y>0:
      ans1+=c*2
      x-=1
      y-=1
    print(ans1)
    sys.exit()

if x==0:
  while y>0:
    ans+=b
    y-=1

else:
  while x>0:
    ans+=a
    x-=1

print(ans)

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

TotalPrice = 2 * 5000 * 10**5
for i in range(max(X, Y) + 1):
    priceA = A * max(X - i, 0)
    priceB = B * max(Y - i, 0)
    priceC = 2 * C * i
    TotalPrice = min(TotalPrice, priceA + priceB + priceC)

print(TotalPrice)

Solution (Python):
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

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

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

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

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

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

p = [a * x + b * y, c * max(x, y) * 2]
if x != y:
    p.append(c * y * 2 + a * (x-y)) if x > y else p.append(c * x * 2 + b * (y-x))

print(min(p))

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

p = [a * x + b * y, c * max(x, y) * 2]
if x != y:
    if x > y:
        p.append(c * y * 2 + a * (x-y))
    else:
        p.append(c * x * 2 + b * (y-x))

print(min(p))

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

ans = float("inf")
for i in range(200000):
    tmp = 0
    tmp += c * i * 2
    if x - i>0:
        tmp += a *(x-i)
    if y - i>0:
        tmp += b *(y-i)
    ans = min(ans, tmp)
print(ans)

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

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

print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
faceAB = (A + B) / 2
sumPizza = 0

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

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

p2 = 0
for i in range(max(x, y)):
    ai = a * (x - i) if i < x else 0
    bi = b * (y - i) if i < y else 0
    abi = 2 * i * c
    p1 = ai + bi + abi

    ai1 = a * (x - i - 1) if i < x else 0
    bi1 = b * (y - i - 1) if i < y else 0
    abi1 = 2 * (i + 1) * c
    p2 = ai1 + bi1 + abi1
    if p1 < p2:
        print(p1)
        exit()

print(p2)

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

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

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

print(ans)