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

ans = 0
if a+b > c*2:
    xy = max(x, y)-abs(x-y)
    ans = c*xy*2
    x -= xy
    y -= xy
    if a <= c*2 and b <= c*2:
        ans += a*x+b*y
    elif a > c*2 and x > 0:
        ans += c*x*2
        y -= x
        if y > 1:
            ans += b*y
    else:
        ans += c*y*2
        x -= y
        if x > 1:
            ans += a*x
else:
    ans = a*x+b*y

print(ans)

Solution (Python):
inf = (5000 * 10 ** 5) * 3

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

ret = inf
for cnt_ab in range(max(x, y) * 2 + 1):
    d = cnt_ab // 2

    cnt_a = max(0, x - d)
    cnt_b = max(0, y - d)

    t = cnt_ab * c + cnt_a * a + cnt_b * b
    ret = min(ret, t)
print(ret)

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

for i in range(max(x, y) - min(x, y)):
    if (x > y):
        if (a > 2 * c):
            price = price - a + 2 * c
        else:
            break
    else:
        if (b > 2 * c):
            price = price - b + 2 * c 
print(price)

Solution (Python):
a,b,c,x,y = map(int,input().split())
cur = a*x+b*y
z = 0
while True:
  x,y,z = x-1,y-1,z+2
  if a*max(0,x)+b*max(0,y)+c*z <= cur:
    cur = a*max(0,x)+b*max(0,y)+c*z
  else:
    print(cur)
    exit()

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

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

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

print(min(p, q, r))

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

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

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

