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 = [int(i) for i in input().split()]

min_price = a * x + b * y

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

print(min_price)

Solution (Python):
def parse_input(raw,format):
    raw=raw.split()
    format=format.split()

    ret={}
    rawpos=0
    for f in format:
        pass


def A(S):
    ret=700
    ret+=S.count("o")*100
    return ret

def B(N,X,m):
    ret=0
    X-=sum(m)
    ret+=len(m)

    ret+=int(X/min(m))

    return ret

def C(A,B,C,X,Y):
    both_price=min(A+B,C*2)
    A_price=min(A,C*2)
    B_price=min(B,C*2)

    both_num=min(X,Y)
    X_num=X-both_num
    Y_num=Y-both_num
    return both_price*both_num+X_num*A_price+Y_num*B_price

import sys

inp = sys.stdin.read().split()
inp=[int(i) for i in inp]
print(C(inp[0], inp[1], inp[2],inp[3],inp[4]))

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

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

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

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

    if((A + B) < C*2):
        result = A*X + B*Y
    else:
        if(X < Y):
            result = X * C * 2
            rem = Y - X
            if(B < C*2):
                result += B * rem
            else:
                result += C * rem*2
        else:
            result = Y * C * 2
            rem = X - Y
            if(A < C*2):
                result += A * rem
            else:
                result += C * rem*2
    
    print(result)
    
if __name__=="__main__":
    main()

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

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

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

ans = 10**8

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

Solution (Python):

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

Solution (Python):
l = list(map(int, input().split()))

sum = 0
a = b = c = 0

if l[0] > l[2]*2 or l[1] > l[2]*2:
    c1 = c2 = 0
    if l[0] > l[2]*2:
        c1 = 2 * l[3]
    if l[1] > l[2]*2:
        c2 = 2 * l[4]
    c = max([c1, c2])
elif l[0]+l[1] > l[2]*2:
    c += min([l[3], l[4]])*2
else:
    a = l[3]
    b = l[4]


if a+c/2 < l[3]:
    a += l[3]-(c/2+a)
if b+c/2 < l[4]:
    b += l[4]-(c/2+b)

sum = a*l[0] + b*l[1] + c*l[2]

print(int(sum))

Solution (Python):


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

sum_cost = 0


if x <= y:
    ryoho = x
else:
    ryoho = y
if (a + b)/ 2 <= ab:
    sum_cost += (a * ryoho)
    sum_cost += (b * ryoho)
else:
    sum_cost += (ab * ryoho * 2)


kataho = abs(x - y)
if x >= y:
    if a <= ab * 2:
        sum_cost += (a * kataho)
    else:
        sum_cost += (ab * kataho * 2)
else:
    if b <= ab * 2:
        sum_cost += (b * kataho)
    else:
        sum_cost += (ab * kataho * 2)

print(sum_cost)

Solution (Python):
import sys

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

best_price = sys.maxsize


for i in range(0, max(x, y) * 2 + 1, 2):
    rest_a = x
    rest_b = y

    if i // 2 >= x:
        rest_a = 0
    else:
        rest_a = x - i // 2

    if i // 2 >= y:
        rest_b = 0
    else:
        rest_b = y - i // 2

    price = rest_a * a + rest_b * b + c * i
    if price < best_price:
        best_price = price
    

print(best_price)

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

if A + B <= 2 * C:
    pri = A * X + B * Y
else:
    while min(X, Y) != 0:
        pri += C * 2
        X -= 1
        Y -= 1
    if A * X + B * Y >= 2 * C * (X + Y):
        pri += 2 * C * (X + Y)
    else:
        pri += A * X + B * Y

print(pri)

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

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

print(ans)

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

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

print(minmoney)

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

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

print(ans)

Solution (Python):
A, B, C, X, Y = map(int, raw_input().split())
ans = 0
if A + B < C * 2:
  ans = A*X+B*Y
