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):
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

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

ans = 1000000000000000000
for i in range(0,x+1):
	B = max(y-(x-i),0)
	AB = max(2*(x-i),0)
	money = i*a+B*b+AB*c
	ans = min(ans,money)

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

for i in range(0,max(x,y)*2+1,2):
	A = max(x - i//2,0)
	B = max(y - i//2,0)
	money = A*a+B*b+i*c
	ans = min(ans,money)

print(ans)

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

sum = 0

if A+B<=2*C:
    sum = (A * X) + (B * Y)
else:
    if X<=Y:
        y = Y - X
        sum += X * 2 * C
        if B<=2*C:
            sum += B * y
        else:
            sum += C * 2 * y
    else:
        x = X - Y
        sum += Y * 2 * C
        if A<=2*C:
            sum += A * x
        else:
            sum += C * 2 * x

print(sum)

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

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

print(ans)

Solution (Python):

def datain(num):

    data = []
    iscnt = True

    while iscnt:
        for val in map(int,input().split()):
            data.append(val)
            if len(data) == num:
                iscnt = False
                break
        
    return data

INF = 10**12
data = datain(5)
ans = INF

for i in range(0,max(data[3],data[4])*2+1,2):   
    
    j = data[3]-i/2 if data[3] >= i/2 else 0   
    k = data[4]-i/2 if data[4] >= i/2 else 0   
    ans = min(ans,i*data[2]+j*data[0]+k*data[1])
    

print(int(ans))

Solution (Python):
a,b,c,x,y=map(int,input().split())
A=a*x
B=b*y
ABa=c*x*2
ABab=b*(y-x) if y>x else 0
ABb=c*y*2
ABba=a*(x-y) if x>y else 0
AB=2*c*x if x>y else 2*c*y
print(min(A+B,ABa+ABab,ABb+ABba,AB))

Solution (Python):
a,b,c,x,y=map(int,input().split())
A=a*x
B=b*y
ABa=c*x*2
ABab=b*(y-x) if y>x else 0
ABb=c*y*2
ABba=a*(x-y) if x>y else 0
AB=2*c*x if x>y else 2*c*y
print(min(A+B,ABa+ABab,ABb+ABba,AB))

Solution (Python):
a,b,c,x,y=map(int,input().split())
A=a*x
B=b*y
ABa=c*x*2
ABab=b*(y-x) if y>x else 0
ABb=c*y*2
ABba=a*(x-y) if x>y else 0
print(min(A+B,ABa+ABab,ABb+ABba))

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

xp, xc, np, nc = (A, X, B, Y) if X > Y else (B, Y, A, X)

x = xp * xc + np * nc
y = C * xc * 2
z = xp * (xc - nc) + C * nc * 2

print(min(x, y, z))

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

Solution (Python):
from sys import stdin
import math


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C,X,Y= list(map(int,_in[0].split(' ')))  
    
    cnt = float('inf')
    for c in range(2*X+2*Y+1):
        if X-c/2>=0 or Y-c/2>=0:
            a = max(math.ceil(X-c/2),0)
            b = max(math.ceil(Y-c/2),0)
            cnt = min(cnt,A*a+B*b+C*c)
        else:
            break
    
    print(cnt)

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = 5000 * (10**5) * 2 + 1
for i in range(max(x, y)+1):
    A = a * (x - i) if x-i > 0 else 0
    B = b * (y - i) if y-i > 0 else 0
    C = 2 * c * i
    v = A + B + C
    if ans > v:
        ans = v
print(ans)

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


l = [x,y]
p = 10**5 * 15000
for i in range(max(l)+1):

    x_ = x-i
    y_ = y-i
    
    if x-i < 0:
        x_= 0
        
    if y-i < 0:
        y_ = 0
    
    if p > (i * 2*c + (x_) * a + (y_) * b):
        p = (i * 2*c + (x_) * a + (y_) * b)
print(p)

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

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

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

Solution (Python):
n=[int(x) for x in list(input().split())]
A=n[0]
B=n[1]
C=n[2]
X=n[3]
Y=n[4]

ans=max(A,B,C)*(X+Y)
t=0
for i in range(max(X,Y)*2+1):
    if A*max(0, X-int(i/2))+B*max(0,Y-int(i/2))+C*i < ans:
        ans=A*max(0, X-int(i/2))+B*max(0,Y-int(i/2))+C*i
        t=i

print(ans)

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

def kansu(A,B,C,X,Y):
    sum = 0
    
    if A+B<=2*C:
        sum += A*X + B*Y    
        return sum
     
    else:
        kosu_sa =0
        if X>Y:
            sum = X * 2 * C
            if A < 2*C:
                sum = (sum - 2*C*(X-Y))+A*(X-Y)

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

A,B,C,X,Y = nyu()
print(kansu(A,B,C,X,Y))

Solution (Python):

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

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

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

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

print(result)

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

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

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

Solution (Python):
A,B,C,X,Y = map(int,input().split())
arr = []
for c in range(0,max(X+1,Y+1)*2,2): 
    a = max(X-c/2,0)
    b = max(Y-c/2,0)
    arr.append(a*A+b*B+c*C)
print(int(min(arr)))

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

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

print(result)

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

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

ans = 0

C *= 2

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

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

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

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

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

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

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

pricemin = a*x + b*y
if x>y:
  for i in range(x+1):
    m = max(y-i,0)
    price = a*(x-i) + b*m + c*2*i
    if price<pricemin:
      pricemin = price
else:
  for i in range(y+1):
    m = max(x-i,0)
    price = a*m + b*(y-i) + c*2*i
    if price<pricemin:
      pricemin = price
print(pricemin)

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

ans = float("inf")
AB = max(X,Y)
for i in range(2*AB+1):
    if X-i//2>=0 and Y-i//2>=0:
        ans = min(A*(X-i//2)+B*(Y-i//2)+C*i,ans)
    elif X-i//2<0 and Y-i//2>=0:
        ans = min(B*(Y-i//2)+C*i,ans)
    elif X-i//2>=0 and Y-i//2<0:
        ans = min(A*(X-i//2)+C*i,ans)
print(ans)

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

low = 100000*2*C

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

print(low)

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

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

print(min(A+B,2*C)*min(X,Y) + D*abs(X-Y))

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

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

print(tot)

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

Solution (Python):
import sys
A, B, C, X, Y = map(int, sys.stdin.readline().split(" "))
ans = float("inf")
 
for i in range(max(X, Y) * 2 + 1):
    j = X - i // 2
    if j < 0:
        j = 0
    k = Y - i // 2
    if k < 0:
        k = 0
    ans = min(ans, C * i + A * j + B * k)
print(ans)

Solution (Python):
from sys import stdin
import sys

[A, B, C, X, Y] = list(map(int, stdin.readline().rstrip().split()))


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

else:
    minimum = float('inf')
    for Z in range(2 * 10**5 + 1):
        a = (max(0, X - Z // 2)) * A
        b = (max(0, Y - Z // 2)) * B
        c = Z * C
        minimum = min(minimum, (a + b + c))
    
    print(minimum)

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

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

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

ans = 0

C *= 2

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

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

Solution (Python):
a=list(input().split(" "))
A=int(a[0])
B=int(a[1])
C=int(a[2])
X=int(a[3])
Y=int(a[4])

minprice = X*A+Y*B

N = max(X,Y)
Z=0
for i in range(N):
    if X>0:
        X-=1
    if Y>0:
        Y-=1
    Z+=2
    price =X*A+Y*B+Z*C
    minprice=min(minprice, price)
print(minprice)

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

a = max([X,Y])
s = 0

for i in range(0,2*a+1,2):
    x = X-i/2 if X-i/2 > 0 else 0
    y = Y-i/2 if Y-i/2 > 0 else 0
    S = A*x + B*y + C*i
    if s == 0:
        s = S
    else:
        if s > S:
            s = S
        else:
            continue

print(int(s))

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


TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2

for a in range(X + 1):
    c = (X - a) * 2
    if c // 2 < Y:
        if B < 2 * C:
            b = Y - c // 2
        else:
            b = 0
            c = max(c, Y * 2) 
    else:
        b = 0
    
    total_tmp = A * a + B * b + C * c
    if total_tmp < TOTAL_MIN:
        TOTAL_MIN = total_tmp
        

print(TOTAL_MIN)

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

i = a if x > y else b
piza_1 = a * x + b * y
piza_2 = min(x,y) * 2 * c + (max(x,y) - min(x,y)) * i
piza_3 = max(x,y) * 2 * c

print(min(piza_1,piza_2,piza_3))

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


if C*2 > A + B:
    x = 0
    price = A * X + B * Y
else:
    if X <= Y:
        x = X * 2
        a = 0
        b = Y - x // 2
        price = C*x + min(b*B, 2*b*C)
    else:
        x = Y * 2
        a = X - x // 2
        b = 0
        price = C*x + min(a*A, 2*a*C)
print(price)

Solution (Python):
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

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

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

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

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

case1 = a * x + b * y
case2 = c * 2 * y + (x - y) * a
case3 = c * 2 * x

print(min(case1, case2, case3))

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

ans = 10**18

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

    ans = min(ans, price)

print(ans)

Solution (Python):



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


def main():
    if A + B < 2 * C:
        ans = A * X + B * Y
    else:
        x = min(X, Y)
        ans = x * (2 * C)
        y = max(X, Y) - x
        v = A if X > Y else B
        ans += min(y * v, y * (2 * C))
    print(ans)


if __name__ == "__main__":
    main()

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

ans=0

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

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

print(ans)

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

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

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

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

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

print(res)

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

Solution (Python):

import math

A, B, C, X, Y = (int(x) for x in input().split())
ans = 0
if X > Y:
    MAX = X
else:
    MAX = Y

for c in range(MAX * 2 + 1):
    a = X - math.floor(c / 2)
    b = Y - math.floor(c / 2)
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    fee = a * A + b * B + c * C
    if ans > fee or ans == 0:
         ans = fee

print(ans)

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

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

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

print(min(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3))

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

if c >= a and c >= b:
    print(a*x + b*y)
    exit()

if 2*c - a - b > 0:
    print(a*x + b*y)
    exit()

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


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


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

print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
M = max(X, Y)
V = int(1e18)
for i in range(M+1):
  v = 2 * C * i
  if i <= X:
    v += (X - i) * A
  if i <= Y:
    v += (Y - i) * B
  if v < V:
    V = v
print(V)

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

Solution (Python):
import sys
import math

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







        








ab_maisu = 0
if x >= y:
    ab_maisu = x * 2
else:
    ab_maisu = y * 2

kingaku = 0
for i in range(0, ab_maisu+2, 2):
    a_maisu = x - (math.ceil(i/2))
    b_maisu = y - (math.ceil(i/2))

    if a_maisu < 0:
        a_maisu = 0
    if b_maisu < 0:
        b_maisu = 0

    if i == 0:
        kingaku = (a*a_maisu) + (b*b_maisu) + (c*i)
    else:
        if kingaku > (a*a_maisu) + (b*b_maisu) + (c*i):
            kingaku = (a*a_maisu) + (b*b_maisu) + (c*i)

print("{}".format(kingaku))

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

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

p1 = 2*c * max(x, y)
p2 = a*x + b*y
p3 = 2*c * min(x, y) + a*(x-min(x, y)) + b*(y-min(x, y))

print(min(p1, p2, p3))

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

Solution (Python):
A, B, C, X, Y = map(int,input().split())
ans = 0
mi = min(X, Y); ma = max(X, Y); sub = abs(X - Y);

price = 0
if max(X, Y) == X:
  price = A
else:
  price = B
part_c = 2*C*mi + sub*price

print(min(2*C*ma, part_c, A*X + B*Y))

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

s = 0
s2 = 0
s3 = 0

s += c * min([x, y]) * 2
s += a * (x - min([x, y]))
s += b * (y - min([x, y]))

s2 += a * x
s2 += b * y

s3 += c * max([x, y]) * 2

print(min([s, s2, s3]))

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

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

Solution (Python):
a,b,c,x,y = map(int, input().split())
 
abmax = max(x,y)+1
 
price = 0
 
for i in range(abmax):
  nab = i*2
  na = x - i
  nb = y - i
  if(na<0):
    na = 0
  if(nb<0):
    nb = 0
  p = c * nab + a * na + b * nb
  if(p<price or price == 0):
    price = p
print(price)

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Solution (Python):
a, b, c, x, y = list(map(int, input().split(" ")))
if x >= y:
    n_c = 2 * x
else:
    n_c = 2 * y

ans = c * n_c

for v in range(n_c):
    n_a = - (-(x - v/2)//1)
    n_b = - (-(y - v/2)//1)
    if n_a < 0:
        n_a = 0
    if n_b < 0:
        n_b = 0
    m = a * n_a + b * n_b + c * v
    if ans > m:
        ans = m
        
print(int(ans))

Solution (Python):
a, b, c, x, y = map(int, open(0).read().split())
a, b, x, y = (b, a, y, x) if x > y else (a, b, x, y)

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

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

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

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

for k in range(0,max(X,Y)*2+1,2):
  if A*max(0,X-k/2)+B*max(0,Y-k/2)+C*k < min:
    min = A*max(0,X-k/2)+B*max(0,Y-k/2)+C*k
        
print(int(min))

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

a = A * X + B * Y
b = 0
m = min(X, Y)
if m == X:
    b = 2 * C * m + B * (Y-X)
else:
    b = C * 2 * m + A * (X-Y)
c = C * 2 * max(X, Y)
print(min(a, b, c))

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

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

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

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

Solution (Python):
A,B,C,X,Y = list(map(int, input().split()))
max_C = max(X,Y)*2
min_amount = 99999999999

for num_C in range(max_C + 1):
  
  if num_C % 2 == 0:
    num_A = max(0, X - 0.5*num_C)
    num_B = max(0, Y - 0.5*num_C)
    
    
    total = A*num_A + B*num_B + C*num_C
    
    if total < min_amount:
      min_amount = total

print(int(min_amount))

Solution (Python):
a, b, c, x, y = [int(e) for e in input().split()]
ans = 0
if a + b <= 2 * c:
    ans = a * x + b * y
elif a + b > 2 * c:
    if x == y:
        ans = x * 2 * c
    elif x < y:
        ans = x * 2 * c
        if b <= 2 * c:
            ans = ans + b * (y-x)
        else:
            ans = ans + 2 * c * (y-x)
    elif y < x:
        ans = y * 2 * c
        if a < 2 * c:
            ans = ans + a * (x-y)
        else:
            ans = ans + 2 * c * (x-y)
print(ans)

Solution (Python):

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

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

print(min(ans))

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

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

print(cost)

Solution (Python):
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



A, B, C, X, Y = list(map(int, sys.stdin.buffer.readline().split()))


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

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

print(ans)

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

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

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

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

ans_1 = X * A + Y * B
if X > Y :
    ans_2 = Y * 2 * C + (X-Y) * A
else :
    ans_2 = X * 2 * C + (Y-X) * B
ans_3 = max(X, Y) * 2 * C

print(min(ans_1,ans_2,ans_3))

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

def main():
    A, B, C, X, Y = map(int, input().split())
    max_c = max([X, Y]) * 2
    min_cost = float("inf")
    for n_c in range(0, max_c + 1, 2):
        n_a = max(X - n_c / 2, 0)
        n_b = max(Y - n_c / 2, 0)
        cost = A * n_a + B * n_b + C * n_c
        if cost < min_cost:
            min_cost = cost
    print(int(min_cost))


if __name__ == '__main__':
    main()

Solution (Python):


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

remain_X=X
remain_Y=Y
num_AB=0
cost=0

if (C*2) < (A+B):
    num_AB += min(X,Y) * 2
    remain_X -= num_AB / 2
    remain_Y -= num_AB / 2

if (C*2) < A and A > B and remain_X > 0:
    num_AB += remain_X * 2
    remain_X = 0
    remain_Y -= num_AB / 2
    
    if remain_Y < 0:
        remain_Y = 0

if (C*2) < B and A < B and remain_Y > 0:
    num_AB += remain_Y * 2
    remain_X -= num_AB / 2
    remain_Y = 0
    
    if remain_X < 0:
        remain_X = 0

if (C*2) < A and remain_X > 0:
    num_AB += remain_X * 2
    remain_X = 0
    remain_Y -= num_AB / 2
    
    if remain_Y < 0:
        remain_Y = 0
        
if (C*2) < B and remain_Y > 0:
    num_AB += remain_Y * 2
    remain_X -= num_AB / 2
    remain_Y = 0
    
    if remain_X < 0:
        remain_X = 0


cost = (remain_X * A) + (remain_Y * B) + (num_AB * C)
print(int(cost))

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

cost = 0
if A+B >= 2*C:
    if X>Y:

        cost += C*Y*2
        X -= Y
        Y -= Y


    else:
        cost += C*X*2
        Y -= X
        X -= X

    if X>0 and A > 2*C:
        cost += X*C*2
    elif X>0 and A <= 2*C:
        cost += X*A
    elif Y>0 and B > 2*C:
        cost += Y*C*2
    elif Y>0 and B <= 2*C:
        cost += Y*B
else:
    cost += X*A + B*Y

print(cost)

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

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

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

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


ans1 = A * X + B * Y


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


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

print(min(ans1, ans2, ans3))

Solution (Python):
A, B, C, X, Y = [int(x) for x in input().split()]
mon1 = X * A + Y * B
mon2 = 2 * C * max(X, Y)
mon3 = 2 * C * min(X, Y)
mon3 += A * (max(X, Y) - min(X, Y)) if X >= Y else B * (max(X, Y)  - min(X, Y))
print(min(mon1, mon2, mon3))

Solution (Python):
A, B, C, X, Y = [int(x) for x in input().split()]
if A + B < 2 * C:
    print(A * X + B * Y)
else:
    money = 0
    if X == Y:
        money = 2 * X * C
    elif X > Y:
        money = 2 * Y * C
        if 2 * C < A:
            money += 2 * (X - Y) * C
        else:
            money += (X - Y) * A
    else:
        money = 2 * X * C
        if 2 * C < B:
            money += 2 * (Y - X) * C
        else:
            money += (Y - X) * B
    print(money)

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

min_count = min(X, Y)
max_count = max(X, Y)

p1 = (C * min_count) * 2 + A * (X - min_count) + B * (Y -min_count)
p2 = A * X + B * Y
p3 = (C * max_count) * 2

print(min(p1, p2, p3))

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