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
inf = 10**9+7
mod = 10**9+7

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

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



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

print(ans)

Solution (Python):
def modelAnswer(A:int,B:int,C:int,X:int,Y:int) -> int:
   ans = 10**9
   for i in range(10**5+1):
      total = i * 2 * C + max(0,X-i) * A + max(0,Y-i) * B
      ans = min(ans,total)
   return ans

def main():
   A,B,C,X,Y=map(int,input().split())
   print(modelAnswer(A,B,C,X,Y))
if __name__ == '__main__':
   main()

Solution (Python):
def modelAnswer(A:int,B:int,C:int,X:int,Y:int) -> int:
   ans = 10**9
   for i in range(10**5+1):
      total = i * 2 * C + max(0,X-i) * A + max(0,Y-i) * B
      ans = min(ans,total)
   return ans

def main():
   A,B,C,X,Y=map(int,input().split())
   print(modelAnswer(A,B,C,X,Y))
if __name__ == '__main__':
   main()

Solution (Python):

def myAnswer(A:int,B:int,C:int,X:int,Y:int) -> int:
   ans = 0
   both = C * 2
   AB=A+B
   while X!=0 or Y!=0:
      if(X>=1 and Y >=1):
         ans += min(AB,both)
         X-=1
         Y-=1
      elif(X>=1 and Y == 0):
         ans += min(both,A)
         X -= 1
      else:
         ans += min(both,B)
         Y -= 1
   return ans


def modelAnswer():
   tmp=1
def main():
   A,B,C,X,Y=map(int,input().split())
   print(myAnswer(A,B,C,X,Y))
if __name__ == '__main__':
   main()

Solution (Python):

def myAnswer(A:int,B:int,C:int,X:int,Y:int) -> int:
   ans = 0
   both = C * 2
   AB=A+B
   while X!=0 or Y!=0:
      if(X>=1 and Y >=1):
         ans += min(AB,both)
         X-=1
         Y-=1
      elif(X>=1 and Y == 0):
         ans += min(both,A)
         X -= 1
      else:
         ans += min(both,B)
         Y -= 1
   return ans


def modelAnswer():
   tmp=1
def main():
   A,B,C,X,Y=map(int,input().split())
   print(myAnswer(A,B,C,X,Y))
if __name__ == '__main__':
   main()

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

