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())

answer = 7000000000
for i in range(100001):
  amount = i*2*c + max(0, x-i)*a + max(0, y-i)*b
  if answer > amount:
    answer = amount
print(answer)

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a,b,c,x,y = i2()

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

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

Solution (Python):
import sys
import math
import numpy as np
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a, b, c, x, y = I2()
    ans = float("inf")
    for i in range(2*max(x,y)+1):
        cost = c * i + a * max(0,x - i // 2) + b * max(0,y - i // 2)
        ans = min(cost,ans)
    print(ans)

Solution (Python):

A,B,C,X,Y = map(int, input().split())
minprice = 10**10
for i in range(max(X,Y)+1):
    tmp = 0
    tmp += C * i*2
    tmp += A * max(0,X-i)
    tmp += B * max(0,Y-i)
    minprice = min(minprice, tmp)
print(minprice)

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

print(int(ans))

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

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

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


ans = A * X + B * Y

if X > Y:
  X, Y = Y, X
  A, B = B, A


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


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

print(ans)

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

for i in range(0, max(x, y) * 2 + 1, 2):
    d = x - i // 2
    e = y - i // 2
    if d < 0 :
        d = 0
    if e < 0:
        e = 0
    sum = a * d + b * e + c * i
    
    if min_sum > sum :
        min_sum = sum

print(min_sum)

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

Solution (Python):
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    ans1 = a * x + b * y
    ans2 = -1
    if x < y:
        ans2 = 2 * c * x + b * (y - x)
    else:
        ans2 = 2 * c * y + a * (x - y)
    ans3 = 2 * c * max(x, y)
    print(min(ans1, ans2, ans3))


if __name__ == '__main__':
    main()

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

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

ans = 10**18
for i in range(max(X,Y)+1):
    cost = i * AB
    if i < X:
        cost += A * (X-i)
    if i < Y:
        cost += B * (Y-i)
    ans = min(ans, cost)

print(ans)

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

ans = 0
if A + B < 2*AB:
    ans += min(X,Y) * (A+B)
else:
    ans += min(X,Y) * 2 * AB

X, Y = X-min(X,Y), Y-min(X,Y)

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

print(ans)

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

for i in range(0, max(X, Y)+1):
    if min(X, Y)-i >= 0:
        P.append(A*(X-i) + B*(Y-i) + 2*C*i)
    else:
        if X > Y:
            P.append(A*(X-i) + 2*C*i)
        else:
            P.append(B*(Y-i) + 2*C*i)

print(min(P))

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

for i in range(100001):
    amount = min(amount, 2*C*i + max(0, A*(X-i)) + max (0, B*(Y-i)))

print(amount)

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

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

p1 = a * x + b * y

p = c * 2 * x

if x >= y:
  p = p

else:
  p = p + (y - x) * b
      

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

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

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

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

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

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

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

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


print(min(cost_1, cost_2, cost_3))

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

ans=A*X+B*Y
Z=0
while max(X,Y)*2>=Z:
    x=max(0,X-(Z//2))
    y=max(0,Y-(Z//2))
    ans=min(ans,A*x+B*y+C*Z)
    Z+=2
print(ans)

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

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


ax = a * x
by = b * y




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


c_maisu_max = 2 * (max(x, y))


ans = 9999999999
for c_maisu in range(c_maisu_max, -1, -2):
    kingaku = 0
    if c_maisu // 2 >= max(x, y):
        kingaku = c * c_maisu
        
    else:
        a_maisu = 0
        b_maisu = 0
        
        
        if x - (c_maisu // 2) > 0:
            a_maisu = x - (c_maisu // 2)
        if y - (c_maisu // 2) > 0:
            b_maisu = y - (c_maisu // 2)
            
        kingaku = (a * a_maisu) + (b * b_maisu) + (c * c_maisu)
        
        
        
    ans = min(ans, kingaku)
    
print(ans)

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

z=min(X,Y)
x=X-z
y=Y-z
ans=min(ans,x*A+y*B+C*2*z)

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

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

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



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

answer = min(answer_1, answer_2, answer_3, answer_4)
print(answer)

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

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

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

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

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

res1 = a * x + b * y

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

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

res = min(res1, res2, res3)
print(res)

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

Solution (Python):

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

    all_double = 2 * max(X, Y) * C
    double = 2 * Y * C + (X - Y) * A if X >= Y else 2 * X * C + (Y - X) * B
    single = X * A + Y * B
    print(min(all_double, double, single))


if __name__ == '__main__':
    main()

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

price1 = A * X + B * Y
price2 = min(X, Y) * 2 * C + abs(X - Y) * (A if X > Y else B)
price3 = max(X, Y) * 2 * C

print(min(price1, price2, price3))

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

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

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

    else:
        minimum += a * x
        minimum += b * y

    print(minimum)


if __name__ == '__main__':
    main()

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

a,b,c,x,y = inpm()

ans = float('inf')
for ab in range(max(x+1,y+1)):
    ans = min(ans,c*ab*2 + a*max(0,x - ab) + b*max(0,y-ab))

print(ans)

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

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

ans = min(a*x+b*y, c*max(x, y)*2, tmp)
print(ans)

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

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

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

p = 0

z1 = a * x + b * y
z2 = 2 * c * min(x, y) + a * max(x-y, 0) + b * max(y-x, 0)
z3 = 2 * c * max(x, y)

print(min(z1, z2, z3))

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

Solution (Python):
import sys


def main():
    A, B, C, X, Y = map(int, sys.stdin.readline().rstrip().split())

    K = max(X, Y) * 2  

    cost = 5000 * 10**6
    for i in range(K + 1):

        
        rest_X = max(X - i // 2, 0)
        rest_Y = max(Y - i // 2, 0)

        
        cost = min(rest_X * A + rest_Y * B + i * C, cost)

    print(cost)


main()

Solution (Python):
A, B, C, X, Y = map(int, input().split())
cntA = 0
cntB = 0
cntC = 0
value = 0
if 2*C<=A+B:
    
    
    Cmaisu = (max(X, Y)-abs(X-Y))*2
    value += C * Cmaisu
    if (2*C<=A and X>Y) or (2*C<=B and X<Y):
        
        value += C * abs(X-Y) * 2
    else:
        if X>Y:
            value += A*(X-Y)
        else:
            value += B*(Y-X)
else:
    value += A*X+B*Y
print(value)

Solution (Python):
a,b,c,x,y = map(int,input().split())
cost = 0
mincost = 100000*5000*10

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

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

if a + b < 2 * ab:
    print(a * x + b * y)

else:
    ans = min(x, y) * 2 * ab
    if x > y:
        ans += min((x - y) * 2 * ab, (x - y) * a)
    elif y > x:
        ans += min((y - x) * 2 * ab, (y - x) * b)

    print(ans)

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

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

print(ans)

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

C*=2

tmp = max([X,Y])
result = 1e10
for i in range(tmp+1):
    current = C*i+max([0,A*(X-i)])+max([0, B*(Y-i)])
    if result>current:
        result = current
print(result)

Solution (Python):




import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1500 2000 1600 3 2"""
        output = """7900"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1500 2000 1900 3 2"""
        output = """8500"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1500 2000 500 90000 100000"""
        output = """100000000"""
        self.assertIO(input, output)


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

    ans = float("inf")
    for i in range(2*max(X, Y)+1):
        a = max(0, X - i//2)
        b = max(0, Y - i//2)
        ans = min(ans, A*a+B*b+C*i)
    print(ans)


if __name__ == "__main__":
    
    resolve()

Solution (Python):

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

    min_sum = 100000 * 5000 + 100000 * 5000 + 200000 * 5000

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


    else:
        for i in range(0, x+1):
            for j in range(0, y+1):
                if min_sum > a * i + b * j + max(x-i, y-j) * c * 2:
                    min_sum =a * i + b * j + max(x-i, y-j) * c * 2

    print(min_sum)
main()

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

if A+B <= 2*C:
    ans = X*A + Y*B
else:
    z = min(X, Y)
    if z == X:
        c = B
    else:
        c = A
    ans = C*2*z
    Z = max(X, Y) - z
    if c <= 2*C:
        ans += c*Z
    else:
        ans += 2*C*Z
    
print(ans)

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

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

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

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

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

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

Solution (Python):


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

numa = 0
numb = 0
numc = max(x, y)*2
value = c*numc



while numc:
    numc_tmp = numc-2
    numa_tmp = max(x-numc_tmp//2, 0)
    numb_tmp = max(y-numc_tmp//2, 0)

    value_tmp = a*numa_tmp+b*numb_tmp+c*numc_tmp
    

    if value_tmp >= value:
        print(value)
        exit()
    numc = numc_tmp
    numa = numa_tmp
    numb = numb_tmp
    value = value_tmp

print(value)

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

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

Solution (Python):

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

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

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

ans = 0

if X > Y:
    X -= Y
    ans += AB * Y
    ans += A * X
else:
    Y -= X
    ans += AB * X
    ans += B * Y

print(ans)

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

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

Solution (Python):
import sys
from sys import stdin


def input(): return stdin.readline().rstrip()


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


def ii():
    return int(input())
A, B, C, X, Y = mips()
money = 0
while X > 0 and Y > 0:
    if (A+B) <= 2*C:
        money += (A+B)
        X -= 1
        Y -= 1
    else:
        money += 2*C
        X -= 1
        Y -= 1
while X > 0:
    if A <= 2*C:
        money += A
        X -= 1
    else:
        money += 2*C
        X -= 1
        Y -= 1
while Y > 0:
    if B <= 2*C:
        money += B
        Y -= 1
    else:
        money += 2*C
        X -= 1
        Y -= 1
print(money)

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

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

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

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

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

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


a = 2*C*min(X,Y) + 2*C*(max(X,Y)-min(X,Y))


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

c = A*X + B*Y

print(min(a,b,c))

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

for i in range(2,all_ab+1,2):
    cnt = i*c
    alt = int(i/2)
    need_a = max(x - alt, 0)
    need_b = max(y - alt, 0)
    cnt += a*need_a + b*need_b
    ans = min(ans, cnt)
    

print(ans)

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

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

p1 = 2 * C * min(X, Y) + A * (X - min(X, Y)) + B * (Y - min(X, Y))
p2 = 2 * C * max(X, Y)
p3 = A * X + B * Y
print(min(p1, p2, p3))

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

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

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

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

max_c = max(2*X, 2*Y)

min_cost = float('inf')
for c in range(0, max_c+1, 2):
  a = max(0, X - c//2)
  b = max(0, Y - c//2)
  cost = A*a + B*b + C*c
  
  if cost < min_cost:
    min_cost = cost
    
    
print(min_cost)

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

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

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

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

cost_list = []
for i in range(0, max([X, Y]) * 2 + 1, 2):
    AB_cost = C * i
    A_cost = A * (X - int(i / 2))
    B_cost = B * (Y - int(i / 2))
    if A_cost < 0 and B_cost >= 0:
        A_cost = 0

    elif A_cost >= 0 and B_cost < 0:
        B_cost = 0
    elif A_cost >= 0 and B_cost >= 0:
        pass
    else:
        A_cost = 0
        b_cost = 0
    cost = AB_cost + A_cost + B_cost
    cost_list.append(cost)

print(min(cost_list))

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


ans=float("INF")
for ab in range(0,2*max(x,y)+1,2):
  
  
  cnt=ab*c
  
  cnt+=a*max(0,x-ab//2)
  
  cnt+=b*max(0,y-ab//2)
  ans=min(cnt,ans)

print(ans)

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

Solution (Python):
A,B,C,X,Y = map(int,input().split())
min_price = float("inf")
c_count = 0
while True:
    min_price = min(min_price,(A * X) + (B * Y) + (C * c_count))
    if X == 0 and Y == 0:
        break
    X = 0 if X <= 0 else (X-1)
    Y = 0 if Y <= 0 else (Y-1)
    c_count += 2
print(min_price)

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

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

if x > 0:
    if a > c * 2:
        ans += x * c * 2
    else:
        ans += x * a

if y > 0:
    if b > c * 2:
        ans += y * c * 2
    else:
        ans += y * b

print(ans)

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

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

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

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

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

    for k in range(max(X, Y) + 1):
        total = 2 * C * k + A * max(0, X - k) + B * max(0, Y - k)
        if total < ans:
            ans = total

    print(ans)


if __name__ == "__main__":
    main()

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

    for k in range(10 ** 5 + 1):
        total = 2 * C * k + A * max(0, X - k) + B * max(0, Y - k)
        if total < ans:
            ans = total

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
class Pizza:
  def __init__(self, price, count = 0):
    self.price = price
    self.count = count
    
  def count_pay(self):
  	return self.price * self.count
  
  def add_count(self,n):
    self.count += n
    if self.count <= 0:
      self.count = 0
      
A, B, C, X, Y = map(int, input().split())
P_A = Pizza(A,X)
P_B = Pizza(B,Y)
P_AB = Pizza(C)

i = 0
pay_list = []
while i <= max(X, Y):
  pay = P_A.count_pay() + P_B.count_pay() + P_AB.count_pay()
  pay_list.append(pay)
  P_A.add_count(-1)
  P_B.add_count(-1)
  P_AB.add_count(2)
  i += 1

print(min(pay_list))

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

    ans = 10**10
    for ai in range(x+1):
        ci = (x - ai)*2
        bi = y - ci//2
        if bi<0:
            bi = 0
        cost = a*ai + b*bi + c*ci
        if cost<ans:
            ans = cost

        if ai==0:
            if c*2 < b:
                bi = 0
                ci = max(x, y)*2
                cost = c*ci
                if cost<ans:
                    ans = cost

    print(ans)

if __name__=="__main__":
    main()

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

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

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

Solution (Python):
import math
A,B,C,X,Y = map(int,input().split())
ans = A * X + B * Y
for c in range(2 * 10 ** 5 + 1):
    a = math.ceil(X - c * 0.5)
    b = math.ceil(Y - c * 0.5)
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    mny = a * A + b * B + c * C
    if mny < ans:
        ans = mny
print(ans)

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

a = [0,1,2,X-2,X-1,X,abs(X-Y),abs(X-Y+1),abs(X-Y-1)]
b = [0,1,2,Y-2,Y-1,Y,abs(Y-X),abs(Y-X+1),abs(Y-X-1)]
c = [0,1,2,X*2-2,X*2-1,X*2,Y*2-2,Y*2-1,Y*2]
ans = A * X + B * Y
for aa in a:
    for bb in b:
        for cc in c:
            if aa + cc * 0.5 >= X and bb + cc * 0.5 >= Y:
                mny = A * aa + B * bb + C * cc
                if mny < ans:
                    ans = mny
print(ans)

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

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

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

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

res = A*X +B*Y

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

Solution (Python):
A,B,C,X,Y = map(int,input().split())
if 2*C >= A+B:
  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):
A, B, C, X, Y = map(int, input().split())

ans = 10**20
for i in range(max(X, Y) * 2 + 1):
    c = i
    a = X - i // 2
    if a < 0:
        a = 0
    b = Y - i // 2
    if b < 0:
        b = 0
    v = a * A + b * B + c * C
    if v < ans:
        ans = v

print(ans)

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

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

print(ans)

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



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

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

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

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd


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

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

ans = 10 ** 18
for i in range(0, 2 * max(X, Y) + 1, 2):
    tmpx = X - (i // 2)
    if tmpx <= 0:
        tmpx = 0
    tmpy = Y - (i // 2)
    if tmpy <= 0:
        tmpy = 0
    ans = min(ans, (i * C) + (tmpx * A) + (tmpy * B))

print(ans)