peterverebics/CodeNet_Python_118 huggingface dataset:
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)
A, B, C, X, Y = map(int, input().split())
ans = X * A + Y * B
for nab in range(2, max(X, Y) * 2 + 2, 2):
    price = nab * C
    price += max(X - (nab // 2), 0) * A
    price += max(Y - (nab // 2), 0) * B
    ans = min(ans, price)
print(ans)
#!/usr/bin/env python3
A, B, C, X, Y = map(int, input().split())

patterns = [0] * 4
patterns[0] = A * X + B * Y
patterns[1] = C * max(X, Y) * 2
patterns[2] = C * Y * 2 + A * (X - Y) if X > Y else float('inf')
patterns[3] = C * X * 2 + B * (Y - X) if X < Y else float('inf')

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

ans = 10**18
for ab in range(max(X, Y) * 2 + 10):
    a = max(0, X - ab // 2)
    b = max(0, Y - ab // 2)
    ans = min(ans, A * a + B * b + C * ab)
print(ans)
a, b, c, x, y = map(int, input().split())
# print(a, b, c, x, y)

ans = 10000 * (10 **5) + 7
c_max = 0
if x > y:
  c_max = x * 2
else:
  c_max = y * 2

for cc in range(0, c_max+1, 2):
  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
  # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))
  ans = min(ans, price)

print(ans)
from numba import njit


@njit
def solve(a, b, c, x, y):
    ans = 10000000000000000
    for i in range(100000 + 1):
        X = i * (2 * c) + max(0, x - i) * a + max(0, y - i) * b
        ans = min(ans, X)
    return ans


a, b, c, x, y = map(int, input().split())
print(solve(a, b, c, x, y))
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)
a, b, c, x, y = map(int, input().split())
ans = x * a + y * b

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

print(ans)
def main():
    A, B, C, X, Y = map(int, input().split())
    ans = 10 ** 10

    for k in range(10 ** 5 + 1):
        total = 2 * C * k + A * max(0, X - k) + B * max(0, Y - k)
        if total < ans:
            ans = total

    print(ans)


if __name__ == "__main__":
    main()
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)
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))
a,b,c,x,y = map(int,input().split())
ans = 0
if a+b<c*2:
    ans = a*x+b*y
else:
    if x>y:
        ans = min(2*c*y+(x-y)*a, 2*c*x)
    else:
        ans = min(2*c*x+(y-x)*b, 2*c*y)
print(ans)
#n = int(input())
a, b, c, x, y = map(int, input().split())
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
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)
A, B, C, X, Y = map(int, input().split())

a,b,ab = 0, 0, 0

a = X
b = Y
ab = 0

m = a * A + b * B + ab * C
big = max(X,Y)
while ab // 2 <= big:
    ab += 2
    if a > 0:
        a -= 1
    if b > 0:
        b -= 1
    m = min(m, a * A + b * B + ab * C)

print(m)
a,b,c,x,y=map(int,input().split())
r=float('inf')
for i in range((10**5)+1):
  r=min(r,i*2*c+max(0,x-i)*a+max(0,y-i)*b)
print(r)
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))
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)))
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)
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()
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)))
A,B,C,x,y = map(int,input().split())
a = 0
b = 0
c = 0
if C*2 >= A + B:
    print (A*x+B*y)
    exit(0)

if C * 2 <= A and C * 2 <= B:
    print (max(x,y) * 2 * C)
    exit(0)

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

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

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

if y > 0:
    if b > c * 2:
        ans += y * c * 2
    else:
        ans += y * b

print(ans)
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))
a, b, c, x, y = map(int, input().split())

ans = 0

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

print(ans)
A, B, C, X, Y = map(int, input().split())
ans = float('inf')
for i in range(10**5 + 1):
    price = 2*C*i + A*max(0, X - i) + B*max(0, Y - i)
    if ans > price:
        ans = price

print(ans)
a,b,c,x,y=map(int,input().split())
ans1=x*a+y*b
if x>=y:
    ans2=2*y*c+(x-y)*a#(x,y)=(3,2)であればABを4枚買う
