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

n_c = min(x, y) * 2
n_a = x - n_c // 2
n_b = y - n_c // 2
amount1 = a * n_a + b * n_b + c * n_c

n_c = max(x, y) * 2
n_a = max(x - n_c // 2, 0)
n_b = max(y - n_c // 2, 0)
amount2 = a * n_a + b * n_b + c * n_c

n_a = x
n_b = y
n_c = 0
amount3 = a * n_a + b * n_b + c * n_c

amount = min(amount1, amount2, amount3)

print(amount)

Solution (Python):
import sys

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 main():
    a, b, c, x, y =MI()
    ans = float('inf')
    for i in range(0, max(x*2, y*2)+1, 2):
        p = a*max(0, x-i//2) + b*max(0, y-i//2) + c*i
        ans = min(ans, p)
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):


def main():

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

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

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

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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
A,B,C,X,Y = map(int,input().split())
print(min(A*X+B*Y,2*C*X+B*max(0,Y-X),2*C*Y+A*max(0,X-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(2*C*X+B*(Y-X),2*C*Y))
  else:
    print(min(2*C*Y+A*(X-Y),2*C*X))

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

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

a,b,ab = 0, 0, 0

a = X
b = Y
ab = 0

m = a * A + b * B + ab * C
big = max(X,Y)
while ab // 2 <= big:
    ab += 2
    if a > 0:
        a -= 1
    if b > 0:
        b -= 1
    m = min(m, a * A + b * B + ab * C)

print(m)

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

    if ans > (i*c)+(xr*a)+(yr*b):
        ans = (i*c)+(xr*a)+(yr*b)

print(ans)

Solution (Python):

a, b, c, x, y = map(int, input().split())
t = (x - y) * a if x > y else (y - x) * b

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

Solution (Python):


import sys


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


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


print(ans)

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


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

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

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

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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

if __name__ == '__main__':
    main()

Solution (Python):

a_yen, b_yen, c_yen, x, y = map(int, input().split())

amax = x
bmax = y
cmax = max(x,y) * 2

nedan = 10**10

for i in range(cmax//2+1):
    c=i*2
    
    a=max(amax-c//2,0)
    b=max(bmax-c//2,0)
    
    yen = a_yen * a + b_yen * b +c_yen * c
    
    nedan = min(nedan,yen)

print(nedan)

Solution (Python):
x=input().split()
x=[int(x[i]) for i in range(len(x))]
if x[0]+x[1]<=2*x[2]:
    print(x[0]*x[3]+x[1]*x[4])
else:
    if x[3]>x[4]:
        ans=x[4]*2*x[2]+(x[3]-x[4])*x[0]
        ans=min(ans,x[3]*2*x[2])
    else:
        ans=x[3]*2*x[2]+(x[4]-x[3])*x[1]
        ans=min(ans,x[4]*2*x[2])
    print(ans)

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

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

Solution (Python):


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

ans = float("inf")

for i in range(0,2*max(X,Y)+1,1):
    tmpans = i*C

    tmp_x = max(0,X-i//2)
    tmp_y = max(0,Y-i//2)
    tmpans += A*tmp_x
    tmpans += B*tmp_y

    ans = min(ans,tmpans)

print(ans)

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

count = a * x + b * y
for i in range(10 ** 6):
  num = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b
  if(count > num):
    count = num

print(count)

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

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

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

print(ans)

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

Solution (Python):
if __name__ == '__main__':

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

	
	tmp1 = (a * x) + (b * y)

	
	mi = min(x,y)

	tmp2 = mi * c * 2

	
	if x - mi == 0:
		
		tmp3 = b * (y - mi)
		
		
		tmp4 = c * (y - mi) * 2
		
		tmp2 += min(tmp3,tmp4)
		
	else:
		
		tmp3 = a * (x - mi)
		
		
		tmp4 = c * (x - mi) * 2
		
		tmp2 += min(tmp3,tmp4)

	
	print(min(tmp1,tmp2))

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

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

if __name__ == '__main__':
    main()

Solution (Python):
import math

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

if __name__ == '__main__':
    main()

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

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

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

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

print(min(res, temp))

Solution (Python):

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


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

print(mn)

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

smallestSum = 0
tempSum = 0

smallestSum = a * x + b * y

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

print(smallestSum)

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

x = X ; y = Y
mn = 1e10
if 2*C-(A+B) >= 0 :
    ans = A * x + B * y
    print(ans)
else :
    for z in range(0,max(X,Y)*2+1,2) :
        if x > 0 and y > 0 :
            ans = A*x + B*y + C*z
            mn = min(mn,ans)
            x -= 1 ; y -= 1
        elif x > 0 and y == 0 :
            ans = A*x + C*z
            mn = min(mn, ans)
            x -= 1
        elif x == 0 and y > 0 :
            ans = B*y + C*z
            mn = min(mn, ans)
            y -= 1
        else :
            ans = C*z
            mn = min(mn, ans)
    print(mn)

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

if a>= c*2 and b >= c*2:
    print(max(x,y)*c*2)

elif a>= c*2 and x>=y :
    print(x*c*2)

elif b >= c*2 and y>=x:
    print(y*c*2)

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

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

ans = a*x+b*y

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

Solution (Python):
A,B,C,X,Y = [int(i) for i in input().split()]
if A + B < C * 2:
    print(A*X + B*Y)
else:
    p1 = min(X,Y) * C * 2 + (X - min(X,Y))*A + (Y - min(X,Y))*B
    p2 = max(X,Y) * C * 2
    print(min(p1, p2))

Solution (Python):
A,B,C,X,Y = (int(X) for X in input().split())
MINPrice = pow(10,9)
for ABP in range(0,2*max(X,Y)+1,2):
    Price = A*max(0,(X-ABP//2))+B*max(0,(Y-ABP//2))+C*ABP
    if Price<=MINPrice:
        MINPrice = Price
print(MINPrice)

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

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

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

single = a*x+b*y
pair_max = 2*c*max(x, y)
pair_min = 2*c*min(x, y) + a*abs(x-y)*(x>y) + b*abs(x-y)*(x<y)

print(min(single, pair_max, pair_min))

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

if X>=Y:ans,Ccnt=C*X*2,X*2
else:ans,Ccnt=C*Y*2,Y*2

for c in range(1,Ccnt//2+1):
	
	temp=(Ccnt-2*c)*C
	if (Ccnt-c*2)//2<Y:
		temp+=(Y-(Ccnt-c*2)//2)*B
	if (Ccnt-c*2)/2<X:
		temp+=(X-(Ccnt-c*2)//2)*A
	
	ans=min(ans,temp)

print(ans)

Solution (Python):
a,b,c,x,y=map(int,input().split())
if x>y:
  a,b=b,a
  x,y=y,x
ans1=0
if a+b>2*c:
  ans1=2*x*c
else:
  ans1=x*a+x*b
y-=x
ans2=10**100
for i in range(y+1):
  tmp=b*i+c*2*(y-i)
  if tmp<ans2:
    ans2=tmp
print(ans1+ans2)

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

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

print(ans)

Solution (Python):


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


n = 10 ** 10
min_a = min_b = min_c = 10**10
max_ab = 0
for ab in range(0, 2*max(X, Y) + 2, 2):
    a = max(X - ab//2, 0)
    b = max(Y - ab//2, 0)
    n = min(n, a*A + b*B + ab*C)

print(n)

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

result = float('inf')
for i in range(0, max(X, Y)+1):
    tmp = C*2*i + max(0, X-i) * A + max(0, Y-i) * B
    if tmp < result:
        result = tmp
print(result)

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

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

print(min(min(a,b),c))

Solution (Python):
def resolve():
    A, B, C, X, Y = list(map(int, input().split()))
    MAX = 2 * max(X,Y)
    ans = 10 ** 14

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

    print(ans)
    return

resolve()

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

if x > y:
    l += (x - y) * a
    p = y
elif x < y:
    l += (y - x) * b
    p = x
else:
    pass
l += p * 2 * c
n = max(x,y) * 2 * c
m = x * a + y * b
print(min(l,n,m))

Solution (Python):
import sys


def main():
    input = sys.stdin.buffer.readline
    a, b, c, x, y = map(int, input().split())
    ans = 0
    if 2 * c < a + b:
        m = min(x, y)
        ans += 2 * c * m
        x -= m
        y -= m
    if 2 * c < a:
        ans += 2 * c * x
        x = 0
    if 2 * c < b:
        ans += 2 * c * y
        y = 0
    ans += a * x + b * y
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

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

anslist=[]

for i in range(0,2*max(X,Y)+1,2):
    ans=C*i
    if X>i//2:
        ans=ans+A*(X-i//2)
    if Y>i//2:
        ans=ans+B*(Y-i//2)
    anslist.append(ans)
print(min(anslist))

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

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

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

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
C *= 2
t,s,P = 0,max(X,Y),1000000000000
while s>=0:
  P = min(P, C*s+A*max(X-s, 0)+B*max(Y-s, 0))
  s -= 1
print(P)

Solution (Python):
def resolve():
    A, B, C, X, Y = [int(i) for i in input().split()]
    
    minA = float("inf")
    for i in range(0, max(X, Y) * 2 + 1, 2):
        sumA = C * i
        sumA += (A * (X - i // 2) if (X - i // 2) > 0 else 0)
        sumA += (B * (Y - i // 2) if (Y - i // 2) > 0 else 0)
        minA = min(minA, sumA)
    print(minA)


resolve()

Solution (Python):




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

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

for i in range(0, max(x, y) + 1):
    c_price = i * 2 * c
    if x - i <= 0:
        a_price = 0
    else:
        a_price = (x - i) * a
    if y - i <= 0:
        b_price = 0
    else:
        b_price = (y - i) * b
    total.append(a_price + b_price + c_price)
print(min(total))

Solution (Python):


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

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

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b,c,x,y = readInts()
c *= 2
if x > y:
    
    
    
    
    ans = min(a*x + b*y, c * x, c*y + a*(x-y))
else:
    ans = min(a*x + b*y, c*y, c*x+b*(y-x))
print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
a = A * X + B * Y
b = C * max(X, Y) * 2
c = A * (X - Y) + 2 * C * Y
d = B * (Y - X) + 2 * C * X
e = max(c, d)
ans = min(a, b, e)
print(ans)

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

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

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

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

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

Price = []

for k in range(min(x, y)+1):
  Price.append((2*c-a-b)*k + a*x + b*y)
Price.append(max(x,y)*2*c)

print(min(Price))

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

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

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

    less = abs(x - y)
    p = a if x > y else b
    if 2 * c < p:
        cnum += 2 * less
        less = 0

    ans = c * cnum + less * p

print(ans)

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

A,B,C,X,Y = list(map(int,input().split()))
cost = A*X+B*Y
if X >= Y:
    maxXY = X
    maxAB = A
else:
    maxXY = Y
    maxAB = B
ans = cost
for xy in range(1,maxXY+1):
    nc =  2*C*xy +max(0,(X-xy))*A+max(0,(Y-xy))*B
    
    if nc < cost: 
        ans = min(ans,nc)
print(ans)

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

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

print(min(ans1, ans2, ans3))

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


print(pmin)

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


print(pmin)

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

Solution (Python):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    a, b, c, x, y = map(int, input().split())
    lim = max(x, y)
    ans = 10**12
    for i in range(lim+1):
        price = a*max(0, x-i) + b*max(0, y-i) + c*2*i
        ans = min(ans, price)
    print(ans)

if __name__ == '__main__':
    main()

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

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

ans=0

if 2*C >= A+B:

    ans = A*X+B*Y
else:
    if 2*C <= A and 2*C <= B:
        if X >= Y:

            ans = C*2*X
            
        elif X < Y:

            ans = C*2*Y
            
    elif 2*C <= A:

        ans = C*2*X + max(0,Y-X)*B
    elif 2*C <= B:

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

            ans = C*2*X + max(0,Y-X)*B
            
        elif X > Y:

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

Solution (Python):
A,B,C,X,Y = map(int,input().split())
ans = 100000000000000000000000000000000000000
for c in range (0,100001):
  price = A*max(0,X-c)+B*max(0,Y-c)+C*2*c
  if price < ans:
    ans = price
print(int(ans))

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

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

res = A*X + B*Y

m = 2 * C * max(X, Y);

sum = C * 2* min_

if(C<=0.5 * A and C <= 0.5 * B):
    sum += 2*C*(max_-min_)

elif(max_==X):
    sum += (max_-min_)*A
else:
    sum += (max_-min_)*B
    
print(min(m,min(res,sum)))

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    a, b, c, x, y = [int(x) for x in input().split()]
    c *= 2
    ans = 0
    if c < a + b:
        z = min(x, y)
        ans += c * z
        x -= z
        y -= z
    if x:
        if c * x < a * x:
            ans += c * x
        else:
            ans += a * x
    if y:
        if c * y < b * y:
            ans += c * y
        else:
            ans += b * y
    print(ans)

t = 1

for case in range(1,t+1):
    ans = solve()


"""

a aa c ca c a b a ab a b c

"""

Solution (Python):
import sys
import math
a,b,c,x,y = map(int,input().split())
ans=0
i=0
j=0
while True:
    if i==x and j==y:
        break
    elif i==x:
        if c*2<b:
            ans+=c*2
        else:
            ans+=b
        j+=1
    elif j==y:
        if c*2<a:
                ans+=c*2
        else:
            ans+=a
        i+=1
    else:
        if c*2<(a+b):
            ans+=c*2
        else:
            ans+=a+b
        i+=1
        j+=1
print(ans)

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

Solution (Python):
a,b,c,x,y=map(int,input().split())
ans=1000000000000000000000000
for i in range(100001):
    tmp=i*2*c+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())



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


a2 = A * X + B * Y


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

print(min(a1, a2, a3))

Solution (Python):

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

Solution (Python):

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

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

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

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

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

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

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

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

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

if X <= Y:
  S = B
  Z = X
  W = Y
else:
  S = A
  Z = Y
  W = X
  
if 2*C > A+B:
  print(A*X+B*Y)

elif 2*C > S:
  print((2*C-S)*Z + S*W)
  
else:
  print(2*C*W)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

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

print(min(p))

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

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

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

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

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

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

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

if x < y:
    print(min(2*c*y, 2*c*x+b*(y-x), a*x+b*y))
else:
    print(min(2*c*x, 2*c*y+a*(x-y), 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(A*(X-Y)+C*Y*2,C*X*2))
    else:
        print(min(B*(Y-X)+C*X*2,C*Y*2))

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

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

price=1000000000
for p in range(0,max(X,Y)*2+1,2):
    q=max(0,X-p//2)
    r=max(0,Y-p//2)
    if price>p*C+q*A+r*B:
        price=p*C+q*A+r*B
print(price)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
ans = None
for ab_count in range(0, max(X, Y) * 2 + 1, 2):
    a_count = max(0, X - ab_count // 2)
    b_count = max(0, Y - ab_count // 2)
    amount = a_count * A + b_count * B + ab_count * C
    if ans is None:
        ans = amount
    else:
        ans = min(ans, amount)
print(ans)

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

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

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

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

Solution (Python):
def LI():return map(int,input().split())
def I(): return input().split()

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

Solution (Python):
def LI():return map(int,input().split())
def I(): return input().split()

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

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

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

ans = 1 << 31

for i in range(max(x,y)+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())

CtoAB1 =0
CtoAB2 =0
AandB =0

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

AandB=A*X+B*Y

print(min(CtoAB1,CtoAB2,AandB))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


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

if __name__ == "__main__":
    main()

Solution (Python):
A,B,C,X,Y=map(int,input().split())
check=[0]*4
check[0]=A*X+B*Y
check[1]=C*max(X,Y)*2
check[2]=C*Y*2+A*(X-Y) if X>Y else float('inf')
check[3]=C*X*2+B*(Y-X) if X<Y else float('inf')
print(min(check))

Solution (Python):

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

patterns = [0] * 4
patterns[0] = A * X + B * Y
patterns[1] = C * max(X, Y) * 2
patterns[2] = C * Y * 2 + A * (X - Y) if X > Y else float('inf')
patterns[3] = C * X * 2 + B * (Y - X) if X < Y else float('inf')

print(min(patterns))

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

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

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