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())
ans = A*X+B*Y
for i in range(1,max(X,Y)+1):
    a = A*(X-i) if X-i>0 else 0
    b = B*(Y-i) if Y-i>0 else 0
    tmp = a+b+C*i*2
    ans = min(ans,tmp)
print(ans)

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

Solution (Python):

input_line =input()
input_line = input_line.rstrip().split(" ")

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

list1=[]
for i in range(max(x,y)+1):
    if x-i<=0 and y-i<=0:
        cost = 2*c*i
        list1.append(cost)
        i +=1
        
    elif x-i<=0:
        cost = b*(y-i)+2*c*i
        list1.append(cost)
        i +=1
        
    elif y-i<=0:
        cost = a*(x-i)+2*c*i
        list1.append(cost)
        i +=1
    
    else:
        cost = a*(x-i)+b*(y-i)+2*c*i
        list1.append(cost)
        i +=1
    

print(min(list1))

Solution (Python):
A, B, C, X, Y = map(int, input().split())
temp = A * X + B * Y
while True:
    if min(X, Y) > 0:        
        X -= 1
        Y -= 1
        now = temp - A - B + 2 * C
        if min(temp, now) == temp:
            break
        else:
            temp = now
    elif max(X, Y) > 0:
        if X == 0:
            Y -= 1
            now = temp - B + 2 * C
            if min(temp, now) == temp:
                break
            else:
                temp = now
        else:
            X -= 1
            now = temp - A + 2 * C
            if min(temp, now) == temp:
                break
            else:
                temp = now
    else:
        break
print(temp)

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

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

print(ans)

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


if 2*C<A and 2*C<B:
	print(2*C*max([X,Y]))
elif 2*C<A:
	if X<Y:
		print(2*C*X+B*(Y-X))
	else:
		print(2*C*X)
elif 2*C<B:
	if Y<X:
		print(2*C*Y+A*(X-Y))
	else:
		print(2*C*Y)
elif 2*C<A+B:
	if Y<X:
		print(2*C*Y+A*(X-Y))
	else:
		print(2*C*X+B*(Y-X))

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

Solution (Python):
import re
import math

if __name__ == '__main__':

    a, b, c, x, y = [int(n) for n in input().split()]

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

    print(ans)

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

candidate = []

candidate.append(C * X * 2 if X >= Y else C * X * 2 + B * (Y - X))
candidate.append(C * Y * 2 if X <= Y else C * Y * 2 + A *(X - Y))
candidate.append(A * X + B * Y)

print(min(candidate))

Solution (Python):
A, B, C, X, Y = map(int, input().split())
c = C / 2
money = 0
if X > Y:
    m = X
    M = A
    f = Y
    F = B
else:
    m = Y
    M = B
    f = X
    F = A

if A + B > 2 * C:
    money = C * f * 2
    m = m - f
    f = 0

if F > 2 * C: money += f * 2 * C
else: money += f * F

if M > 2 * C: money += m * 2 * C
else: money += m * M

print(money)

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

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

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

Zmax = max(X,Y)
Zmin = min(X,Y)
tot = 0

if A+B >= 2*C:
    if X >= Y:
        if A <= 2*C:
            tot = 2*Zmin *C + (Zmax-Zmin) * A
        else:
            tot = 2*Zmin *C + 2*(Zmax-Zmin) * C
    else:
        if B <= 2*C:
            tot = 2*Zmin *C + (Zmax-Zmin) * B
        else:
            tot = 2*Zmin *C + 2*(Zmax-Zmin) * C
else:
    tot = X*A + Y*B

print(tot)

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

Solution (Python):
A,B,c,a,b=map(int,input().split());print(min(c*max(a,b)*2,A*a+B*b,[A,B][a<b]*abs(a-b)+c*min(a,b)*2))

Solution (Python):


A, B, AB, an, bn = map(int, input().split())
L = []
L += [AB*max(an, bn)*2]
L += [A*an+B*bn]
if an < bn:
    L += [B*(bn-an) + AB*min(an, bn)*2]
else:
    L += [A*(an-bn) + AB*min(an, bn)*2]
print(min(L))

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

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

if x == y:
    pass
elif 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)