else:
    ans2=2*x*c+(y-x)*b
ans3=2*max(x,y)*c
print(min(ans1,ans2,ans3))
A,B,C,X,Y = map(int,input().split())
if A+B <= 2*C:
    ans = A*X+B*Y
elif (A <= 2*C and X>=Y) or (B <= 2*C and X <= Y):
    minAB = min(X,Y)
    ans = 2*C*minAB+(X-minAB)*A+(Y-minAB)*B
else:
    ans = 2*C*max(X,Y)
print(ans)
#「ABピザを買う枚数」で全探索

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

ans = float("inf")

for i in range(0,2*max(X,Y)+1,1):#「ABピザを買う枚数」で全探索
    tmpans = i*C#ABピザの代金

    tmp_x = max(0,X-i//2)
    tmp_y = max(0,Y-i//2)
    tmpans += A*tmp_x
    tmpans += B*tmp_y

    ans = min(ans,tmpans)

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

ans = 10**18

for i in range(100100):
    ans = min(ans, 2*c*i + max(0, x-i)*a + max(0,y-i)*b)
        
print(ans)
import numpy as np
def f(a, b, c, x, y):
    Min = np.inf
    for use_c in range(max(x, y) * 2 + 1):
        price = use_c * c + max(0, x - use_c // 2) * a + max(0, y - use_c // 2) * b
        if price < Min:
            Min = price
    print(Min)

a, b, c, x, y = map(int, input().split())
f(a, b, c, x, y)
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)
A, B, C, X, Y = map(int, input().split())
C = min(2*C, A+B)

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

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

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

mi=min([x,y])
ma=max([x,y])
g=ma-mi
ans,ab=0,0


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

if ab >= ans: 
  print(ans)
else:
  if ab!=0:
    print(ab)
  else:
    print(ans)
A,B,C,X,Y = map(int,(input().split()))

#ABピザの最大枚数
limit = max(X,Y)*2
Min = 10**10

for i in range(limit+1):
    a=0
    b=0
    c=0
    
    if i/2 < X:
        a = (X-int(i/2)) *A
    if i/2 < Y:
        b= (Y-int(i/2))*B    
        
    c = i*C
    
    Min = min(Min,a+b+c)
    
    
    
print(Min)
a, b, c, x, y = map(int, input().split())

if x>=y:
    print(min(a*x+b*y, c*x*2, c*y*2+a*(x-y)))
elif x<y:
    print(min(a*x+b*y, c*y*2, c*x*2+b*(y-x)))
#!/usr/bin/env python3

def main():
    A, B, C, X, Y = map(int, open(0).read().split())
    
    S = []
    for i in range(0, 2*max(X, Y)+1):
        S.append(A*max(0, X - i//2) + B*max(0, Y - i//2) + C*i)
    print(min(S))

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

ans1 = c*max(x,y)*2
ans2 = a*x + b*y
if x<y:
    ans3 = c*2*x + b*(y-x)
else:
    ans3 = c*2*y + a*(x-y)

print(min(ans1,ans2,ans3))
A, B, C, X, Y = map(int, input().split(" "))

prices = []
if X > Y:
    half_max_count = X + 1
else:
    half_max_count = Y + 1

# 3 for文はダメなので削減する
# sliceで半分にできる多分。
for i in range(0, half_max_count):
    a_price = int(X - i) * A if (int(X - i) >= 0) else 0
    b_price = int(Y - i) * B if (int(Y - i) >= 0) else 0
    half_price = 2 * i * C
    price = half_price + a_price + b_price
    prices.append(price)
print(min(prices))
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)
a, b, ab, x, y = map(int, input().split())

min_value = a * x + b * y

max_num = max(x, y)

for i in range(2, max_num * 2 + 1, 2):
    # print(i)
    value = ab * i + a * max(0, x - i // 2) + b * max(0, y - i // 2)
    # print(value)
    min_value = min(min_value, value)

print(min_value)
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
        #print("%d = %d x %d + %d x %d + %d x %d " %(amount,p,a,q,b,n,c))
        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))
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)
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))
a,b,c,X,Y=map(int,input().split())

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

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

