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

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

Solution (Python):

import sys


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    A, B, C, X, Y = list(map(int, input().split()))

    return A, B, C, X, Y


def main(A: int, B: int, C: int, X: int, Y: int) -> None:
    """
    メイン処理.

    Args:\n
        A (int): Aピザの値段
        B (int): Bピザの値段
        C (int): ABピザの値段
        X (int): Aピザの必要枚数
        Y (int): Bピザの必要枚数
    """
    
    ans = sys.maxsize
    max_c = 2 * max(X, Y)
    for c in range(0, max_c + 1, 2):
        a = max(X - c // 2, 0)
        b = max(Y - c // 2, 0)
        price = a * A + b * B + c * C
        ans = min(ans, price)

    
    print(ans)


if __name__ == "__main__":
    
    A, B, C, X, Y = get_input()

    
    main(A, B, C, X, Y)

Solution (Python):

import sys


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


ans = sys.maxsize
max_c = 2 * max(X, Y)
for c in range(0, max_c + 1, 2):
    a = max(X - c // 2, 0)
    b = max(Y - c // 2, 0)
    price = a * A + b * B + c * C
    ans = min(ans, price)


print(ans)

Solution (Python):
def main():
    A, B, C, X, Y = map(int, input().split())
    ans = 10**10
    max_c = max(X, Y) + 1
    for i in range(max_c):
        num_c = i * 2
        num_a = max(0, X - i)
        num_b = max(0, Y - i)
        price = num_a * A + num_b * B + num_c * C
        ans = min(price, ans)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    A, B, C, X, Y = map(int, input().split())
    if A >= 2*C and B >= 2*C:
        ans = max(X, Y) * 2 * C
        print(ans)
        return
    if A>= 2*C:
        num_c = X * 2
        ans = num_c * C
        if Y * 2 > num_c:
            ans += (Y - num_c//2) * B
        print(ans)
        return
    if B >= 2*C:
        num_c = Y * 2
        ans = num_c * C
        if X * 2 > num_c:
            ans += (X - num_c//2) * A
        print(ans)
        return
    if A + B >= 2*C:
        num_c = min(X, Y) * 2
        ans = num_c * C
        ans += (X - num_c//2) * A
        ans += (Y - num_c//2) * B
        print(ans)
        return
    ans = X * A + Y * B
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
""" tutorial05
    https://atcoder.jp/contests/abc095/tasks/arc096_a
"""
import sys
import math
from functools import reduce

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def main(A, B, C, X, Y):
    """ main
    """
    if A + B > 2 * C:
        result = min([X, Y]) * 2 * C

        if X > Y:
            if A > 2 * C:
                return result + (X - Y) * 2 * C
            else:
                return result + (X - Y) * A
        else:
            if B > 2 * C:
                return result + (Y - X) * 2 * C
            else:
                return result + (Y - X) * B
    else:
        return X * A + Y * B

if __name__ == "__main__":
    _A, _B, _C, _X, _Y = readIntegerSet(5)

    print(main(_A, _B, _C, _X, _Y))

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

    ans1 = x*a + y*b
    min_num = min(x, y)
    max_num = max(x, y)
    x, y = x-min_num, y-min_num
    ans2 = min_num*c*2 + max(x, 0)*a + max(y, 0)*b
    ans3 = max_num*c*2
    ans = min(ans1, ans2, ans3)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
A,B,C,X,Y=map(int,input().split())
"""
X枚のA、Y枚のBが必要
ABピザの値段2枚が安いかどうかが分かれ目
"""
ans=(X+Y)*(A+B+C)

for i in reversed(range(max(X,Y)+1)):
    num_c=i*2
    num_a=max(0,X-i)
    num_b=max(0,Y-i)
    if ans>num_a*A+num_b*B+num_c*C:
        ans=num_a*A+num_b*B+num_c*C
print(ans)

Solution (Python):
A,B,C,X,Y=map(int,input().split())
"""
X枚のA、Y枚のBが必要
ABピザの値段2枚が安いかどうかが分かれ目
"""
ans=(X+Y)*(A+B+C)

for i in reversed(range(max(X,Y)+1)):
    num_c=i*2
    num_a=max(0,X-i)
    num_b=max(0,Y-i)
    if ans>num_a*A+num_b*B+num_c*C:
        ans=num_a*A+num_b*B+num_c*C
    else:
        break
print(ans)

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

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

min_total = float("inf")
for i in range(max(X, Y) + 1):
    sum_C = 2 * C * i
    sum_A = A * max(0, X - i)
    sum_B = B * max(0, Y - i)
    total = sum_C + sum_A + sum_B
    if total < min_total:
        min_total = total

print(min_total)

Solution (Python):
def main():
    A, B, C, X, Y = map(int, input().split())
    prices = sorted([(X, A, C), (Y, B, C)], key=lambda x: x[0])
    min_price = 1e10
    for i in range(prices[0][0]+1):
        tmp_price = prices[0][1] * i + 2 * prices[0][2] * (prices[0][0]-i)
        rest = prices[1][0] - (prices[0][0]-i)
        tmp_price += min(rest * prices[1][1], 2 * rest * prices[1][2])
        min_price = min(min_price, tmp_price)

    print(min_price)


if __name__ == '__main__':
    main()

Solution (Python):

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

n = a*x+b*y

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

if x<y:
    p = b
else:
    p = a

l = 2*c*min(x,y) + p*abs(x-y)

ans = min(n,min(m,l))

print(ans)

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

min_xy = min(x, y) 
max_xy = max(x, y)

min_xy_cost = min(a + b, c * 2) * min_xy

if x >= y:
  rest = x - y
  rest_cost = rest * min(a, c * 2)
else:
  rest = y - x
  rest_cost = rest * min(b, c * 2)
  
total = min_xy_cost + rest_cost

print(total)

Solution (Python):
import sys
import math

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

ans = 10**15
a = []

for i in range(max(X, Y)+1):
    if X-i < 0:
        money = B*(Y-i) + 2 * C * i
    elif Y-i < 0:
        money = A*(X-i) + 2 * C * i
    else:
        money = A*(X-i) + B*(Y-i) + 2*C*i
    a.append(money)


print(min(a))

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

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

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

mi=min([x,y])
ma=max([x,y])
g=ma-mi
ans,ab=0,0


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

if ab >= ans: 
  print(ans)
else:
  if ab!=0:
    print(ab)
  else:
    print(ans)

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

cnt = max(x, y)

ans = 1 << 60
for i in range(cnt + 1):
    ans = min(ans, 2 * i * c + max(x - i, 0) * a + max(y - i, 0) * b)

print(ans)

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

price = X * A + Y * B
for a in [0,abs(X-Y),X]:
    for b in [0,abs(X-Y),Y]:
        c = max(X-a,Y-b)*2
        price = min(price,a*A + b*B + c*C)

print(price)

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

ans = A * X + B * Y

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

print(min(ans, ans1,ans2))

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

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

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

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


print(kei)

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

values = []

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

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

print(min(values))

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

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

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

Solution (Python):
A,B,C,x,y = map(int,input().split())
ans = 0
if A+B > 2*C:
    ans += min(x,y)*C*2
else:
    ans += x*A + y*B
    print(ans)
    exit()    

if x >= y:
    x -= y
    y = 0
    if A <2*C:
        ans += x*A
    else:
        ans += x*2*C    
else:
    y -= x
    x = 0
    if B < 2*C:
        ans += y*B
    else:
        ans += y*2*C
print(ans)

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

cost = 0

while x>0 or y>0:
  
  if a+b>=2*c:
    while x>0 and y>0:
      cost += 2*c
      x -= 1
      y -= 1
      
  if x>0:
    if a>=2*c:
      cost += 2*c
    else:
      cost += a
    x -= 1
  elif y>0:
    if b>=2*c:
      cost += 2*c
    else:
      cost += b
    y -= 1
    
print(cost)

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




ans = float('inf')


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

Solution (Python):
import sys

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

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

def ii():
    return int(input())

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

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

if __name__ == '__main__':
    main()

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

mins, maxs = min(x,y), max(x,y)
diff = maxs - mins

total = min((a+b) * mins, c * mins*2)

pp = a if x > y else b
total += (pp if pp < c * 2 else c * 2 ) * diff
print(total)

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

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

print(ans)

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

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

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

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

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

if A + B < 2 * C:
    ans = A*X + B*Y

else:
    for _ in range(min(X, Y)):
        ans += 2 * C

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

print(ans)

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

ans = A * X + B * Y

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

print(ans)

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

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

print(res)

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

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

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

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

print(aaa)

Solution (Python):
a,b,c,x,y=map(int,input().split())
money=0
ans=float("INF")

money=a*x+b*y
ans=min(money,ans)


money=2*min(x,y)*c+(x-min(x,y))*a+(y-min(x,y))*b
ans=min(money,ans)


money=2*c*max(x,y)
ans=min(money,ans)

print(ans)

Solution (Python):






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





ans1 = A*X + B*Y
ans2 = C*min(X,Y)*2 + A*(X-min(X,Y)) + B*(Y-min(X,Y))
ans3 = C*max(X,Y)*2
print(min(ans1, ans2, ans3))

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


ans = 10000 * (10 **5) + 7
c_max = 0
if x > y:
  c_max = x * 2
else:
  c_max = y * 2

for cc in range(0, c_max+1, 2):
  ac = x - (cc // 2)
  bc = y - (cc // 2)
  
  if ac < 0:
    ac = 0
  if bc < 0:
    bc = 0
  price = ac * a + bc * b + cc * c
  
  ans = min(ans, price)

print(ans)

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

Solution (Python):
import math

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

for c in range(0, max(2*X, 2*Y)+1, 2):
  a = max(0, math.ceil(X-0.5*c))
  b = max(0, math.ceil(Y-0.5*c))
  if A*a + B*b + C*c < lowest:
    lowest = A*a + B*b + C*c

print(lowest)

Solution (Python):
import math

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

for a in range(0, X+1):
  c = (X-a)*2
  if Y - 0.5*c < 0:
    b = 0
  else:
    b = math.ceil(Y - 0.5*c)
  if A*a + B*b + C*c < lowest:
    lowest = A*a + B*b + C*c
    
for b in range(0, Y+1):
  c = (Y-b)*2
  if X - 0.5*c < 0:
    a = 0
  else:
    a = math.ceil(X - 0.5*c)
  if A*a + B*b + C*c < lowest:
    lowest = A*a + B*b + C*c

print(lowest)

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

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

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


print(a)

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

K=10**9
for i in range(10**5+1):
    S=i*2*C+max(0,X-i)*A+max(0,Y-i)*B
    K=min(K,S)
print(K)

Solution (Python):
def resolve():
    A, B, C, X, Y = list(map(int, input().split()))
    ans = []
    for i in range(0, 100000+1):
        ans.append(i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B)
    print(min(ans))
    return


resolve()

Solution (Python):
a, b, c, x, y = map(int, input().split())
l = []
l.append(a*x + b*y)
l.append(2*c * max(x, y))

if x < y:
    l.append(2*c*x + b*(y-x))
elif x > y:
    l.append(2*c*y + a*(x-y))

print(min(l))

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

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

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

Solution (Python):
A,B,C,X,Y = map(int,input().split())
p_sum = []
for i in range(100001):
  p_sum.append(i*2*C + max(0,X-i)*A + max(0,Y-i)*B)
print(min(p_sum))

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

ans = 10 ** 10
for c in range(2 * 10 ** 5 + 1):
    a = X - c // 2
    b = Y - c // 2
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    ans = min(ans, A * a + B * b + C * c)
print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

print(min(p1,p2,p3))

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

print(output)

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

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

Solution (Python):
def resolve():
    import sys
    input = sys.stdin.readline    
    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)+c*z*2,max(x,y)*2*c)
    print(ans)

if __name__ == '__main__':
    resolve()

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    A, B, C, X, Y =map(int, input().split())
    ans = min(min(2*X*C + max((Y-X)*B, 0), 2*Y*C + max((X-Y)*A, 0)), A*X + B*Y)
    print(ans)    

if __name__ == '__main__':
    main()

Solution (Python):

a, b, c, x, y = map(int,input().split())
ans1 = a * x + b * y
if x <= y:
    ans2 = c * 2 * x + b * (y - x)
    ans5 = c * 2 * y
else:
    ans2 = c * 2 * y + a * (x - y)
    ans5 = c * 2 * x
ans3 = a * x + c * 2 * y
ans4 = b * y + c * 2 * x





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

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

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

ans = 0
if a + b <= c * 2:
    ans += a * x + b * y
else:
    if x == y:
        ans += c * 2 * x
        x, y = 0, 0
    elif x > y:
        ans += c * 2 * y
        x -= y
        y = 0
    elif y > x:
        ans += c * 2 * x
        y -= x
        x = 0
    if x > 0:
        if a <= c * 2:
            ans += a * x
        else:
            ans += c * 2 * x
    elif y > 0:
        if b <= c * 2:
            ans += b * y
        else:
            ans += c * 2 * y

print(ans)

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

Solution (Python):

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

cost = a * x + b * y
n = max(x, y)

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

print(cost)

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

for i in range(100001):
    price = 2*C*i + A*max(0,X-i) + B*max(0,Y-i)
    list.append(price)

print(min(list))

Solution (Python):
import sys


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

    min_price = None

    for i in range(max(x, y) + 1):
        nc = i * 2
        na = x - i
        if na < 0:
            na = 0
        nb = y - i
        if nb < 0:
            nb = 0

        price = na * a + nb * b + nc * c
        if min_price is None or price < min_price:
            min_price = price

    print(min_price)


if __name__ == '__main__':
    main()

Solution (Python):



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

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

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

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

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

Solution (Python):
import sys
from collections import deque
from itertools import *


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, C, X, Y = LI()
avg = (A+B)/2
ans = 0
if avg > C:
    ans += C * min(X, Y) * 2
    if X > Y:
        if A > C * 2:
            ans += C * (X - Y) * 2
        else:
            ans += A * (X - Y)
    elif X < Y:
        if B > C * 2:
            ans += C * (Y - X) * 2
        else:
            ans += B * (Y - X)
    elif X == Y:
        pass
else:
    ans = A * X + B * Y
print(ans)

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

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

ans = min(X,Y)*min(2*AB, A+B)
cnt_A = min(X,Y)
cnt_B = min(X,Y)


if X > cnt_A:
    ans += min(2*AB,A)*(X-cnt_A)
else:
    ans += min(2*AB,B)*(Y-cnt_B)
    
print(ans)

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

ans=10**9

my_min=min(X,Y)
my_max=max(X,Y)

ans1=2*C*my_min+A*(X-my_min)+B*(Y-my_min)
ans2=2*C*my_max
ans3=A*X+B*Y
print(min(ans1,ans2,ans3))

Solution (Python):
A, B, C, X, Y = map(int, input().split())
sum = 0
min_num = 10**10
num = [0]*3
for c in range(max(X, Y)+1):
    sum += C*c*2
    num[0] = c*2
    sum += A*max(0,X-c) + B*max(0, Y-c)
    num[1] = max(0, X-c)
    num[2] = max(0, Y-c)
    if min_num > sum:
        min_num = sum
    sum = 0
print(min_num)

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

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

Solution (Python):
a,b,c,x,y=map(int,input().split())
minpr=10e+10
memo=None
if x>=y:
  for i in range(x+1):
    price= i*a+ 2*(x-i)*c+ max(0,y-(x-i))*b
    minpr=min(price,minpr)
  print(minpr)
else:
  
  for i in range(y+1):
    price= i*b+ 2*(y-i)*c+ max(0,x-(y-i))*a
    minpr=min(price,minpr)
  print(minpr)

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

Solution (Python):
def main():
    a,b,ab,ac,bc = map(int,input().split())
    price = 0
    if a+b < ab*2:
        price = a*ac + b*bc
    else:
        if ac < bc:
            price += ab*ac*2
            x = bc-ac
            price += min(x*b, x*ab*2)
        else:
            price += ab*bc*2
            x = ac-bc
            price += min(x*a, x*ab*2)
    print(price)

if __name__ == "__main__":
    main()

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

Solution (Python):
def solve(a,b,c,x,y):
  l = []
  for i in range(10**6):
    s = a*max(x-i,0)+b*max(y-i,0)+c*i*2
    l.append(s)
  return min(l)

        

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

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

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

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

print(res)

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

ans += min(a+b,c)*z

ans += min(v,c)*w

print(ans)

Solution (Python):


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

ans = 2*5000*100000
for k in range(100001):
    tmp = 2*c*k + max(x-k, 0)*a + max(y-k, 0)*b
    ans = min(ans, tmp)
print(ans)

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

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

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

print(min(naive, recon, over))

Solution (Python):
a, b, c, x, y=map(int,input().split())
 
cnt = 10**9
for m in range(max(x,y)+1):
    price = (2*m*c) + max(0,(x-m))*a + max(0,y-m)*b
    cnt = min(cnt, price)

print(cnt)

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, C, X, Y = lr()
if X > Y:
    A, B = B, A
    X, Y = Y, X

AB2 = 2 * C
answer = 0
if AB2 < A + B:
    answer += AB2 * X
    Y -= X; X = 0
else:
    answer += (A + B) * X
    Y -= X; X = 0
if AB2 < B:
    answer += AB2 * Y
else:
    answer += B * Y

print(answer)

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

cnt=10**9
for m in range(max(x,y)+1):
    price=(2*m*c)+max(0,(x-m))*a+max(0,y-m)*b
    cnt=min(cnt,price)
    
print(cnt)

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

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

ans = a * x + b * y
cnt = 1

while x != 0 or y != 0:
  x = max(x - 1, 0)
  y = max(y - 1, 0)
  ans = min(ans,a*x+b*y+c*2*cnt)
  cnt += 1
print(ans)

Solution (Python):

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


ans = a * x + b * y
cnt = 1
while x != 0 or  y!= 0:
    x = max(x - 1, 0)
    y = max(y - 1, 0)
    ans = min(ans,a*x+b*y+c * 2 * cnt)
    cnt += 1
    
print(ans)

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

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

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

print(ans)

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

ans = A*X + B*Y
tmp = A*X + B*Y
x = X
y = Y
z = 0

while x >= 0 or y >= 0:
    tmp = A*max(0,x) + B*max(0,y) + C*z
    ans = min(ans,tmp)
    x=x-1
    y=y-1
    z=z+2

print(ans)

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

ans = A*X + B*Y
tmp = A*X + B*Y
x = X
y = Y
z = 0

while x >= 0 or y >= 0:
    if x<0 and y<0:
        tmp = C*z
    elif x<0:
        tmp = B*y + C*z
    elif y<0:
        tmp = A*x + C*z
    else:
        tmp = A*x + B*y + C*z
    ans = min(ans,tmp)
    x=x-1
    y=y-1
    z=z+2

print(ans)

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

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

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

print(ans)

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

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

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

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

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

else:
    ans = 2*C*max(X, Y)

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

Solution (Python):
def resolve():
    import sys
    input = sys.stdin.readline
    
    
    
    a, b, c, x, y = map(int, input().split())
    
    
    
    
    
    

    pizzamax = [x for x in range(max(x,y)+1)]
    pizzamax.sort(reverse=True)

    paymin = 5000 * 2 * 10**5
    for i in pizzamax:
        pay = 2 * i * c
        if i < x:
            pay += (x-i) * a
        if i < y:
            pay += (y-i) * b
        paymin = min(paymin, pay)

    print(paymin)
resolve()

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

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

print(cost)