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, d, e = map(int, input().split())
f = c * max(d, e) * 2
g = c * min(d, e) * 2 + (abs(d - e) * a if d > e else abs(d - e) * b)
h = a * d + b * e
print(min(f, g, h))

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

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

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

mini = 1000000000000
for i in range(max(x,y)+1):
	summ = (2*c*i) + (a * max(0,x-i)) + (b * max(0,y-i))
	if summ < mini:
		mini = summ
print(mini)

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

min_cost = 1000000000

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

print(min_cost)

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

min_cost = 1000000000

if X <=Y:
    for i in range(0,2*Y +1,2):
        if 0<=i<=2*X:
            cost = i * C + (X - i//2)*A + (Y - i//2)*B
        elif i <= 2*Y:
            cost = i * C + (Y - i//2)*B
        if cost < min_cost:
            min_cost = cost
elif X >Y:
    for i in range(0,2*X +1,2):
        if 0<=i<=2*Y:
            cost = i * C + (X - i//2)*A + (Y - i//2)*B
        elif i <= 2*X:
            cost = i * C + (X - i//2)*A
        if cost < min_cost:
            min_cost = cost
print(min_cost)

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

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

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

for i in range(x+1):
    n = x - i
    if y >= n:
        pay = a*i + 2*n*c + (y-n)*b
    else:
        pay = a*i + 2*n*c
    if cost > pay:
        cost = pay

for i in range(y+1):
    n = y -i
    if x >= n:
        pay = b*i + 2*n*c + (x-n)*a
    else:
        pay = b*i + 2*n*c
    if cost > pay:
        cost = pay
print(cost)

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


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

print(count)

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

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

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

Solution (Python):
a, b, ab, x, y = map(int, input().split())
if a + b > ab*2:
  ab1 = True
else:
  ab1 = False

if a > ab*2:
  a1 = True
else:
  a1 = False

if b > ab*2:
  b1 = True
else:
  b1 = False

price = 0
if x > y:
  if ab1 is True:
    price += ab*2*y
    if a1 is True:
  	  price += ab*2*(x-y)
    else:
      price += a*(x-y)
  else:
    price += a*x + b*y
else:
  if ab1 is True:
    price += ab*2*x
    if b1 is True:
      price += ab*2*(y-x)
    else:
      price += b*(y-x)
  else:
    price += a*x + b*y
    
print(price)

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

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

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

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

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


cost1 = a*x+b*y


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


cost_ab = min(x,y)*2*c    
if  max(x,y) == x:
    tmp2 = (x-y)*a
else:
    tmp2 = (y-x)*b

cost3 = cost_ab + tmp2

print(min(cost1,cost2,cost3))

Solution (Python):



def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    A, B, C, X, Y = read_h()

    base_cnt = min(X, Y)
    ans = min(A + B, C * 2) * base_cnt + (X - base_cnt) * min(A, C * 2) + \
        (Y - base_cnt) * min(B, C * 2)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):



def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    A, B, C, X, Y = read_h()

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

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

    print(ans)


if __name__ == '__main__':
    main()

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

ans = X * A + Y * B

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

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

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

print(ans)

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

Solution (Python):
row = list(map(int, input().split()))
min_pay = 5000 * 1e+5 * 2
if row[3] > row[4]:
    Z = row[3]
else:
    Z = row[4]
for z in range(2*Z+1):
    if z % 2 == 0:
        x = row[3] - z / 2
        y = row[4] - z / 2 
        if x < 0:
            x = 0
        if y < 0:
            y = 0
        pay = x*row[0] + y*row[1] + z*row[2]
        if pay < min_pay:
            min_pay = pay
            
print(int(min_pay))

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

print(cnta*A+cntb*B+cntc*C)

Solution (Python):
a,b,c,x,y = map(int,input().split())
min_total = a*x + b*y
for ci in range(max(x,y)*2+1):
  ai = max(0,x - ci//2)
  bi = max(0,y - ci//2)
  
  total = ai*a + bi*b + ci*c
  if min_total > total:
    min_total = total    
print(min_total)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
def calc(x, y):
    return A*x+B*y

mi = min(X, Y)
ma = max(X, Y)
print(min(calc(X,Y), calc(X-mi, Y-mi) + C*mi*2, C*ma*2))

Solution (Python):
A, B, C, X, Y = map(int, input().split())
def calc(x, y):
    return A*x+B*y

mi = min(X, Y)
ma = max(X, Y)
print(min(calc(X,Y), calc(X-mi, Y-mi) + C*mi*2, C*ma*2))

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

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

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

cost = []
if x < y:
    cost.append(y*c*2)
    cost.append(c*x*2+(y-x)*b)
else:
    cost.append(x*c*2)
    cost.append(c*y*2+(x-y)*a)

cost.append(x*a+y*b)
    
print(min(cost))

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

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

_1=a*x+b*y

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

print(min(_1,_2,_3)  )

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

min_price = 100000 * 3 * 5000
for pizza_c in range(max(x, y) * 2 + 1):
        pizza_a = max(x - int(pizza_c / 2), 0)
        pizza_b = max(y - int(pizza_c / 2), 0)
        min_price = min(pizza_a * a + pizza_b * b + pizza_c * c, min_price)
print(min_price)

Solution (Python):
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

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

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

else:
    print(X*A+Y*B)

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

total=0
total2=0
if A+B>2*C:
    total+=2*C*min(X,Y)
    if X>Y:
        total+=(X-Y)*A
    else:
        total+=(Y-X)*B
    total2+=2*C*max(X,Y)
else:
    total = X*A+Y*B
    print(total)
    exit()
print(min(total,total2))

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

min_money = float('inf')

for k in range(max(X,Y) + 1):
    i = X - k
    j = Y - k
    sum_momey = 2 * k * C
    if (i > 0):
        sum_momey += i * A
    if (j > 0):
        sum_momey += j * B
    if min_money > sum_momey:
        min_money = sum_momey

print(min_money)

Solution (Python):
a, b, c, x, y = list(map(int, input().split()))
result = [a*x+b*y]

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

result.append(c*2*max(x,y))
print(min(result))

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))
s=min(x,y)
ans.append(min(x,y)*c*2+a*(x-s)+b*(y-s))
print(min(ans))

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

Solution (Python):
A,B,C,X,Y = list(map(int,input().split()))
c = [X,Y]
total = 0
if A+B >= 2*C:
  total += 2*C*(min(c))
  if X > Y:
    if A >= 2*C:
      total += 2*C*(X-Y)
    else:
      total += A*(X-Y)
  else:
    if B >= 2*C:
      total += 2*C*(Y-X)
    else:
      total += B*(Y-X)
else:
  total += A*X + B*Y

print(total)

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

separate = A * X + B * Y
middle = X * 2 * C + B * (Y - X) if min(X, Y) == X else Y * 2 * C + A * (X - Y)
whole = max(X, Y) * 2 * C

print(min(separate, middle, whole))

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
result = 0
hlf = c*2

if a+b < hlf:  
    result = a*x + b*y
else:  
    result = min(x, y)*hlf
    rem = abs(x-y)
    tmp = a*rem if max(x, y) == x else b*rem

    if hlf*rem < tmp:
        tmp = hlf*rem
    result += tmp

print(result)

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

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

v1 = A * X + B * Y

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

v3 = C * 2 * max([X, Y])
print(min([v1, v2, v3]))

Solution (Python):
a = list(map(int, input().split()))
sum = 0

if a[0] / 2 + a[1] / 2 < a[2]:
    for i in range(a[3]):
        sum += a[0]
    for i in range(a[4]):
        sum += a[1]
else:
    if a[3] <= a[4]:
        for i in range(a[3]):
            sum += a[2]*2
        if a[1] < a[2] * 2:
            for i in range(a[4] - a[3]):
                sum += a[1]
        else:
            for i in range(a[4] - a[3]):
                sum += a[2]*2
    else:
        for i in range(a[4]):
            sum += a[2]*2
        if a[0] < a[2] * 2:
            for i in range(a[3] - a[4]):
                sum += a[0]
        else:
            for i in range(a[3] - a[4]):
                sum += a[2]*2
print(sum)

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

ans = 10**9
for i in range(10**6):
    pizza_AB = 2*i*C
    pizza_A = max(X-i,0)*A
    pizza_B = max(Y-i,0)*B
    if ans > pizza_AB+pizza_A+pizza_B:
        ans = pizza_AB+pizza_A+pizza_B

print(ans)

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

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

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

a = 0
b = 0
c = 0

ABcand = min([X, Y])
if A + B >= C * 2:
    c += ABcand * 2
else:
    a += ABcand
    b += ABcand

if X == ABcand:
    res = Y - ABcand
    if B * res >= C * res * 2:
        c += res * 2
    else:
        b += res
else:
    res = X - ABcand
    if A * res >= C * res * 2:
        c += res * 2
    else:
        a += res
print(A*a+B*b+C*c)

Solution (Python):
A,B,C,X,Y = map(int,input().split())
 
ans = float('inf')
for i in range(max(X,Y)+1):
    tmp = C*i*2 + 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())
N=max(X,Y)
pay=0
for i in range(N+1):
    c=i*2
    a=max(0,X-i)
    b=max(0,Y-i)
    if pay==0:
        pay=A*a+B*b+C*c
    else:
        pay=min(pay,A*a+B*b+C*c)
print(pay)

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

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

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

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

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

    print(total)

main()

Solution (Python):
A,B,C,X,Y=map(int,input().split(' '))
ans=-1
for n_ab in range(max(X,Y)+1):
  n_a = max(X-n_ab, 0)
  n_b = max(Y-n_ab, 0)
  p = n_a*A+n_b*B+n_ab*2*C
  ans=p if ans==-1 or p<ans else ans
print(ans)

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

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

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

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

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

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

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

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

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

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

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

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

best = 10**9
for c in range(max(X, Y)*2+1):
    a = X-c
    b = Y-c
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    p = A*a + B*b + C*c*2
    if p < best:
        best = p

print(best)

Solution (Python):
a, b, c, x, y = map(int, input().split())
min_val = 2**30
if x < y:
    tmp = x
    x = y
    y = tmp
    tmp = a
    a = b
    b = tmp

for i in range(x + 1):
    k = (x - i) * 2
    k = 0 if k < 0 else k
    j = y - (k // 2)
    j = 0 if j < 0 else j
    val = i * a + j * b + k * c
    if val < min_val:
        min_val = val
print(min_val)

Solution (Python):










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

for i in range(10**5 + 1):
    
    x = i
    y = i
    a = max(X - i, 0)
    b = max(Y - i, 0)
    cost.append(A * a + B * b + C * 2 * i)
print(min(cost))

Solution (Python):
import sys

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

a = min(A, 2*C)
b = min(B, 2*C)
ab = min(A+B, 2*C)
cost = 0

if ab < (a + b):
  if X == Y:
    print(ab * X)
    sys.exit()
  elif X > Y:
    cost += ab * Y
    if ab <= a:
      cost += ab * (X - Y)
      print(cost)
      sys.exit()
    else:
      cost += a * (X - Y)
      print(cost)
      sys.exit()
  else:       
    cost += ab * X
    if ab <= b:
      cost += ab * (Y - X)
      print(cost)
      sys.exit()
    else:
      cost += b * (Y - X)
      print(cost)
      sys.exit()
else:
  print(a*X + b*Y)
  sys.exit()

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

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

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

totalA1 = A * X
totalA2 = C * X * 2
totalB1 = B * Y
totalB2 = C * Y * 2

totalAB = A * X + B * Y

totalAC = C * Y * 2
if X > Y:
    totalAC += (X - Y) * A

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

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

print(min(totalAB, totalAC, totalCB, totalCC))

Solution (Python):
import sys

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

price = 0
another = sys.maxsize

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

Solution (Python):
A = [int(i) for i in input().split(' ')]
if 2*A[2] < A[0] + A[1]:
  m = min(A[3], A[4])
  print(A[2] * m * 2 + (A[3] - m)*min(A[0],2*A[2]) + (A[4] - m)*min(A[1],2*A[2]) )
else:
  print(A[3] * A[0] + A[4] * A[1])

Solution (Python):
A, B, C, X, Y = [int(x) for x in input().split()]
maxAB = max(X, Y)
min = 2*maxAB*C+1

for i in range(maxAB+1):
    numA = max(X-i, 0)
    numB = max(Y-i, 0)
    value = numA*A+numB*B+2*i*C
    if value < min:
        min = value

print(min)

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


anss = []
for abset in range(max(X,Y)+1):
	anss.append(abset*2*C+max(0,X-abset)*A+max(0,Y-abset)*B)
				
print(min(anss))

Solution (Python):
A, B, C, X, Y = map(int, input().split())
if X >= Y:
	a = X
else:
	a = Y
min = 2*C*a
for i in range(0, a):
	if X-i > 0 and Y-i > 0:
		ans = 2*C*i + (X-i)*A + (Y-i)*B
	elif X-i <= 0 and Y-i>=0:
		ans = 2*C*i + (Y-i)*B
	elif X-i >= 0 and Y-i <= 0:
		ans = 2*C*i + (X-i)*A
	if min > ans:
		min = ans
print(min)

Solution (Python):


import sys

lst = list(map(int, input().split()))

a_value = lst[0]
b_value = lst[1]
c_value = lst[2]
a_number = lst[3]
b_number = lst[4]

value = 0

if a_value + b_value <= c_value * 2:
    value = a_value * a_number + b_value * b_number
    print (value)
else:
    if a_number >= b_number:
        value += c_value * 2 * b_number
        if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:
            value += (a_number - b_number) * c_value * 2
        else:
            value += (a_number - b_number) * a_value

    else:
        value += c_value * 2 * a_number
        if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:
            value += (b_number - a_number) * c_value * 2
        else:
            value += (b_number - a_number) * b_value
    print (value)

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

def r(a, b, c, x, y):
    if x == 0 and y == 0:
        return 0
    if x == 0:
        return min(y*b, 2*y*c)
    if y == 0:
        return min(x*a, 2*x*c)
    if (a + b) / 2 < c:
        return a*x+b*y
    else:
        z = min(x, y) * 2
        x = x - z/2
        y = y - z/2
        return r(a, b, c, x, y) + z*c


print(int(r(A, B, C, X, Y)))

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

strat1 = A*X + B*Y  
strat2 = 2*C*X + abs(Y-X)*B  
strat3 = 2*C*Y + abs(X-Y)*A  
strat4 = 2*C*max(X,Y) 

print min(strat1, strat2, strat3, strat4)

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

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


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

min_price = 1000000000000

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

Solution (Python):

"""
Created on Tue Mar  5 17:16:53 2019

@author: yuta
"""

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

def main(a,b,c,x,y):
    if a + b - 2*c > 0:
    
        set_num_min = min(x,y)
        price_min = set_num_min * 2*c 
        price_min += a * max(0,x-set_num_min) 
        price_min += b * max(0,y-set_num_min) 
    
        set_num_max = max(x,y)
        price_max = set_num_max * 2*c 
        print(min(price_min,price_max))
    else:
        price = a*x + b*y
        print(price)
main(A,B,C,X,Y)

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

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

Solution (Python):

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

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

print(ans)

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

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

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

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

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

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

print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
if X < Y:
    cn = range(Y+1)
    p = X
else:
    cn = range(X+1)
    p = Y
min_price = A*X + B*Y
for i in cn:
    if i <= p:
        price = (A*(X-i)+C*i)+(B*(Y-i)+C*i)
        if min_price > price:
            min_price = price
    else:
        if p == X:
            price = C*i+(B*(Y-i)+C*i)
            if min_price > price:
                min_price = price
        else:
            price = (A*(X-i)+C*i) + C*i
            if min_price > price:
                min_price = price
print(min_price)

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

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

print(min([a1,a2,a3]))

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

Solution (Python):
a, b, c, x, y=map(int,input().split())
ans = max(a,b,2*c)*100000
for i in range(100001):
    if i*2*c + max(0,x-i)*a + max(0,y-i)*b < ans:
        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())
if a+b<=2*c:
    print(a*x+b*y)
else:
    print(min(2*min(x,y)*c+(a*(x-y) if x>y else b*(y-x)),2*max(x,y)*c))

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

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

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

l = a+b-2*c

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

Solution (Python):
A,B,C,X,Y = map(int,input().split(" "))
list = []
list.append(A*X+B*Y)
less = min(X,Y)
if X > Y:
    list.append(2*C*less + A * (X - less))
else:
    list.append(2*C*less + B * (Y - less))
more = max(X,Y)
if X > Y:
    list.append(2*C*more)
else:
    list.append(2*C*more)
print(min(list))

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

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

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

yen = float('inf')
for nc in range(max(x, y) * 2, -2, -2):
    na = max(0, x - nc//2)
    nb = max(0, y - nc//2)
    tmp = na * a + nb * b + nc * c
    if tmp < yen:
        yen = tmp

print(yen)

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

if a > 2*c:
    total += 2 * c * x
    y -= x
    x = 0

if b > 2*c:
    total += 2 * c * y
    x -= y
    y = 0

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

print(total)

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

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

Solution (Python):



import sys
def solveProblem(priceA,priceB,priceABSet,wantA,wantB):
	minPrice = sys.maxsize
	for buyABSet in range(0,200000+1,+2):
		
		alreadyA = buyABSet//2
		alreadyB = buyABSet//2
		moreWantA = wantA-alreadyA
		moreWantB = wantB-alreadyB
		
		
		if moreWantA <=0 :
			getA = 0
		else :
			getA = moreWantA
		
		if moreWantB <= 0:
			getB = 0
		else:
			getB = moreWantB
		needMoney = priceA * getA + priceB * getB + priceABSet * buyABSet
		if needMoney <= minPrice:
			minPrice = needMoney
	answer = minPrice
	return answer

if __name__ == '__main__':
	A,B,C,X,Y = map(int,input().strip().split(' '))
	solution = solveProblem(A,B,C,X,Y)
	print("{}".format(solution))

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