Problem:
 Score : 300 points    Problem Statement "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.      Constraints  1 ≤ A, B, C ≤ 5000  1 ≤ X, Y ≤ 10^5  All values in input are integers.         Input Input is given from Standard Input in the following format:  A  B  C  X  Y       Output Print the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.        Sample Input 1 1500 2000 1600 3 2      Sample Output 1 7900  It is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.       Sample Input 2 1500 2000 1900 3 2      Sample Output 2 8500  It is optimal to directly buy three A-pizzas and two B-pizzas.       Sample Input 3 1500 2000 500 90000 100000      Sample Output 3 100000000  It is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.

Solution (Python):
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


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

if A + B < 2 * C:
    print(A * X + B * Y)
    exit()
p = min(X, Y) * 2 * C
n = max(X - Y, Y - X)
if X < Y:
    p += min(2 * C * n, n * B)
else:
    p += min(2 * C * n, n * A)
print(p)

Solution (Python):
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


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

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

Solution (Python):
import numpy
A, B, C, X, Y = map(int, raw_input().split())
min_idx = numpy.argmin([X, Y])
max_idx = numpy.argmax([X, Y])
cost = 0
if A + B > 2 * C:
    cost += 2 * C * min(X, Y)
else:
    cost += (A + B) * min(X, Y)
if [A, B][max_idx] > 2 * C:
    cost += 2 * C * (max(X, Y) - min(X, Y))
else:
    cost += [A, B][max_idx] * (max(X, Y) - min(X, Y))
print cost

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

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

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

Solution (Python):


if __name__=='__main__':
    a, b, c, x, y = list(map(int, input().split()))
    half = c/2
    pizza = 0

    if a + b < 2*c:
        pizza = a*x + b*y
    else:
        m = min(x, y)
        n = max(x, y)
        pizza = 2*c*m

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

    print(pizza)

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

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

Solution (Python):
A, B, C, X, Y = list(map(int, input().split(' ')))
x = X
y = Y
ans = 0
flag = True
if X > Y:
    flag = False
if A+B >= 2*C:
    if flag:
        ans += X * 2*C
        x -= X
        y -= X
    else:
        ans += Y * 2*C
        x -= Y
        y -= Y

ans += x*min(A, 2*C)
ans += y*min(B, 2*C)

print(ans)

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

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

Solution (Python):
A, B, C, X, Y = list(map(int, input().strip().split()))
costmin = 5e9
for i in range(100001):
	cost = 0
	cost += i*C*2
	if X > i:
		cost += A*(X-i)
	if Y > i:
		cost += B*(Y-i)
	if cost < costmin:
		costmin = cost
print(costmin)

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

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

print(min(p))

Solution (Python):
def main():
    a,b,c,x,y = [int(i) for i in input().split()]
    ans = 1 << 32
    if x < y:
        tmp = 2*x*c
        tmp += (y-x)*b
        ans = min(tmp,ans)
    else:
        tmp = 2*y*c
        tmp += (x-y)*a
        ans = min(tmp,ans)
    if a//2+b//2 < c:
        ans = x*a+ y*b
    ans=min(ans,2*max(x,y)*c)
    print(ans)

if __name__ == '__main__':
    main()

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


sum1 = 0
sum1 = A * X + B * Y

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

sum3 = 0
sum3 = C * max(X, Y) * 2

print(min(sum1, sum2, sum3))

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 = list(map(int, input().split()))
C = 2 * C

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

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

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

Solution (Python):
def inpl(): return [int(i) for i in input().split()]

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

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

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

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

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

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

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

a_sum = a * x
b_sum = b * y
c_sum = c * (x+y)
price = 0

if a_sum + b_sum > c_sum:
    num = min(x, y)
    price += num * c * 2
    x -= num
    y -= num
    if x > 0:
        if a < c * 2:
            price += a * x
        else:
            price += c * 2 * x
    if y > 0:
        if b < c * 2:
            price += b * y
        else:
            price += c * 2 * y
else:
    price += a*x + b*y
print(price)

Solution (Python):
f = lambda: map(int,input().split())

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

Solution (Python):
a,b,c,x,y = list(map(int,input().split()))
dic = {a:x,b:y}
if 2*c >= a+b:print(a*x+b*y)
elif 2*c >= max(a,b):print(a*x+b*y-min(x,y)*(a+b-2*c))
elif 2*c >= min(a,b) and dic[min(a,b)]>=float(x+y)/2:print(a*x+b*y-min(x,y)*(a+b-2*c))
else:print(max(x,y)*2*c)

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

print(money)

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

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

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

