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

cost = 10**9
for i in range(2*10**5+1):
    if i%2==0:
        a_num = X-int(0.5*i)
        b_num = Y-int(0.5*i)
        if a_num < 0 and b_num < 0:
            break
        cost = min(cost, A*max(a_num, 0)+B*max(b_num, 0)+C*i)

print(cost)

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

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

Solution (Python):
from collections import Counter

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

if a+b >= ab*2:
    if x < y:
        less, more = x, y
        cost_l, cost_m = a, b
    else:
        less, more = y, x
        cost_l, cost_m = b, a
    
    cost = less*ab*2
    more -= less
    less = 0

    if cost_m < ab * 2:
        cost += more*cost_m
    else:
        cost += more*ab*2

    print(cost)
else:
    print(a*x+b*y)

Solution (Python):
from collections import Counter

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

if a+b >= ab*2:
    less = more = 0
    cost_l = cost_m = 0
    if x < y:
        less, more = x, y
        cost_l, cost_m = a, b
    else:
        less, more = y, x
        cost_l, cost_m = b, a
    
    cost = less*ab*2
    more -= less
    less = 0

    if cost_m < ab * 2:
        cost += more*cost_m
    else:
        cost += more*ab*2

    print(cost)
else:
    print(a*x+b*y)

Solution (Python):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

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

