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
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    
    A, B, C, X, Y = Scanner.map_int()
    ans = 0
    C *= 2
    if A + B >= C:
        n = min(X, Y)
        X -= n
        Y -= n
        ans += C * n
    if A <= C:
        ans += X * A
    else:
        ans += X * C
    if B <= C:
        ans += Y * B
    else:
        ans += Y * C
    print(ans)


if __name__ == "__main__":
    main()

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

C2 = C * 2
diff = abs(X - Y)

ans = 0


if C2 > A + B:
  ans = (A * X) + (B * Y)

elif C2 <= A + B:
  if X > Y:
    ans = min(C2 * Y + A * diff,C2 * X)

  else:
    ans = min(C2 * X + B * diff,C2 * Y)
    
print(ans)

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

for i in range(10**5+1):
    tmp = i*2*c
    if i>=x:
        pass
    else:
        tmp += (x-i)*a
    if i>=y:
        pass
    else:
        tmp += (y-i)*b
    if ans > tmp:
        ans = tmp

print(ans)

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

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

C_max = max(X, Y)
min_count = float('inf')

for i in range(0,C_max*2+1,2):
    count = 0
    count += A * max(int(X-i/2),0)
    count += B * max(int(Y-i/2),0)
    count += C * i
    if min_count > count:
        min_count = count

print(min_count)

Solution (Python):
a_price, b_price, c_price, X, Y = list(map(int, input().split()))

total_price_1 = 0
total_price_2 = 0
diff = 0





if a_price + b_price < c_price * 2:
    total_price_1 = a_price * X + b_price * Y
    print(total_price_1)
else:
    if X > Y:
        total_price_1 = (c_price * 2) * X
        total_price_2 = (c_price * 2) * Y + a_price * (X - Y)
    else:
        total_price_1 = (c_price * 2) * Y
        total_price_2 = (c_price * 2) * X + b_price * (Y - X)

    print(min([total_price_1, total_price_2]))

Solution (Python):
a_price, b_price, c_price, X, Y = list(map(int, input().split()))

a_num = X
b_num = Y

total_price_1 = 0
total_price_2 = 0
max_pizza = 0
diff = 0

if a_price + b_price < c_price * 2:
    total_price_1 = a_price * X + b_price * Y
    print(total_price_1)
else:
    if X > Y:
        total_price_1 = (c_price * 2) * X
    else:
        total_price_1 = (c_price * 2) * Y

    if X > Y:
        total_price_2 += (c_price * 2) * Y
        diff = X - Y
        total_price_2 += a_price * diff
    else:
        total_price_2 += (c_price * 2) * X
        diff = Y - X
        total_price_2 += b_price * diff

    
    
    
    
    

    
    
    
    
    
    
    
    print(min([total_price_1, total_price_2]))

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












X1 = X
Y1 = Y
price = []
for i in range(0, max(X,Y)+1):
    price.append(max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C) 
print(min(price))

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

sum_ = 0
if AB <= (A+B)/2:
  if X >= Y:
    sum_ = min(AB*Y*2 + A*(X-Y), AB*X*2)
  else:
    sum_ = min(AB*X*2 + B*(Y-X), AB*Y*2)
else:
  sum_ = A*X + B*Y

print(sum_)

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

ans = 100000000000000000000000000

AB = C * 2

for ab in range(100000 + 1):
  x = 0
  if X - ab > 0:
    x = X - ab
  
  y = 0
  if Y - ab > 0:
    y = Y - ab
  
  d = (x * A) + (y * B) + (AB * ab)

  if ans > d:
    ans = d

print(ans)

Solution (Python):
a,b,mix,n_a,n_b=input().rstrip().split()
a=int(a)
b=int(b)
mix=int(mix)
n_a=int(n_a)
n_b=int(n_b)
x=[n_a,n_b]
fee=a*n_a+b*n_b
fee_a=2*mix*max(x)
fee_mix=0
if n_a>=n_b:
    fee_mix=n_b*2*mix+(n_a-n_b)*a
else:
    fee_mix=n_a*2*mix+(n_b-n_a)*b
print(min(fee,fee_a,fee_mix))

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