else:
  num_ab_a = X*2
  num_b_a = 0 if Y-X < 0 else Y-X
  ans_a = C*num_ab_a+B*num_b_a
  num_ab_b = Y*2
  num_a_b = 0 if X-Y < 0 else X-Y
  ans_b = C*num_ab_b+A*num_a_b
  ans = ans_a if ans_a < ans_b else ans_b
print ans

Solution (Python):


a,b,c,x,y=map(int,raw_input().split())
res=float('inf')
for i in xrange(max(x,y)+2):
 t=2*c*i+max(0,x-i)*a+max(0,y-i)*b
 res=min(res,t)
print res

Solution (Python):


a,b,c,x,y=map(int,raw_input().split())
res=float('inf')
for i in xrange(100000+2):
 t=2*c*i+max(0,x-i)*a+max(0,y-i)*b
 res=min(res,t)
print res

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

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

print(ans)

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

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

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

Solution (Python):
import sys
l1 = input().split()
l2 = []
for num in l1:
    l2.append(int(num))
value = []
for c in range(0,2*max([l2[3],l2[4]])+1,2):
    a = max([l2[3]-(c/2),0])
    b = max([l2[4]-(c/2),0])                    
    value.append(int((a*l2[0])+(b*l2[1])+(c*l2[2    ])))
print(min(value))

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

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

	print(p)

Solution (Python):
def main():
    """
    1 <= A,B,C<=5*10^3
    1 <= X,Y<=10^5
    """
    A, B, C, X, Y = map(int, input().split())

    search(A, B, C, X, Y)