print(total)

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

v1 = A * X + B * Y
v2 = A * max(X-Y, 0) + B * max(Y-X, 0) + C * 2 * min(X, Y)
v3 = C * 2 * max(X, Y)

print(min(v1, v2, v3))

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

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

C = min(2 * C, A + B)
A = min(A, C)
B = min(B, C)

Z = min(X,Y)

print( Z * C + (X-Z) * A + (Y-Z) * B)

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

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

print(cost)

Solution (Python):
input_data=input()
new_input = input_data.split(" ")

A=int(new_input[0])
B=int(new_input[1])
C=int(new_input[2])
X=int(new_input[3])
Y=int(new_input[4])
min_num=min([X,Y])


if min_num * (A+B) > min_num * 2 * C:
    price = min_num * 2* C
else:
    price = min_num*(A+B)

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

print(price)

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

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

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

print(min_cost)

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

cost1 = X * A + Y * B

c = X * 2
a = 0
b = max([0, Y - c / 2])
cost2 = a * A + b * B + c * C

c = Y * 2
a = max([0, X - c / 2])
b = 0
cost3 = a * A + b * B + c * C

print(int(min([cost1, cost2, cost3])))

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

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

Solution (Python):
p = [int(x) for x in input().split()]

A = p[0]
B = p[1]
C = p[2]
X = p[3]
Y = p[4]

total = 0

if A + B > 2 * C:
    while X and Y > 0:
        total += 2 * C
        X -= 1
        Y -= 1      

while X > 0:
    if A > 2 * C:
        total += 2 * C
    else:
        total += A
    X -= 1
while Y > 0:
    if B > 2 * C:
        total += 2 * C
    else:
        total += B
    Y -= 1

print(total)

Solution (Python):



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


ans = [i * 2*C + max(0, X-i)*A + max(0, Y-i)*B for i in range(0, 100001)]


print(min(ans))

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

Solution (Python):
l = raw_input().split()
A = int(l[0])
B = int(l[1])
C = int(l[2])
X = int(l[3])
Y = int(l[4])

cost = 0

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

print(cost)

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):
l = list(input().split())
c = 0
for i in l:
 l[c] = int(i)
 c+=1

k = min(l[3],l[4])
money = min((l[0]+l[1])*k, l[2]*2*k)

if l[3]>l[4]:
 m = l[3]-l[4]
 money += min(l[0], l[2]*2)*m
else:
 m = l[4]-l[3]
 money += min(l[1], l[2]*2)*m

print(money)

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

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

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

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

Solution (Python):
A, B, C, X, Y = [int(x) for x in raw_input().split()]
s = 0
p = min(X, Y)
X -= p
Y -= p
s += p * min(A+B, 2*C)
s += X * min(A, 2*C)
s += Y * min(B, 2*C)
print s

Solution (Python):
def compare(q,p):
    if q>p:
        return p
    else:
        return q
a,b,c,x,y= map(int, input().split())
re=0
if a+b>2*c:
    if x>y:
        re=compare(c*x*2,c*y*2+a*(x-y))
    else:
        re=compare(c*y*2,c*x*2+b*(y-x))
else:
    re=a*x+b*y
print(re)

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

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

Solution (Python):

A,B,C,X,Y=map(int,input().split())
if X>=Y:
    more=X
    more_price=A
    less=Y
else:
    more=Y
    more_price=B
    less=X
if more_price>=C*2:
    price=C*2*more
else:
    if A+B>=2*C:
            price=C*2*less+(more-less)*more_price
        
    else:
        price=A*X+B*Y
print(price)

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

Solution (Python):
ABCXY = [int(i) for i in input().split()]
A, B, C, X, Y = ABCXY[0], ABCXY[1], ABCXY[2], ABCXY[3], ABCXY[4]
ans = 0

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

if 2 * C <= A:
    ans += X * 2 * C
else:
    ans += X * A

if 2 * C <= B:
    ans += Y * 2 * C
else:
    ans += Y * B

print(ans)

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

Solution (Python):
a, b, ab, x, y = (int(i) for i in input().split())
costcut = a + b - 2*ab
if costcut<=0:
    total = a*x + b*y
