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())
cost=[]
cm=0
while cm<=2*max(x,y):
    am=x-cm//2    
    bm=y-cm//2
    if am>=0 and bm>=0: cost.append(am*a+bm*b+cm*c)
    elif am>=0 and bm<=0: cost.append(am*a+cm*c)
    elif am<=0 and bm>=0: cost.append(bm*b+cm*c)
    elif am<=0 and bm<=0: cost.append(cm*c)
    cm+=2
print(min(cost))

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

Solution (Python):
a,b,c,x,y = map(int,input().split())
if x >y:
    mini = [b,y]
    maxi = [a,x]
else:
    maxi = [b,y]
    mini = [a,x]

cost = 0
if a+b > 2*c:
    cost += c*mini[1]*2
    dif = maxi[1]-mini[1]
    if dif*maxi[0] > c*2*dif:
        cost += c*2*dif
    else:
        cost += dif * maxi[0]
else :
    cost += mini[0]*mini[1] + maxi[0]*maxi[1]

print(cost)

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

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

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

result = 5000*5000*200000
ab = 0
while(x >= 0):
    tmp = x * a + y * b + ab*c
    if(result > tmp):
        result = tmp
    x -= 1
    if(y > 0):
        y -= 1
    ab += 2

print(result)

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

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

min = X if X < Y else Y
max = X if X > Y else Y
sub = X - Y

if A+B > 2*C:
    ch = 2*C
else:
    ch = A+B

m = ch * min

if sub > 0:
    m += sub * A
else:
    m += sub * B * (-1)
    
m_ = ch * max

if m_ > m:
    print(m)
else:
    print(m_)

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

cost = 0

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

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

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

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

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

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

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

result = a * x + b * y

mx = max([x, y])

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

    if result > tmp:
        result = tmp

print(result)

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

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


A, B, C, X, Y = readnums()

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

print(ans)

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

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

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

answer = 10**18
for c in range(10**5+1):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a,0)*A
  cost += max(b,0)*B
  if answer > cost:
    answer = cost
print(answer)

Solution (Python):
a,b,c,x,y = map(int,input().split())
A_B = a*x+b*y
AB = 2*c*max(x,y)
A_AB = 10**11
AB_B = 10**11
if x-y > 0:
  A_AB = a*(x-y)+2*c*y
if y-x > 0:
  AB_B = 2*c*x+b*(y-x)

