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):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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

    ans = INF
    for k in range(0, 2 * max(X, Y) + 1, 2):
        i = max(0, X - k // 2)
        j = max(0, Y - k // 2)
        if ans > A * i + B * j + C * k:
            ans = A * i + B * j + C * k

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b, c, x, y = mi()
    if x <= y:
        print(min(2 * c * x + (y - x) * b, 2 * c * y, a * x + b * y))
    else:
        print(min(2 * c * y + (x - y) * a,  2 * c * x, a * x + b * y))


if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
price = float("inf")
max_iter = max(x, y)*2

for i in range(max_iter):
    a_num = max(x-i, 0)
    b_num = max(y-i, 0)
    price = min(price, a_num*a + b_num*b + 2*i*c)

print(price)

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

ans=[]

ans.append(A*X+B*Y)
ans.append(C*max(X,Y)*2)

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

print(min(ans))

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

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

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

print(ans)

Solution (Python):

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

Solution (Python):

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

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


min_cost = 0

if X - Y > 0:
    temp_cost = 2 * C * Y
    temp_cost += A * (X - Y)    

    temp_cost2 = 2 * C * X

    if temp_cost > temp_cost2:
        min_cost = temp_cost2
    else:
        min_cost = temp_cost

else:
    temp_cost = 2 * C * X
    temp_cost += B * (Y - X)

    temp_cost2 = 2 * C * Y

    if temp_cost > temp_cost2:
        min_cost = temp_cost2
    else:
        min_cost = temp_cost


temp_cost3 = A * X + B *Y

if temp_cost3 < min_cost:
    min_cost = temp_cost3

print(min_cost)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    a, b, c, x, y = MI()

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

    else:
        mn = min(x, y)
        ans = mn * 2 * c + max(0, x-mn) * min(a, 2*c) + max(0, y-mn) * min(b, 2*c)

    print(ans)



if __name__ == '__main__':
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    a, b, c, x, y = MI()

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


if __name__ == '__main__':
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    a, b, c, x, y = MI()

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

        if x < y:
            x = y
            a = b

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

    else:
        mn = min(x, y)
        ans = mn * 2 * c
        x -= mn
        y -= mn

        if x < y:
            x = y
            a = b

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

    print(ans)



if __name__ == '__main__':
    solve()

Solution (Python):
A, B, C, x, y = map(int, input().split())

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

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

if A + B >= AB * 2:
    min_price = min(AB * 2 * min_sheet + A * (X - min_sheet) + B * (Y - min_sheet), AB * 2 * max(X,Y))
else:
    min_price = A * X + B * Y
    
print(min_price)

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

cost = 0
a_count = 0
b_count = 0

while a_count < x and b_count < y:
    if a + b < 2 * c:
        cost += a + b
        a_count += 1
        b_count += 1
    else:
        cost += 2 * c
        a_count += 1
        b_count += 1

while a_count < x:
    if a < 2 * c:
        cost += a
        a_count += 1
    else:
        cost += 2 * c
        a_count += 1
        b_count += 1

while b_count < y:
    if b < 2 * c:
        cost += b
        b_count += 1
    else:
        cost += 2 * c
        a_count += 1
        b_count += 1

print(cost)

Solution (Python):
import sys
input = sys.stdin.readline

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

cost = float('inf')
mz = max(x,y)*2
for z in range(1,mz+1):
    
    if z > 0:
        cost = min(cost, a*max((x-0.5*z),0) + b*max((y-0.5*z),0) + c*z)
cost = int(min(cost, a*x + b*y))
print(cost)

Solution (Python):

import sys
input = sys.stdin.readline









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

ans = 0

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

print(ans)

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



mcost = 2 ** 30
for i in range(0,200001,2):
    XX = max(0, X - (i // 2))
    YY = max(0,Y - (i // 2))
    cost = XX * A + YY * B + i * C
    if mcost > cost:
        mcost = cost

print(mcost)

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

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

print(min(k))

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

l = a*x + b*y
m = max(x,y)*2*c
if x >= y:
    n = y*2*c + (x-y)*a
else:
    n = x*2*c + (y-x)*b

print(min(l,m,n))

Solution (Python):
import math

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

cost_a = min(2*c,a)
cost_b = min(2*c,b)
cost_ab = min(2*c,cost_a+cost_b)
min_xy = min(x,y)

cost_res = 0
if 2*c < a+b:
    cost_res = min_xy * (2*c)
    cost_res += (x-min_xy)*cost_a+(y-min_xy)*cost_b
else:
    cost_res = min_xy * (a+b)
    cost_res += (x-min_xy)*cost_a+(y-min_xy)*cost_b
print(cost_res)

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

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





tar1 = a * x + b * y
tar2 = 2 * c * max(x, y)

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


ans = min(tar1, tar2, tar3)



print(ans)

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

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

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

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

Solution (Python):

def inp():
    return(int(input()))



def inlist():
    return(list(map(int, input().split())))



def instr():
    s = input()
    return(list(s[:len(s)]))



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


def which(a, b, x, y):
    if x < y:
        return b
    return a


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

cost1 = a * x + b * y
cost2 = 1000000000000
cost3 = 1000000000000

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


print(min(cost1, cost2))

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    ans = []
    A, B, C, X, Y = map(int, input().split())
    for i in range(10**5+1):
        ans.append((C*2*i) + (A*max(0, X-i)) + (B*max(0, Y-i)))

    print(min(ans))

if __name__ == '__main__':
    main()

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

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

if x > y:
  dai = a
else:
  dai = b
  
if dai >= 2 * c:
  print(c * max(x, y) * 2)

else:
  for i in range(min(x, y) + 1):
    temp = a * (x - i) + b * (y - i) + c * (i * 2)
    if ans > temp:
      ans = temp
  print(ans)

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

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

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

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

Solution (Python):
a, b, c, x, y = [int(s) for s in input().split()]
ans = 10 ** 9
for i in range(max(x, y) + 1):
    ans_temp = c * 2 * i + a * max(x - i, 0) + b * max(y - i, 0)
    if ans_temp < ans:
        ans = ans_temp
print(ans)

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

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

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


mm=min(x,y)

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


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 make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





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

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

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

answer = sys.maxsize
for i in range(max(X, Y)+1):
  total = i*2*C+A*max(0,X-i)+B*max(0,Y-i)
  answer = min(answer, total)
print(answer)

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

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

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

print(answer)

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

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

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

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

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

print(ans)

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

p1 = X *A +Y *B

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

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

print(min(p1,p2,p3))

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

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

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

plan1 = (A*X) + (B*Y)
plan2 = (C*2) * max(X,Y)
plan3 = (C*2) * X + B*(Y-X)
plan4 = (C*2) * Y + A*(X-Y)

if X <= Y:
  print(min(plan1,plan2,plan3))
else:
  print(min(plan1,plan2,plan4))

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

print(v)

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







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

Solution (Python):











INF = 1001001001001


def main():

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

    ans = INF
    for i in range(0, ab_max + 1, 2):
        a_num = max(0, X - i // 2)
        b_num = max(0, Y - i // 2)
        price = A * a_num + B * b_num + C * i
        
        ans = min(ans, price)

    print(ans)


if __name__ == '__main__':
    main()

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

ans = float('inf')

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 ** 12
for i in range(10 ** 5 + 1):
  money = 2 * i * C
  money += A * max(0, X - i)
  money += B * max(0, Y - i)
  ans = min(ans, money)
  
print(ans)

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

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

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
if x > y:
    x, y = y, x
    a, b = b, a
i = 0
total = a*(x-i) + (y-i)*b + 2*i*c
while True:
    
    i += 1
    ntotal = a*max(0 ,x-i) + b*max(0, (y-i)) + 2*i*c
    if total < ntotal:
        break
    total = ntotal
print(total)

Solution (Python):
def main():
    A, B, C, X, Y = list(map(int, input().split(' ')))
    p1 = A * X + B * Y
    p2 = 2 * C * X + B * max([0, Y - X])
    p3 = 2 * C * Y + A * max([0, X - Y])
    p4 = 2 * C * max([X, Y])
    print(min([p1, p2, p3, p4]))


if __name__ == '__main__':
    main()

Solution (Python):

import math
A, B, C, X, Y = map(int, input().split())
money = []
for i in range(0, max(X,Y) + 1 ):
    val = 0
    val += A * (X - i) if X - i > 0 else 0
    val += B * (Y - i) if Y - i > 0 else 0
    money.append(  val + C * 2*i )
print(min(money))

Solution (Python):
a, b, c, x, y = map(int, input().split())
m = 0
l = 2 * c * max(x, y)
d = abs(x - y)

if c * 2 <= a + b:
    m += 2 * c * min(x, y)
    if x <= y:
        m += b * d
    else:
        m += a * d
    print(min(m, l))
else:
    m += a * x + b * y
    print(m)

Solution (Python):
def half_and_half(a,b,c,x,y):
    z = x   if x > y else y
    can = []
    
    for n in range(z+1):
        p = x - n if x > n else 0
        q = y - n if y > n else 0
        amount = p*a + q*b + n*c*2
        
        can.append(amount)

    return min(can)

if __name__ == '__main__':
    a,b,c,x,y = map(int,input().split())
    print(half_and_half(a,b,c,x,y))

Solution (Python):
def half_and_half(a,b,c,x,y):
    z = x   if x > y else y
    can = []
    
    for n in range(z+1):
        p = x - n if x > n else 0
        q = y - n if y > n else 0
        amount = p*a + q*b + n*c*2
        
        can.append(amount)

    
    print(min(can))
    
if __name__ == '__main__':
    a,b,c,x,y = map(int,input().split())
    
    
    half_and_half(a,b,c,x,y)

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

min_price = A * X + B * Y

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

if X > 0 and A > 2 * C:
    while X > 0:
        X = X - 1
        min_price -= A - 2 * C

if Y > 0 and B > 2 * C:
    while Y > 0:
        Y = Y - 1
        min_price -= B - 2 * C

print(min_price)

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

min_price = A * X + B * Y

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

if X > 0 and A > 2 * C:
    while X > 0:
        X = X - 1
        min_price -= A - 2 * C

if Y > 0 and B > 2 * C:
    while Y > 0:
        Y = Y - 1
        min_price -= B - 2 * C

print(min_price)

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

print(ans)

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

cost = 1e+15
for i in range(max(x, y)+1):
  xx = max(0, x - i)
  yy = max(0, y - i)
  cost = min(cost, A * xx + B * yy + 2*C*i)
print(cost)

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

ans=10**9
for i in range(0,max(x,y)*2+2,2):
  tx=max(x-i//2,0)
  ty=max(y-i//2,0)
  t_ans=tx*a+ty*b+i*c
  ans=min(ans,t_ans)
print(ans)

Solution (Python):
def main():
  A, B, C, X, Y = map(int, input().split())
  print(min([C*max(X, Y)*2, A*X + B*Y, 2*C*Y+A*(max(0, X-Y)), 2*C*X + B*(max(0, Y-X))]))
if __name__ == "__main__":
  main()

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

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

List=[(A*X)+(B*Y)]

AB=0
AP=0
BP=0
ANS=0
while 1:
    if AP>=X and BP>=Y:
        
        List.append(ANS)
        break
    if AB==2:
        AP+=1
        BP+=1
        AB=0
    else:
        ANS+=C
        AB+=1

AB=0
AP=X
BP=Y
ANS=0
while 1:
    if AP==0:
        ANS+=(BP*B)
        List.append(ANS)
        break
    elif BP==0:
        ANS+=(AP*A)
        List.append(ANS)
        break
    else:
        if AB==2:
            AP-=1
            BP-=1
            AB=0
        else:
            ANS+=C
            AB+=1
            

print(min(List))

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

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

print(ans)

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

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

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

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

    if ans > total:
        ans = total

print(ans)

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

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

Solution (Python):


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

cost=a*x + b*y

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

print(cost)

Solution (Python):
a,b,c,x,y=map(int,input().split())
l=sorted([a,b,c*2])
if l[0]==c*2:
    print(max(x,y)*c*2)
elif l[1]==c*2:
    if l[0]==a:
        print(y*c*2+max((x-y),0)*a)
    else:
        print(x*c*2+max((y-x),0)*b)
else:
    if a+b>=c*2:
        if x>=y:
            print(y*2*c+(x-y)*a)
        else:
            print(x*2*c+(y-x)*b)
    else:
        print(x*a+y*b)

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

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

Solution (Python):
A, B, C, X, Y = map(int, input().split())
a1 = A * X + B * Y
a2 = B * (Y - X) + C * 2 * X
a3 = A * (X - Y) + C * 2 * Y
a4 = a3 if X > Y else a2
a5 = C * 2 * max(X, Y)
ans = min(a1, a4, a5)
print(ans)

Solution (Python):
import sys
import math
ans = float('inf')
a,b,c,x,y = map(int,sys.stdin.readline().rstrip().split())
for i in range(max(x,y)+1):
  if x > y and i >= y:
  	sum = a * (x - i) +  2 * i * c
  elif y > x and i >= x:
    sum = b * (y - i) + 2 * i * c
  else:
    sum = a * (x - i) + b * (y - i) + 2 * i * c
  ans = min(ans,sum)
print(ans)

Solution (Python):
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007



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















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

print(kotae)

Solution (Python):
a,b,c,x,y = map(int,input().split())
if x>y:
  a,b,x,y = b,a,y,x
res = a*x +b*y
for i in range(x):
  p_res = res
  res += 2*c-(a+b)
  if p_res<res:
    res = p_res
    break
for i in range(y-x):
  p_res = res
  res += 2*c-b
  if p_res < res:
    res = p_res
    break
print(res)

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

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

print(ans)

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

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

Solution (Python):
[a, b, ab, x, y] = [int(i) for i in input().split()]
price = []
price.append(a * x + b * y)
if x > y:
    price.append(2 * ab * y + a * (x-y))
else:
    price.append(2 * ab * x + b * (y-x))
price.append(ab * 2 * max(x, y))
print(min(price))

Solution (Python):


import sys

def main():
    A, B, C, X, Y = map(int, sys.stdin.readline().split())
    
    
    if C*2 >= A+B:
        ans = A*X + B*Y
    else:
        ans = min(X, Y) * C * 2
        
        
        ans += min(A*(X-min(X, Y)), C*2*(X-min(X, Y))) + min(B*(Y-min(X, Y)), C*2*(Y-min(X, Y)))
    print(ans)
    
if __name__ == "__main__":
    main()

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

ans = 0

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

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

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

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

Solution (Python):
def resolve():
	a, b, c, x, y = map(int, input().split())
	opt1 = a*x + b*y
	v = a if x > y else b
	opt2 = min(x, y) * 2 * c + abs(x - y)*v
	opt3 = min(x, y)*2*c + abs(x-y)*2*c
	print(min([opt1, opt2, opt3]))
resolve()