else:
    base = min(x,y)*2*ab
    nokori = abs(x-y)
    if x>y:
        if a>2*ab:
            total = base + nokori*2*ab
        else:
            total = base + nokori*a
    else:
        if b>2*ab:
            total = base + nokori*2*ab
        else:
            total = base + nokori*b
print(total)

Solution (Python):
a_yen , b_yen, c_yen , a_count,b_count = map(int,input().split())

abmax = max(a_count, b_count)
c_count = 0
kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count

while c_count <= 2*abmax:
    if kouhopiza > a_yen * a_count + b_yen * b_count + c_yen * c_count and a_count > -1 and b_count > -1:
        kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count
    elif a_count > -1 and b_count < 0:
        if kouhopiza > a_yen * a_count + c_yen * c_count:
            kouhopiza = a_yen * a_count + c_yen * c_count
    elif a_count < 0 and b_count > -1:
        if kouhopiza > b_yen * b_count + c_yen * c_count:
            kouhopiza = b_yen * b_count + c_yen * c_count
        
    c_count = c_count + 2
    a_count = a_count - 1
    b_count = b_count - 1
print(kouhopiza)

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


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

Solution (Python):
def C():
    A, B, C, nA, nB = map(int, input().split())
    minAB = min(nA, nB)
    
    ns = [nA - minAB, nB - minAB]
    amounts = [
        A * nA + B * nB,
        minAB * 2 * C + ns[0] * A + ns[1] * B,
        max(nA, nB) * 2 * C
    ]
    return min(amounts)

print(C())

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

print(min(cost))

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

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

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

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

print(min_sum)

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

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

print(min_sum)

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

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

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

ab = 2 * c
money = 0

if a + b >= ab:
    if x >= y:
        if  a >= ab:
            money = x * ab
        else:
            money = (x - y) * a + y * ab
    else:
        if b >= ab:
            money = y * ab 
        else:
            money = (y - x) * b + x * ab

else:

    if a < ab and b < ab:
        money = a*x + b*y

    if a >= ab and b < ab:
        if y - x >= 0:
            money = x * ab + b * (y - x)
        else:
            money = x * ab

    if a < ab and b >= ab:
        if x -y >= 0:
            money = y * ab + a * (x -y)
        else:
            money = y * ab

    if a >= ab and b >= ab:
        money = x * ab + y * ab

print(money)

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

cost = 0
n_small = min(X, Y)

if A + B > 2*C:
    cost += n_small * (2*C)
else:
    cost += n_small * (A+B)

X -= n_small
Y -= n_small

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

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

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

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

def dp(num_a,num_b):
    """
    if num_a<=0 and num_b<=0:return 0
    elif num_b>0:
        if B<2*C:return B+dp(num_a,num_b-1)
        else :return C*2+dp(num_a-1,num_b-1)
    else:
        if A<2*C:return A+dp(num_a-1,num_b)
        else: return C*2+dp(num_a-1,num_b-1)
    """
    if A+B>2*C:
        if min(num_a,num_b)>0:
            if num_a > num_b:
                return num_b*2*C+dp(num_a-num_b,0)
            else :
                return num_a*2*C+dp(0,num_b-num_a)
        elif num_a==0 and num_b>0:
            if B<2*C:
                return num_b*B
            else :
                return C*2*num_b
        elif num_a>0 and num_b==0:
            if A<2*C:
                return A*num_a
            else :
                return 2*C*num_a
        else :
            return 0
    else :
        return num_a*A+num_b*B
print(dp(X,Y))

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

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

Solution (Python):
line = list(map(int,input().split(" ")))
A,B,C,X,Y = line[0],line[1],line[2],line[3],line[4]

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

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

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

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

Solution (Python):
import random




def criterion(x, y):
    z=xo*x+yo*y

    if x>a or y>b or x+y>2*c or x<0 or y<0:
        z=-z
    
    return z


def update_position(x, y, vx, vy):
 
    new_x = x + vx
    new_y = y + vy

    return new_x, new_y