ans = min(A_B,A_AB,AB_B,AB)
print(ans)

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

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

  min_cost = 2 * (10 ** 5) * max(A, B, C)

  for i in range(max(X, Y) + 1):
    num_c = 2 * (max(X, Y) - i)
    num_b = max(0, Y - num_c // 2)
    num_a = max(0, X - num_c // 2)
    total = A * num_a + B * num_b + C * num_c
    min_cost = min(total, min_cost)

  print(min_cost)

if __name__ == "__main__":
    main()

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

  min_cost = 2 * (10 ** 5) * max(A, B, C)

  for i in range(max(X, Y) + 1):
    num_c = 2 * (max(X, Y) - i)
    num_b = max(0, min(Y - num_c // 2, i))
    num_a = max(0, min(X - num_c // 2, i))
    total = A * num_a + B * num_b + C * num_c
    min_cost = min(total, min_cost)

  print(min_cost)

if __name__ == "__main__":
    main()

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

z = max(X,Y)*2

act_list = []
for i in range(0,z+1,2):
    x = int(X - i*0.5)
    y = int(Y - i*0.5)
    
    if x <= 0:
        x = 0
    if y <= 0:
        y = 0
    act = x * A + y * B + i * C
    act_list.append(act)

print(min(act_list))

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

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

ans = [0,0,0]
ans[0] = a*x + b*y
ans[1] = max(x,y)*2*c

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

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

l = a * x + b * y
m = c * max(x, y) * 2

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

ans = min(l, min(m, n))
print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
"""
Cを2k枚買う
"""

ans = 10 ** 10
k = 0
while True:
    money = C * k
    money += A * max(0, X - k // 2) + B * max(0, Y - k // 2)
    
    ans = min(ans, money)
    if k // 2 >= max(X, Y):
        break
    k += 2
print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
"""
Cを2k枚買う
"""

ans = 10 ** 10
k = 0
while True:
    money = C * k
    money += A * max(0, X - k // 2) + B * max(0, Y - k // 2)
    
    ans = min(ans, money)
    if k // 2 >= max(X, Y):
        break
    k += 2
print(ans)

Solution (Python):


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





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

Solution (Python):


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

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

print(ans)

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

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

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

ans = 100000000000
if X > Y:
    for n_a in range(X+1):
        n_c = 2 * (X - n_a)
        n_b = Y - (n_c // 2)
        if n_b < 0:
            n_b = 0
        temp = A * n_a + B * n_b + C * n_c
        if ans > temp:
            ans = temp
    print(ans)
    exit()
else:
    for n_b in range(Y+1):
        n_c = 2 * (Y - n_b)
        n_a = X - n_c // 2
        if n_a < 0:
            n_a = 0
        temp = A * n_a + B * n_b + C * n_c
        if ans > temp:
            ans = temp
    print(ans)
    exit()

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

base = a * x + b * y

if x < y:
    t = y
else:
    t = x
    
for i in range(t+1):
    money = a * max(0, x - i) + b * max(0, y - i) + 2 * c * i 
    if money < base:
        base = money

print(base)

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

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

ans = 0

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

print(ans)

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

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

print(ans)

Solution (Python):

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

ans = 0
while min(x,y) != 0:
    if min(x, y) == x:
        ans += x*min(a+b, 2*c)
        y -= x
        x = 0
    elif min(x, y) == y:
        ans += y*min(a+b, 2*c)
        x = x - y
        y = 0
        
if x == 0:
    ans += y*min(b, 2*c)
elif y == 0:
    ans += x*min(a, 2*c)
    
print(ans)

Solution (Python):


def main():
    A, B, C, X, Y = map(int, open(0).read().split())
    
    S = []
    for i in range(0, 2*max(X, Y)+1):
        S.append(A*max(0, X - i//2) + B*max(0, Y - i//2) + C*i)
    print(min(S))

main()

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



v1 = max(x*2,y*2)*c
v2 = a*x+b*y
v3=120000*100000
for i in range(max(x,y)+1):
    c_sum = c*2*(i)
    if x > i:
        c_sum += a*(x-i)
    if y > i:
        c_sum += b*(y-i)
    if c_sum < v3:
        v3 = c_sum
    

 
print(min(v1,v2,v3))

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

Solution (Python):



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

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

print(ans)

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





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

print(min(ans1,ans2,ans3,ans4))

Solution (Python):



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


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

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

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

print(ans)

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

ans = 10**18

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

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

value = a+b
values = c*2

ans = 0

if value <= values:
    ans += a*x + b*y
    print(ans)
    exit()

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

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

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

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

print(Sum)

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

print(ans)

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

v1 = (C * 2) * max(X, Y)
v2 = (C * 2) * min(X, Y)
if X > Y:
    v2 += (X - Y) * A
else:
    v2 += (Y - X) * B
v3 = (A * X) + (B * Y)

print(min(v1, v2, v3))

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

if A+B > 2*C:
    m = C*min(X, Y)*2
    if X >= Y:
        rem = X-Y
        tmp = min(A*rem, C*2*rem)
    else:
        rem = Y-X
        tmp = min(B*rem, C*2*rem)
    print(m+tmp)
else:
    AX = A * X
    BY = B * Y
    print(AX+BY)

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

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
value = float('inf')
D = max(X,Y)
for i in range(D+1):
  E = max((X-i)*A, 0)
  F = max((Y-i)*B, 0)
  valueX = 2*i*C+E+F
  if valueX < value:
    value  = valueX
print(str(value))

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

if X < Y:
    temp = A
    A = B
    B = temp
    temp = X
    X = Y
    Y = temp


lower_price = 0


for i in range(0, X + 1, 1):
    
    price_a = A * i + C * 2 * (X - i)
    price_b = 0
    
    if X - i < Y:
        price_b = B * (Y - (X - i))
    price = price_a + price_b
    if lower_price == 0 or price < lower_price:
        lower_price = price

print(lower_price)

Solution (Python):
import numpy as np
def f(a, b, c, x, y):
    Min = np.inf
    for use_c in range(max(x, y) * 2 + 1):
        price = use_c * c + max(0, x - use_c // 2) * a + max(0, y - use_c // 2) * b
        if price < Min:
            Min = price
    print(Min)

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

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

ab = max(x, y) * 2 * c
a_b = a * x + b * y
if x >= y:
    ab_a_b = y*2*c + (x-y)*a
else:
    ab_a_b = x*2*c + (y-x)*b

print(min(ab, a_b, ab_a_b))

Solution (Python):




  




      





      

  
if __name__ == "__main__":
  A, B, C, X, Y = [int(item) for item in input().split()]

  min_cost = None
  for Nc in range(0, max(X, Y)*2+1):
    Na = max(0, X - Nc//2)
    Nb = max(0, Y - Nc//2)
    
    
    cost = Na*A + Nb*B + Nc*C
    if not min_cost:
      min_cost = Na*A + Nb*B + Nc*C
    else:
      min_cost = min(cost, min_cost)

  print(min_cost)

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

Solution (Python):
A,B,C,X,Y = map(int,input().split())
achete_A = 0
achete_B = 0
price = 0
C = 2 * C 
while achete_A < X and achete_B < Y:
    if A+B <= C:
        achete_A += 1
        achete_B += 1
        price += (A+B)
    else:
        achete_A += 1
        achete_B += 1
        price += C
if achete_A < X :
    while achete_A < X:
        if A < C:
            achete_A += 1
            price += A
        else:
            achete_A += 1
            price += C
elif achete_B < Y:
    while achete_B < Y:
        if B < C:
            achete_B += 1
            price += B
        else:
            achete_B += 1
            price += C
print(price)

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

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

for i in range(0, max(2*x + 1, 2*y + 1), 2):
    price_new = int(max(a * (x - i/2), 0) + max(b * (y - i/2), 0) + c * i)
    if price > price_new:
        price = price_new
print(price)

Solution (Python):

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

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

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

A = []

A.append(a * x + b * y)

if x > y:
    A.append(2 * c * y + (x - y) * a)
    A.append(2 * c * x)
else:
    A.append(2 * c * x + (y - x) * b)
    A.append(2 * c * y)

print(min(A))

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

a,b,c,x,y = map(int,input().split())
"""
AとBのみ
"""
cost = x*a + y*b
"""
ABと個数あわせ
"""
cost2 = c*2*min(x,y)
if x>y:
    cost2 += (x-y)*a
else:
    cost2 += (y-x)*b
"""
ABのみ
"""
cost3 = c*2*max(x,y)
ans = min(cost,cost2)
ans = min(ans,cost3)
print(ans)

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

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

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

Solution (Python):
pa, pb, pab, na, nb = map(int, input().split())

'''
1. そのまま
2. 少ない方全てをabで

3. abいっぱいで余らせる
'''

ans1 = pa * na + pb * nb
ans2 = pab * min(na, nb) * 2 + (pa if(na > nb) else pb) * abs(na - nb)
ans3 = pab * max(na, nb) * 2

print(min(ans1, ans2, ans3))

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



min_val = 0

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

print(min_val)

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

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

print(ans)

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


ans = A * X + B * Y


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

print(ans)

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

ans = a*x + b*y
for i in range(100001):
    m = 2*c*i + max([0,x-i])*a +max([0,y-i])*b
    if ans > m:
        ans = m
print(ans)

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

pizza = {X : A, Y : B}
ans = 0

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

print(ans)

Solution (Python):

def main():
    A, B, C, X, Y = map(int, input().split())
    M1 = A*X + B*Y
    M2 = C*2*min(X, Y) + (Y >= X) * (Y - X) * B + (X > Y) * (X - Y) * A
    M3 = C*2*max(X, Y)
    ans = min(M1, M2, M3)
    print(ans)


if __name__ == "__main__":
    main()

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

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

ans = 0

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

print (ans)

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

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

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

cmax=max(x,y)*2
zmin=(a+b)*10**5
for nc in range(0,cmax+1,2):
    na=max(x-nc//2,0)
    nb=max(y-nc//2,0)
    z=a*na+b*nb+c*nc
    zmin=min(zmin,z)
    
print(zmin)

Solution (Python):



A, B, C, X, Y = map(int, input().split())
a, b = X, Y
est = []


esth = C * min(X, Y) * 2
a -= min(X,Y)
b -= min(X,Y)
esth += A * a + B * b
est.append(esth)


a, b = X, Y
estah = C * max(X, Y) * 2
est.append(estah)


a, b = X, Y
estfa = A * a + B * b
est.append(estfa)

print(min(est))

Solution (Python):
n = list(map(int,input().split()))
price = []


for i in range(max(n[3], n[4]) + 1):
    temp = 2 * i * n[2]
    if n[3] - i > 0:
        temp += (n[3] - i) * n[0]
    if n[4] - i > 0:
        temp += (n[4] - i) * n[1]

    
    price.append(temp)

print(min(price))

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

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

Solution (Python):


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

    i = min(x, y)
    if ab < a + b:
        pay = ab * i
    else:
        pay = a * i + b * i
    x -= i
    y -= i

    if x != 0:
        if ab < a:
            pay += ab * x
        else:
            pay += a * x
    elif y != 0:
        if ab < b:
            pay += ab * y
        else:
            pay += b * y

    print(pay)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    A, B, C, X, Y = map(int, input().split())
    
    if A + B <= 2*C:
        print(A*X+B*Y)
    
    elif A + B > 2*C:
        cost = 0
        mi = min(X, Y)
        cost += 2*C*mi
        X -= mi
        Y -= mi
        
        if X > 0 and Y == 0:
            if A <= 2*C:
                cost += A*X
            else:
                cost += 2*C*X
        else:
            if B <= 2*C:
                cost += B*Y
            else:
                cost += 2*C*Y
        print(cost)
if __name__ == "__main__":
    main()

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

if X >= Y:
    x=X ; y=Y ; a=A ; b=B
else:
    x=Y ; y=X ; a=B ; b=A
    
if 2*c < a+b:
    ans += 2*c*y
    if x!=y:
        if 2*c < a:
            ans += 2*c*(x-y)
        else:
            ans += a*(x-y)
else:
    ans += a*x + b*y
    
print(ans)

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

    k = 0
    ans = A * X + B * Y
    while True:
        ans = min(
            ans,
            AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B
        )

        if k >= M: break
        k += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
s=list(map(int,input().split()))
a=0
if s[0]+s[1]>=2*s[2]:
  b=min(s[3],s[4])
  a+=(b*s[2]*2)
  s[3]-=b
  s[4]-=b
  if s[3]==0:
    if s[1]>=2*s[2]:
      a+=2*s[2]*s[4]
    else:
      a+=s[1]*s[4]
  else:
    if s[0]>=2*s[2]:
      a+=2*s[2]*s[3]
    else:
      a+=s[0]*s[3]
else:
  if s[0]>=2*s[2]:
    a+=2*s[2]*s[3]
    a+=s[1]*s[4]
  else:
    if s[1]>=2*s[2]:
      a+=2*s[2]*s[4]
      a+=s[0]*s[3]
    else:
      a+=s[0]*s[3]
      a+=s[1]*s[4]
print(a)

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

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

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

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

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

print(ans)

Solution (Python):
import numpy as np
import sys

input = sys.stdin.readline

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


ans = A*X+B*Y
acnt = X
bcnt = Y

for i in range(max(X,Y)):
    tmp = ans

    if acnt > 0:
        acnt-=1
        tmp -= A
    if bcnt > 0:
        bcnt-=1
        tmp -= B

    ans =min(ans, tmp + C*2)

print(ans)

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

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

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

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

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

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

Solution (Python):
import sys
input=sys.stdin.readline
a,b,c,x,y=map(int,input().split())
money1=a*x+b*y
money2=min(x,y)*2*c+(x-min(x,y))*a+(y-min(x,y))*b
money3=max(x,y)*c*2
print(min(money1,money2,money3))

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





def main():
    a, b, c, x, y = map(int, input().split())
    case1 = a * x + b * y
    if x - y > 0:
        case2 = c * 2 * y + a * (x - y)
    else:
        case2 = c * 2 * y
    if y - x > 0:
        case3 = c * 2 * x + b * (y - x)
    else:
        case3 = c * 2 * x
    print(min(case1, case2, case3))


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, X, Y = MAP()

ans = INF

ma = max(X, Y)
t = ma * C * 2
ans = A * X + B * Y


mi = min(X, Y)
mi_X = X - mi
mi_Y = Y - mi
tmp = mi_X * A + mi_Y * B + C * mi * 2
ans = min(ans, tmp, t)
print(ans)
exit()



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

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

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

    else:
        p2 = minp * 2 * c + (max(x, y) - minp) * b
    p3 = max(x, y) * 2 * c
    print(min(p1, p2, p3))

resolve()

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

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  


A, B, C, X, Y = read_ints()


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

if X:
    c2 = min(A, 2 * C) * X
elif Y:
    c2 = min(B, 2 * C) * Y
else:
    c2 = 0

print(c1 + c2)