print(min(ans1,ans2,ans3))
a,b,c,x,y = map(int,input().split())
l = 0
flg = x
if x > y:
    l += (x - y) * a
    flg = y
elif x < y:
    l += (y - x) * b
else:
    pass
l += flg * 2 * c
n = max(x,y) * 2 * c
m = x * a + y * b
print(min(l,n,m))
a,b,c,x,y=map(int,input().split())
if a+b<=2*c:
  print(a*x+b*y)
else:
  if x>=y:
    total=y*2*c
    if a*(x-y)>=2*c*(x-y):
      total+=2*c*(x-y)
    else:
      total+=a*(x-y)
  else:
    total=x*2*c
    if b*(y-x)>=c*2*(y-x):
      total+=2*c*(y-x)
    else:
      total+=b*(y-x)
  print(total)
a, b, c, x, y = map(int, input().split())
ans = 0
min_ = min(x, y)
res = abs(x-y)
if a+b < 2*c:
    ans += min_*(a+b)
else:
    ans += min_*2*c
if x>y and res*a < res*2*c:
    ans += res*a
elif x<y and res*b < res*2*c:
    ans += res*b
else:
    ans += res*2*c
print(ans)
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)
a, b, c, x, y = map(int, input().split())
k = min(x, y)
ans = 0
if a + b >= 2 * c:
  ans += 2 * k * c
  if x >= y:
    ans += min((x - k) * a, 2 * c * (x - k))
  elif x < y:
    ans += min((y - k) * b, 2 * c * (y - k))
else:
  ans += x * a + y * b
print(ans)
A, B, C, X, Y = list(map(int, input().split()))

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

print(ans)
A, B, C, X, Y = map(int, input().split())
ans = 0
if 2 * C < A + B:
    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)
a, b, c, x, y = map(int, input().split())
ans = 10 ** 9
for cn in range(0, max(x, y) * 2 + 1, 2):
    may = max(0, x - cn // 2) * a + max(0, y - cn // 2) * b + cn * c
    ans = min(ans, may)
print(ans)
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) # 無駄にならない範囲でABピザを買い、残りを買う
ans2 = A*X + B*Y # ABピザを買わない
ans3 = 2 * C * max_xy # ABピザだけを買う
print (min(ans1,ans2,ans3))
def solve(a,b,c,x,y):
  l = []
  for i in range(10**6):
    s = a*max(x-i,0)+b*max(y-i,0)+c*i*2
    l.append(s)
  return min(l)

        

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

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

print(ans)
#n=int(input())
a,b,c,x,y=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

ans=a*x+b*y

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

    ans = 1000000007
    for i in range(100001):
        cost = c * i * 2 + a * max(0, x - i) + b * max(0, y - i)
        if cost < ans:
            ans = cost

    print(ans)

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

s = set()
s.add(a*x + b*y)
if x < y:
    s.add(2*x*c + b*(y-x))
    s.add(2*(x+1)*c + b*(y-x-1))
    s.add(2*y*c)
    print(min(s))
else:
    s.add(2*y*c + a*(x-y))
    s.add(2*(y+1)*c + a*(x-y-1))
    s.add(2*x*c)
    print(min(s))
a, b, c, x, y = map(int, input().split())

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

print(ans)
A, B, C, X, Y = map(int, input().split())
ans = float('inf')
for c_2 in range(10**5 + 1):
    a = max(X - c_2, 0)
    b = max(Y - c_2, 0)
    ans = min(ans, a * A + b * B + c_2 * C * 2)
print(ans)
A, B, C, X, Y = map(int, input().split())
all = A * X + B * Y
all_half = max(X, Y) * C * 2
m = min(X, Y)
appropriate_half = (m * C * 2) + A * (X - m) + B * (Y - m)
print(min(all, all_half, appropriate_half))
a,b,c,x,y = map(int,input().split())
res = 9999999999999
for i in range(0, 200002, 2):
    na = x - i//2
    nb = y - i//2
    na = 0 if na < 0 else na
    nb = 0 if nb < 0 else nb
    res = min(res, c * i + a*na + b*nb)