def update_velocity(x, y, vx, vy, p, g, w=1, ro_max=0.5,v_max=10):
    
    ro1 =random.uniform(0, ro_max)
    ro2 =random.uniform(0, ro_max)
    
    new_vx = int((w * vx + ro1 * (p["x"] - x) + ro2 * (g["x"] - x)))
    new_vy = int((w * vy + ro1 * (p["y"] - y) + ro2 * (g["y"] - y)))
    if abs(new_vx)>v_max:
        new_vx=int(v_max*new_vx/abs(new_vx))
    if abs(new_vy)>v_max:
        new_vy=int(v_max*new_vy/abs(new_vy))

    
    return new_vx, new_vy
    
def main():
    N = 2000  
    x_min, x_max = 0, a
    y_min, y_max = 0, b
    
    ps = [{"x": random.randint(x_min, x_max), 
        "y": random.randint(y_min, y_max)} for i in range(N)]
    vs = [{"x": 0, "y": 0} for i in range(N)]

    personal_best_positions = list(ps)
    personal_best_scores = [criterion(p["x"], p["y"]) for p in ps]

    best_particle = personal_best_scores.index(max(personal_best_scores))
    global_best_position = personal_best_positions[best_particle]

    T = 100  
    for t in range(T):
        for n in range(N):
            x, y = ps[n]["x"], ps[n]["y"]
            vx, vy = vs[n]["x"], vs[n]["y"]
            p = personal_best_positions[n]
            
            new_x, new_y = update_position(x, y, vx, vy)
            ps[n] = {"x": new_x, "y": new_y}
            
            new_vx, new_vy = update_velocity(
                new_x, new_y, vx, vy, p, global_best_position)
            vs[n] = {"x": new_vx, "y": new_vy}
            
            score = criterion(new_x, new_y)
            if score > personal_best_scores[n]:
                personal_best_scores[n] = score
                personal_best_positions[n] = {"x": new_x, "y": new_y}
        
        best_particle = personal_best_scores.index(max(personal_best_scores))
        global_best_position = personal_best_positions[best_particle]


    
    return max(personal_best_scores), global_best_position["x"], global_best_position["y"]




a, b, c, xo, yo = [int(i) for i in input().split()]

best=-100000000
xx=0
yy=0
for i in range(3):
    kouho_best, kouho_x, kouho_y=main()
    if best<kouho_best:
        best=kouho_best
        xx=kouho_x
        yy=kouho_y

print(best)

Solution (Python):
S = map(int, raw_input().split())
A = S[0]
B = S[1]
C = S[2]
X = S[3]
Y = S[4]

if X > Y:
    A = S[1]
    B = S[0]
    X = S[4]
    Y = S[3]

totals = []
for i in range(Y + 1):
    total = 0
    total += C * 2 * i
    if i < X:
        total += A * (X - i)
    if i < Y:
        total += B * (Y - i)

    totals.append(total)

print(sorted(totals)[0])

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

Solution (Python):

if __name__ == "__main__":
    a, b, c, x, y = map(int, input().split())
    ans = float('inf')
    for tmp in range((10**5)+1):
        ans = min(ans, a*max(0, x-tmp)+b*max(0,y-tmp)+c*2*tmp)
    else:
        print(ans)

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

ans1=max(X,Y)*C*2
ans2=X*A+Y*B
if X>Y:
  ans3=C*Y*2+(X-Y)*A
else:
  ans3=C*X*2+(Y-X)*B

print(min(ans1,ans2,ans3))

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

least_price = float("inf")
less_list = sorted([X, Y])

for i in range(less_list[1]+1):
    num_A = X- i
    num_B = Y - i
    
    if num_A <= 0 :
        num_A = 0
    if num_B <= 0:
        num_B = 0

    total_price = C * 2*i +  A * num_A + B * num_B
    if least_price > total_price:
            least_price = total_price
    else:
        pass

print(least_price)

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

least_price = float("inf")
less_list = sorted([X, Y])

for i in range(less_list[1]+1):
    num_A = X- i
    num_B = Y - i
    
    if num_A <= 0 :
        num_A = 0
    if num_B <= 0:
        num_B = 0

    total_price = C * 2*i +  A * num_A + B * num_B
    if least_price > total_price:
            least_price = total_price
    else:
        pass

print(least_price)

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