Solution (Python):
N = list(map(int,input().split(" ")))
"""
for i in range(0,X+Y+1):
    for j in range(0,X+1):
        for k in range(0,Y+1):
            A2 = i/2
            B2 = i/2
            if A2+j == X and B2+k == Y:
                print(A*j+B*k+C*i)

"""
C = 0
ABC = N[0:3]
if ABC[2] != max(ABC) and abs(min(ABC) - ABC[2]) < abs(max(ABC) - ABC[2]):
    R = []
    AB = N[3]+N[4]+(abs(N[3]-N[4]))
    for i in range(AB+1):
        C=0
        A = i/2
        B = i/2
        C+=ABC[2]*i
        if A % 1 == 0.0 and B % 1 == 0.0:
            if N[3] > int(A) and (N[3]-A)*ABC[0] >= 0:
                C+=(N[3]-int(A))*ABC[0]
                A+=N[3] - int(A)
            if N[4] > int(B) and (N[4]-B)*ABC[1] >= 0:
                C+=(N[4]-int(B))*ABC[1]
                B+=N[4] - int(B)
            if A >= N[3] and B >= N[4]:
                R.append(C)
    print(int(min(R)))
else:
    print(ABC[0]*N[3]+ABC[1]*N[4])

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

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

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

    if a > 0:
        if A > 2*C:
            c += 2*a
            a = 0
    elif b > 0:
        if B > 2*C:
            c += 2*b
            b = 0

print(a*A + b*B + c*C)

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

ABcheap=min(C*2,A+B)
Acheap=min(A,C*2)
Bcheap=min(B,C*2)
answer=0

while(True):
  if(X>=1 and Y>=1):
    answer+=ABcheap
    X-=1
    Y-=1
  elif(X>=1 and Y==0):
    answer+=Acheap
    X-=1
  elif(X==0 and Y>=1):
    answer+=Bcheap
    Y-=1
  else:
    print(answer)
    exit()

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

min_price = 10000000000000000000000000001

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

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

ans1 = a*x + b*y

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

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

Solution (Python):
from sys import stdin, stdout


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

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

stdout.write(str(ans))

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

extra_pizza=max(X,Y)
surplus=max(X,Y)-min(X,Y)

number_of_pair=(X+Y-surplus)/2
money_sum=0

if number_of_pair*(A+B) > number_of_pair*2*C:
    money_sum+=number_of_pair*2*C
else:
    money_sum+=number_of_pair*(A+B)

if extra_pizza==X:
    if surplus*A > surplus*2*C:
        money_sum+=surplus*2*C
    else:
        money_sum+=surplus*A
else:
    if surplus*B > surplus*2*C:
        money_sum+=surplus*2*C
    else:
        money_sum+=surplus*B

print(int(money_sum))

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

Solution (Python):
import sys

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

if X >= Y:
    
    a = X * A + Y * B
    b = 2 * Y * C + (X - Y) * A
    c = 2 * X * C
    
    res = min([a,b,c])
    
if  X < Y:
    
    a = X * A + Y * B
    b = 2 * X * C + (Y - X) * B
    c = 2 * Y * C
    
    res = min([a,b,c])
print(res)

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




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


resx = x - min(x,y)
resy = y - min(x,y)

ans = ans + (resx * a) + (resy * b)
ans = min(ans  , uu)
print(ans)

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




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


resx = x - min(x,y)
resy = y - min(x,y)

ans = ans + (resx * a) + (resy * b)
ans = min(ans  , uu)
print(ans)

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

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

ans = []

ans.append(a*x + b*y)
ans.append(c*max(x, y)*2)
if x-y > 0:
    ans.append(a*(x-y) + c*min(x, y)*2)
elif x-y < 0:
    ans.append(b*(y-x) + c*min(x, y)*2)
    
print(min(ans))

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

all_ab = a*x + b* y
all_c = max(x,y) * 2 *c

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





print(min(all_ab, all_c, mix_abc))

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

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

Solution (Python):
import sys

a,b,c, x,y = [int(x) for x in sys.stdin.readline().split(" ")]


if a + b < c * 2:
	z = a * x + b * y
else:
	d = abs(x - y)
	e = max(x, y) - d

	zd1 = (a if x > y else b) * d
	zd2 = c * d * 2

	z = c * e * 2 + min(zd1, zd2)

print(z)

Solution (Python):

import sys



data = tuple(map(int, sys.stdin.readline().strip().split(' ')))
aPizza = data[0]
bPizza = data[1]
cPizza = data[2]
x = data[3]
y = data[4]

cost = 0