print(res)
a, b, c, x, y = map(int, input().split())
ans = a * x + b * y
ans = min(c * max(x, y) * 2, ans)
if x < y:
    ans = min(c * x * 2 + (y - x) * b, ans)
else:
    ans = min(c * y * 2 + (x - y) * a, ans)

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

#Cについての全列挙する
v1 = max(x*2,y*2)*c
v2 = a*x+b*y
v3=120000*100000
for i in range(max(x,y)+1):
    c_sum = c*2*(i)
    if x > i:
        c_sum += a*(x-i)
    if y > i:
        c_sum += b*(y-i)
    if c_sum < v3:
        v3 = c_sum
    # print(c_sum)

 # print(v1,v2,v3)
print(min(v1,v2,v3))
a, b, c, x, y = map(int, input().split())
i = a*x+b*y
j = c*min(x, y)*2+a*(x-min(x, y))+b*(y-min(x, y))
k = c*max(x, y)*2
print(min(i, j, k))
def main():
    A, B, C, X, Y = map(int, input().split())

    ans = 1 << 30
    c = 0  # even
    while True:
        j = c // 2
        t = A * max(0, X - j) + B * max(0, Y - j) + C * c
        if ans <= t: break
        ans = t
        c += 2

    print(ans)


if __name__ == '__main__':
    main()
a, b, c, x, y = map(int, input().split())
total = 0
if x >= y:
    total = min(a*x+b*y, c*x*2, c*y*2+a*(x-y))
else:
    total = min(a*x+b*y, c*y*2, c*x*2+b*(y-x))
print(total)
a, b, c, x, y=map(int,input().split())
 
cnt = 10**9
for m in range(max(x,y)+1):
    price = (2*m*c) + max(0,(x-m))*a + max(0,y-m)*b
    cnt = min(cnt, price)

print(cnt)
a,b,c,x,y = map(int, input().split())
if (a+b <= c*2):
    print(a*x+b*y)
else:
    if (x>=y):
        print(min(y*c*2+(x-y)*a,x*c*2))
    else:
        print(min(x*c*2+(y-x)*b,y*c*2))
A, B, C, X, Y = map(int, input().split())

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

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

pay = 0
same = min(X, Y)
pay += same * min(A + B, C * 2)

X -= same
Y -= same

pay += X * min(A, C * 2)
pay += Y * min(B, C * 2)

print(pay)
a, b, c, x, y = map(int, input().split())
ans1 = a * x + b * y  #そのまま
ans2 = 0
if x > y:  #少ない方をABで補う
    ans2 = c * min(x, y) * 2 + a * (x - y)
else:
    ans2 = c * min(x, y) * 2 + b * (y - x)
ans3 = c * max(x, y) * 2  #すべてABで
print(min(ans1, ans2, ans3))
def inpl():
    return list(map(int, input().split()))


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

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

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

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

cost = A*X + B*Y
a = X
b = Y
c  = 0
N = max(X,Y)

for i in range(N):
  c += 2
  if a > 0:
    a -= 1
  if b > 0:
    b -= 1
  cost = min(cost,A*a + B*b + c*C)
print(cost)
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 and b>=2*c:
    print(y*2*c + max(0,x-y)*a)
elif a>=2*c and b<2*c:
    print(x*2*c + max(0,y-x)*b)
elif a+b>2*c:
    if x>y:
        print(y*2*c+(x-y)*a)
    else:
        print(x*2*c+(y-x)*b)
else:
    print(a*x+b*y)
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))
A, B, C, X, Y = map(int, input().split())

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

print(ans)
price_A, price_B, price_AB, num_A, num_B = map(int,input().split())
AandB = price_A * num_A + price_B * num_B
if num_A >= num_B:
    minAB = price_AB*num_B*2 + price_A*(num_A-num_B)