ans = 0
if 2*AB < A+B:
    if X < Y:
        ans += 2*AB * X
        Y -= X
        if 2*AB < B:
            ans += 2*AB * Y
        else:
            ans += B*Y
    else:
        ans += 2*AB * Y
        X -= Y
        if 2*AB < A:
            ans += 2*AB * X
        else:
            ans += A*X
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:  
    ans = float('inf')
    for i in range(0, max(X, Y) * 2 + 1, 2):
        ans = min(ans, max(A * (X - i // 2), 0) + max(B * (Y - i // 2), 0) + C * i)
    print(ans)

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

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

x1 = A * X + B * Y
if X > Y:
  x2 = Y * 2 * C + (X - Y) * A
else:
  x2 = X * 2 * C + (Y - X) * B
x3 = max(X, Y) * 2 * C

print(min(x1, x2, x3))

Solution (Python):
ABCXY = input().split()
A,B,C,X,Y = int(ABCXY[0]),int(ABCXY[1]),int(ABCXY[2]),int(ABCXY[3]),int(ABCXY[4])
resultA = []
resultB = []
Min = float("inf")
if(X >= Y):
    taisyou = X*2
else:
    taisyou  = Y*2
    
for i in reversed(range(0, taisyou+1, 2)):
    
    
    if(X - i/2 <= 0):
        Xcount = 0
    else:
        Xcount = X-i/2
    if(Y - i/2 < 0):
        Ycount = 0
    else:
        Ycount = Y-i/2
    Min =  min(Min, i * C + Xcount* A + Ycount * B)
print(int(Min))

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

Solution (Python):
a,b,c,x,y = map(int,input().split())
ans = 0
ans2 = 10**10
if (a+b) / 2 > c:
    x2 = x - min(x,y)
    y2 = y - min(x,y)
    ans += 2 * min(x,y) * c
    ans2 = 2 * max(x,y) * c
else:
    x2 = x
    y2 = y
ans += a*x2 + b*y2

print(min(ans,ans2))

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

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

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    a, b, c, x, y = MII()
    fee = min(a+b,c*2) * min(x,y)
    if x > y: fee += min(a,c*2)*(x-y)
    else: fee += min(b,c*2)*(y-x)
    print(fee)


if __name__ == '__main__':
    main()

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

Solution (Python):
def LI(): return list(map(int,input().split()))
A,B,C,X,Y = LI()
ans = min(A*X+B*Y,C*(max(X,Y)*2))
if X!=Y:
    temp = (min(X,Y)*2)*C + (max(X,Y)-min(X,Y))*(A if X>Y else B)
    ans = min(temp,ans)
print(ans)

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

solution()

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

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

print(ans)

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

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

Solution (Python):
def halfandhalf(A,B,C,X,Y):
    if X >= Y:
        if A+B > 2*C:
            sum = min(C*2*Y + A*(X-Y), C*2*X)
        else:
            sum = A*X + B*Y
        
    else:
        if A+B > 2*C:
            sum = min(C*2*X + B*(Y-X), C*2*Y)
        else:
            sum = A*X + B*Y
    return sum




if __name__ == "__main__":
    A,B,C,X,Y = map(int, input().split())
    print(halfandhalf(A,B,C,X,Y))

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

x2 = x
y2 = y
total = 0
m = x
if a+b > c*2:
    total += m*c*2
    x -= m
    y -= m

if x > 0:
    total += x*a
if y > 0:
    total += y*b



total2 = 0
m = y2
if a+b > c*2:
    total2 += m*c*2
    x2 -= m
    y2 -= m

if x2 > 0:
    total2 += x2*a
if y2 > 0:
    total2 += y2*b


print(min(total,total2))

Solution (Python):


from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

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


main()

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

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

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

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip() 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

def abc_c095(a,b,c,x,y):
    ab = x*2
    if y - ab//2 > 0:
        return b*(y - ab//2) + c*ab
    else:
        return c*ab

def main():
    a,b,c,x,y = na()
    ans = a*x + b*y
    ans = min(ans, abc_c095(a,b,c,x,y))
    ans = min(ans, abc_c095(b,a,c,y,x))
    print(ans)
    return

if __name__ == '__main__':
    main()

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

ans = 10**14

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

print(ans)

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

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

if x > y:
    print(num * s + a * (x - s))
else:
    print(num * s + b * (y - s))

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

if X>Y:
    A,B,X,Y = B,A,Y,X

if 2*C < B:
    print(C*2*Y)

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

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

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

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

print(ans)

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

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

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

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

print(ans)

Solution (Python):
s = input().rstrip().split(' ')
costa = int(s[0])
costb = int(s[1])
costc = int(s[2])
needa = int(s[3])
needb = int(s[4])
mini = min(needa, needb)
maxi = max(needa, needb)
lst = []
total = costa * needa + costb * needb
totala = costa * needa + costb * needb
totalb = costc * maxi * 2
for i in range(mini+1):
  temp = costa * (needa - i) + costb * (needb - i) + costc * i * 2
  if total > temp:
    total = temp
lst.append(total)
lst.append(totala)
lst.append(totalb)
mintotal = min(lst)
print(mintotal)

Solution (Python):
import sys

a, b, c, x, y = map(int, sys.stdin.readline().split())
if x > y:
    a, b = b, a
    x, y = y, x

def main():
    res = min(c * 2, a + b) * x + min(c * 2, b) * (y - x)
    print(res)

if __name__ ==  '__main__':
    main()

Solution (Python):
A,B,AB,X,Y = [int(x) for x in input().split()]
total = A*X+B*Y
for xy in range(0,max(X,Y)+1):
  x = X-xy
  y = Y-xy
  if x<0:
    x=0
  if y<0:
    y=0
  if x*A+y*B+xy*2*AB < total:
    total = x*A+y*B+xy*2*AB
    
print(total)

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

Solution (Python):

url = "https://atcoder.jp//contests/abc095/tasks/arc096_a"

def main():
    A, B, C, X, Y = list(map(int, input().split()))
    piza = [X, Y]
    price = 0
    if A + B > C * 2:
        min_piza = min(X, Y)
        price += min_piza * (C * 2)
        piza = [v - min_piza for v in piza]
    
    if A > C * 2:
        price += piza[0] * (C * 2)
        piza[1] -= piza[0]
    else:
        price += piza[0] * A
    
    if B > C * 2:
        price += piza[1] * (C * 2)
    else:
        price += piza[1] * B
    print(price)


if __name__ == '__main__':
    main()

Solution (Python):
a, b, c, x, y = map(int, input().split())
a_yen = 0
b_yen = 0
c_yen = 0
if a + b <= 2*c:
    a_yen = a*x
    b_yen = b*y
    print(a_yen + b_yen)

elif a + b > 2*c:
    c_yen = 2*c*min(x, y)

    if min(x, y) == x and b <= 2*c:
        b_yen = b*(y-x)
    elif min(x, y) == x and b > 2*c:
        c_yen += 2*c*(y-x)

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

    print(a_yen + b_yen + c_yen)

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

anset = set()
for i in range(0, max(X, Y)+1):
    anset.add(i*2*C + max(0, X-i)*A + max(0, Y-i)*B)

print(min(anset))

Solution (Python):
import math

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

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

print(m)

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

prise = A*X + B*Y
x = X
y = Y
anset = set()
anset.add(prise)
while max(x, y)>0:
    if x > 0:
        prise -= A
    if y > 0:
        prise -= B
    prise += C * 2
    anset.add(prise)

    x -= 1
    y -= 1

print(min(anset))

Solution (Python):




mod = 10**9 + 7

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

    
    c *= 2

    

    if x > y: 
    
        ans = min(a * x + b * y, c * x, c * y + a*(x-y))
    else:
        ans = min(a * x + b * y, c * y, c * x + b * (y-x))
    print(ans)
if __name__ == '__main__':
  main()

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

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

A = a*x + b*y
B = 2*c*mini + a*(x - mini) + b*(y - mini)
C = 2*c*max(x, y)

print(min(A, B, C))

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

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

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

print(ans)

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

s1 = A * X + B * Y

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

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

print(min(s1, s2, s3))

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

s1 = a*x + b*y
s2 = c*(max(x,y)*2)
if x>y:
    s3 = c*(y*2) + a*(x-y)
elif y>x:
    s3 = c*(x*2) + b*(y-x)
else: s3 = 10**10

print(min(s1,s2,s3))

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

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

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

print(ans)

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

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

print(min(a,b,c))

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

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

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

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

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

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

print(min(A * X + B * Y, 2 * C * max(X, Y), price))

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

if x < y:
    big_num = y
    small_num = x
    big_price = b
    
else:
    big_num = x
    small_num = y
    big_price = a
    
    
ans = 0
ans += min(a + b, 2 * c) * small_num
ans += min(big_price, 2 * c) * (big_num - small_num)

print(ans)

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

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

d = X * A + Y * B
e = 2 * C * max(X, Y)
f = 2 * C * min(X, Y) + (X - min(X, Y)) * A + (Y - min(X, Y)) * B
print(min(d, e, f))

Solution (Python):
import math
a, b, c, x, y = map(int, input().split())
n = a*x + b*y
m = c*2*max(x,y)
min_xy = min(x,y)
k = min_xy*2*c + (x-min_xy)*a + (y-min_xy)*b
print(min(n,m,k))

Solution (Python):


from sys import stdin
A, B, C, X, Y = [int(x) for x in stdin.readline().rstrip().split()]
ans1 = 0

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

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

Solution (Python):

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

Solution (Python):
A,B,C,X,Y = map(int, input().split())
ans = float('inf')
for i in range(0,max(X,Y)*2+1,2):
    s = 0
    x = X-i//2
    y = Y-i//2
    if x >= 1:
        s += x*A 
    if y >= 1:
        s += y*B
    s += i*C
    ans = min(ans, s)
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*X*C+B*(Y-X),2*Y*C))
  else:
    print(min(2*Y*C+A*(X-Y),2*X*C))

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

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

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

print(ans)

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

ans = a * x + b * y

if x < y:
    e = c * 2 * x
    f = b * (y-x)
    ans = min(ans, f+e)
    g = c * 2 * y
    ans = min(ans,g)
else:
    e = c * 2 * y
    f = a * (x-y)
    ans = min(ans, f+e)
    g = c * 2 * x
    ans = min(ans,g)
print(ans)

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

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

smaller = X if X < Y else Y
diff = Y - smaller if X < Y else X - smaller
diff_type = 'b' if X < Y else 'a'
cost = 0

if A+B > 2*AB:
    cost += 2*AB*smaller
    
    if diff_type == 'b':
        if B > 2*AB:
            cost += AB*2*diff
        else:
            cost += B*diff
    else:
        if A > 2*AB:
            cost += AB*2*diff
        else:
            cost += A*diff
else:
    cost = A*X + B*Y

print(cost)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

ans = 10000000000000000000000000000

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

Solution (Python):
import sys
sys.setrecursionlimit(10000)
def resolve():
    A, B, C, X, Y = list(map(int, input().split(" ")))
    if A + B < 2 * C:
        print(A*X+B*Y)
        return
    if X < Y:
        m = min((Y-X)*B, 2*(Y-X)*C)
        print(2*X*C+m)
        return
    else:
        m = min((X-Y)*A, 2*(X-Y)*C)
        print(2*Y*C+m)
        return

    
    
if '__main__' == __name__:
    resolve()

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

ans = []


for ab in range(max(x,y) + 1):
    ans.append(a * max((x - ab),0) + b * max((y - ab),0) + 2 * c * ab)

print(min(ans))

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

    ans = 10**10
    for i in range(0,max(x,y)*2+2, 2):
        tmp = i*c
        x_count = i//2
        y_count = i//2
        tmp += max(0,x-x_count)*a + max(0,y-y_count)*b
        ans = min(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()

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

def calc_cost(max_a,max_b):
    need_ab = max(X-max_a, Y-max_b)
    a = max(X - need_ab, 0)
    b = max(Y - need_ab, 0)
    return A*a + B*b + C*(2*need_ab)

print(min([calc_cost(x,y) for x in [0,X] for y in [0,Y]]))

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

Solution (Python):
import math
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())
result = A*X + B*Y

for c2 in {0, X, Y}:
    a = max(X - c2, 0)
    b = max(Y - c2, 0)
    fee = int(a*A + b*B + c2*C *2)
    
    
    result = min(fee,result)

print(result)

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

tan = A*X + B*Y
hukuA = max(X,Y)*2*C
hukuB = min(X,Y)*2*C + (max(X,Y)-min(X,Y)) * (A if X>=Y else B)

print(min(tan,hukuA,hukuB))

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

Solution (Python):
import sys


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


sys.setrecursionlimit(10 ** 9)


def main():
    A, B, C, X, Y = map(int, input().split())
    answer = float("inf")
    for c in range(10 ** 5 + 1):
        a = X - c
        b = Y - c
        money = c * C * 2
        a = A * max(a, 0)
        b = B * max(b, 0)
        if answer > money + a + b:
            answer = money + a + b
    print(answer)


if __name__ == "__main__":
    main()

Solution (Python):
import sys


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


sys.setrecursionlimit(10 ** 9)


def main():
    A, B, C, X, Y = map(int, input().split())
    money = []
    money.append(X * A + Y * B)
    if X > Y:
        money.append(X * 2 * C)
        money.append(Y * 2 * C + (X - Y) * A)
    elif X == Y:
        money.append(X * 2 * C)
    else:
        money.append(Y * 2 * C)
        money.append(X * 2 * C + (Y - X) * B)
    print(min(money))


if __name__ == "__main__":
    main()