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

i = 0
ans = float('inf')
while i // 2 <= max(x, y):
    price = a * max(0, x - i // 2) + b * max(0, y - i // 2) + c * i
    ans = min(price, ans)
    i += 2

print(ans)

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

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

Solution (Python):
A,B,C,X,Y=map(int,input().split())
L=[]
L.append(A*X+B*Y)
for i in range(min(X,Y)+1):
    L.append(A*X+B*Y-A*i-B*i+2*C*i)
ans=min(L)
if max(X,Y)*2*C<ans:
    ans=max(X,Y)*2*C
print(ans)

Solution (Python):
A,B,C,X,Y=map(int,input().split())
L=[]
L.append(A*X+B*Y)
for i in range(min(X,Y)+1):
    L.append(A*X+B*Y-A*i-B*i+2*C*i)
ans=min(L)
if max(X,Y)*2*C<ans:
    ans=max(X,Y)*2*C
print(ans)

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

if ave > ab:
    amt = ab * min(x, y) * 2
    if x > y:
        if a > ab * 2:
            amt += ab * (x - y) * 2
        else:
            amt += a * (x - y)
    else:
        if b > ab * 2:
            amt += ab * (y - x) * 2
        else:
            amt += b * (y - x)
else:
    amt = a * x + b * y
    
print(amt)

Solution (Python):
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2
ans = 0

if ab >= ave:
    ans += a * x + b * y
else:
    if x > y:
        ans += ab * y * 2
        if a > ab * 2:
            ans += ab * (x - y) * 2
        else:
            ans += a * (x - y)
    else:
        ans += ab * x * 2
        if b > ab * 2:
            ans += ab * (y - x) * 2
        else:
            ans += b * (y - x)
        
print(ans)

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

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

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

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

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

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

Solution (Python):
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2
minxy = min(x, y)
amt = 0

if ave > ab:
    amt += ab * minxy * 2
else:
    amt += (a + b) * minxy
    
if x == minxy:
    if b / 2 > ab:
        amt += ab * (y - minxy) * 2
    else:
        amt += b * (y - minxy)
else:
    if a / 2 > ab:
        amt += ab * (x - minxy) * 2
    else:
        amt += a * (x - minxy)
        
print(amt)

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

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

Solution (Python):
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2
minxy = min(x, y)
ans = 0

if ave > ab:
    ans += 2 * minxy * ab
    if x > y:
        if a < ab * 2:
            ans += (x - minxy) * a
        else:
            ans += (x - minxy) * 2 * ab
    else:
        if b < ab * 2:
            ans += (y - minxy) * b
        else:
            ans += (y - minxy)  * 2 * ab
else:
    ans = a * x + b * y
    
print(ans)

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

if x > y:
    tmp1 = a
    tmp2 = x
    a = b
    b = tmp1
    x = y
    y = tmp2
    
arr = []

arr.append(a*x+b*y)
arr.append(b*y+(2*c-b)*x)
arr.append(2*c*y)

print(min(arr))

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

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

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

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

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

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

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


ans=1000000000000
for k in range(0,100000+1):
  i=x-k
  if i<0:
    i=0
  j=y-k
  if j<0:
    j=0
  price=a*i+b*j+2*c*k
  if price < ans:
    ans = price
    
print(ans)

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


z=max(x,y)

ans=1000000000000
for k in range(0,z+1):
  i=x-k
  if i<0:
    i=0
  j=y-k
  if j<0:
    j=0
  price=a*i+b*j+2*c*k
  if price < ans:
    ans = price
    
print(ans)

Solution (Python):
def main():
    a, b, c, x, y = map(int, input().split())
    res = a * x + b * y
    for n_c in range(2, 2 * max(x, y) + 1, 2):
        xx = x - n_c // 2
        yy = y - n_c // 2
        p = a * max(xx, 0) + b * max(yy, 0) + c * n_c
        res = min(res, p)
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
pr_a, pr_b, pr_c, num_a, num_b = map(int, input().split())

res = 10**10
for num_half in range(max(num_a, num_b)+1):
    rest_a = (lambda x: x if x >= 0 else 0)(num_a - num_half)
    rest_b = (lambda x: x if x >= 0 else 0)(num_b - num_half)
    price = rest_a*pr_a + rest_b * pr_b + num_half * pr_c*2
    res = min(res, price)

print(res)

Solution (Python):


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

for i in range(1000000):
    p = 2 * c * i
    if i < x:
        p += a * (x - int(i))
    if i < y:
        p += b * (y - int(i))
    
    price.append(p)

print(min(price))
    

"""
if (a>c):
    p += c*x*2
    flag = 1

else:
    p += a*x
    flag = 0

if (b>c) :
    if (flag==1):
        p+= (y-int(x/2)) * c
    else:
        p+= c*y*2
else:
    if (flag==1):
        p+= (y-int(x/2)) * c
    else:
        p+= b*y

print(p)

"""

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

Solution (Python):
A,B,H,x,y = map(int,input().split(" "))
money = 0
if A + B <= H * 2:
    money += A * x
    money += B * y
else:
    if x >= y:
        money += (y * H) * 2
        if A <= H * 2:
            money += (x - y) * A
        else:
            money += (x - y) * (H * 2)
    else:
        money += (x * H) * 2
        if B <= H * 2:
            money += (y - x) * B
        else:
            money += (y - x) * (H * 2)
print(money)

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

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

Solution (Python):


"""
purpose
"""


def main() -> None:
    """
    main function
    """
    (A, B, C, X, Y) = map(int, input().split())

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

    print(ans)


if __name__ == "__main__":
    main()

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

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

print(ans)

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


total = 0



same_amount = min(x,y)

x -= same_amount
y -= same_amount


if a+b > 2*c:
    
    total += 2*c*same_amount
else:
    
    total += (a+b)*same_amount


if (x*a + y*b) > (2*(x+y)*c):
    total += (2*(x+y)*c)
else:
    
    total += (x*a + y*b)

print(total)

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

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

a1 = A * X + B * Y

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

ans = min(a1, a2)
print(ans)

Solution (Python):

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

candidate = [0] * 3


candidate[0] = A * X + B * Y


if X < Y: candidate[1] = (2 * C) * X + B * (Y - X)
else: candidate[1] = (2 * C) * Y + A * (X - Y)


candidate[2] = (2 * C) * max((X, Y))

print(min(candidate))

Solution (Python):

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

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

count = a * x + b * y

if x >= y:
	for i in range(x+1):
		if i > y:
			tmp = a * (x-i) + c * (i*2)
		else:
			tmp = a * (x-i) + b * (y-i) + c * (i*2)
		count = min(count, tmp)
else:
	for j in range(y+1):
		if j > x:
			tmp = b * (y-j) + c * (j*2)
		else:
			tmp = a * (x-j) + b * (y-j) + c * (j*2)
		count = min(count,tmp)

print(count)

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

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

Solution (Python):
A, B, C, X, Y = [int(_) for _ in input().split()]
M = max(X, Y)
print(min(2 * C * M, 2 * C * (X + Y - M) + A *
          (M - Y) + B * (M - X), A * X + B * Y))

Solution (Python):
A, B, C, X, Y = [int(_) for _ in input().split()]
ans = A * X + B * Y
for i in range(max(X, Y) + 1):
    cost = 2 * C * i
    if X > i:
        cost += A * (X - i)
    if Y > i:
        cost += B * (Y - i)
    ans = min(ans, cost)
print(ans)

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

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

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

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

minp = A * X + B * Y
for i in range (1, 100001):
    p = 2 * C * i + A * max(0, X - i) + B * max(0, Y - i)
    if p < minp:
        minp = p
print(minp)

Solution (Python):
iA,iB,iC,iX,iY = map(int,input().split())


if iY > iX:
    iX,iY = iY,iX
    iA,iB = iB,iA
print(min(2*iC*iX ,iX*iA+iY*iB, (iA+iB)*iY+2*iC*(iX-iY),2*iC*iY+iA*(iX-iY)))

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

a,b,c,x,y=map(int,input().split())
minxy=min(x,y)
deff=max(x,y)-minxy
if a+b<=2*c:
    print(a*x+b*y)
else:
    half=2*c*minxy
    if max(x,y)==x and a<=2*c:
        print(half+deff*a)
    elif max(x,y)==y and b<=2*c:
        print(half+deff*b)
    else:
        print(half+deff*2*c)

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

a,b,c,x,y=map(int,input().split())
minxy=min(x,y)
deff=max(x,y)-minxy
if a+b<=2*c:
    print(a*x+b*y)
else:
    half=2*c*minxy
    if max(x,y)==x and a<=2*c:
        print(half+deff*a)
    elif max(x,y)==y and b<=2*c:
        print(half+deff*b)
    else:
        print(half+deff*2*c)

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

a,b,c,x,y=map(int,input().split())
minxy=min(x,y)
deff=max(x,y)-minxy
if a+b<=2*c:
    print(a*x+b*y)
else:
    half=2*c*minxy
    if max(x,y)==x and a<=2*c:
        print(half+deff*a)
    elif max(x,y)==y and b<=2*c:
        print(half+deff*b)
    else:
        print(half+deff*2*c)

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

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

cost = 0

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

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

print(cost)

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

miab = min(X, Y)
c1 = A * X + B * Y
c2 = C * miab * 2 + A * (X - miab) + B * (Y - miab)
c3 = C * max(X, Y) * 2

print(min(c1, c2, c3))

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

Solution (Python):
a,b,ab,x,y=map(int,input().split())
if(a<b):
    mymax=[b,y]
    mymin=[a,x]
else:
    mymax=[a,x]
    mymin=[b,y]


if( 2*ab <= mymin[0]):
    print( 2*ab*max([x,y]) )
elif(2*ab <=mymax[0]):
    if(max([x,y]) ==mymax[1]):
        nedan=ab*2*mymax[1]
    else:
        nedan=ab*2*min([x,y]) + (mymin[1]-mymax[1])*mymin[0]
    print(nedan)
elif(2*ab <=a+b):
    if(mymax[1]==max([x,y])):
        print(2*ab*mymin[1] + mymax[0]*(mymax[1]-mymin[1]))
    else:
        print(2*ab*mymax[1] + mymin[0]*(mymin[1] - mymax[1]) )
else:
    print(a*x+b*y)

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

p = A+B
q = 2*C
z = min(X,Y)
r = abs(X-Y)
if p <= q :
    ans = A*X+B*Y
else :
    ans = q*z
    if z == Y :
        if A <= 2*C :
            ans += A*r
        else :
            ans += q*r
    else :
        if B <= 2*C :
            ans += B*r
        else :
            ans += q*r
print(ans)

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

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

print(ans)

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

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

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):
    XRE=max(X-i//2,0)
    YRE=max(0,Y-i//2)

    if ANS>i*C+XRE*A+YRE*B:
        ANS=i*C+XRE*A+YRE*B

    

print(ANS)

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

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

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

abonly = a*x + b*y

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

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

print(min(abonly, abandc, conly))

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

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

z = min(x,y)
w = abs(x - y)
count = 0

if 2 * c > a + b:
    count += (a + b) * z
else:
    count += 2 * c * z

if x > y:
    if 2 * c < a:
        count += 2 * c * w
    else:
        count += a * w
elif x < y:
    if 2 * c < b:
        count += 2 * c * w
    else:
        count += b * w

print(count)

Solution (Python):
a,b,c,x,y = [int(i) for i in input().split()]
P = [0, x, y]
while P[1]>0 or P[2]>0:
  if P[1]>0 and P[2]>0 and a+b>c*2:
    P[0] += c*2
    P[1] -= 1
    P[2] -= 1
  elif P[1]>0 and P[2]>0 and c*2>a+b:
    P[0] += a+b
    P[1] -= 1
    P[2] -= 1
  elif P[1]>0 and a>c*2:
    P[0] += c*2
    P[1] -= 1
    P[2] -= 1
  elif P[2]>0 and b>c*2:
    P[0] += c*2
    P[1] -= 1
    P[2] -= 1
  elif P[1]>0:
    P[0] += a
    P[1] -= 1
  elif P[2]>0:
    P[0] += b
    P[2] -= 1
print(P[0])

Solution (Python):
def run(A, B, C, X, Y):
    '''
    以下のうち一番安い金額を出力する
    - A, Bピザ両方単独で買う
    - ABピザで少ない方全部まで買い、残りは単独で買う
    - ABピザで全部買う
    '''
    max_XY = max(X, Y)
    min_XY = min(X, Y)
    diff = max_XY - min_XY
    if X > Y:
        D = A
    else:
        D = B
    ret = A*X + B*Y
    ret = min(ret, min_XY*C*2 + diff*D)
    ret = min(ret, max_XY*C*2)
    return ret


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


if __name__ == '__main__':
    main()

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

ans = 0

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


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

print(ans)

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

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

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

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

print(min(ans1, ans2, ans3))

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


    ness_cost = 2*X*C
    add_cost_min = (Y-X)*min(2*C,B)
    total_cost = ness_cost + add_cost_min
    print(total_cost)
  elif X >= Y:
    ness_cost = 2*Y*C
    add_cost_min = (X-Y)*min(2*C,A)
    total_cost = ness_cost + add_cost_min
    print(total_cost)

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

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

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

ans = []

for z in range(0,max(X+1, Y+1)*2, 2):
    x = max(X - z//2, 0)
    y = max(Y - z//2, 0)
    ans.append((A * x) + (B * y) + (C * z))

print(min(ans))

Solution (Python):

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

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

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

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

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

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

ans1 = A*X + B*Y
ans2 = C*max(X,Y)*2

ans = C*MIN*2
X -= MIN
Y -= MIN
ans += A*X + B*Y

print(min([ans,ans1,ans2]))

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

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

pair = min(x,y)
cost = 0

if a + b > 2 * c:
    cost = 2 * c * pair
else:
    cost = (a + b) * pair

if (x - pair) > (y - pair):
    if a > 2 * c:
        cost = cost + 2 * c * (x - pair)
    else:
        cost = cost + a * (x - pair)

else:
    if b > 2 * c:
        cost = cost + 2 * c * (y - pair)
    else:
        cost = cost + b * (y - pair)

print(cost)

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

pair = min(x,y)
cost = 0

if a + b > 2 * c:
    cost = 2 * c * pair
else:
    cost = (a + b) * pair

if (x - pair) > (y - pair):
    if a > 2 * c:
        cost = cost + 2 * c * (x - pair)
    else:
        cost = cost + a * (x - pair)

else:
    if b > 2 * c:
        cost = cost + 2 * c * (y - pair)
    else:
        cost = cost + b * (y - pair)

print(cost)

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

Solution (Python):

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

prices = []
for c in range(0,max([X,Y])*2+1,2):
    a = max([X - c//2, 0])
    b = max([Y - c//2, 0])
    prices.append(A*a+B*b+C*c)

print(min(prices))

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

ans1 = a*x + b*y

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

ans3 = 2*c*max(x, y)
print(min(ans1, ans2, ans3))

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

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

print miny

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

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

m = a*x+b*y

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
price = A * X + B * Y
ma, mi = (X, Y) if X > Y else (Y, X)
ma_p, mi_p = (A, B) if X > Y else (B, A)

for i in range(1, ma+1):
    if i <= mi:
        temp = price - (ma_p + mi_p) + 2 * C
        if price > temp:
            price = temp
    else:
        temp = price - ma_p + 2 * C
        if price > temp:
            price = temp

print(price)

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

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


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

    print(min(ans1, ans2))
else:
    ans = a * x + b * y 
    print(ans)

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

mi=min(x,y)

pr=0

if c*2<=a+b :
    pr+=c*2*mi
    x-=mi
    y-=mi



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

if c*2<b :
    pr+=c*2*y
else :
    pr+=b*y

print(pr)

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

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

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

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

ans = 0

if C <= A:
    ans += X * C
    Y -= X
    X = 0

if Y > 0 and C <= B:
    ans += Y * C
    X -= Y
    Y = 0

if X > 0 and Y > 0 and C <= A + B:
    cnt = min(X, Y)
    ans += cnt * C
    X -= cnt
    Y -= cnt

if X > 0:
    ans += X * A
    X = 0

if Y > 0:
    ans += Y * B
    Y = 0

print(ans)

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

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

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

cheapest=price_1
if price_2<cheapest:
	cheapest=price_2
if price_3<cheapest:
	cheapest=price_3
print(cheapest)

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

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

print(ans)

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

if A >= C and B >= C:
    ans += max(X, Y) * C
elif C >= A+B:
    ans += A*X + B*Y
elif C >= max(A,B):
    if X>Y:
        ans += Y*C + (X-Y)*A
    else:
        ans += X*C + (Y-X)*B
else:
    if A >= C:
        ans += X*C
        if Y-X>0:
            ans+=(Y-X)*B
    else:
        ans += Y*C
        if X-Y>0:
            ans+=(X-Y)*A

print(ans)

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

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

total_ab = a * x + b * y
total_c = c * 2 * max(xy)
if x > y:
    total_abc = c * 2 * min(xy) + a * (x-y)
else:
    total_abc = c * 2 * min(xy) + b * (y-x)

total = [total_ab, total_c, total_abc]
print(min(total))

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

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

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

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

if  m==x:
    mm=a
    nn=b
else:
    mm=b
    nn=a

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

Solution (Python):

from math import ceil

A,B,AB,x,y = list(map(int,input().split()))
p = []
for i in range(0,max(x,y)*2+1,2):
    ab = i
    a = max(0,ceil(x - (1/2)*i))
    b = max(0,ceil(y - (1/2)*i))
    p.append(A*a+B*b+AB*ab)
print(min(p))

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

ans = a*x+b*y

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

print(ans)

Solution (Python):
A,B,AB,AX,BY = map(int,input().split())

a = min(A+B, 2*AB)
if AX <= BY:
    ans = a * AX + (BY - AX) * min(B, 2*AB)
else:
    ans = a * BY + (AX - BY) * min(A, 2*AB)
print(ans)

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

ans = []

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

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

if X > Y:
    ans.append(C*2*Y + A*(X-Y))

else:
    ans.append(C*2*X + B*(Y-X))

print(min(ans))

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

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

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

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