byeEachAB = A * X + B * Y
byeABless = A * (X - min(X, Y)) + B * (Y - min(X, Y)) + C * min(X, Y) * 2
byeABmore = C * max(X, Y) * 2
print(min(byeEachAB, byeABless, byeABmore))

Solution (Python):

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

price = min(A+B, C*2)*min(X, Y)

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

print(price)

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



gyou=4 
retsu=6 

matrix=[[0 for i in range(retsu)] for j in range(gyou)]


matrix[0][0], matrix[0][1]= -x, -y 

matrix[1][0], matrix[1][1]= 1, 0
matrix[2][0], matrix[2][1]= 0, 1
matrix[3][0], matrix[3][1]= 1, 1

matrix[1][5], matrix[2][5], matrix[3][5]=a, b, 2*c


matrix[1][2]=1
matrix[2][3]=1
matrix[3][4]=1

for i in range(10):
    if min(matrix[0])>=0:
        break
    else:
        p_column=min(enumerate(matrix[0]), key=lambda x: x[1])[0]
        const_per_p=[10**6 for i in range(gyou)]

    for j in range(gyou):
        if matrix[j][p_column]>0:
            const_per_p[j]=matrix[j][5]/matrix[j][p_column]

            k_row=min(enumerate(const_per_p), key=lambda x: x[1])[0]
            pivot=matrix[k_row][p_column]

            new_matrix=[[0 for i in range(retsu)] for j in range(gyou)]
            for l in range(gyou):
                for j in range(retsu):
                    if l==k_row:
                       new_matrix[l][j]/=pivot
                    else:
                       new_matrix[l][j]=matrix[l][j]-matrix[l][p_column]*matrix[k_row][j]/pivot

    matrix=new_matrix[:][:]

print(int(matrix[0][5]))

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

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

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

pay = 0

XY = min([X, Y])
X -= XY
Y -= XY

if (A+B) > C*2:
    pay += XY*C*2
else:
    pay += XY*A + XY*B

if A > C*2:
    pay += X*C*2
else:
    pay += X*A

if B > C*2:
    pay += Y*C*2
else:
    pay += Y*B

print(pay)

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


"""                                                                                                                                                                   
                                                                                                                                                                      
1500 2000 1600 3 2                                                                                                                                                    
                                                                                                                                                                      
A * 3 + B * 2                         = 8500                                                                                                                          
                                                                                                                                                                      
2C + A*2 + B * 1 = 3200 + 4000 + 1600 = 8800                                                                                                                          
4C + A*1 + B * 0 = 6400 + 1500        = 7900                                                                                                                          
6C                                    = 9600                                                                                                                          
                                                                                                                                                                      
"""

acc = []

maxC = 2 * max(X,Y) + 2

for i in range(maxC):
    x=i
    if x % 2 == 0:
        Csize = x/2
        remXsize = X - Csize
        remYsize = Y - Csize
        acc.append( C * x + A * max(remXsize,0) + B * max(remYsize,0) )


print min(acc)

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

Solution (Python):


s = input().split(" ")
a = int(s[0])
b = int(s[1])
c = int(s[2])
x = int(s[3])
y = int(s[4])

out = 0
if x > y:
    mx = (x - y , "a")
    my = y
else:
    mx = (y - x , "b")
    my = x

cc = min([a+b, c*2])
for i in range(my):
    out += cc
if mx[1] == "a":
    if cc > a:
        out += a * mx[0]
    else:
        out += cc * mx[0]
else:
    if cc > b:
        out += b * mx[0]
    else:
        out += cc * mx[0]

print(out)

Solution (Python):
a, b, c, x, y = map(int, input().split())
[m,n],[M,N]= sorted([[x,a],[y,b]])
print(min(a*x+b*y,c*2*M,c*2*m+(M-m)*N))

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
print(min(a*x+b*y, c*2*max(x,y), c*2*min(x,y)+abs(x-y)*max([[x,a],[y,b]],key=lambda s:s[0])[1]))

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

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

res = A * X + B * Y
for i in range(2, 4 * (X + Y) + 1,2):
	curr = max(0,A * (X - i // 2)) + max(0,B * (Y - i // 2)) + C * i

	res = min(res, curr)

print(res)