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

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

print(ans)

Solution (Python):
a,b,c,x,y = map(int,input().split())
s = 0
k = 2 * c
money = 0
s = min(a+b,k)
if k<a:
    a = k
if k<b:
    b = k
little = min(x,y)
money = little * s
x -= little
y -= little
if x:
    money += x*a
elif y:
    money += y*b
print(money)

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

ans = 0

if x<y:
    xy = x
    y -= x
    if b < 2*c:
        ans += b*y
    else:
        ans += 2*c*y

else:
    xy = y
    x -= y
    if a < 2*c:
        ans += a*x
    else:
        ans += 2*c*x

if a+b<2*c:
    ans += xy*(a+b)
else:
    ans += xy*(2*c)

print (ans)

Solution (Python):
def calc_ans(a,b,c,x,y):
    
    less = min([x,y])
    if less == y:
        use_c = 2*c*less + a*(x-less)
    else:
        use_c = 2*c*less + b*(y-less)
        
    not_use_c = a*x + b*y
    
    only_c = 2*c*max([x,y])
    
    return min([use_c, not_use_c, only_c])

def main():
    
    a,b,c,x,y = map(int, input().split())
    
    
    ans = calc_ans(a,b,c,x,y)
    print(ans)

if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,x,y = Is()
ans = 10**10
for i in range(0,max(x*2,y*2)+3,2):
    a = max(0,(x - i//2)*A)
    b = max(0,(y - i//2)*B)
    c = i*C
    ans = min(a+b+c,ans)
print(ans)

Solution (Python):


A, B, C, X, Y=map(int, input().split())
numA=0
numB=0
numC=0
answer=0

if A>2*C:
    
    answer+=2*X*C 
    numC+=2*X
    Y-=X 
    X=0

if B>2*C and Y>0:
    
    answer+=2*Y*C 
    numC+=2*Y
    X-=Y 
    Y=0

if X>0 or Y>0: 
    if A+B>2*C: 
        answer+=2*min(X, Y)*C
        numC+=2*min(X, Y)
        m=min(X, Y)
        X-=m
        Y-=m

    answer+=A*X+B*Y
    numA+=X
    numB+=Y


print(answer)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
price = 0
P = []
s = 0
t = 0
u = 0
if A + B <= 2*C:
    price = A*X + B*Y
else:
    sa = abs(X - Y)
    price = C*2*(min(X, Y)-sa)
    XX = X - (min(X, Y)-sa)
    YY = Y - (min(X, Y)-sa)
    dai = max(XX, YY)
    syou = min(XX, YY)

    for i in range(dai+1):
        u = i*2
        if syou>=i:
            s = XX - i
            t = YY - i
        else:
            if X >= Y:
                s = XX - i
                t = 0
            else:
                s = 0
                t = YY - i
        P.append(A*s + B*t + C*u)
    price += min(P)

print(price)

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

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

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

Solution (Python):
l = list(map(int,input().split()))
a,b,c,x,y = l[0],l[1],l[2],l[3],l[4]
ans = 0
minxy = min(x,y)
maxxy = max(x,y)
if maxxy == x:
    remab = a
elif maxxy == y:
    remab = b
rem = maxxy - minxy
if a + b >= 2*c:
    ans += 2*minxy*c
else:
    ans += minxy*(a+b)
if rem == 0:
    print(ans)
else:
    if 2*c <= remab:
        ans += 2*rem*c
    else:
        ans += rem*remab
    print(ans)

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

if y > x:
    o = c*min(x,y)*2 + b*abs(x-y)
else:
    o = c*min(x,y)*2 + a*abs(x-y)
p = a*x + b*y
q = c*max(x,y)*2

print(min(o,p,q))

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

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

Solution (Python):
a,b,c,x,y = map(int,input().split())
cou = 0
lis = []
lis.append(a * x + b * y)
lis.append(max(x,y) * 2 * c)
nu = min(x,y)
cou += min(x,y) * 2 * c
x -= nu
y -= nu
cou += x * a + y * b
lis.append(cou)

print(min(lis))

Solution (Python):
s = list(map(int, input().split()))
a, b, c, x, y = s[0], s[1], s[2], s[3], s[4]
pa = 0
pb = 0
res = 10**10
for i in range(0, 2*(x+y+1), 2):
 t = i*c+(x-min(x, i//2))*a+(y-min(y, i//2))*b
 if t<res:
  res = t

print(res)

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

Solution (Python):




def main(a, b, c, x, y):

    
    
    
    m = []
    
    m.append(a * x + b * y)
    
    m.append(c * max(x, y) * 2)
    
    if x >= y: m.append(c * min(x, y) * 2 + a * (x - y))
    if x < y: m.append(c * min(x, y) * 2 + b * (y - x))
    print(min(m))
    


if __name__ == '__main__':
    try:
        a, b, c, x, y = list(map(int, input().strip().split(' ')))
        main(a, b, c, x, y)
    except EOFError:
        pass

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

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

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

Solution (Python):

"""
Created on Sat Apr 21 21:25:13 2018

@author: Kim
"""

IN = input().split()
A = int(IN[0])
B = int(IN[1])
C = int(IN[2])
X = int(IN[3])
Y = int(IN[4])


As = A * X
Bs = B * Y
ALLSUM = As + Bs


Cmax = 2 * max(X,Y) * C
Cmin = 2 * min(X,Y) * C


sabunkosuu = max(X,Y) - min(X,Y)
if X > Y:
    sabungaku = A * sabunkosuu
elif X < Y:
    sabungaku = B * sabunkosuu
else:
    sabungaku = 0


halfmin = Cmin + sabungaku 


ANS = min(ALLSUM, Cmax, halfmin)
print(ANS)

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

cost1 = x * a + y * b

if x > y:
    price = a
else:
    price = b

cost2 = min(x, y) * 2 * c + (max(x, y) - min(x, y)) * price

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

print(min(cost1,cost2,cost3))

Solution (Python):
def n():
    A, B, C, X, Y = map(int, input().split())
    ab = A + B
    cc = C * 2
    cost = 0
    if ab > cc:
        minn = min(X, Y)
        cost += minn * cc
    else:
        minn = min(X, Y)
        cost += minn * A + minn * B

    if X > Y:
        diff = X - Y
        aaa = A * diff
        ccc = cc * diff
        cost += min(aaa, ccc)
    else:
        diff = Y - X
        bbb = B * diff
        ccc = cc * diff
        cost += min(bbb,ccc)

    return cost


print(n())

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

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

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

    max_c = max([X,Y]) * 2
    yen = [0 for _ in range(max_c+1)]
    for c in range(max_c+1):
        x = X - c//2
        if x < 0:
            x = 0
        y = Y - c//2
        if y < 0:
            y = 0
        yen[c] = x*A + y*B + c*C
    return min(yen)

if __name__ == '__main__':
    print(main())

Solution (Python):
import sys
if __name__ == "__main__":
    A, B, C, X, Y = list(map(int, (input().split(' '))))
    cost_A = A * X
    cost_B = B * Y
    least_cost = cost_A + cost_B
    max_cnt = 0
    if X >= Y:
        max_cnt = X
    else:
        max_cnt = Y
    for i in range(0, 2*max_cnt+1, 2):

        buf_cost_A = 0
        buf_cost_B = 0
        buf_cost = C * i
        if (X - i*0.5) > 0:
            buf_cost_A = (X - i*0.5) * A
        if (Y - i*0.5) > 0:
            buf_cost_B = (Y - i*0.5) * B

        if least_cost > (buf_cost + buf_cost_A + buf_cost_B):
            least_cost = buf_cost + buf_cost_A + buf_cost_B
    print(int(least_cost))

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

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

Solution (Python):
A,B,C,X,Y = map(int, input().split())
minAB = min(X,Y)
maxAB = max(X,Y) - minAB
ans = 0

if A + B > C * 2:
    ans = minAB * C * 2
else:
    ans = minAB * A + minAB * B


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

print(ans)

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



currentX = X
currentY = Y
currentH = 0


while (currentX>0)or(currentY>0):
    if currentX > 0:
        tmpX = currentX - 1
    if currentY > 0:
        tmpY = currentY - 1
    if ((tmpX * A) +(tmpY * B) +((currentH + 2) * C)) < ((currentX * A) +(currentY * B) +((currentH) * C)):
        if currentX > 0:
            currentX -= 1
        if currentY > 0:
            currentY -= 1
        currentH += 2
    else:
        break


print ((currentX * A) +(currentY * B) +((currentH) * C))

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

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

if x>=y:
    if a >= 2*c:
        count += 2*c*d
    else:
        count += a*d
else:
    if b >= 2*c:
        count += 2*c*d
    else:
        count += b*d

print(count)

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

print(ans)

Solution (Python):
a,b,c,x,y=map(int,input().split())
if x<y:
  min,max=x,y
  a2,b2=a,b
else:
  min,max=y,x
  a2,b2=b,a

if c*2<=a2+b2:
  res=2*min*c
  tmp1=(max-min)*b2
  tmp2=2*(max-min)*c
  if tmp1<tmp2:
    print(res+tmp1)
  else:
    print(res+tmp2)
else:
  if a2>b2:
    a2,b2=b2,a2
    min,max=max,min
  tmp1=a2*min+b2*max
  tmp2=2*max*c
  if min>max:
    tmp2+=(min-max)*a2
  if tmp1<tmp2:
    print(tmp1)
  else:
    print(tmp2)

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

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

print sum

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

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

ans = 10**1000

dat3 = [0, x*2,y*2]

for cc in dat3:
  aa = x - cc/2
  if aa < 0:aa = 0
  bb = y - cc/2
  if bb < 0:bb=0
  p = aa*a + bb*b + cc*c
  if p < ans:
    ans = p
print ans

Solution (Python):





if __name__ == '__main__':
    a, b, c, x, y = list(map(int, input().split()))
    ab_yen = a + b
    c_yen = 2 * c
    min_x_y_count = min(x, y)
    cost = 0

    if ab_yen >= c_yen:
        cost += c_yen * min_x_y_count
        cost += min(a, c_yen) * (x - min_x_y_count)
        cost += min(b, c_yen) * (y - min_x_y_count)
    else:
        cost = (a * x) + (b * y)

    print(cost)

Solution (Python):
def smaller(m, n):
	if m < n: return m
	else: return n

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

smallerpizza = smaller(X, Y)
morepizza = X + Y - 2*smallerpizza
neededpizza = ''
if smallerpizza == X: neededpizza = 'B'
else: neededpizza = 'A'

cost1 = A + B
if 2 * C < cost1: cost1 = 2 * C
cost2 = 0
if neededpizza == 'A': cost2 = A
if neededpizza == 'B': cost2 = B
if 2 * C < cost2: cost2 = 2 * C

print cost1 * smallerpizza + cost2 * morepizza

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

price = a*x + b*y
a_num = x
b_num = y

while True:
	if a_num > 0:
		a_num -= 1
		next_price = price - a
	if b_num > 0:
		b_num -= 1
		next_price = next_price - b

	next_price = next_price + c*2
	if next_price < price:
		price = next_price
	else:
		print(price)
		break

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a,b,c,x,y = na()
tot = c*2
ans = 0
if a+b <= tot:
    ans = a*x + b*y
else:
    if a > tot and b > tot:
        mi = min(x,y)
        ans = mi*2*c + (max(x,y) - mi)*2*c
    elif a > tot and b <= tot:
        mi = min(x,y)
        if mi == x:
            ans = mi*2*c + (max(x,y) - mi)*b
        else:
            ans = mi*2*c + (max(x,y) - mi)*2*c
    elif a <= tot and b > tot:
        mi = min(x,y)
        if mi == x:
            ans = mi*2*c + (max(x,y) - mi)*2*c
        else:
            ans = mi*2*c + (max(x,y) - mi)*a
    else:
        mi = min(x,y)
        if mi == x:
            ans = mi*2*c + (max(x,y) - mi)*b
        else:
            ans = mi*2*c + (max(x,y) - mi)*a
print(ans)

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

Solution (Python):
a,b,c,x,y = map(int,input().split())
ans = 0
if a + b > c*2:
    if x > y and a < c*2 :
        ans += 2*c*y + (x-y)*a
    elif y > x and b < c*2:
        ans += 2*c*x+(y-x)*b
    else:
        ans += 2*c*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 (a + b)/2 > c :
    price_min = c * min(x,y) * 2
    price_max = c * max(x,y) * 2

    if x-y > 0:
        price = a*(x-y) + price_min
    else:
        price = b*(y-x) + price_min

    if price > price_max:
        ans = price_max
    else:
        ans = price

else:
    ans = a * x + b * y

print(ans)

Solution (Python):
cols = input('').split()

a = int(cols[0])
b = int(cols[1])
c = int(cols[2])
x = int(cols[3])
y = int(cols[4])

total_ab = x * a + b * y

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

print(min(total_ab, total_ac, total_bc))

Solution (Python):


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


mean_AB = (A + B) / 2

if mean_AB > C:
    if X <= Y:
        price = C * X * 2 + B * (Y-X)
        
        price_AB = C * Y * 2
        if price_AB < price:
            price = price_AB
    else:
        price = C * Y * 2 + A * (X-Y)
        
        price_AB = C * X * 2
        if price_AB < price:
            price = price_AB

else:
    price = A * X + B * Y

print(price)

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

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

Solution (Python):
a,b,c,x,y=input().split()
a=int(a)
b=int(b)
c=int(c)
x=int(x)
y=int(y)
ans = 5000 * 100000 * 3 * 2
ans1 = a*x+b*y
ans2 = a*max(0,x-y)+c*2*y
ans3 = b*max(0,y-x)+c*2*x
print(min([ans1, ans2, ans3]))

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

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

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

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

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

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

Solution (Python):
import sys
A,B,C,X,Y = map(int,input().split())
ans = 0
if A+B > 2*C:
    judge = True
else:
    ans += X*A
    ans += Y*B
    print(ans)
    sys.exit()

    

if judge:
    min_XY = min(X,Y)
    if min_XY == 0:
        ans += X*A
        ans += Y*B
        print(ans)
        sys.exit()
    else:
        X -= min_XY
        Y -= min_XY
        ans += 2*C*min_XY
        if X !=0:
            if 2*C*X < A*X:
                ans +=  2*C*X
            else:
                ans += A*X
        if Y !=0:
            if 2*C*Y < B*Y:
                ans +=  2*C*Y
            else:
                ans += B*Y
    print(ans)

Solution (Python):

import math
a,b,c,d,e = map(int, input().split())
flag = 0
flaga = 0
flagb = 0
cost = 0
if(a+b< 2*c):
    cost = a*d + b*e
    flag = 1
if(2*c<=a):
    flaga = 1
if(2*c<=b):
    flagb = 1

if(flag == 0):
    if(d<=e):
        if(flagb == 1):
            cost += e * 2 * c
        else:
            cost += d * 2 * c + (e-d)*b
    else:
        if(flaga == 1):
            cost += d * 2 * c
        else:
            cost += e * 2 * c + (d-e)*a
print(cost)

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

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

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

ans = 0
dic = {x:a,y:b}

if a+b < 2*c:
    ans += a*x + b*y

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

print(ans)

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())
price = 0
if A+B > C*2:
    if X < Y:
        price += X * C * 2
        if B > C*2:
            price += (Y-X) * C*2
        else:
            price += (Y-X) * B

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

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

print(price)

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

if a+b>2*c:
    if (x<y and b>2*c) or (x>y and a>2*c) :
        nc=2*max(x,y)
        print(c*nc)
    else:
        mi=min(x,y)
        print(c*2*mi+(x-mi)*a+(y-mi)*b)
else:
    print(a*x+b*y)

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

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

Solution (Python):



def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    A, B, C, X, Y = get_next_ints()

    proper = (A * X) + B * Y
    if X > Y:
        smaller = Y
        remainder = X - Y
        value = A
    else:
        smaller = X
        remainder = Y - X
        value = B
    mixed = C * smaller * 2 + min(remainder * value, remainder * C * 2)

    print(min(proper, mixed))


solve()

Solution (Python):
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

a, b, c, x, y = read_line(int, int, int, int, int)

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

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

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

if x > y:
  total1 += (x-y) * a
elif y > x:
  total1 += (y-x) * b

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

print(min(total1, total2))

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

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

print(ans)

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

Solution (Python):


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

ab_max_pairs = max(x, y)

price_min = 1000000000

for i in range(ab_max_pairs + 1):
    price = c * i * 2 + max(0, (x-i)) * a + max(0, (y-i)) * b
    if price < price_min:
        price_min = price

print(price_min)

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = 0
maxxy = max(x,y)
minxy = min(x,y)
abcost = a * minxy + b * minxy
ccost = c * minxy * 2
ans += min(abcost, ccost)
amari = maxxy - minxy
if x > y:
    acost = a * amari
    ccost = c * amari * 2
    ans += min(acost, ccost)
elif x < y:
    bcost = b * amari
    ccost = c * amari * 2
    ans += min(bcost, ccost)

print(ans)

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

k = 0 
if c*2 < a+b:
    z = min([x,y])
    k += z*c*2
    x -= z
    y -= z

if c*2 < a: k += x*c*2
else: k += x*a
    
if c*2 < b: k += y*c*2
else: k += y*b

print(k)

Solution (Python):


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

m = []


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


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

if X < Y:
    m.append( (Y-X)*B + 2*X*C )

if X < Y:
    m.append(2*Y*C)
elif X == Y:
    m.append(2*Y*C)
else:
    m.append(2*X*C)

print(min(m))

Solution (Python):
from sys import stdin


def main():
    A, B, C, X, Y = [int(x) for x in stdin.readline().rstrip().split()]
    if A + B <= C * 2:
        print(A * X + B * Y)
    elif X < Y:
        spam = C * 2 * X
        if B < C * 2:
            print(B * (Y - X) + spam)
        else:
            print(C * 2 * (Y - X) + spam)
    else:
        spam = C * 2 * Y
        if A < C * 2:
            print(A * (X - Y) + spam)
        else:
            print(C * 2 * (X - Y) + spam)


if __name__ == '__main__':
    main()

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

A_p = A * X
B_p = B * Y
justAB = A_p + B_p

min_x_y = min(X, Y)
AB_p = int((min_x_y / 0.5 * AB))

dif = 0
dif_p = 0
if X > Y:
    dif = X - Y
    dif_p = dif * A
else:
    dif = Y - X
    dif_p = dif * B


max_x_y = max(X,Y)
AB_max_p = int(max_x_y / 0.5 * AB)

print(min(justAB, AB_p + dif_p, AB_max_p))

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

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

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

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

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

mi = min(x,y)
sa = abs(x-y)
if c*2 <= a+b:
    daikin = c*2*mi
    if x >= y:
        piza = min(c*2,a)
        daikin += piza*sa
    else:
        piza = min(c*2,b)
        daikin += piza*sa
    print(daikin)
else:
    print(a*x + b*y)

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

cost_AplusB = min(A+B, 2*C)
costA = min(A, 2*C)
costB = min(B, 2*C)

flag = (X > Y)
many_pizza = max(X, Y)
few_pizza = min(X, Y)



price = cost_AplusB * few_pizza
if flag:
    price += costA * (many_pizza - few_pizza)
else:
    price += costB  * (many_pizza - few_pizza)

print(price)

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

price = 0

if x - y > 0:
    diff = x - y
    n_same = y
    rest_pr = a
else:
    diff = y - x
    n_same = x
    rest_pr = b


if a + b < c * 2:
    price += (a+b) * n_same
else:
    price += c * n_same * 2

if rest_pr < c * 2:
    price += rest_pr * diff
else:
    price += c * diff * 2

print(price)

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

    
    
    

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

    
    n_c_at_least = 2 * min(X, Y)

    X, Y = X - n_c_at_least // 2, Y - n_c_at_least // 2
    total = C * n_c_at_least

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

    print(total)

Solution (Python):
A, B, C, X, Y = map(int,input().split())
Sum=[0 for i in range(max(X,Y)+1)]


for AB in range(0, 2*max(X,Y)+1,2):
    Sum[AB//2]=max((X-AB//2),0)*A+max((Y-AB//2),0)*B+AB*C

print(min(Sum))

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

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

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



if (a+b) >= 2*c:
    price += 2 * c * num
else:
    price += (a+b) * num

print(price)

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

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

price = 0
if c >= (a + b) / 2:
    price += a * x + b * y

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

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

print(price)

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

val1=A*X+B*Y

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

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

print min(val1,val2,val3)