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

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

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

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

    res = min(res, cand)

print(res)

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

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

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

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

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

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

print(ans)

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

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

print(mincost)

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


if x < y: 
    x,y = y,x
    a,b = b,a

price_1 = a*x + b*y
price_2 = a*(x-y) + 2*c*y
price_3 = 2*c*x

print(min(price_1, price_2, price_3))

Solution (Python):


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

ans = 0

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

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

if ab_total < ans:
    print(ab_total)
else:
    print(ans)

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

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

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

Solution (Python):

import sys
from math import factorial

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

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

mcost = INF

cnum = max(X, Y)
for i in range(cnum+1):
    anum = max(0, (X - i))
    bnum = max(0, (Y - i))
    cost = A * anum + B * bnum + C * i * 2
    mcost = min(mcost, cost)

print("{}".format(mcost))

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


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

    Z = max(X,Y)

    ans = INF
    C *= 2

    for i in range(0,Z+1):
        trial = i*C
        At = X - i
        Bt = Y - i
        if At > 0:
            trial += At*A
        if Bt > 0:
            trial += Bt*B
        ans = min(ans, trial)
    print(ans)

  
  
 
  
if __name__=="__main__":
    main()

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

ans = float("inf")
for c in range(200_001):
    cost = c * C
    cost += A * max(0, X - c // 2)
    cost += B * max(0, Y - c // 2)
    ans = min(ans, cost)
print(ans)

Solution (Python):

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


pay1 = X*A + Y*B

pay2 = 10**10
if Y >= X:
    pay2 = C*2*X + B*(Y-X)

pay3 = 10**10
if X >= Y:
    pay3 = A*(X-Y) + C*2*Y

pay4 = C*max(X,Y)*2
print(min(pay1,pay2,pay3,pay4))

Solution (Python):
import math

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

ans = A * X + B * Y

if (A + B) / 2 < C:
    pass
else:
    for i in range(max(X * 2, Y * 2)+1):
        j = max(0, X - int(i / 2))
        k = max(0, Y - int(i / 2))

        ans = min(ans, i * C + j * A + k * B)

print(ans)

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

min1 = 10**10
for z in range(0,200001,2):
    x = max(0,X-z//2)
    y = max(0,Y-z//2)
    min1 = min(min1,a*x + b*y + c*z)

print(min1)

Solution (Python):
a,b,c,x,y = map (int,input().split())
max_xy = max(x,y)
count_x=0
count_y=0
p=0
p_min = c*2*max_xy

for i in range(0,max_xy+1):
    
    x_last = x-i
    y_last = y-i
    if x_last <0 : x_last=0
    if y_last <0 : y_last=0
    p = c*2*i + a*(x_last) + b*(y_last)
    p_min = min(p_min,p)
print(p_min)

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

piza_min = min(x,y)

plan1 = c*piza_min*2 + a*(x-piza_min) + b*(y-piza_min)
plan2 = a*x + b*y
plan3 = c*max(x,y)*2

print(min(plan1,plan2,plan3))

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

ans = [a * x + b * y]

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

print(min(ans))

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

ans = 10**18
for k in range(2*10**5+1):
    if k%2 != 0:
        continue
    i = max(x-k//2, 0)
    j = max(y-k//2, 0)
    temp = a*i+b*j+c*k
    ans = min(ans, temp)
print(ans)

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

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

print(cost)

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

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

Solution (Python):

import sys
input=sys.stdin.readline

def main():
    a,b,c,x,y = map(int,input().split())
    ans1=99999999999999999999999999
    if a+b>2*c:
        if x > y:
            ans1=2*c*y+a*(x-y)
        elif y > x:
            ans1=2*c*x+b*(y-x)
    ans2=c*2*max(x,y)
    ans3=a*x+b*y
    print(min(ans1,ans2,ans3))

if __name__=="__main__":
    main()

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

print(res)

Solution (Python):
a_price,b_price,ab_price,num_a,num_b = map(int, input().split())
total = 0

if a_price + b_price < 2 * ab_price:
	total = a_price * num_a + b_price * num_b

elif a_price + b_price >= 2 * ab_price:
	if num_a >= num_b:
		if a_price > ab_price * 2:
			total = ab_price * 2 * num_a
		else:
			total = ab_price * 2 * num_b + a_price * (num_a - num_b)
	else:
		if b_price > ab_price * 2:
			total = ab_price * 2 * num_b
		else:
			total = ab_price * 2 * num_a + b_price * (num_b - num_a)

print(total)

Solution (Python):
a_price,b_price,ab_price,num_a,num_b = map(int, input().split())
total = 0

if a_price + b_price < 2 * ab_price:
	total = a_price * num_a + b_price * num_b

elif a_price + b_price >= 2 * ab_price:
	if num_a >= num_b:
		if a_price > ab_price * 2:
			total = ab_price * 2 * num_a
		else:
			total = ab_price * 2 * num_b + a_price * (num_a - num_b)
	else:
		if b_price > ab_price * 2:
			total = ab_price * 2 * num_b
		else:
			total = ab_price * 2 * num_a + b_price * (num_b - num_a)

print(total)

Solution (Python):
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=998244353
from collections import deque

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

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

Solution (Python):
l = list(map(int, input().split()))
A, B, C, X, Y = l[0], l[1], l[2], l[3], l[4]
s_1, s_2, s_3 = 0, 0, 0

s_1 = A*X + B*Y

maxv = max([X, Y])
s_2 = 2*C*max([X, Y])
if X >= Y:
    s_3 = 2*C*Y + A*(X-Y)
else:
    s_3 = 2*C*X + B*(Y-X)

print(min([s_1, s_2, s_3]))

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

print(ans)

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

import math
saishou = math.inf

temp = 0

for i in range (0, X+1):
	temp = A*i+C*2*(X-i)
	if X-i < Y:
		if 2*C <= B:
			temp+=2*C*(Y-(X-i))
		else:
			temp+=B*(Y-(X-i))
	if saishou > temp:
		saishou = temp
                      
print(saishou)

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

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


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

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

cost = A * X + B * Y
ans = min(ans, cost)

print(ans)

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

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:
        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+(x-y)*a)
        else:
            print(2*c*x)

Solution (Python):


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

ans = 10000 * 10**5
for z in range(10**5+1):
    x = max(X-z, 0)
    y = max(Y-z, 0)
    yen = A*x + B*y + 2*C*z
    if ans > yen:
        ans = yen

print(ans)

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

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

result = []

if X > Y:
    result.append(A * X + B * Y + C * 0)
    result.append(A * (X - Y) + B * 0 + C * 2 * min(X,Y))
    result.append(A * 0 + B * 0 + C * 2 * max(X,Y))
elif X < Y:
    result.append(A * X + B * Y + C * 0)
    result.append(A * 0 + B * ( Y - X ) + C * 2 * min(X,Y))
    result.append(A * 0 + B * 0 + C * 2 * max(X,Y))
else:
    result.append(A * X + B * Y + C * 0)
    result.append(A * 0 + B * 0 + C * 2 * max(X,Y))

print(min(result))

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

mast = max(x,y)
ans = float('INF')

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

Solution (Python):
a,b,c,x,y = [int(x) for x in input().split()]
res = 0
if a + b > 2 * c:
  res += min(x,y) * 2 * c
  if x == min(x,y):
    if b > 2 * c:
      res += (y - min(x,y)) * 2 * c
    else:
      res += (y - min(x,y)) * b
  else:
    if a > 2 * c:
      res += (x - min(x,y)) * 2 * c
    else:
      res += (x - min(x,y)) * a
else:
  res += a * x
  res += b * y
print(res)

Solution (Python):



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

price = a * x + b * y


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

    price = min(price, cand)

print(price)

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

ans = 10 ** 9

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

    cost = A * a + B * b + C * 2 * c
    ans = min(cost, ans)

print(ans)

Solution (Python):
def main():
    a, b, c, x, y = map(int, input().split())
    r = float('inf')
    for piza_c in range(0, max(x, y) * 2 + 1, 2):
        piza_a = max(0, x - piza_c // 2)
        piza_b = max(0, y - piza_c // 2)
        r = min(r, piza_c * c + piza_a * a + piza_b * b)
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):



def main():
    A, B, C, X, Y = map(int, input().split())
    ans = 0
    min_p = min(X, Y)
    d = X - Y

    if A + B > 2 * C:
        ans += 2 * C * min_p
    else:
        ans += (A + B) * min_p

    if d > 0:
        if A > 2 * C:
            ans += 2 * C * d
        else:
            ans += A * d
    elif d < 0:
        if B > 2 * C:
            ans += 2 * C * -d
        else:
            ans += B * -d

    print(ans)

if __name__ == "__main__":
    main()

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

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

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

for i in range(0,2*max(X,Y)+1,2):
  if X-i//2 >= 0 and Y-i//2 >= 0:
    moneys.append((X-i//2)*A + (Y-i//2)*B + C*i)
  elif X-i//2 >= 0 and Y-i//2 < 0:
    moneys.append((X-i//2)*A + C*i)
  elif X-i//2 < 0 and Y-i//2 >= 0:
    moneys.append((Y-i//2)*B + C*i)
  else:
    moneys.append(C*i)
    
print(min(moneys))

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

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

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

Solution (Python):
import math
a, b, c, x, y = map(int, input().split(' '))
ans = float('inf')
c = c*2
for i in range(max(x, y)+1):
    if i > x:
        price = b*(y-i) + c*i
    elif i > y:
        price = a*(x-i) + c*i
    else:
        price = a*(x-i) + b*(y-i) + c*i

    if ans > price:
        ans = price
print(ans)

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

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

if (a + b) <= 2 * c:
  print(a * x + b * y)
else:
  max_c = max(x,y)
  min_c = min(x,y)
  AB = 2 * c * max_c
  if x > y:
    SP = ((x - min_c) * a) + (2 * c * min_c)
  else:
    SP = ((y - min_c) * b) + (2 * c * min_c)
  print(min(AB,SP))

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

ans = A*X+B*Y
price = 0
AB = 2*C

for i in range(max(X,Y)+1):
    price = AB*i + max(0,X-i)*A + max(0,Y-i)*B
    ans = min(ans,price)

print(ans)

Solution (Python):

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


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

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

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

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

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


moneys=[]
for i in range(0,max(x,y)*2+1,2):
    apizza=x-int(i/2)
    bpizza=y-int(i/2)
    if apizza<0:
        apizza=0
    if bpizza<0:
        bpizza=0
    money=apizza*a+bpizza*b+i*c
    moneys.append(money)

print(min(moneys))

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

price = 0

m = min(A + B , C * 2)
n = min(X, Y)
price += m * n

d = max(X, Y) - min(X, Y)
if d != 0:
    if X > Y:
        price += min(A, C * 2) * d
    else:
        price += min(B, C * 2) * d

print(price)

Solution (Python):



A, B, C, X, Y = (int(x) for x in input().split())

ret = 0
if A + B > C * 2:
    m = min(X, Y)
    X -= m
    Y -= m
    ret += m * C * 2

if X > 0:
    if A > C * 2:
        ret += X * C * 2
    else:
        ret += X * A

if Y > 0:
    if B > C * 2:
        ret += Y * C * 2
    else:
        ret += Y * B

print(ret)

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

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

ans = float("inf")


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

ans = min(A * X + B * Y, ans)

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

print(ans)

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

mini = float('inf')

for i in range(10**6 + 1):
    calc = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B
    if calc < mini:
        mini = calc

print(mini)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

if 2 * c >= a + b:
    print(a * x + b * y)
    sys.exit(0)

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

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

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

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

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

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

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

print(ans)

Solution (Python):


def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

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

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

    print(ans)

if __name__ == '__main__':
    main()

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

print(ans)

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

Solution (Python):
import sys

input = sys.stdin.readline
a, b, c, x, y= map(int, input().split())
ab = 2*c
count_x = 0
count_y = 0
buy_a = 0
buy_b = 0
buy_c = 0

if ab < a+b:
    min_count = min(x,y)
    count_x = min_count
    count_y = min_count
    buy_c = 2*min_count
    if x - count_x > 0:
        if ab > a:
            buy_a += x - count_x
        else:
            buy_c += 2 * (x - count_x)
    
    elif y - count_y > 0:
        if ab > b:
            buy_b += y - count_y
        else:
            buy_c += 2*(y - count_y)
else:
    min_count = min(x,y)
    if min_count == x:
        buy_a = min_count
        if ab > b:
            buy_b += y
        else:
            buy_c += 2 * y
    else:
        buy_b = min_count
        if ab > a:
            buy_a += x
        else:
            buy_c += 2 * x

print(buy_a * a + buy_b * b + buy_c * c)

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

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

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

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

c *= 2
t = 0

if a+b > c:
  v = min([x,y])
  t = v * c
  x, y = x-v, y-v

  if x>0:
    if a<c:
      t = t + a*x
    else:
      t = t + c*x
  elif y>0:
    if b<c:
      t = t + b*y
    else:
      t = t + c*y
else:
  t = a*x + b*y

print(t)

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

Solution (Python):
A,B,C,X,Y=map(int,input().split())
ABset = 2*C
gokei = A*X+B*Y
for i in range(0,max(X+1,Y+1)):
    ABdai = i*ABset
    Adai = A*(X-i)
    if X<i:
        Adai = 0
    Bdai = B*(Y-i)
    if Y<i:
        Bdai = 0
    gokei = min(gokei,ABdai+Adai+Bdai)
print(gokei)

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

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

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

ans1 = x * a + y * b

min_xy = min(x, y)
ans2 = min_xy * 2 * c + (x - min_xy) * a + (y - min_xy) * b

max_xy = max(x, y)
ans3 = max_xy * 2 * c

print(min(ans1, ans2, ans3))

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


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

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

print(ans)

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

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):
A,B,C,X,Y = map(int,input().split())
sumAB = A+B
if sumAB >= 2*C:
    minXY = min(X,Y)
    ans = min(X,Y)*2*C
    X -= minXY
    Y -= minXY
    if X != 0:
        ans += X*min(A,2*C)
    elif Y !=0:
        ans += Y*min(B,2*C)
    print(ans)

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

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

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    A,B,C,X,Y = mi()

    ans = INF
    for z in range(10**6):
        x = max(0,X-z//2)
        y = max(0,Y-z//2)

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

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

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

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

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

Solution (Python):
import math

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

min_sum = A*X+B*Y
for c in range(0, (max(X, Y)*2)+1, 2):
    s = (max(X-math.floor(c/2), 0))*A + (max(Y-math.floor(c/2), 0))*B + c*C
    if s < min_sum:
        min_sum = s
print(min_sum)

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

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

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

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

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

res = float("inf")

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

print(res)

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

Solution (Python):
def solve():
    A, B, C, X, Y = [int(i) for i in input().split()]
    ans1 = A * X + B * Y
    ans2 = C * 2 * X + B * (Y - X) if X < Y else C * 2 * Y + A * (X - Y)
    ans3 = C * 2 * max(X, Y)
    print(min(ans1, ans2, ans3))

if __name__ == "__main__":
    solve()

Solution (Python):




def resolve():
    import sys
    input = sys.stdin.readline

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

    a_count = 0
    b_count = 0
    ab_count = 0
    if a + b > 2 * c:
        
        min_pizza = min(x,y)
        ab_count += min_pizza * 2
        x = x - min_pizza
        y = y - min_pizza

    
    if c * 2 < a:
        
        ab_count += x * 2
    else:
        
        a_count += x

    
    if c * 2 < b:
        
        ab_count += y * 2
    else:
        
        b_count += y

    print(a_count * a + b_count * b + ab_count * c)


if __name__ == "__main__":
    resolve()

Solution (Python):

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

ans = x*a + y*b 

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


if max(x, y) == x: 
    A = True
else:
    A = False
left = (max(x, y) - min(x, y))*(a if A else b)
ans = min(ans, 2*c*min(x, y) + left)

print(ans)

Solution (Python):

def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


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

min_v = min(x, y)
max_v = max(x, y)

candidate1 = (a * x) + (b * y)
candidate2 = c * (max_v * 2)
candidate3 = c * (min_v * 2) + (a * (max_v - min_v) if max_v == x else b * (max_v - min_v))

print(min(candidate1, candidate2, candidate3))

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

ans = float("inf")

if X > Y:
    ab = 2 * X
    while ab >= 0:
        a = X - (ab / 2)
        if ab / 2 < Y:
            b = int(Y - ab / 2)
        else:
            b = 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
else:
    ab = 2 * Y
    while ab >= 0:
        b = Y - (ab / 2)
        if ab / 2 < X:
            a = int(X - ab / 2)
        else:
            a = 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
print(int(ans))

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

res = 0

is_lower_a = True
if X > Y:
    is_lower_a = False

if A + B >= 2 * C:
    if is_lower_a:
        res += 2 * C * X
    else:
        res += 2 * C * Y
    if X != Y:
        if is_lower_a:
            if 2 * C <= B:
                res += (Y - X) * 2 * C
            else:
                res += (Y - X) * B
        else:
            if 2 * C <= A:
                res += (X - Y) * 2 * C
            else:
                res += (X - Y) * A
else:
    res += A * X
    res += B * Y
print(res)

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

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

Solution (Python):
A,B,C,X,Y = list(map(int,input().split()))
out = 10**9
L = []
L.append(A*X+B*Y)
L.append(C*2*max(X,Y))
if X<Y:
    L.append(C*2*X+B*(Y-X))
if X>Y:
    L.append(C*2*Y+A*(X-Y))
print(min(L))

Solution (Python):
A,B,C,X,Y=map(int,input().split())
if 2*C <= A+B:
  price= 2*C
else:
  price = A+B
maxN = max(X,Y)
miniN = min(X,Y)
res = miniN * price
residue = maxN - miniN
if residue == 0:
  print(res)
elif X > Y:
  res+= min(residue*A, residue*2*C)
  print(res)
elif Y > X:
  res +=  min(residue*B, residue*2*C)
  print(res)