print(min(price))

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

def Cal(A, B, C, D, E): 
    if (A+B) >= 2*C:
        ans = min(2*C*E + A*(D-E), 2*C*D)
    else:
        ans = A*D+B*E
    return ans


if x >= y:
    ans = Cal(a, b, c, x, y)
else:
    ans = Cal(b, a, c, y, x)

print(ans)

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

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

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

print(ans)

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

minf = sys.maxsize
X1 = X
Y1 = Y


for i in range(0, max(X,Y)+1):
    price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C
    if minf > price:
        minf = price


print(minf)

Solution (Python):



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

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

print(result)

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

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

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

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

Solution (Python):

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

result = []

n = A*X + B*Y 
result.append(n) 

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

n = C*max(X,Y)*2
result.append(n)

print(min(result))

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

Solution (Python):


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

    range_i = range(0, 100001)
    min_z = 1000000000
    for i in range_i:
        z = i * (2 * c) + (max(0, x - i) * a) + (max(0, y - i) * b)
        if z < min_z:
            min_z = z
    print(min_z)


if __name__ == "__main__":
    main()

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

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

print(money)

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


z = min(x, y)
price = 0

if a + b <= 2 * c:
  price += z * (a + b)
  aa += z
  bb += z
else:
  price += z * 2 * c
  cc += 2 * z


if x > y:
  
  if a <= 2 * c:
    price += (x - y) * a
    aa += x - y
  else:
    price += (x - y) * 2 * c
    cc += 2 * (x - y)
else:
  
  if b <= 2 * c:
    price += (y - x) * b
    bb += y - x
  else:
    price += (y - x) * 2 * c
    cc += 2 * (y - x)


print(price)

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

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

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

for countC in range(1, 2*(X+Y)):
    if countC % 2 == 0:
        countA -= 1
        if countA < 0:
            countA = 0
        countB -= 1
        if countB < 0:
            countB = 0
        tmpPrice = countA * A + countB * B + countC * C
        if tmpPrice < price:
            price = tmpPrice
print(price)

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

min_cost = 1e10
for a in range(X+1):
    c = (X-a)*2
    left_b = max(0, Y - (X-a))
    cost = a*A+round(left_b)*B+c*C
    if cost < min_cost:
        min_cost = cost
    
    left_b = max(X-a, Y)
    cost = a*A + left_b*2*C
    if cost < min_cost:
        min_cost = cost