def search(A, B, C, X, Y):
    ans = float("inf")
    for a in range(X+1):
        ab = 2 * (X - a)
        b = max(Y - ab // 2, 0)
        price = A * a + B * b + C * ab
        ans = min(ans, price)

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

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

"""
C - Half and Half
https://beta.atcoder.jp/contests/abc095/tasks/arc096_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A, B, C, X, Y):
    if A + B <= 2 * C:
        return A * X + B * Y

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

    Y -= m
    if 2 * C < B:
        ans += 2 * C * Y
    else:
        ans += B * Y

    X -= m
    if 2 * C < A:
        ans += 2 * C * X
    else:
        ans += A * X

    return ans


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


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
def solve(a, b, c, x, y):
    flag = None
    if x < y:
        flag = True
    else:
        flag = False
    if c < (a / 2) and c < (b / 2):
        return c * max(x, y) * 2
    c_many = min(x, y)
    c_total = c * c_many * 2
    return min([
        (y - c_many) * b + c_total if flag else (x - c_many) * a + c_total, 
        a * x + b * y,
        max(x, y) * 2 * c,
    ])
   
if __name__ == '__main__':
    a, b, c, x, y = map(lambda x: int(x), input().split())

    print(solve(a, b, c, x, y))

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

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

Solution (Python):
a , b , c ,x , y = map(int , input().split())
c2 = c *2
na , nb ,nc = 0 , 0 ,0 
if a > c2 :
    a = c2
if b > c2 :
    b = c2

if a <= c2 and b <= c2 :
    if a + b >= c2 :
        nc = min(x,y)
        if x > y :
            na = x - y
        else :
            nb = y -x
    else :
        na = x
        nb = y
print(na*a+nb*b+nc*c2)

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

answer = a * x + b * y

while (2*c) < (a+b):
    if x >= 1 and y >= 1:
        answer = answer +  (2*c) - (a+b)
        x -= 1
        y -= 1
    else:
        break

while (2*c) < a:
    if x >= 1:
        answer = answer + (2*c) -a
        x -= 1
    else:
        break

while (2*c) < b:
    if y >= 1:
        answer = answer + (2*c) -b
        y -= 1
    else:
        break
print(answer)

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


p1 = a * x + b * y


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


p3 = c*max(x, y)*2

print(min(p1, p2, p3))

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


p1 = a * x + b * y


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


p3 = c*(x+y) * 2
p4 = c*max(x, y)*2

print(min(p1, p2, p3, p4))

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

if a + b // 2 < c:
    c = a + b // 2

n = a * x + b * y
m = c * max(x, y) * 2

v = 0

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

print(min(n, v, m))

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

Solution (Python):
a,b,c,x,y = map(int,input().split())
fx = x
fy = y
fl = 0
val = int(0)
fmin = min(x,y)
if a>2*c:
  x = 0
  y = y - fx
  val += 2*c*fx
  fl += 1
if y < 0:
  y = 0
if b>2*c:
  if fl == 1:
    val += 2*c*y
    y = 0
  else:
    val += 2*c*y
    x = x -y
    y = 0 
if x < 0:
  x = 0
nx = x
ny = y
if a+b>2*c:
  x = x - min(nx,ny)
  y = y - min(nx,ny)
  val += 2*c*min(nx,ny)
print(val+a*x+b*y)

Solution (Python):
def main():
    """
    1 <= A,B,C<=5*10^3
    1 <= X,Y<=10^5
    """
    A, B, C, X, Y = map(int, input().split())

    
    
    a4 = A * X + min(B * Y, 2 * C * Y)
    a5 = B * Y + min(A * X, 2 * C * X)
    a6 = 2 * C * max(X, Y)

    a1 = 2 * C * min(X, Y)
    d = abs(X - Y)
    price = A if X >= Y else B
    a1 += min(price * d, 2 * C * d)

    
    a2 = float("inf")
    if 2 * C < A:
        d = max(Y - X, 0)
        a2 = 2 * C * X + min(B * d, 2 * C * d)

    
    a3 = float("inf")
    if 2 * C < B:
        d = max(X - Y, 0)
        a3 = 2 * C * Y + min(A * d, 2 * C * d)

    ans = min([a1, a2, a3, a4, a5, a6])
    print(ans)


if __name__ == '__main__':
    main()

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

if x >= y:
	i = a * (x - y) + c * y * 2
	j = a * x + b * y
	k = c * x * 2
	if i >= j and k >= j:
		count = j
	elif i >= k and j >= k:
		count = k
	elif j >= i and k >= i:
		count = i
else:
	i = b * (y - x) + c * x * 2
	j = a * x + b * y
	k = c * y * 2
	if i >= j and k >= j:
		count = j
	elif i >= k and j >= k:
		count = k
	elif j >= i and k >= i:
		count = i

print(count)

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

min_money=2*5000*10**5
for nc in range(0,2*10**5+1,2):
    if nc > 2*x and nc > 2*y:
        break
    if nc > 2*x:
        money = (y-nc//2)*b + nc*c
    elif nc > 2*y:
        money = (x-nc//2)*a + nc*c
    else:
        money = (x-nc//2)*a + (y-nc//2)*b + nc*c
    if min_money > money:
        min_money = money
            
print(min_money)

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

Solution (Python):
import math

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

a1 = max(x, y) * c * 2

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

a3 = a * x + b * y

answer = min(a1, a2, a3)
print(str(answer))

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

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

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

print(res)

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

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

rem_C = remain*C
rem_AorB = remain*(A,B)[X<Y]

if rem_C*2 < rem_AorB:
    ans += rem_C*2
else:
    ans += rem_AorB

print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
pa = A * X
pb = B * Y
pab = pa + pb
pc_max = C * max(X, Y) * 2
pc_min = C * min(X, Y) * 2
if X > Y:
    n = X - Y
    pc_min += A * n
else:
    n = Y - X
    pc_min += B * n
print(min(pab, pc_max, pc_min))

Solution (Python):
if __name__ == "__main__":
    A, B, C, X, Y = list(map(int, input().split()))
    ans = 0
    if (A + B) >= 2*C:
        
        if (A >= B):
            if (B >= 2*C):
                
                if X >= Y:
                    ans += (2*C) * X
                    print(ans)
                    exit()
                else:
                    ans += (2*C) * Y
                    print(ans)
                    exit()
            elif (A >= 2*C):
                
                ans += (2*C) * X
                if Y >= X:
                    ans += A * (Y - X)
                print(ans)
                exit()
            else:
                
                if X >= Y:
                    ans += (2*C) * Y
                    ans += A * (X - Y)
                else:
                    ans += (2*C) * X
                    ans += B * (Y - X)
                print(ans)
                exit()
        else:
            if (A >= 2*C):
                if X >= Y:
                    
                    ans += (2*C) * X
                    print(ans)
                    exit()
                else:
                    
                    ans += (2*C) * Y
                    print(ans)
                    exit()
            elif (B >= 2*C):
                
                ans += (2*C) * Y
                if X >= Y:
                    ans += A * (X - Y)
                print(ans)
                exit()
            else:
                
                if X >= Y:
                    ans += (2*C) * Y
                    ans += A * (X - Y)
                else:
                    ans += (2*C) * X
                    ans += B * (Y - X)
                print(ans)
                exit()
    else:
        
        ans += A * X + B * Y
        print(ans)
        exit()

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

Z = max(X,Y)
W = min(X,Y)

if Z % 2 == 1:
  Zeven = Z + 1
else:
  Zeven = Z

if W % 2 == 1:
  Weven = W + 1
else:
  Weven = W


price1 = X*A + Y*B


price2 = C * Z * 2


if Z % 2 == 0:
  price3 = price2
else:
  price3 = C * (Z-1)*2 + A * max(0, X - Z + 1) + B * max(0,Y - Z + 1)


price4 = C * W * 2 + A * max(0,X-W) + B * max(0,Y-W)


if W % 2 == 0:
  price5 = price4
else:
  price5 = C * (W-1) * 2+ A * max(0,X - W + 1) + B * max(0,Y - W + 1)


print(min(price1,price2,price3,price4,price5))

Solution (Python):
def a():
    s = input()
    total = 700
    for i in s:
        total += 100 if i == 'o' else 0
    print(total)


def b():
    n, x = map(int, input().split())
    m = [int(input()) for _ in range(n)]
    print(len(m) + ((x - sum(m)) // min(m)))


def c():
    a, b, c, x, y = map(int, input().split())
    total = 0
    while x > 0 or y > 0:
        
        xi = min(x, 1)  
        yi = min(y, 1)  
        x -= xi
        y -= yi
        total += min(xi*a+yi*b, 2*c)
        
        
        
        
    print(total)


c()

Solution (Python):
def solve(a, b, c, x, y):
    i = div(x, 2)
    j = div(y, 2)
    m = a * i + b * j

    for k in range(1, max(x, y) + 1):
        i = div(x - k, 2)
        j = div(y - k, 2)
        m = min(m, a * i + b * j + c * k)
    
    return m


def div(x, y):
    if x <= 0:
        return 0

    n, r = divmod(x, y)
    if r != 0:
        return n + 1
    else:
        return n


def main():
    a, b, c, x, y = map(int, input().split())
    print(solve(a, b, c, x * 2, y * 2))

main()

Solution (Python):
l = input().split(' ')
a,b,c,x,y = int(l[0]),int(l[1]),int(l[2]),int(l[3]),int(l[4])

place = []
place.append( a * x + b * y )

if x-y > 0:
    place.append(c * x * 2)
else:
    place.append(c * y * 2)

if x < y :
    place.append(c * x * 2 + b * (y-x))
else :
    place.append(c * y * 2 + a * (x-y))
    
print(sorted(place)[0])

Solution (Python):
A, B, C, X, Y = [int(i) for i in input().split()]
ma = max(X, Y)
mi = min(X, Y)
memo = []
if A + B > 2 * C:
    result1 = A * (X - mi) + B * (Y - mi) + C * 2 * mi
    result2 = C * 2 * ma
    print(min(result1, result2))
else:
    print(A * X + B * Y)

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

price = 0

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

print(price)

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

print(sum)

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

for i in range(x+1):
    v = x-i
    s = a*i + b*(y-v) + c*v
    if y <= v:
        s = a*i + c*v
    if s < mi:
        mi = s

for i in range(y+1):
    v = y-i
    s = a*(x-v) + b*i + c*v
    if x <= v:
        s = b*y + c*v
    if s < mi:
        print('h', a*(x-v) + b*i + c*v)
        mi = s

if c*max((x,y)) < mi:
    mi = c*max((x,y))

print(mi)

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

Solution (Python):
def main():
    A, B, C, X, Y = (int(i) for i in input().split())
    if(A + B) <= C *2:
        print(A * X + B * Y)

    else:
        value = 0
        value = min(X, Y) * C * 2
        if (X - Y) >0:
            min_value = min(int(X - Y)*A, abs(X-Y)*C*2)
        else:
            min_value = min(int(Y - X)*B, abs(X-Y)*C*2)

        print(value + min_value)
if __name__ == '__main__':
    main()

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

if C * 2 <= A and C * 2 <= B:
    print(max(X, Y) * 2 * C)
    exit()

if C * 2 >= A + B:
    print(A * X + B * Y)
    exit()

result = 0
while True:
    if X <= 0 and Y <= 0:
        break

    if X == 0 and C * 2 >= B:
        print(result + Y * B)
        exit()
    elif Y == 0 and C * 2 >= A:
        print(result + X * A)
        exit()

    result += C * 2
    X -= 1
    Y -= 1

print(result)

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

Solution (Python):
da = list(map(int,input().split()))
oka = 0
o = 0
p = 0
l = 0
k = 0
if da[3] <= da[4]:
  oka = da[3]
  o = da[4]
  p = da[4]-da[3]
  l = 1
  k = 0
elif da[4] <= da[3]:
  oka = da[4]
  o = da[3]
  p = da[3]-da[4]
  l = 0
  k = 1
if (da[0]*da[3] + da[1]*da[4]) >= (da[2]*o*2 + da[k]*p):
  if da[3] <= da[4]:
    print(da[2]*da[4]*2)
  else:
    print(da[2]*da[3]*2)
elif (da[0]*da[3] + da[1]*da[4]) >= (da[2]*oka*2 + da[l]*p):
  if da[3] <= da[4]:
    print(da[2]*da[3]*2 + da[1]*(da[4]-da[3]))
  else:
    print(da[2]*da[4]*2 + da[0]*(da[3]-da[4]))
else:
  print(da[0] * da[3] + da[1] * da[4])

Solution (Python):
ABCXY = list(int(i) for i in input().split())

XY = []
XY.append(ABCXY[3])
XY.append(ABCXY[4])

ans = 0
if 2*ABCXY[2] < ABCXY[0] + ABCXY[1]:
    ans += min(XY)*2*ABCXY[2]
    if XY[0] > XY[1]:
        if ABCXY[0] < 2*ABCXY[2]:
            ans += (XY[0]-XY[1])*ABCXY[0]
        else:
            ans += (XY[0]-XY[1])*ABCXY[2]*2
    else:
        if ABCXY[1] < 2*ABCXY[2]:
            ans += (XY[1]-XY[0])*ABCXY[1]
        else:
            ans += (XY[1]-XY[0])*ABCXY[2]*2
else:
    ans += ABCXY[0]*XY[0] + ABCXY[1]*XY[1]
print(ans)

Solution (Python):
import sys
raw_input = sys.stdin.readline
range = xrange
a, b, c, x, y = map(int, raw_input().split())
if 2 * c >= a + b :
    print x * a + y * b
else:
    DP = [0]*(max(x, y)+1)
    for i in range(max(x, y)+1):
        DP[i] = 2 * c * i + a * max(0, x-i) + b * max(0, y-i)
    print min(DP)

Solution (Python):
if __name__ == '__main__':
    a,b,c,x,y = map(int, raw_input().split())
    if c * 2 > a + b:
        print a * x + b * y
    else:
        cost = c * 2 * min(x,y)
        z = abs(x-y)
        if x < y :
            if c * 2 * z < b * z:
                print cost + c * 2 * z
            else:
                print cost + b * z
        else:
            if c * 2 * z < a * z:
                print cost + c * 2 * z
            else:
                print cost + a * z

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

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

price1 = X * A + Y * B
price2 = X * 2 * C + (Y - X) * B if Y > X else X * 2 * C
price3 = Y * 2 * C + (X - Y) * A if X > Y else Y * 2 * C
min_price = min(price1, price2, price3)

print(min_price)

Solution (Python):
a,b,c,x,y=list(map(int,input().split()))
mxy=min([x,y])
Mxy=max([x,y])
mab=min([a,b])
ans=0
if 2*c<a+b:
	ans+=2*c*mxy
	if x<y:
		ans+=b*(y-mxy)
	else:
		ans+=a*(x-mxy)
else:
	ans=a*x+b*y

if ans>2*c*Mxy:
	ans=2*c*Mxy

print(ans)

Solution (Python):
def getinputdata():

    
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()


a = int(arr_data[0][0])

b = int(arr_data[0][1])

c = int(arr_data[0][2])


x = int(arr_data[0][3])


y = int(arr_data[0][4])

mysum1 = a * x + b * y
mysum2 = c * max(x, y) * 2
mysum3 = c * min(x, y) * 2 + a * (x-min(x, y)) + b * (y-min(x, y))

arr=[mysum1,mysum2,mysum3]
arr.sort()
print(arr[0])

Solution (Python):
a_price, b_price, ab_price, a_want, b_want = list(map(int, input().split()))
ab_price = ab_price * 2
anb = a_price + b_price
ans = 0

def return_small_num(a, b):
	return min(a, b)


def remaining_amount_list(a, b, a_price, b_price):
	if a > b:
		return [a - b, a_price]
	else:
		return [b - a, b_price]


which = remaining_amount_list(a_want, b_want, a_price, b_price)

small_num = return_small_num(a_want, b_want)


if anb <= ab_price:
	ans = a_want * a_price + b_want * b_price

elif anb > ab_price:
	ans = ab_price * small_num
	
	
	
	
	
	remaining = which[0]
	amount = which[1]
	if amount <= ab_price:
		ans = ans + remaining * amount
	else:
		ans = ans + remaining * ab_price

print(ans)

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


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

print(money)

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

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

print(ans)

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

if x > y:
    if a - c*2 > 0:
        res += c*2*x
        x -= x
else:
    if b - c*2 > 0:
        res += c*2*y
        y -= y

res += a*x + b*y
print(res)

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

price = min(A+B, 2*C) * min(X, Y)
need_A = max(0, X-Y)
need_B = max(0, Y-X)

if need_A > 0:
    price += need_A * min(A, 2*C)
if need_B > 0:
    price += need_B * min(B, 2*C)

print(price)

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

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

if __name__ == '__main__':
    main()

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

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

print(count)

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

smaller = X if X < Y else Y
bigger = X if X >= Y else Y
bigger_yen = A if bigger==X else B
cheaper = A if A <B else B
higher = A if A >= B else B

if 2*C >= A + B:
    buy = A*X + B*Y
elif 2*C < A + B:
    if bigger_yen < 2*C:
        buy = smaller*2*C + (bigger-smaller)*bigger_yen
    else:
        buy = bigger*2*C

print(buy)

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

print(s)

Solution (Python):


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

if __name__ == '__main__':
    main()

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

    case1 = A * X + B * Y
    case2 = C * 2 * max(X, Y)
    if X < Y:
        case3 = C * X * 2 + B * (Y - X)
    else:
        case3 = C * Y * 2 + A * (X - Y)
    ans = min(case1, case2, case3)

    print(ans)

main()

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

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