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.



Sample input:
1500 2000 1600 3 2


Sample output:
7900

Submission status: Accepted

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

def solve():
    ans = float('inf')

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



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
#!python
# -*- coding: utf-8 -*-

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

if not(X >= Y):
    X, Y = Y, X
    A, B = B, A

P1 = (A * X + B * Y)
P2 = (C * (X * 2))
P3 = (C * (Y * 2) + A * (X - Y))

print(min(P1, P2, P3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil
A, B, C, X, Y = map(int, input().split())

ans = float('inf')
# ABピザの枚数
for i in range(2*max(X, Y)+1):
    tmpX = max(X - i/2, 0)
    tmpY = max(Y - i/2, 0)
    ans = min(ans, i*C + ceil(tmpX)*A + ceil(tmpY)*B)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
ans=A*X+B*Y
for i in range(min([X,Y])+1):
    M=A*X+B*Y-A*i-B*i+2*C*i
    if M<ans:
        ans=M
S=max([X,Y])
T=min([X,Y])
if S*2*C<ans:
    ans=S*2*C
print(ans)

Submission status: Accepted

Solution code:
import random


def slv(A, B, C, X, Y):
    a = A * X + B * Y
    b = min(X, Y) * 2 * C + (X - min(X, Y)) * A + (Y - min(X, Y)) * B
    c = max(X, Y) * 2 * C
    # print(a, b, c)

    return min(a, b, c)


def main():
    # N = int(input())
    A, B, C, X, Y, = list(map(int, input().split()))
    print(slv(A, B, C, X, Y))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3


def gen_cands(a, b, c, x, y):
    for z in range(0, max(2 * x, 2 * y) + 1, 2):
        x0 = max(0, x - z // 2)
        y0 = max(0, y - z // 2)
        money = a * x0 + b * y0 + c * z
        yield money


def solve(a, b, c, x, y):
    return min(gen_cands(a, b, c, x, y))


def main():
    a, b, c, x, y = (int(z) for z in input().split())
    print(solve(a, b, c, x, y))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
inline = list(map(int,input().split()))

A = inline[0]
B = inline[1]
C = inline[2]
X = inline[3]
Y = inline[4]

kouho1 = A*X+B*Y
less = min(X,Y)
many = max(X,Y)
if A+B>2*C:
    kouho1-=less*(A+B-2*C)
kouho2 = many*2*C

print(min(kouho1,kouho2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
#N=int(input())
#a = list(map(int,input().split()))

#x = []
#y = []
#for i in range(5):
#    x1,y1=[int(i) for i in input().split()]
#    x.append(x1)
#    y.append(y1)
import math

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

v=2*C*max(X,Y)
for r in range(2*max(X,Y)+2):
    R=r//2
    p=max(math.ceil(X-R),0)
    q=max(math.ceil(Y-R),0)
#    print(p*A+q*B+C*r,p,q,r)
    v=min(v, p*A+q*B+C*r)

print(v)

Submission status: Accepted

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

Submission status: Accepted

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

#cost for a = min(a, 2*c)
#cost for b = min(b, 2*c)

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

Submission status: Accepted

Solution code:

def main():
    a, b, c, x, y = [int(i) for i in raw_input().strip().split()]
    foo = x * a + b * y
    for k in xrange(max(x, y)+1):
        foo = min(foo, (k * c * 2) + (max(x-k, 0) * a) + (max(y-k, 0) * b))
    print foo
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

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

ans = int(1e100)
ab_num = 0

while ab_num // 2 <= max(X, Y):
    money = ab_num * C
    money += max(0, (X - ab_num // 2)) * A
    money += max(0, (Y - ab_num // 2)) * B
    ans = min(ans, money)
    ab_num += 2

print(ans)

Submission status: Accepted

Solution code:
tmp = list(map(int, input().split()))
a, b ,c,x,y = tmp[0],tmp[1],tmp[2],tmp[3],tmp[4]
if x >= y:
    s1 = a * x + b * y
    s2 = x * c * 2
    s3 = y * c * 2 + (x-y) * a
    print(min(s1,s2,s3))
else:
    s1 = a * x + b * y
    s2 = y * c * 2
    s3 = x * c * 2 + (y-x) * b
    print(min(s1,s2,s3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=[int(k) for k in raw_input().split(" ")]

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split(" "))
m = min(X,Y)
ans = m * min((A+B),(C+C))
X -= m
Y -= m
if X != 0:
	ans += (min(A,C+C) * X)
else:
	ans += (min(B,C+C) * Y)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ret=10**10
for i in range(2*max(x,y)+1):
    aleft=max(x-(i//2),0)
    bleft=max(y-(i//2),0)
    ret=min(ret,c*i+aleft*a+bleft*b)
print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

p1 = X * A + Y * B
m = min(X, Y)
p2 = m * 2 * C + (X - m) * A + (Y - m) * B
M = max(X, Y)
p3 = M * 2 * C

print(min(p1, p2, p3))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    a, b, c, x, y = map(int, input().split())
    cost = 10 ** 10
    for z in range(0, max(x, y) + 1):
        rx = max(0, x - z)
        ry = max(0, y - z)
        cost = min(cost, rx * a + ry * b + z * 2 * c)
    print(cost)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a, b, c, x, y = map(int, input().split())
answer = 0
if 2 * c < a + b:
    z = min(x, y)
    x -= z
    y -= z
    answer += 2 * c * z
a = min(a, 2 * c)
b = min(b, 2 * c)
answer += a * x
answer += b * y
print(answer)

Submission status: Runtime Error

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


if A+B > c*2:
    Z = min(X,Y)
    ans += 2*C*Z
    X -= Z
    Y -= Z
a = min(A,2*C)
b = min(B,2*C)

ans += a*X
ans += b*Y

print(ans)

Submission status: Runtime Error

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

min_sum = int(float('inf'))
for c in range(0, 200000+2, 2):
    print(c)
    sum = C*c
    if X - c/2 > 0:
        sum += A * (X - c/2)
    if Y - c/2 > 0:
        sum += B * (Y - c/2)
    if sum < min_sum:
        min_sum = sum
print(min_sum)

Submission status: Runtime Error

Solution code:
ll A, B, C, X, Y;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B >> C >> X >> Y;
    
    ll ans = infl;
    rep(ab, 0, 201010) {
        ll sm = C * ab;
 
        ll x = X - ab / 2;
        ll y = Y - ab / 2;
 
        if (0 < x) sm += x * A;
        if (0 < y) sm += y * B;
 
        chmin(ans, sm);
    }
 
    cout << ans << endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,C,X,Y = map(int, input().split())
price = A*X + B*Y + 2*C*(X+Y)
for i in range(X+1):
  for j in range(Y+1):
    for k in range(2*max(X,Y)+2):
      while (i+2*k) >= X and (j+2*k) >= Y:
      num = A*i + B*j + C*k
      if num < price:
        price = num
print(price)

Submission status: Runtime Error

Solution code:
A,B,C,X,Y = map(int, input().split())
price = A*X + B*Y + 2*C*max(X,Y)
for i in range(X+1):
  for j in range(Y+1):
    for k in range(2*max(X,Y)+2):
      if (i+2*k) < X or (j+2*k) < Y:
        break
      A*i + B*j + C*k = num
      if num < price:
        price = num
print(price)

Submission status: Runtime Error

Solution code:
A,B,C,X,Y = map(int, input().split())
price = A*X + B*Y + 2*C*max(X,Y)
for i in range(X+1):
  for j in range(Y+1):
    for k in range(2*max(X,Y)+2):
      if (i+2*k)==X and (j+2*k)==Y:
        continue
      A*i + B*j + C*k = num
      if num < price:
        price = num
print(price)

Submission status: Runtime Error

Solution code:
a, b, c, x, y = map(int, input().split())
possible_minimum_sum1 = a * x + b * y
possible_minimum_sum2 = c * max(a, b) * 2
possible_minimum_sum3 = c * a * 2 + max(b-a, 0) * b
possible_minimum_sum4 = c * b * 2 + max(a-b, 0) * a

print(min(tuple(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3, possible_minimum_sum4)))

Submission status: Runtime Error

Solution code:
inputs = open(0).readlines()
a, b, c, x, y = map(int, open(0).read().split())

prices = []
prices.append(a*x + b*y)
prices.append(a*abs(x-y) + 2*c*min(x, y))
prices.append(b*abs(x-y) + 2*c*min(x, y))
prices.append(2*c*max(x, y))
print(min(prices))

Submission status: Runtime Error

Solution code:
# Half and Half
a,b,c,x,y = map(int,input().split())

ans = []
for i in range(max(x,y)):
    ans.append(2*c*i + a*max(0,x-i) + b*max(0,y-i))
    print(ans)

print(min(ans))

Submission status: Runtime Error

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

D = (A + B) // 2
C2 = C * 2

ans = 0

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

Submission status: Runtime Error

Solution code:
import sys
A, B, C, X, Y = map(int,input().split())
 
minf = sys.maxsize
X1 = X
Y1 = Y
 
for i in range(0, max(X,Y)+1):
    price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C 
print(min(price))

Submission status: Runtime Error

Solution code:
import sys
A, B, C, X, Y = map(int,input().split())
 
minf = sys.maxsize
X1 = X
Y1 = Y
 
 
for i in range(0, max(X,Y)+1):
    price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C
 
 
print(min(price))

Submission status: Runtime Error

Solution code:
import math

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

ans = 100000000000000000000000000

for x in range(X):
  ab = (X - x) * 2
  
  if Y > (ab / 2):
    continue

  y = Y - (ab / 2)

  a = (A * x) + (B * y) + (C * ab)

  if ans > a:
    ans = a

print(math.floor(a))

Submission status: Runtime Error

Solution code:
price = min((a + b) / 2, c) * X + min(a, c/2)
print(price)

Submission status: Runtime Error

Solution code:
N, C= map(int,input().split())
XV = sorted([list(map(int,input().split())) for _ in range(N)])
acmXV = []
dbl_acmXV = []
for i, xv in enumerate(XV):
  x,v = xv
  if i == 0:
    acmXV.append(v-x)
    dbl_acmXV.append(v-x*2)
  else:
    acmXV.append(v-(x-XV[i-1][0])+acmXV[i-1])
    dbl_acmXV.append(v-(x-XV[i-1][0])*2+dbl_acmXV[i-1])

acmXV_rev = [0 for _ in range(N)]
dbl_acmXV_rev = [0 for _ in range(N)]
for i in range(N-1, -1, -1):
  x,v = XV[i]
  if i == N-1:
    acmXV_rev[i] = v-(C-x)
    dbl_acmXV_rev[i] = v-(C-x)*2
  else:
    acmXV_rev[i] = (v-(XV[i+1][0]-XV[i][0])+acmXV_rev[i+1])
    dbl_acmXV_rev[i] = (v-(XV[i+1][0]-XV[i][0])*2+dbl_acmXV_rev[i+1])
    
ans = max(0,max(acmXV),max(acmXV_rev))
for i in range(N-1):
  for j in range(N-2,i+1,-1):
    #print(i,j,dbl_acmXV[i],acmXV_rev[N-1-j])
    ans = max(ans, dbl_acmXV[i]+acmXV_rev[j], acmXV[i]+dbl_acmXV_rev[j]) 
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
a,b,c,x,y = map(int, input().split())
half_a = a/2
half_b = b/2
more_price = a if x>y else b
more = abs(x-y)
n = min(x,y)
 
if c > half_a +half_b:
  return a*x + b*y
 
if more_price > c*2:
  add = c*2*more
else:
  add = more_price*more
 
return c*n + add

Submission status: Runtime Error

Solution code:
a,b,c,x,y = map(int, input().split())
half_a = a/2
half_b = b/2
more_price = a if x>y else b
more = abs(x-y)
n = min(x,y)
 
if c > half_a +half_b:
  return a*x + b*y
 
if more_price > c*2:
  add = c*2*more
else:
  add = more_price*more
 
  return c*n + add

Submission status: Runtime Error

Solution code:
a = arg[0]
b = arg[1]
half_a = a/2
half_b = b/2
c = arg[2]
x = arg[3]
y = arg[4]
more_price = a if x>y else b
more = abs(x-y)
n = min(x,y)

if c > half_a +half_b:
  return a*x + b*y

if more_price > c*2:
  add = c*2*more
else:
  add = more_price*more

  return c*n + add

Submission status: Runtime Error

Solution code:
ans_min = x * a + y * b
for i in range(100000):
    ans = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b
    if ans < ans_min:
        ans_min = ans
print(ans)

Submission status: Runtime Error

Solution code:
a,b,c,x,y=map(int, input().split())
cnta=0
cntb=0
cntc=0
if a+b>2*c:
  cntc=min(x,y) * 2
else:
  cnta=min(x,y)
  cntb=min(x,y)

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

ptint(cnta*a+cntb*b+cntc*c)

Submission status: Runtime Error

Solution code:
a,b,c,x,y=map(int,input().split())
ans=a*x+b*y
for i in range(x+1):
  for j in range(y+1):
    if a*i+j*b+(x+y-i+j)*c<num:
      ans=a*i+j*b+(x+y-i+j)*c
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import*
from numpy import array
n,c=map(int,input().split())

l1=[]
l2=[]
for i in range(n):
    x,v=map(int,input().split())
    l1.append(x)
    l2.append(v)
#print(l1,l2)

ll=array([0]+l1)
lll=array([0]+list(accumulate(l2)))
lr=array([0]+[c-i for i in l1][::-1])
llr=array([0]+list(accumulate(l2[::-1])))
x=lll-ll
y=llr-lr
for i in range(2,n+1):
    x[i]=max(x[i-1],x[i])
    y[i]=max(y[i-1],y[i])
z=array([min(ll[i],lr[i])for i in range(n+1)])
print(max(x[::-1]+y-z))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from itertools import accumulate
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, C = map(int, input().split())

posDist = []
posVal = []
for _ in range(N):
    d, v = list(map(int, input().split()))
    posDist.append(d)
    posVal.append(v)

negDist = []
negVal = []
for d, v in zip(reversed(posDist), reversed(posVal)):
    negDist.append(C-d)
    negVal.append(v)


posDist = [0]+posDist
negDist = [0]+negDist

posVal = [0]+list(accumulate(posVal))
negVal = [0]+list(accumulate(negVal))
# print(posDist)
# print(negDist)
# print(posVal)
# print(negVal)
for i, d in enumerate(posDist):
    posVal[i] -= d
for i, d in enumerate(negDist):
    negVal[i] -= d
ans = 0

# print("after")
# print(posVal)
# print(negVal)
for l in range(N+1):
        if negVal[l] < 0:
            continue
        for r in range(N-l+1):
            tmp = posVal[r]+negVal[l]-min(posDist[r], negDist[l])
            #print("l,r->", l, r, tmp)
            ans = max(tmp, ans)
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys

args = sys.argv

a_value = int(args[1])
b_value = int(args[2])
c_value = int(args[3])
a_number = int(args[4])
b_number = int(args[5])

value = 0

if a_value + b_value <= c_value * 2:
    value = a_value * a_number + b_value * b_number
    print (value)
else:
    if a_number >= b_number:
        value += c_value * 2 * b_number
        if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:
            value += (a_number - b_number) * c_value * 2
        else:
            value += (a_number - b_number) * a_value

    else:
        value += c_value * 2 * a_number
        if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:
            value += (b_number - a_number) * c_value * 2
        else:
            value += (b_number - a_number) * a_value
    print (value)

Submission status: Runtime Error

Solution code:
import sys

A, B, C, X, Y = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]
A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)

strat1 = A*X + B*Y  # simple strategy
strat2 = 2*C*X + abs(Y-X)*B  # more A, add back B
strat3 = 2*C*Y + abs(X-Y)*A  # more B, add back A
strat4 = 2*C*max(X,Y) # overbuy C

print min(strat1, strat2, strat3, strat4)

Submission status: Runtime Error

Solution code:
import sys

A, B, C, X, Y = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]
A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)

strat1 = A*X + B*Y  # simple strategy
strat2 = 2*C*X + abs(Y-X)+B  # more A, add back B
strat3 = 2*C*Y + abs(X-Y)*A  # more B, add back A
strat4 = 2*C*max(X,Y) # overbuy C

print min(strat1, strat2, strat3, strat4)

Submission status: Runtime Error

Solution code:
import sys

A, B, C, X, Y = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]
A = int(A)                                                                                                         │chou@HEROZnoMacBook-Pro:~$ pyhton test.py 1 2 3 4 5
B = int(B)                                                                                                         │-bash: pyhton: command not found
C = int(C)                                                                                                         │chou@HEROZnoMacBook-Pro:~$ python test.py 1 2 3 4 5
X = int(X)                                                                                                         │1 2 3 4 5
Y = int(Y)                                                                                                         │chou@HEROZnoMacBook-Pro:~$ python test.py 1500 2000 1900 3 2


strat1 = A*X + B*Y  # simple strategy
strat2 = 2*C*X + abs(Y-X)+B  # more A, add back B
strat3 = 2*C*Y + abs(X-Y)*A  # more B, add back A
strat4 = 2*C*max(X,Y) # overbuy C

print min(strat1, strat2, strat3, strat4)

Submission status: Runtime Error

Solution code:
import sys

A, B, C, X, Y = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]

strat1 = A*X + B*Y  # simple strategy
strat2 = 2*C*X + abs(Y-X)+B  # more A, add back B
strat3 = 2*C*Y + abs(X-Y)*A  # more B, add back A
strat4 = 2*C*max(X,Y) # overbuy C

print min(strat1, strat2, strat3, strat4)

Submission status: Runtime Error

Solution code:
A, B, C, X, Y = map(int, input().split())
if X < Y:
    ab = range(Y + 1)
    p = X
else:
    ab = range(X + 1)
    p = Y
min_price = A*X+B*Y
for i in ab:
    if i <= p
        price = A*(X-i)+B*(Y-i)+(2*C*i)
        if min_price > price:
            min_price = price
    else:
        if p == X:
            price = B*(Y-i)+(2*C*i)
            if min_price > price:
                min_price = price
        else:
            price = A*(X-i)+(2*C*i)
            if min_price > price:
                min_price = price
print(min_price)

Submission status: Runtime Error

Solution code:
valuesStr = input()
[A, B, C, X, Y] = valuesStr.split(" ")

price = 0

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

print(price)

Submission status: Runtime Error

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

ans1 = a*x + b*y

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

print(min(ans1, ans2), ans3)

Submission status: Runtime Error

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

i=0
min_value=10000000
while True:
    if x-i//2<0 or y-i//2<0:
        break
        
    value=(x-i//2)*a+(y-i//2)*b+i*c
    
    if value<=min_value:
        min_value=value
        flag=True
    else:
        if flag:
            break
    i+=2

print(min_value)

Submission status: Runtime Error

Solution code:
# input
N, C = map(int, input().split(" "))
x, v = [], []
for i in range(1, N+1):
    xv = list(map(int, input().split(" ")))
    x.append(xv[0])
    v.append(xv[1])

# x_i メートル
# v_i キロカロリー
max_cal = 0
S = [[i for i in range(N)]]  # stack
place = 0  # 位置
cal = 0
S[0].append(cal)
S[0].append(place)
while len(S) > 0:
    s = S.pop()  # n = len
    # index -1 : place
    # index -2 : calorie
    if len(s) == 3:
        # len(s) = 1 になったとき
        idx = s[0]  # first
        next_place = x[idx]
        place_step = min(dist, C - dist)
        next_cal = s[-2] - place_step + v[s[0]]
        max_cal = max(max_cal, next_cal)
    else:
        #while len(s) > 1:
        # x[s[0]] は s[0] 番目の寿司の相手ある絶対位置（初期値からの距離）
        place = s[-1]
        idx = s[0]  # first
        next_place = x[idx]
        dist = abs(next_place - place)
        place_step = min(dist, C - dist)
        next_cal = s[-2] - place_step + v[idx]
        max_cal = max(max_cal, next_cal)
        S.append(s[1:-2] + [next_cal, next_place])
        place = s[-1]
        idx = s[-3]  # last
        next_place = x[idx]
        #place_step = abs(next_place - place) % C
        place_step = min(dist, C - dist)
        next_cal = s[-2] - place_step + v[idx]
        max_cal = max(max_cal, next_cal)
        S.append(s[:-3] + [next_cal, next_place])
print(max_cal)

Submission status: Runtime Error

Solution code:
# input
N, C = map(int, input().split(" "))
x, v = [], []
for i in range(1, N+1):
    xv = list(map(int, input().split(" ")))
    x.append(xv[0])
    v.append(xv[1])

# x_i メートル
# v_i キロカロリー
max_cal = 0
S = [[i for i in range(N)]]  # stack
place = 0  # 位置
cal = 0
S[0].append(cal)
S[0].append(place)
while len(S) > 0:
    s = S.pop()  # n = len
    # index -1 : place
    # index -2 : calorie
    print("pop", s, max_cal)
    if len(s) == 3:
        # len(s) = 1 になったとき
        idx = s[0]  # first
        next_place = x[idx]
        place_step = min(dist, C - dist)
        next_cal = s[-2] - place_step + v[s[0]]
        max_cal = max(max_cal, next_cal)
    else:
        #while len(s) > 1:
        # x[s[0]] は s[0] 番目の寿司の相手ある絶対位置（初期値からの距離）
        place = s[-1]
        idx = s[0]  # first
        next_place = x[idx]
        dist = abs(next_place - place)
        place_step = min(dist, C - dist)
        next_cal = s[-2] - place_step + v[idx]
        max_cal = max(max_cal, next_cal)
        S.append(s[1:-2] + [next_cal, next_place])
        place = s[-1]
        idx = s[-3]  # last
        next_place = x[idx]
        #place_step = abs(next_place - place) % C
        place_step = min(dist, C - dist)
        next_cal = s[-2] - place_step + v[idx]
        max_cal = max(max_cal, next_cal)
        S.append(s[:-3] + [next_cal, next_place])
print(max_cal)

Submission status: Runtime Error

Solution code:

x = input().split()
A=int(x[0])
B=int(x[1])
C=int(x[2])
X=int(x[3])
Y=int(x[4])
D=(A+B)/2
if D>=C:
    if X>=Y:
        print(Y*C*2+(X-Y)*A)
    else:
        print(X*C*2+(Y-X)*B)
else:
    print(A*X+B*Y)
x = input().split()
A=x[0]
B=x[1]
C=x[2]
X=x[3]
Y=x[4]
D=(A+B)/2
if D>=C:
    if X>=Y:
        print(Y*C*2+(X-Y)*A)
    else:
        print(X*C*2+(Y-X)*B)
else:
    print(A*X+B*Y)

Submission status: Runtime Error

Solution code:
x = input().split()
A=x[0]
B=x[1]
C=x[2]
X=x[3]
Y=x[4]
D=(A+B)/2
if D>=C:
    if X>=Y:
        print(Y*C*2+(X-Y)*A)
    else:
        print(X*C*2+(Y-X)*B)
else:
    print(A*X+B*Y)

Submission status: Runtime Error

Solution code:
D=(A+B)/2
if D>=C:
    if X>=Y:
        print(Y*C*2+(X-Y)*A)
    else:
        print(X*C*2+(Y-X)*B)
else:
    print(A*X+B*Y)

Submission status: Runtime Error

Solution code:
D=(A+B)/2
if D>=C:
    if X>=Y:
        print(Y*C*2+(X-Y)*A)
    else:
        print(X*C*2+(Y-X)*B)
else:
    print(A*X+B*Y)

Submission status: Runtime Error

Solution code:
n,c=map(int,input().split())
x=[0]
v=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    v.append(b)
x1=[x[i+1]-x[i] for i in range(len(x)-1)]
x2=[c-x[-1]]+x1[:0:-1]
#print(x1,x2)
h=[0]
t=[0]
for i,j in zip(x2,reversed(v)):
    h.append(h[-1]+j+-i)
hm=[max(h[:-i]) for i in range(1,len(h))]+[0]
#print(h,hm)
m=0
for k,(i,j) in enumerate(zip(x1,v)):
    t.append(t[-1]+j-i)
    #print(m,t[-1],i)
    m=max(m,t[-1]+hm[k])
print(m)

Submission status: Runtime Error

Solution code:
n,c=map(int,input().split())
x=[0]
v=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    v.append(b)

x1=[x[i+1]-x[i] for i in range(len(x)-1)]
x2=[c-x[-1]]+x1[:0:-1]
print(x1,x2)
h=[0]
t=[0]
for i,j in zip(x2,reversed(v)):
    h.append(h[-1]+j+-i)
hm=[max(h[:-i]) for i in range(1,len(h))]+[0]
print(h,hm)
m=0
for k,(i,j) in enumerate(zip(x1,v)):
    t.append(t[-1]+j-i)
    print(m,t[-1],i)
    m=max(m,t[-1]+hm[k])
print(m)

Submission status: Runtime Error

Solution code:
a, b, c, x, y=map(int, input().split())
m=2＊x＊c
n=c＊y＊2+a＊(x-y)
d=2＊y＊c
e=c＊x＊2+b＊(y-x)
f=a＊x+b＊y
g=min(m,n,f)
h=min(d,e,f)
if x>=y:
    print(g)
else:
    print(h)

Submission status: Runtime Error

Solution code:
a, b, c, x, y=map(int, input().split())
m=2＊x＊c
n=c＊y＊2+a＊(x-y)
d=2＊y＊c
e=c＊x＊2+b＊(y-x)
f=a＊x+b＊y
g=min(m,n,f)
h=min(d,e,f)
if a[3]>=a[4]:
    print(g)
else:
    print(h)

Submission status: Runtime Error

Solution code:
print 1

Submission status: Runtime Error

Solution code:
a=list(map(int, input().split()))

print 1

Submission status: Runtime Error

Solution code:
a=list(map(int, input().split()))
b=2＊a[3]＊a[2]
c=a[2]＊a[4]＊2+a[0]＊(a[3]-a[4])
d=2＊a[4]＊a[2]
e=a[2]＊a[3]＊2+a[1]＊(a[4]-a[3])
f=a[0]＊a[3]+a[1]＊a[4]
g=min(b,c,f)
h=min(d,e,f)
if a[3]>=a[4]:
    print(g)
else:
    print(h)