if (x != 0 and y != 0):
    sheets = (x if x < y else  y)
    if (aPizza + bPizza > cPizza * 2):
        cost = cost + cPizza * 2 * sheets
    else:
        cost = cost + (aPizza + bPizza) * sheets
    x = x - sheets
    y = y - sheets


if (x != 0):
    if (aPizza > cPizza * 2):
        cost = cost + cPizza * 2 * x
    else:
        cost = cost + aPizza * x

if (y != 0):
    if (bPizza > cPizza * 2):
        cost = cost + cPizza * 2 * y
    else:
        cost = cost + bPizza * y




print(cost)

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

if c < a/2 and c < b/2:
    result = max(x,y) * c * 2
elif a + b < c * 2:
    result = a * x + b * y
elif c < a/2:
    result = c * 2 * x
    if y > x:
        result += b * (y - x)
elif c < b/2:
    result = c * 2 * y
    if x > y:
        result += a * (x - y)
else:
    if x == y:
        result = c * 2 * x
    elif x > y:
        result = c * 2 * y + a * (x - y)
    elif x < y:
        result = c * 2 * x + b * (y - x)

print(result)

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

total_price = 0

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

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

print(total_price)

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

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

Solution (Python):

import sys
sys.setrecursionlimit(1000000)

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



def calcBestPrice(A, B, C, X, Y):

    if(X > 0 and Y > 0):
        if(A + B > 2 * C):
            return 2 * C + calcBestPrice(A, B, C, X - 1, Y - 1)
        elif(A > 2 * C):
            return 2 * C * X + calcBestPrice(A, B, C, 0, Y)
        elif(B > 2 * C):
            return 2 * C * Y + calcBestPrice(A, B, C, X, 0)
        else:
            return A * X + B * Y
    elif(X == 0):
        if(B > 2 * C):
            return 2 * C * Y
        else:
            return B * Y
    elif(Y == 0):
        if(A > 2 * C):
            return 2 * C * X
        else:
            return A * X


print(calcBestPrice(A, B, C, X, Y))

Solution (Python):
import os



inputs = str(input()).split(' ')
inputs = [int(i) for i in inputs]
A, B, C, X, Y = inputs


def cost(a, b, c):
	return a*A+b*B+c*C

cost_list = []
maxc = max([X*2, Y*2])
for i in range(0, maxc+1):
	c = i
	a = max([X - int(c/2), 0])
	b = max([Y - int(c/2), 0])
	cst = cost(a, b, c)
	cost_list.append(cst)

mincost = min(cost_list)
print(int(mincost), end='')

Solution (Python):


import os
import sys

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

if A + B < C*2:
    print A * X + B * Y
    sys.exit()

tmp = min(X, Y)
if tmp == X:
    t1 = C*2*tmp+(Y-tmp)*B
else:
    t1 = C*2*tmp+(X-tmp)*A
t2 = max(X, Y)*C*2
print min(t1, t2)

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

if (A + B <= C * 2):
  print(A * X + B * Y)
else:
  
  price1 = C * 2 * X + B * max(Y - X, 0)
  
  price2 = C * 2 * Y + A * max(X - Y, 0)
  print(min(price1, price2))

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

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

Solution (Python):
import sys
from collections import Counter
import random
import numpy as np
import time

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

Solution (Python):


ipt = [int(i) for i in input().split()]

a = ipt[0]
b = ipt[1]
c = ipt[2]
x = ipt[3]
y = ipt[4]

a_pizza = x
b_pizza = y
c_pizza = 0
if a+b > 2*c:
    c_pizza = 2*min(a_pizza, b_pizza)
    a_pizza -= c_pizza / 2
    b_pizza -= c_pizza / 2
if a_pizza > 0 and a > 2*c:
    c_pizza += 2*a_pizza
    a_pizza = 0
if b_pizza > 0 and b > 2*c:
    c_pizza += 2*b_pizza
    b_pizza = 0

print(int(a*a_pizza+b*b_pizza+c*c_pizza))

Solution (Python):
input_str = input()

A, B, C, X, Y = input_str.split(" ")

A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)

answer = 0
ave_AB = (A + B) / 2
if ave_AB <= C:
    answer = X*A + Y*B
else:
    xy_min = min(X,Y)
    answer = xy_min * C * 2
    tmp = X - Y
    if tmp > 0:
        if A < C*2:
            answer += tmp*A
        else:
            answer += tmp*C*2
    elif tmp < 0:
        if B < C*2:
            answer += -tmp*B
        else:
            answer += -tmp*C*2
print(answer)

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