Solution (Python):
A,B,C,X,Y = map(int,input().split(" "))
P = 0
ans = 0
finans = 10 ** 9
for i in range(0,max(X,Y) * 2 + 1,2):
    ans = 0
    ans += C * i
    if X - i // 2 > 0:
        ans += A * (X - i // 2)
    if Y - i // 2 > 0:
        ans += B * (Y - i // 2)
    if ans < finans:
        finans = ans
print(finans)

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

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

is_ab = ((A+B)/2) >= C

amount = 0

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

else:
    amount += (A*X+B*Y)

print(amount)

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

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

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

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

AV = (A + B) / 2

cost = 0

if AB <= AV:
    n = min(X, Y)
    cost += AB * n * 2
else:
    n = min(X, Y)
    cost += (A + B) * n

X -= n
Y -= n

if X > 0:
    if 2 * AB <= A:
        cost += 2 * AB * X
    else:
        cost += A * X
elif Y > 0:
    if 2 * AB <= B:
        cost += 2 * AB * Y
    else:
        cost += B * Y

print(cost)

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

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
res = float('Inf')
for Z in range(10**5+1):
    total = 2*Z*C + max(0, X - Z)*A + max(0, Y - Z)*B
    if res > total:
        res = total
print(res)

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

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

Solution (Python):
A,B,C,X,Y=[int(x) for x in input().rstrip().split()]
ans=float('inf')
for i in range(10**5+1):
  now=2*C*i+max(0,X-i)*A+max(0,Y-i)*B
  ans=min(ans,now)
print(ans)

Solution (Python):

def main():
    import sys, math
    A,B,C,X,Y = map(int, sys.stdin.readline().split())
    ans = float('inf')
    for i in range(10**5+1):
        tmp = i*2*C + max(0, (X-i)*A) + max(0, (Y-i)*B)
        ans = min(tmp, ans)
        if i > X and i > Y:
            break
    print(ans)  

if __name__=='__main__':
    main()

Solution (Python):

def main():
    import sys, math
    A,B,C,X,Y = map(int, sys.stdin.readline().split())
    L =[]
    
    L.append(max(X, Y)*2*C)
    
    
    if X <= Y:
        L +=[X*2*C + (Y-X)*B]
    else:
        L +=[Y*2*C + (X-Y)*A]
    
    
    L.append(A*X+B*Y)
    print(min(L))


if __name__=='__main__':
    main()

Solution (Python):
a,b,c,X,Y=map(int,input().split())

s=min(X,Y)
t=max(X,Y)

ans1=2*c*s+a*(X-s)+b*(Y-s)
ans2=a*X+b*Y
ans3=2*c*t

print(min(ans1,ans2,ans3))

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())
import math
price_min = -1
for ab in [0, 2*X, 2*Y]:
    X_need = X - 0.5*ab
    Y_need = Y - 0.5*ab
    if X_need < 0:
        X_need = 0
    if Y_need < 0:
        Y_need = 0
    price = ab * C + A * math.ceil(X_need) + B * math.ceil(Y_need)
    if price_min == -1:
        price_min = price
    else:
        price_min = min(price, price_min)
print(price_min)

Solution (Python):
import math

A,B,C,X,Y=map(int,input().split())
limit=max(2*X,2*Y)

ans=float('inf')

for i in range(limit+1):
    temp=C*i+A*math.ceil(max(0,X-i/2))+B*math.ceil(max(0,Y-i/2))
    
    ans=min(ans,temp)

print(ans)

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

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

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

Solution (Python):
def solve(A, B, C, X, Y):
    ret = float("inf")
    for a_num in range(X + 1):
        ab_num = 2 * (X - a_num)
        price = min(
            a_num * A + max(0, Y - ab_num // 2) * B + ab_num * C,
            a_num * A + max(ab_num, 2 * Y) * C
        )
        ret = min(ret,price)
    return ret

if __name__ == "__main__":
    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 = 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()) 

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


    if remain_a > 0 and a > 2*c:
        print(ab_cnt*2*c + remain_a*2*c)
    elif remain_b > 0 and b > 2*c:
        print(ab_cnt*2*c + remain_b*2*c)
    else:
        print(ab_cnt*2*c + remain_a*a + remain_b*b)

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

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

print(min(l))

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

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

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

print(ans)

Solution (Python):
a,b,c,x,y=map(int,input().split())
if a+b<=2*c:
  print(a*x+b*y)
else:
  total=2*c*min(x,y)
  if x<=y:
    if b<=2*c:
      print(total+b*(y-x))
    else:
      print(total+2*c*(y-x))
  else:
    if a<=2*c:
      print(total+a*(x-y))
    else:
      print(total+2*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=i*c*2+a*max(x-i,0)+b*max(y-i,0)
    ans=min(ans,tmp)
print(ans)

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from collections import Counter
def resolve():
    A,B,C,X,Y=pin()
    ans=A*X+B*Y
    if X>Y:
        ans=min(ans,A*(X-Y)+2*C*Y)
        ans=min(ans,C*2*X)
    else:
        ans=min(ans,B*(Y-X)+2*C*X)
        ans=min(ans,C*2*Y)
    print(ans)

resolve()

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

ans.append(a*x + b*y)

ans.append(max(x, y)*c*2)

p = a if x > y else b
ans.append(min(x, y)*c*2 + (abs(x - y) * p))
print(min(ans))

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

for i in range(1, max(X,Y)+1):
    if X >= i:
        A_num = X-i
    else:
        A_num = 0
    if Y >= i:
        B_num = Y-i
    else:
        B_num = 0
    
    ans = min(ans, C*i+A*A_num+B*B_num)

print(ans)

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

ans1 = A * X + B * Y

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

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

print(min(ans1, ans2, ans3))

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

ans1 = a * x + b * y
ans2 = 2 * c * max(x, y)
z = min(x, y)
ans3 = 2 * c * z + a * (x - z) + b * (y - z)
print(min(ans1, ans2, ans3))

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

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

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

Solution (Python):
a,b,c,x,y = map(int, input().split())
min_price = 10**100
for n_ab in range(0, 2*max(x, y) + 1, 2):
    price = c * n_ab
    rest_x = x - n_ab//2
    if rest_x <= 0:
        rest_x = 0
    rest_y = y - n_ab//2
    if rest_y <= 0:
        rest_y = 0 
    price += rest_x * a + rest_y * b
    min_price = min(min_price, price)

print(min_price)

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

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

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

print(ans)

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

Solution (Python):
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

inf = float("inf")


def main():
    A, B, C, X, Y = map(int, input().split())
    if A + B > 2 * C:
        if X > Y:
            ret = 2 * C * Y
            if A > 2 * C:
                ret += 2 * C * (X - Y)
            else:
                ret += A * (X - Y)
        else:
            ret = 2 * C * X
            if B > 2 * C:
                ret += 2 * C * (Y - X)
            else:
                ret += B * (Y - X)
    else:
        ret = A * X + B * Y
    print(ret)
        
      
if __name__=='__main__':
    main()

Solution (Python):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

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

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

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

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

AB = A + B

num_A = 0
num_B = 0
num_C = 0
ans_cost = 5000 * 2 * 10**5
if 2 * C > AB:
    num_A = X
    num_B = Y
    num_C = 0
    ans_cost = int(A*num_A + B*num_B + C*num_C)
else:
    min_C = min(X,Y) *2
    max_C = max(X,Y) *2
    for i in range(min_C, max_C+1, 2):
        num_A = X - i / 2
        num_B = Y - i / 2
        if num_A < 1:
            num_A = 0
        if num_B < 1:
            num_B = 0
        
        total_cost = int(A*num_A + B*num_B + C*i)
    
        if total_cost < ans_cost:
            ans_cost = total_cost

print(ans_cost)

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

    p1 = a*x+b*y
    p2 = max(x,y)*c*2
    p3 = min(x,y)*c*2+max(x-y,0)*a+max(y-x,0)*b
    print(min(p1,p2,p3))
main()

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

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

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

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

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

print(min(p1,p2,p3))

Solution (Python):
def main():
    a, b, c, x, y = map(int, input().split())
    res = 10**100
    for i in range(10**5+1):
        pizza_a = max(0, x-i) * a
        pizza_b = max(0, y-i) * b
        pizza_c = 2 * c * i
        cost = pizza_c + pizza_a + pizza_b
        res = min(res, cost)
    print(res)

if __name__ == "__main__":
    main()

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

INF = float('inf')
min_cost = INF

k = 0
while X - k >= 0 or Y - k >= 0:
    cost = A * max(0, X-k) + B * max(0, Y-k) + 2 * C * k
    min_cost = min(min_cost, cost)
    k += 1

print(min_cost)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import math
    a,b,c,x,y=map(int, input().split())
    
    
    cmax=max(x,y) 
    c=2*c
    l=[]
    for i in range(cmax+1):
        amai = max(x - i,0)
        bmai = max(y - i,0)
        l.append(amai*a+bmai*b+i*c)
    print(min(l))
resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import math
    a,b,c,x,y=map(int, input().split())
    cmax=max(x,y)*2
    l=[]
    for i in range(cmax+1):
        amai = max(math.ceil(x - 0.5 * i),0)
        bmai = max(math.ceil(y - 0.5 * i),0)
        l.append(amai*a+bmai*b+i*c)
    print(min(l))
resolve()

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

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

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

price = 0

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

print(price)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import math
    a,b,c,x,y=map(int, input().split())
    cmax=max(x,y)*2
    l=[]
    for i in range(cmax+1):
        amai = math.ceil(x - 0.5 * i)
        bmai = math.ceil(y - 0.5 * i)
        if 0.5*i>=x and 0.5*i>=y:
            amai=0
            bmai=0
        elif 0.5*i>=x:
            amai=0
        elif 0.5*i>=y:
            bmai=0
        l.append(amai*a+bmai*b+i*c)
    print(min(l))
resolve()

Solution (Python):
import sys
readline = sys.stdin.readline
intin = map( int, readline().rstrip().split() )

a , b ,c , x , y  = intin

times = max(x,y)

total = 0
for t in range(times):
    if x > 0 and y > 0 :
        if a + b >= 2 * c :
            total += 2 * c
            x -= 1
            y -= 1
            continue
        else:
            total += a+b
            x -= 1 
            y -= 1
            continue
    elif x > 0 and y <= 0 :
        if a > 2 * c :
            total += 2 * c
            x -= 1
            continue
        else:
            total += a
            x -= 1
            continue
    elif y > 0 and x <= 0 :
        if b > 2 * c :
            total += 2 * c
            y -= 1
            continue
        else:
            total += b
            y -= 1
            continue
    else:
        break

print(total)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True




def warshall_floyd(d, n):
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d



def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)






def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



a, b, c, x, y = map(int, input().split())
n = 2 * max(x, y)
ans = INF
for z in range(n + 1):
    
    costc = c * z

    
    cnta = max(0, x - z // 2)

    
    cntb = max(0, y - z // 2)

    
    cost = costc + a * cnta + b * cntb

    ans = min(ans, cost)
print(ans)

Solution (Python):
a,b,ab,ax,bx = map(int,input().split())


import math
import sys

abmax = max(ax,bx)*2
candi = list()

for nab in range(abmax,-1,-1):
  na = max(math.ceil(ax - nab * 0.5),0)
  nb = max(math.ceil(bx - nab * 0.5),0)
  candi.append((na,nb,nab))

mincost = candi[0][0]*a + candi[0][1]*b + candi[0][2]*ab

for i in candi:
  cost = i[0]*a + i[1]*b + i[2]*ab
  if(cost < mincost):
    mincost = cost

print(mincost)

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

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

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

only = A*X+B*Y
only_mix = C*max(X,Y)*2
comp = 0
if X > Y:
    comp = C*Y*2+A*(X-Y)
elif X < Y:
    comp = C*X*2+B*(Y-X)
else:
    comp = C*Y*2

print(min(only,only_mix,comp))

Solution (Python):
a,b,c,x,y=[int(i)  for i in input().split()]
ans=1000000000
for k in range(10**5+1):
	money=2*c*k + max(x-k,0)*a + max(y-k,0)*b
	if(ans>money):
		ans=money
print(ans)

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

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

cost = a*x+b*y

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

print(cost)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
c_max = max(X, Y) * 2
ans = float('inf')
for c in range(0, c_max+1, 2):
    a = X - c // 2
    b = Y - c // 2
    ans = min(max(a, 0)*A + max(b, 0)*B + c*C, ans)

print(ans)

Solution (Python):
import sys
a,b,c,x,y = map(int,input().split())
ans = a*x + b*y
for i in range(max(x,y)+1):
    if (x-i >=0) and (y-i >=0):
        id = a*(x-i) + b*(y-i) + 2*c*i
        if id <= ans:
            ans = id
        else:
            print(ans)
            sys.exit()
    elif (x-i <0) and (y-i>=0):
        id = b*(y-i) + 2*c*i
        if id <= ans:
            ans = id
        else:
            print(ans)
            sys.exit()
    elif (x-i >=0) and (y-i<0):
        id = a*(x-i) + 2*c*i
        if id <= ans:
            ans = id
        else:
            print(ans)
            sys.exit()
print(ans)

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

AB_optimal = min(A+B, C*2)
A_optimal = min(A,C*2)
B_optimal = min(B,C*2)

XY_diff = abs(X-Y)

ans = 0
if X>=Y:
  ans += (X-XY_diff) * AB_optimal
  ans += XY_diff * A_optimal
else:
  ans += (Y-XY_diff) * AB_optimal
  ans += XY_diff * B_optimal

print(ans)

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


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

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

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

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

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

costs = 0

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

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

Solution (Python):

import sys

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

"""
ans = A * X + B * Y
for z in range(2, 2 * 10 ** 5 + 1, 2):
    x = max(X - int(z / 2), 0)
    y = max(Y - int(z / 2), 0)

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

print(ans)
"""

price1 = A * X + B * Y
price2 = C * 2 * X + B * max(Y - X, 0)
price3 = A * max(X - Y, 0) + C * 2 * Y
print(min(price1, price2, price3))

Solution (Python):

import sys

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

ans = A * X + B * Y
for z in range(2, 2 * 10 ** 5 + 1, 2):
    x = max(X - int(z / 2), 0)
    y = max(Y - int(z / 2), 0)

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

print(ans)

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


ans=10**15

for i in range(0,max(x,y)+7):
    tmp = 2*i*c
    tmp+=max(0,(x-i)*a)
    tmp+=max(0,(y-i)*b)
    ans=min(ans, tmp)
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())

total = 0


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

print(total)

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