print(min_cost)

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

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):
    s1=(max(x-i//2,0))*a
    s2=(max(y-i//2,0))*b
    s3=i*c
    ans=min(ans,s1+s2+s3)
print(ans)

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

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

c_list = list(range(max(x, y) * 2, -1, -2))
min_cost = max(x, y) * 2 * c

for index, numc in enumerate(c_list):
	numa = int(x - numc/2) if x > numc / 2 else 0
	numb = int(y - numc/2) if y > numc / 2 else 0
	cost = numa * a + numb * b + numc * c
	if cost < min_cost:
		min_cost = cost
		
print(min_cost)

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

T = abs(X-Y)*B if X < Y else abs(X-Y)*A
T1 = A*X + B*Y
T2 = max(X, Y)*2*C
T3 = min(X, Y)*2*C + T

print(min(T1, T2, T3))

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


total1 = A * X + B * Y


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


P = B if X < Y else A
total3 = 2 * C * min(X, Y) + P * abs(X - Y)


ret = min(total1, min(total2, total3))
print(ret)

Solution (Python):

import sys


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

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    X = int(next(tokens))  
    Y = int(next(tokens))  
    print(solve(A, B, C, X, Y))

if __name__ == '__main__':
    main()

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

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

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

print(ans)

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

mi = min(x, y)
ma = max(x, y)
print(min(c*mi*2+a*(x-mi)+b*(y-mi), c*ma*2, a*x+b*y))

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

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

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

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

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

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

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

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

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

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

Solution (Python):
a,b,ab,x,y = map(int,input().split())
total = 0
if (a+b)/2 > ab :
	m = max(x,y)
	n = min(x,y)
	total += n*ab*2
	z = 0
	s = 0
	t = 0
	if x > y :
		z = x-y
		s = z*a
	elif y>x :
		z = y-x
		s = z*b
	t = z*ab*2
	total += s if s<t else t

else :
	total += a*x+b*y
print(total)

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


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


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())
min_price = A * X + B * Y
AB = 2 * C
for i in range(10**5 + 1):
    p = i * AB + max(0, X - i) * A + max(0, Y - i)  * B   
    if p < min_price:
        min_price = p           

print(min_price)

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

if cnt == X:
    for i in range(Y + 1):
        p = A * (X - i) + B * (Y -i) + C * i * 2
        if p < min_price:
            min_price = p
    for i in range(Y + 2, cnt + 1):
        p = A * (X - i) + C * i * 2
        if p < min_price:
            min_price = p
elif cnt == Y:
    for i in range(X + 1):
        p = A * (X - i) + B * (Y -i) + C * i * 2
        if p < min_price:
            min_price = p
    for i in range(X + 2, cnt + 1):
        p = B * (Y - i) + C * i * 2
        if p < min_price:
            min_price = p                   

print(min_price)

Solution (Python):
a,b,c,x,y=(int(x) for x in input().split())
m=float('inf')
for i in range(100001):
  n=2*c*i+max(0,x-i)*a+max(0,y-i)*b
  if n<m:
    m=n
print(m)

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

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

Solution (Python):

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

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

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

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

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

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


if s_c < s_ab:
    if x < y:
        price1 = s_c * x + b * (y-x)
        price2 = s_c * y
        print(min(price1, price2))
    elif x > y:
        price1 = s_c * x
        price2 = s_c * y + a * (x-y)
        print(min(price1, price2))
    else:
        print(s_c * x)
elif s_c >= s_ab:
    print(a * x + b * y)

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

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

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

print(price)

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

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

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

ans = 0

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

print(ans)

Solution (Python):
I = input().split(" ")
A, B, C, X, Y = int(I[0]), int(I[1]), int(I[2]), int(I[3]), int(I[4])
AB = C * 2
if A + B >= AB:
    if A >= AB and B >= AB:
        if X >= Y:
            print(X * AB)
        else:
            print(Y * AB)
    elif A >= AB and B <= AB:
        if X >= Y:
            print(X * AB)
        else:
            print(X * AB + (Y - X) * B)
    elif A <= AB and B >= AB:
        if X >= Y:
            print((X - Y) * A + Y * AB)
        else:
            print(Y * AB)
    else:
        if X >= Y:
            print((X - Y) * A + Y * AB)
        else:
            print(X * AB + (Y - X) * B)

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

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


if __name__ == '__main__':
    main()

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

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

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

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

lst = []

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

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

print(min(lst))

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

ans = 0

if A+B<2*C:
  ans += (A+B)*min(X,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 = 2 * C
if AB > A + B:
  case = 1
else:
  case = 2

if case == 1:
  print(A * X + B * Y)
  exit()

if case == 2:
  if X > Y:
    Z = Y
    X = X - Y
    Y = 0
    if AB < A:
      Z = Z + X
      X = 0
  else:
    Z = X
    Y = Y - X
    X = 0
    if AB < B:
      Z = Z + Y
      Y = 0
print(A * X + B * Y + AB * Z)

Solution (Python):
A,B,C,X,Y=map(int,input().split())
ans=A*X+B*Y
for z in range (0,100001):
  J=(max(0,X-z))*A+(max(0,Y-z))*B+2*C*z
  if ans > J:
    ans = J
    
print(ans)

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

price=a*x+b*y

for k in range(0,10**5+1):
  s=2*c*k+max(0,x-k)*a+max(0,y-k)*b
  if price>s :
    price=s

print(price)

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

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

q = A*X + B*Y

print(min(p, q))

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

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

Solution (Python):

import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, X, Y = map(int, input().split())
        print(min([max(X, Y) * 2 * C, A * X + B * Y, X * 2 * C + max(0, Y - X) * B, max(0, X - Y) * A + Y * 2 * C]))



if __name__ == '__main__':
    AtCoder().main()

Solution (Python):
A, B, C, X, Y = map(int, input().rstrip("\n").split())
Z = min(X, Y)

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

print(min(ans))

Solution (Python):





from sys import stdin,setrecursionlimit


setrecursionlimit(10**6)
input=stdin.readline

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

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

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

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

Solution (Python):
ip = list(map(int,input().split()))
a = ip[0]
b = ip[1]
c = ip[2]
xy = []
xy.append(ip[3])
xy.append(ip[4])

ans = (a+b+c)*max(xy)
for k in range(max(xy)+1):
	aa = xy[0] - k
	bb = xy[1] - k
	cc = 2*k
	if aa < 0:
		aa = 0
	if bb < 0:
		bb = 0
	tmp = aa*a + bb*b + cc*c
	if tmp < ans:
		ans = tmp

print(ans)

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


mini = 1000000000000

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

print(mini)

Solution (Python):
A,B,C,X,Y = map(int,input().split())
ans = float('inf')
for i in range(max(X,Y)+1):
  if X - i > 0 and Y - i > 0:
    price = A * (X - i) + B * (Y - i ) + C * i * 2
  elif X - i <= 0 and Y - i > 0:
    price = B * (Y - i ) + C * i * 2
  elif X - i > 0 and Y - i <= 0:
    price = A * (X - i) + C * i * 2
  else:
    price = C * i * 2
  if ans > price:
    ans = price

print(ans)

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

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

print(ans)

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

Solution (Python):
A, B, C ,Req_A ,Req_B = map(int,input().split())
min = 10000000000000
end = True
result = 0

while (Req_A + Req_B) > 0:
    if 2*C < A+B and 0 < Req_A and 0 < Req_B:
        Req_B -= 1
        Req_A -= 1
        result += 2*C
    elif 2*C < A and 0 < Req_A:
        Req_A -= 1
        result += 2*C
    elif 2*C < B and 0 < Req_B:
        Req_B -= 1
        result += 2*C
    elif 0 < Req_A :
        Req_A -= 1
        result += A
    elif 0 < Req_B:
        Req_B -= 1
        result += B
print(result)

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

Solution (Python):


import copy
import sys
import math


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

t=min(x,y)
u=max(x,y)

print(min(a*x+b*y, min(2*t*c+(x-t)*a+(y-t)*b, 2*u*c)))

Solution (Python):

a, b, c, x, y = [int(c) for c in input().split(' ')]
max_num_ab = 2 * max(x, y)
min_price = a * x + b * y
for num_ab in range(0, max_num_ab + 2, 2):
    price_ab = c * num_ab
    count_a = int(num_ab / 2)
    count_b = int(num_ab / 2)
    if count_a >= x:
        price_a = 0
    else:
        price_a = (x - count_a) * a

    if count_b >= y:
        price_b = 0
    else:
        price_b = (y -count_b) * b

    min_price = min(min_price, price_ab + price_a + price_b)
print(min_price)

Solution (Python):

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

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

for c in range(max(X, Y)+1):
    if c < X:
        a = X - c
    else:
        a = 0

    if c < Y:
        b = Y - c
    else:
        b = 0

    if c == 0:
        min = a*A + b*B + c*C*2
    elif a*A + b*B + c*C*2 < min:
        min = a*A + b*B + c*C*2

print(min)

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

ans = 0

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

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



cost = a*x + b*y

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

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

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

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

s = [0,0,0]

s[0] = x*a + y*b

c_half_num = min(x,y)
s[1] = max((x-c_half_num),0)*a + max((y-c_half_num),0)*b + c_half_num*(c*2)

c_half_num = max(x,y)
s[2] = c_half_num * (c*2)

print(min(s))

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = 0
if c * 2 <= a and c * 2 <= b:
    ans = max([x, y]) * 2 * c
elif c * 2 <= a:
    if x >= y:
        ans += x * 2 * c

    else:
        ans += x * 2 * c
        ans += (y-x) * b

elif c * 2 <= b:
    if y >= x:
        ans += y * 2 * c

    else:
        ans += y * 2 * c
        ans += (x - y) * a

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

    else:
        ans += x * 2 * c
        ans += (y - x) * b

else:
    ans = a * x + b * y

print(ans)

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