ab_set = min(a+b, 2*c)

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,c,x,y = LI()
    if a < b:
        a,b = b,a
        x,y = y,x
    r = 0
    if a > c*2:
        r += x * c*2
        y = max(y-x,0)
        x = 0
    if b > c*2:
        r += y * c*2
        y = 0
    if a+b > c*2:
        t = min(x,y)
        r += t * c*2
        x -= t
        y -= t
    r += a * x
    r += b * y


    return r



print(main())

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

print(min([A*X + B*Y, max(X, Y)*C*2, min(X, Y)*C*2 + abs(X-Y)*(A if Y < X else B)]))

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

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

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

pizza_num_dict = {'A': 0, 'B': 0}

price_sum = 0
if A >= 2 * C:
    pizza_num_dict['A'] += X
    pizza_num_dict['B'] += X
    price_sum += 2 * X * C
    if X >= Y:
        print(price_sum)
        exit(0)
    else:
        if B >= 2 * C:
            price_sum += 2 * (Y - X) * C
        else:
            price_sum += (Y - X) * B
        print(price_sum)
        exit(0)

elif B >= 2 * C:
    pizza_num_dict['A'] += Y
    pizza_num_dict['B'] += Y
    price_sum += 2 * Y * C
    if Y >= X:
        print(price_sum)
        exit(0)
    else:
        price_sum += (X - Y) * A
        print(price_sum)
        exit(0)

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

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

ans = 0

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

print(ans)

Solution (Python):
X=list(map(int,input().split()))
if X[3]>X[4]:
	X=[X[i] for i in [1,0,2,4,3]]
print(min(X[0]*X[3]+X[1]*X[4], X[1]*X[4]+(2*X[2]-X[1])*X[3], 2*X[2]*X[4]))

Solution (Python):


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



Z = min(X, Y)
sum_of_pay = 0

if A+B > 2*C:
    sum_of_pay += 2 * Z * C

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

print(sum_of_pay)

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

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

res = 0

if x == y:
    res = min(a * x + b * y, c * x * 2)

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

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

print(res)

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

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

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

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

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

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

if A>2*C:
    print(2*C*X)
    exit()
print( 2*C*Y + (X-Y)*A)

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

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

low, high = min(x, y), max(x, y)

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

print common_price + diff_price

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

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

Solution (Python):
import sys

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

best_price = sys.maxsize


for i in range(0, max(x, y) * 2 + 1, 2):
    rest_a = x
    rest_b = y

    if i // 2 >= x:
        rest_a = 0
    else:
        rest_a = x - i // 2

    if i // 2 >= y:
        rest_b = 0
    else:
        rest_b = y - i // 2

    price = rest_a * a + rest_b * b + c * i
    if price < best_price:
        best_price = price
    

print(best_price)

Solution (Python):



import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def main():
    A, B, C, X, Y = srl(int)
    r = X * A + Y * B
    for i in xrange(2, 2*max(X, Y) + 2, 2):
        r = min(r, i * C + max(0, (X - i/2)) * A + max(0, (Y - i/2)) * B)
    print r


if __name__ == '__main__':
    main()

Solution (Python):
a,b,c,x,y=[int(i) for i in raw_input().split()]
if x<=y:
    print min(a*x+b*y,(2*x)*c+(y-x)*b,2*max(x,y)*c)
else:
    print min(a*x+b*y,(2*y)*c+(x-y)*a,2*max(x,y)*c)

Solution (Python):



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

price = 0
if a + b <= 2 * c:
    price = (a * x) + (b * y)
else:
    num_ab = min(x, y)
    price = 2 * c * num_ab

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


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

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

Solution (Python):
import re
PIZ=re.split('[ ]', input())
A=int(PIZ[0])
B=int(PIZ[1])
C=int(PIZ[2])
X=int(PIZ[3])
Y=int(PIZ[4])
a=0
b=0
c=0
if(A+B>=C*2):
    if X<=Y:
        for i in range(X):
            X-=1
            Y-=1
            c+=2
    else:
        for i in range(Y):
            X-=1
            Y-=1
            c+=2
    if A<C*2:
        a+=X
    else:
        c+=X*2
    if B<C*2:
        b+=Y
    else:
        c+=Y*2
else:
    for j in range(X):
        X-=1
        a+=1
    for k in range(Y):
        Y-=1
        b+=1
print(A*a+B*b+C*c)

Solution (Python):
a, b, c, x, y=map(int, input().split())
m=2*x*c
n=c*y*2+a*(x-y)
d=2*y*c
e=c*x*2+b*(y-x)
f=a*x+b*y
g=min(m,n,f)
h=min(d,e,f)
if x>=y:
    print(g)
else:
    print(h)

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

Solution (Python):


import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq





def solve(f):
    a,b,c,x,y = f.read_int_list()

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

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case 
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

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