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
a = b = c = 0

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

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

ans += A*X + B*Y
a = X
b = Y

print(ans)

Solution (Python):

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

def cal(cp):
    res=2*cp*c
    xx=x-cp
    yy=y-cp
    res+=a*max(0,xx)+b*max(0,yy)
    return res

ans=[cal(0),cal(x),cal(y),cal(x+y)]
print(min(ans))

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

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

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


mx = 10**18
for i in range(0, max(x,y)*2+1):
  if i%2==1: continue
  total = max(a*(x-i//2), 0) + max(b*(y-i//2), 0) + c*i
  if total<mx:
    mx=total

print(mx)

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

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

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

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

print(price)

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

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

print(price)

Solution (Python):
a,b,c,x,y=map(int,input().split())
ans1=a*x+b*y
ans2=0
ans3=max(x,y)*2*c

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

print(min(ans1,ans2,ans3))

Solution (Python):
import glob


REL_PATH = 'ABC\\95\\C'


TOP_PATH = 'C:\\AtCoder'


class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        q = [int(i) for i in self.input_data().split()]
        A = q[0]
        B = q[1]
        C = q[2]
        X = q[3]
        Y = q[4]

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

            else:
                result = C * X * 2
                if B > C * 2:
                    result += (Y - X) * C * 2
                else:
                    result += (Y -X) * B

        print(str(result))


solver = Solver(REL_PATH)
solver.exec_resolve()

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

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

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

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

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

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

A, B, C, X, Y = map(int, input().split(' '))
set_price = min(A+B, C*2)
set_num = min(X, Y)

ans = set_price * set_num
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())
sum=0
m=min(x,y)
if(a+b>2*c):
    sum+=2*c*m
else:
    sum+=x*a+b*y
    print(sum)
    exit()
s=0
z=0
if x>y:s=a
else: s=b
sum+=min(2*c,s)*max(x-m,y-m)
print(sum)

Solution (Python):
a,b,c,x,y=map(int,input().split())
buy_x=x
buy_y=y
buy_z=0
ans=a*buy_x+b*buy_y

for i in range(max(x,y)*2):
    if (a+b>c*2):
        if (buy_x>0 and buy_y>0):
            buy_x-=1
            buy_y-=1
            buy_z+=2
        elif (buy_x==0 and buy_y>0 and b>c*2):
            buy_y-=1
            buy_z+=2
        elif (buy_x>0 and buy_y==0 and a>c*2):
            buy_x-=1
            buy_z+=2
    else:
        break
        
print(buy_x*a+buy_y*b+buy_z*c)

Solution (Python):

import math

def main():
    A, B, C, X, Y = map(int, input().split())
    ans = float("inf")
    for k in range(2 * max(X, Y) + 1):
        i = max(0, math.ceil(X - 0.5 * k))
        j = max(0, math.ceil(Y - 0.5 * k))
        total = A * i + B * j + C * k
        if ans > total:
            ans = total
    print(ans)

if __name__ == '__main__':
    main()

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

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

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













min_nedan=5000*(X+Y)
tmp_nedan=0
if A+B > 2*C:
    tmp_nedan += 2*C*min(X,Y)
    if X > Y:
        if A > 2*C:
            tmp_nedan+=2*C*(X-Y)
        elif A <= 2*C:
            tmp_nedan+=A*(X-Y)
    elif X<= Y:
        if B > 2*C:
            tmp_nedan+=2*C*(Y-X)
        elif B <= 2*C:
            tmp_nedan+=B*(Y-X)
elif A+B <= 2*C:
    tmp_nedan += A*X+B*Y

print(tmp_nedan)

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

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

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

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

ans = float("inf")
for i in range(0, max(2*x, 2*y)+1, 2):
    na = 0 if x-i//2 < 0 else x-i//2
    nb = 0 if y-i//2 < 0 else y-i//2
    ans = min(ans, c*i + a*na + b*nb)

print(ans)

Solution (Python):
a, b, c, x, y = map(int, input().split())
mini = 10000000000
if x < y: temp = y
else: temp = x
for i in range(0, temp * 2 + 1, 2):
    a_price = a * (x - int(i/2))
    b_price = b * (y - int(i/2))
    if a_price < 0:
        a_price = 0
    if b_price < 0:
        b_price = 0
    price = a_price + b_price + c * i
    
    if price < mini:
        mini = price
print(mini)

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

min_value = a * x + b * y

max_num = max(x, y)

for i in range(2, max_num * 2 + 1, 2):
    
    value = ab * i + a * max(0, x - i // 2) + b * max(0, y - i // 2)
    
    min_value = min(min_value, value)

print(min_value)

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

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

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

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

if b>c*2:
	if y>0:
		ans=ans+(y*2*c)
		y=0
elif y>0:
	ans=ans+(y*b)
	y=0

print(ans)

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

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

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

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

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


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

    cost = A if X > Y else B
    piece = max(X, Y) - min(X, Y)

    for i in range(piece):
        ans = min(ans, ans - 2 * C + cost)
    print(ans)

Solution (Python):
a,b,c,x,y=map(int,input().split())
ans=float('inf')
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)

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:
        i=a
    elif x<y:
        i=b
    else:
        i=0
    
    p=min(x,y)*c*2 + abs(x-y)*i
    q=max(x,y)*c*2
    
    if p >= q:
        print(q)
    else:
        print(p)

Solution (Python):
import math
S = input().split(" ")

A = int(S[0])
B = int(S[1])
C = int(S[2])
X = int(S[3])
Y = int(S[4])

def calculate(a,b,c,x,y):


    base = min([x,y])

    values = []
    for index in range(base+1):
        tmp = 2 * C * index + a * (x - index) + b * (y - index)
        values.append(tmp)

    s2 = max([x,y]) * 2 * c
    values.append(s2)

    print(min(values))

calculate(A,B,C,X,Y)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    A,B,C,x,y = LI()
    ans = float("inf")
    for c in range(200001)[::2]:
        a = b = c >> 1
        a = max(0,x-a)
        b = max(0,y-b)
        s = A*a+B*b+C*c
        if s < ans:
            ans = s
    print(ans)
    return


if __name__ == "__main__":
    solve()

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

print(ans)

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

    mn = float('inf')
    for i in range(max(X,Y)+1):
        price = 0
        price += C * i
        if Y - i > 0:
            price += B * (Y - i)
        
        if X - i > 0:
            price += A * (X - i)
        
        mn = min(price, mn)
    
    print(mn)

if __name__ == '__main__':
    solve()

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

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

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

print(ans)

Solution (Python):
A, B, C, X, Y = map(lambda x: int(x), input().split())
price = A * X + B * Y
for Z in range(2, X * 2 + 1 if X > Y else Y * 2 + 1, 2):
    x, y = int(X - Z / 2), int(Y - Z / 2)
    x, y = 0 if x < 0 else x, 0 if y < 0 else y
    next_price = A * x + B * y + C * Z
    if next_price >= price:
        break
    price = next_price
print(price)

Solution (Python):

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

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

print(cost)

Solution (Python):




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

price1 = x * a + y * b
price2 = max(x, y) * 2 * c
price3 = min(x, y) * 2 * c + a * (x - min(x, y)) + b * (y - (min(x, y)))
print(min(price1, price2, price3))

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

Solution (Python):
A,B,C,X,Y = map(int,input().split())
A_and_B = A*X + B*Y
plus1AB = -(A+B)+2*C
if(plus1AB >= 0):
    print(A_and_B)
else:
    ABs= 2*C*min(X,Y)
    amari = abs(X-Y)
    if(X>=Y):
        only = amari*A
    else:
        only = amari*B
    ABonly = amari*2*C
    if(only >= ABonly):
        print(ABs + ABonly)
    else:
        print(ABs +only )

Solution (Python):
A, B, C, X, Y = map(int, input().split())
min1 = 10**18
max1 = max(X, Y)
for i in range(0, max1+1):
    if Y-i<0 and X-i<0:
        cnt = C*2*i
    elif Y-i<0:
        cnt = C*2*i + A*(X-i)
    elif X-i<0:
        cnt = C*2*i + B*(Y-i)
    else:
        cnt = C*2*i + A*(X-i) + B*(Y-i)
    if cnt<min1:
        min1 = cnt
print(min1)

Solution (Python):
import math
A,B,C,x,y=map(int,input().split())
price=5000*(10**6)
for c in range(1+max([2*x,2*y])):
    a=0
    b=0
    if x>c/2:
        a=math.ceil(x-(c/2))
    if y>c/2:
        b=math.ceil(y-(c/2))
    if A*a+B*b+C*c<price:
        price=A*a+B*b+C*c
print(price)

Solution (Python):

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

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

print(ans)

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

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

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

ans = A*X+B*Y
Z=0
while True:
    X=max(X-1,0)
    Y=max(Y-1,0)
    Z=Z+2
    price=A*X+B*Y+C*Z
    
    if ans > price:
        ans=price
    if X==0 and Y==0:
        break


print(ans)

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

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

cost = []

cost.append(A*X + B*Y)

cost.append(2*C*X+abs(X-Y)*B)

cost.append(2*C*Y+abs(X-Y)*A)

cost.append(2*C*max(X,Y))

print(min(cost))

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

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

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

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

print(ans)

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


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

elif a + b < c * 2:
    ans = (a * x) + (b * y)


print(ans)

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

print(ans)

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

print(ans)

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

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

loop=max(x*2,y*2)+1
ans=10**9

for i in range(loop):
  ab=i//2
  if x-ab>=0 and y-ab>=0:
    ans=min(ans,a*(x-ab)+b*(y-ab)+c*i)
  if x>=ab and y<ab:
    ans=min(ans,a*(x-ab)+c*i)
  if x<ab and y>=ab:
    ans=min(ans,b*(y-ab)+c*i)
  if x<ab and y<ab:
    ans=min(ans,c*i)
print(ans)

Solution (Python):


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





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

print(price_min)

Solution (Python):

a,b,c,x,y=map(int,input().split())
price=0
d=min(x,y)
if a+b>c*2:
    price+=2*c*d
else:
    price+=(a+b)*d

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

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

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

yenmin=a*x+b*y
for zz in range(2*10**5+1):
    xx=max(x-zz//2,0)
    yy=max(y-zz//2,0)
    yen=a*xx+b*yy+c*zz
    if yen<yenmin:
        yenmin=yen
print(yenmin)

Solution (Python):
A, B, C, X, Y = [int(x) for x in input().split(' ')]
if (A + B) / 2 > C:
  p = 10**10
  for i in range(min(X, Y), max(X, Y)+1):
    p = min(p, A * max(0, X-i) + B * max(0, Y-i) + C * i * 2)
  print(p)
else:
  print(A * X + B * Y)

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

MAX = max(X, Y)
MIN = 2*C*max(X, Y)
i = MAX
x=X
y=Y

while i > 0:
    tmpC = (MAX-i)*2*C
    total = (A*x)+(B*y)+tmpC
    if(MIN > total):
        MIN = total
    i-=1
    if(x!=0):
        x-=1
    if(y!=0):
        y-=1

print(MIN)

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

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

min_money = A*X + B*Y

status = np.array([X,Y,0])
delta_status = np.array([-1,-1,2])
block_status = np.array([0,0,0])
values = np.array([A,B,C])

for _ in range(max(X,Y)):
    status += delta_status
    status = np.max(np.array([status,block_status]), axis=0)
    
    tmp_money = sum(status * values)
    min_money = min(tmp_money,min_money)
print(min_money)

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

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

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

total_price = a*x+b*y
max_num = max(x,y)

for i in range(0,(max_num+1)*2,2):
    new_x = 0 if x-i//2 <= 0 else x-i//2
    new_y = 0 if y-i//2 <= 0 else y-i//2
    current_price = i*c + new_x*a + new_y*b
    
    if current_price < total_price:
        total_price = current_price

print(total_price)

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

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

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

Solution (Python):

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

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    A, B, C, X, Y = map(int, input().split())
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    C *= 2
    AB = A * X + B * Y
    allC = C * Y
    CB = C * X + B * (Y - X)
    print(min([AB, allC, CB]))
    
    
    return 0

if __name__ == "__main__":
    solve()

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

A = a * x + b * y
if x <= y: B = c * x * 2 + b * (y-x)
else: B = c * y * 2 + a * (x-y)
C = c * max(x, y) * 2

print(min(A, B, C))

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 
    x = min(X,Y)
    X -= x
    Y -= x
    
    ans += min(X * A + Y * B,X * C * 2+ Y * C * 2)

print(ans)

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

print(ans)

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

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

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


if __name__ == '__main__':
    main()

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

AB_set = C * 2

ans = min(A*X + B*Y, AB_set*max(X,Y), AB_set*min(X,Y) + A*abs(X-min(X,Y)) + B*abs(Y-min(X,Y)))

print(ans)

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

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


if 2 * C < A:
    k = X
    X -= k
    Y -= k
    ans += 2 * C * k
if 2 * C < B:
    k = Y
    X -= k
    Y -= k
    ans += 2 * C * k


ans += A * max(0, X) + B * max(0, Y)
print(ans)

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

ans = A*X + B*Y

i = 1
while True:
    cost = A*max(X-i, 0) + B*max(Y-i, 0) + 2*C*i
    if cost > ans:
        break
    ans = min(cost, ans)
    i += 1

print(ans)

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

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

print(ans)

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

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

print(ans)

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

cand1=a*x+b*y

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

cand3=2*c*x+b*(y-x) if x<y else 2*c*y+a*(x-y)
print(min(cand1,cand2,cand3))

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

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

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

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

a, b, c, x, y = mi()
n_min = min(x,y)
price = 0
if(a+b > 2*c):
    price += 2*c * n_min
else:
    price += (a+b) * n_min

if(x>y):
    n_mod = x-n_min
    d = a
else:
    n_mod = y-n_min
    d = b

if(d < c*2):
    price += d * n_mod
else:
    price += c*2 * n_mod

print(price)

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

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

Solution (Python):
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  
def grid(n): return [s_list() for _ in range(n)]


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

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

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

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    
    
    
    
    
    
    
    
    
    
    
    
    
    n = list(map(int,input().split()))
    maisu = max(n[3],n[4])
    ans = [0]*(maisu+1)
    for i in range(maisu+1):
        ans[i] = n[2]*i*2+n[0]*max(0,(n[3]-i))+n[1]*max(0,(n[4]-i))
    print(min(ans))

if __name__ == '__main__':
    main()

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

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

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

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

ans = 0


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

X -= buy
Y -= buy


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


print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
A, B, C, X, Y = map(int, input().split())

cost1 = A * X + B * Y
cost2 = max(X, Y) * 2 * C
if X <= Y:
    cost3 = X * 2 * C + (Y - X) * B
else:
    cost3 = Y * 2 * C + (X - Y) * A

print(min([cost1, cost2, cost3]))