ans = float('inf')
for k in range(2*max(x, y)+1):
    cost = c * k
    need_x = max(0, x - k // 2)
    need_y = max(0, y - k // 2)
    cost += a * need_x + b * need_y
    ans = min(ans, cost)
print(ans)

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

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

print(ans)

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

def best_pizza_cost(ln, hn):
    if ln == X: lp = A
    else: lp = B

    if hn == Y: hp = B
    else: hp = A

    fnp = lp * ln + hp * ln
    fhp = C * ln * 2

    left = hn-ln
    snp = hp * left
    shp = C * left * 2
    
    return min(fnp, fhp) + min(snp, shp)

print(best_pizza_cost(min(X, Y), max(X, Y)))

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

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def divisor(n):
        i = 1
        table = []
        while i * i <= n:
            if n % i == 0:
                table.append(i)
                table.append(n // i)
            i += 1
        table = list(set(table))
        return table


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)

    def list(self):
        return self.__q

    def length(self):
        return len(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    
    A, B, C, X, Y = Scanner.map_int()
    C *= 2
    ans = 0
    if A + B > C:
        a = min(X, Y)
        ans += a * C
        X -= a
        Y -= a
    if A < C:
        ans += A * X
    else:
        ans += C * X
    if B < C:
        ans += B * Y
    else:
        ans += C * Y
    print(ans)
    return


if __name__ == "__main__":
    main()

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

ans = 0

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

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

print(ans)

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


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

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

Solution (Python):
import sys
import itertools



read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

    ans = 1000000000

    tmp_x = x
    tmp_y = y

    for ab in range(max(x, y)+1):
        x -= ab
        y -= ab
        if x < 0:
            x = 0
        if y < 0:
            y = 0
        ans = min(ans, a * x + b * y + 2 * ab * c)
        x, y = tmp_x, tmp_y

    print(ans)

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

Solution (Python):
import sys
read_=sys.stdin.buffer.readline

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

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

print(min(ans1,ans2,ans3))

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

ans=10**10
for i in range(max(X,Y)+1):
    cnt=0
    cnt+=C*2*i
    x=X-i
    y=Y-i
    cnt+=max(0,x*A)
    cnt+=max(0,y*B)
    if ans>cnt:
        ans=cnt
print(ans)

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

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

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

Solution (Python):

"""
別解(定数時間)
https://atcoder.jp/contests/abc095/submissions/10226556
"""

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

ans = float("inf")



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

ans = 0


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

X -= MINXY
Y -= MINXY


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

print(ans)

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

Solution (Python):
"""
CでAやBが0.5枚できる分だけ買う意味はないので、必ず一枚作れるように買う
X,Yが 10**5までなので、Cで何枚作るか決めて、残りをA、B単品で埋めた時のコストの最小値を全探索
"""

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


ans = float("inf")

for i in range(max(X,Y)+1):
    
    cost = 2*i*C
    
    if i < X:
        cost += (X-i)*A
    
    if i < Y:
        cost += (Y-i)*B
    ans = min(ans, cost)

print(ans)

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

Solution (Python):
def solve():
    A, B, C, X, Y = map(int, input().split())
    
    ans = 5000 * 2 * 10 ** 5
    for i in range(max(X, Y) + 1):
        ans = min(ans, 2 * i * C + A * max(0, X - i) + B * max(0, Y - i))
    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)
elif x>=y:
  print(min(y*2*c+(x-y)*a,x*2*c))
else:
  print(min(x*2*c+(y-x)*b,y*2*c))

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

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

Solution (Python):

import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    result = 5000 * 10 ** 5 * 2 + 1
    for i in range(0, 10 ** 5 + 1):
        cost = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = 0
cnt = 0
while x > cnt and y > cnt:
    ans += min(a+b, c*2)
    cnt += 1

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

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

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

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

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

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
min_num = min(X, Y)
max_num = min(X, Y)
min_price = min(A + B, C * 2)
max_price = min(A + B, C * 2)
answer = min_num * min_price


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

print(answer)

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

if X > Y:
    max_pizzas = X
else :
    max_pizzas = Y
    
costs = []
for i in range(max_pizzas+1):
    A_left = X - i
    B_left = Y - i
    if A_left > 0:
        A_cost = A * A_left
    else :
        A_cost = 0

    if B_left > 0:
        B_cost = B * B_left
    else :
        B_cost = 0
    
    costs.append(A_cost + B_cost + (C * 2 * i))
    
print(min(costs))

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

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

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

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

for i in range(2*Z+1):
    temp=i*C
    x=max(X-i//2,0)
    y=max(Y-i//2,0)
    temp+=A*x+B*y
    ans=min(ans,temp)
    
print(ans)

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

arr = []
for i in range(10**5+1):
    arr.append(i*2*c + max(0,x-i)*a + max(0,y-i)*b)

print(min(arr))

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter


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

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

print(ans)

Solution (Python):
def buy_ab(cost_a, cost_b, cost_ab, target_a, target_b, target_ab):
    target_a = max(0, target_a - target_ab // 2)
    target_b = max(0, target_b - target_ab // 2)
    return cost_ab * target_ab + cost_a *target_a  + cost_b * target_b


def main():
    cost_a, cost_b, cost_ab, target_a, target_b = map(int, input().split(" "))
    buy_whole = cost_a * target_a + cost_b * target_b
    print(min(buy_ab(cost_a, cost_b, cost_ab, target_a, target_b, min(target_b, target_a) * 2),
              buy_ab(cost_a, cost_b, cost_ab, target_a, target_b, max(target_b, target_a) * 2),
              buy_whole))


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):

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

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

print(ans)

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

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

if x<y:
    
    print(min((y-x)*b+x*ab*2 , a*x+b*y , y*ab*2))
else:
    
    print(min((x-y)*a+y*ab*2,a*x+b*y , x*ab*2))

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

    n_c = min(x, y)

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


if __name__ == "__main__":
    resolve()

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

Solution (Python):


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,c,x,y = map(int,input().split())
if 2*c <= a and 2*c <= b:
    print(max(x,y)*2*c)
elif 2*c <= a:
    print(x*2*c + max(0,y-x)*b)
elif 2*c <= b:
    print(y*2*c + max(0,x-y)*a)
elif 2*c <= a+b:
    if y < x:
        print(y*2*c + (x-y)*a)
    else: print(x*2*c + (y-x)*b)
else:
    print(a*x + b*y)

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

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

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

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

print(ans)

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

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

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

print(ans)

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

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

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

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

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

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

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

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

Solution (Python):
piza = list(map(int,input().split()))
x = piza[0] * piza[3] + piza[1] * piza[4] 
y = piza[2] * 2 * max(piza[3],piza[4])

if piza[3] >= piza[4]:
    z = piza[2] * (2 * piza[4]) + piza[0] * (piza[3] - piza[4])
else:
    z = piza[2] * (2 * piza[3]) + piza[1] * (piza[4] - piza[3])
print(min(x,y,z))

Solution (Python):
piza = list(map(int,input().split()))
x = piza[0] * piza[3] + piza[1] * piza[4]
y = piza[2] * 2 * max(piza[3],piza[4])
if piza[3] >= piza[4]:
	z = piza[2] * (2 * piza[4]) + piza[0]*(piza[3]-piza[4])
else:
	z = piza[2] * (2 * piza[3]) + piza[1]*(piza[4]-piza[3])
print(min(x,y,z))

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


main()

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

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

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

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


main()

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


main()

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

ans = A*X+B*Y
for i in range(max(X,Y)+1): 
    a = max(X - i,0)
    b = max(Y - i,0)
    c = 2*i
    sum = A*a + B*b + C*c
    
    if sum < ans:
        ans = sum
print(ans)

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

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    A, B, C, X, Y = [int(x) for x in input().split()]
    ans = []
    ans.append(A * X + B * Y)
    ans.append(C * 2 * (max(X, Y)))
    if X > Y:
        ans.append(C * 2 * Y + (X - Y) * A)
    else:
        ans.append(C * 2 * X + (Y - X) * B)

    print(min(ans))


    

if __name__ == '__main__':
    main()

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
C *= 2
if X == Y:
    print(min((A * X + B * Y, C * X)))
elif X > Y:
    ans = 0
    ans += min(C * Y, A * Y + B * Y)
    num = X - Y
    ans += min(C, A) * num
    print(ans)
elif Y > X:
    ans = 0
    ans += min(C * X, A * X + B * X)
    num = Y - X
    ans += min(C, B) * num
    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().rstrip()
nas = lambda: stdin.readline().split()

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

ans = 0
while x or y:
    if x and y:
        if a + b > c * 2:
            z = min(x, y)
            x -= z
            y -= z
            ans += c * 2 * z
        else:
            z = min(x, y)
            x -= z
            y -= z
            ans += (a + b) * z
    else:
        q = c * 2 * (x + y)
        if q <= a * x + b * y:
            ans += c * 2 * (x + y)
            x = 0
            y = 0
        if x:
            ans += a * x
            x = 0
        if y:
            ans += b * y
            y = 0

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().rstrip()
nas = lambda: stdin.readline().split()

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

ans = 0
while x or y:
    if x and y:
        if a + b > c * 2:
            x -= 1
            y -= 1
            ans += c * 2
        else:
            x -= 1
            y -= 1
            ans += a + b
    else:
        q = c * 2 * (x + y)
        if q <= a * x + b * y:
            ans += c * 2 * (x + y)
            x = 0
            y = 0
        if x:
            ans += a * x
            x = 0
        if y:
            ans += b * y
            y = 0

print(ans)

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

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
x, y = min(X,Y), max(X,Y)-min(X,Y)
D = [A,B][X<=Y]
if A+B <= C+C:
    ans = (A+B)*x+D*y
else:
    ans = (C+C)*x+min(D,C+C)*y
print(ans)

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

C2=C*2

if(A>C2 and B>C2):
    print(max(X,Y)*2*C)
    exit()

if(A>C2):
    t=X*2*C
    y=Y-X
    t+=max(0,y)*B
    print(t)
    exit()

if(B>C2):
    t=Y*2*C
    x=X-Y
    t+=max(0,x)*A
    print(t)
    exit()

if(A+B>C2):
    z=min(X,Y)
    t=z*2*C
    t+=(X-z)*A
    t+=(Y-z)*B
    print(t)
    exit()

print(A*X+B*Y)

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

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

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

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

print(m)

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

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


total = 1<<60
for i in range(10**5+1):
  cost = 2*C*i + max(X-i, 0)*A + max(Y-i, 0)*B
  total = min(cost, total)

print(total)

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

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

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

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

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

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

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

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

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

ret = A * X + B * Y
X -= 1
Y -= 1
Z = 2
while X >= 0 or Y >= 0:
    ret = min(ret, max(0, A * X) + max(0, B * Y) + C * Z)
    X -= 1
    Y -= 1
    Z += 2

print(ret)

Solution (Python):
import sys
input = sys.stdin.readline
A,B,C,X,Y = [int(i) for i in input().split()]
money = A * X + B * Y
ans = money
m = min(X,Y)
M = max(X,Y)
d = M - m
if A + B > C * 2 :
    for i in range(m) :
        ans = ans -( A + B) + (2 * C)
    if m == X :
        if B * d > C * 2 * d :
            ans =ans - (B * d) + C * 2 * d
    else :
        if A * d > C * 2 * d :
            ans = ans -(A * d) + C * 2 * d
print(ans)

Solution (Python):
a,b,c,x,y = map(int, input().split())
cost = {x:a, y:b}
s = min(x,y) * c * 2 + abs(x - y) * cost[max(x,y)]
t = max(x,y) * c * 2
u = a * x + b * y

print(min([s, t, u]))

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



ans = 0

ans += a*x + b*y

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

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

print(ans)

Solution (Python):
A,B,C,X,Y = map(int,input().split())
ABset = min(A+B,2*C)
Asgl = min(A,2*C)
Bsgl = min(B,2*C)
Z = min(X,Y)
Ans = ABset * Z
Ans += Asgl * (X - Z)
Ans += Bsgl * (Y - Z)
print(Ans)

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

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

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

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