else:
    minAB = price_AB*num_A*2 + price_B*(num_B-num_A)
maxAB = price_AB * max(num_A, num_B) * 2
print(min(AandB, minAB, maxAB))
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)
#!/usr/bin/env python3

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()
a, b, c, x, y = map(int, input().split())

A = a * x + b * y
if x <= y: B = c * x * 2 + b * (y-x)
else: B = c * y * 2 + a * (x-y)
C = c * max(x, y) * 2

print(min(A, B, C))
def calcPizza(k, mai):
    return k*mai

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

asum = calcPizza(a, x)
bsum = calcPizza(b, y)
absum = calcPizza(c,mins*2)
if x > mins:
    atmp= calcPizza(a,x-mins)
    abtmp= calcPizza(c,(x-mins)*2)
    absum += min(atmp,abtmp)
elif y > mins:
    btmp = calcPizza(b,y-mins)
    abtmp = calcPizza(c,(y-mins)*2)
    absum += min(btmp,abtmp)
print(min(asum+bsum, absum))
a,b,c,x,y = map(int, input().split())

if a+b <= c*2:
  print(a*x+b*y)
else:
  if x == y: print(c*x*2)
  elif x > y: 
    if a <= c*2: print(c*y*2+a*(x-y))
    else: print(c*x*2)
  elif x < y: 
    if b <= c*2: print(c*x*2+b*(y-x))
    else: print(c*y*2)
def resolve():
    A, B, C, X, Y = [int(i) for i in input().split()]
    # Cを0～max(X,Y)の2倍まで購入
    minA = float("inf")
    for i in range(0, max(X, Y) * 2 + 1, 2):
        sumA = C * i
        sumA += (A * (X - i // 2) if (X - i // 2) > 0 else 0)
        sumA += (B * (Y - i // 2) if (Y - i // 2) > 0 else 0)
        minA = min(minA, sumA)
    print(minA)


resolve()
A,B,C,X,Y=map(int,input().split())
cost=A*X+B*Y
Z=max(X,Y)
for i in range(0,2*Z+1,2):
    x=max(0,X-(i//2))
    y=max(0,Y-(i//2))
    cost=min(cost,C*i+A*x+B*y)
print(cost)
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)
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()
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))
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()
a, b, c, x, y = map(int, input().split())

p2 = 0
for i in range(max(x, y)):
    ai = a * (x - i) if i < x else 0
    bi = b * (y - i) if i < y else 0
    abi = 2 * i * c
    p1 = ai + bi + abi

    ai1 = a * (x - i - 1) if i < x else 0
    bi1 = b * (y - i - 1) if i < y else 0
    abi1 = 2 * (i + 1) * c
    p2 = ai1 + bi1 + abi1
    if p1 < p2:
        print(p1)
        exit()

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

print(ans)
#<100q.全探索（計算量注意）>
a, b, c, x, y = map(int,input().split())
ans1 = a * x + b * y
if x <= y:
    ans2 = c * 2 * x + b * (y - x)
    ans5 = c * 2 * y
else:
    ans2 = c * 2 * y + a * (x - y)
    ans5 = c * 2 * x
ans3 = a * x + c * 2 * y
ans4 = b * y + c * 2 * x
##print(ans1)
##print(ans2)
##print(ans3)
##print(ans4)
##print(ans5)
print(min(ans1,ans2, ans3, ans4, ans5))
import sys
stdin = sys.stdin

mod = 10**9 + 7

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

A, B, C, X, Y = na()
ans = 10**10
for ab in range((10**5+1)*2):
    cost = ab * C
    cost += max(0, X - ab//2) * A
    cost += max(0, Y - ab//2) * B
    ans = min(ans, cost)
print(ans)
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    v1 = 2*c*max(x, y)
    v2 = 2*c*min(x, y) + (y-x if x < y else x-y)*(b if x < y else a)
    v3 = a*x + b*y
    print(min(v1, v2, v3))


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

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

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