Problem:
 Score : 100 points    Problem Statement There is a hotel with the following accommodation fee:   X yen (the currency of Japan) per night, for the first K nights  Y yen per night, for the (K+1) -th and subsequent nights   Tak is staying at this hotel for N consecutive nights.
Find his total accommodation fee.      Constraints  1 \leq N, K \leq 10000  1 \leq Y < X \leq 10000  N,\,K,\,X,\,Y are integers.         Input The input is given from Standard Input in the following format:  N  K  X  Y       Output Print Tak's total accommodation fee.        Sample Input 1 5
3
10000
9000      Sample Output 1 48000  The accommodation fee is as follows:   10000 yen for the 1 -st night  10000 yen for the 2 -nd night  10000 yen for the 3 -rd night  9000 yen for the 4 -th night  9000 yen for the 5 -th night   Thus, the total is 48000 yen.       Sample Input 2 2
3
10000
9000      Sample Output 2 20000

Solution (Python):

def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    cost = 0

    for i in range(1, n+1):
        if i <= k:
            cost += x
        else:
            cost += y
    else:
        print(cost)
        
    
if __name__ ==  "__main__":
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    K = int(readline())
    X = int(readline())
    Y = int(readline())
    if N <= K:
        ans = X * N
    else:
        ans = X * K + Y * (N - K)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
ans = 0
if k <= n:
    ans +=  k*x + (n -k)*y
else:
    ans += x*n
print(ans)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

xdays = min(n,k)
ydays = n-xdays

ans = xdays*x + ydays*y
print(ans)

Solution (Python):
N=int(input())
K=int(input())
X=int(input())
Y=int(input())

print(min(N,K)*X+max(0,N-K)*Y)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if k < n:
    num = k*x + (n-k)*y
else:
    num = n*x
print(num)

Solution (Python):
N= [int(input()) for n in range(4)]
if N[0] < N[1]:
    print(N[0]*N[2])
else:
    print(N[1]*N[2]+(N[0]-N[1])*N[3])

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N <= K:
    ans = N * X
else:
    ans = K * X + (N - K) * Y
print(ans)

Solution (Python):
n,k,x,y=[int(input()) for _ in range(4)]
print(x*min(k,n)+y*max(n-k,0))

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0


if(K>N):
    ans = X * N
    
else:
    ans = X*K+Y*(N-K)

print(ans)

Solution (Python):
def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())

    if n - k >= 0:
        print(x * k + y * (n - k))
    else:
        print(x * n)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n < k:
    print(x*n)
else:
    print(k*x + (n-k)*y)

Solution (Python):
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
print(min(K,N)*X+max((N-K),0)*Y)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())

sale=0

if n<=k:
    sale+=n*x
else:
    sale+=k*x+y*(n-k)

print(sale)

Solution (Python):
n,k,x,y = [int(input()) for i in range(4)]

total = 0
day = 0
for i in range(n):
    day += 1
    if day <= k:
        total += x
    else:
        total += y
print(total)

Solution (Python):
N=int(input())
K=int(input())
x=int(input())
y=int(input())

if N>K:
  s=x*K+y*(N-K)
else:
  s=x*N
print(int(s))

Solution (Python):
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if K > N:
    print(N*X)
else:
    print(K*X+(N-K)*Y)

Solution (Python):
list = []
price = 0

for i in range(4):
    list.append(int(input()))

for i in range(list[0]):
    if i < list[1]:
        price += list[2]
    else:
        price += list[3]

print(price)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if k<n:
    print(x*k+y*(n-k))
else:
    print(x*n)

Solution (Python):







n = int(input())
k = int(input())
x = int(input())
y = int(input())

temp = n - k

if (temp >= 0):
    print(x*k + temp*y)
else:
    print(x*n)

Solution (Python):
n,k,x,y = [int(input()) for i in range(4)]
print(min(n,k) * x + max(n-k,0) * y)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

print(x * min(n, k) + y * max(n-k, 0))

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(x*n if n<=k else y*(n-k)+x*k)

Solution (Python):
a = [int(input()) for i in range(4)]
if a[0] <= a[1]:
  print(a[0] * a[2])
else:
  print(a[1] * a[2] + (a[0] - a[1]) * a[3])

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n <= k:
  ans = n*x
else:
  ans = k*x
  ans = ans + (n-k)*y

print(ans)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(x*min(n,k)+y*max(n-k,0))

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n<=k:
    print(n*x)
else:
    print(k*x+(n-k)*y)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k:
    print(n * x)
else:
    m = n - k
    print((k * x) + (m * y))

Solution (Python):
N,K,X,Y = [int(input()) for _ in range(4)]
print(N*X-(X-Y)*max(N-K,0))

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
if n <= k:
    ans = x * n
else:
    ans = x * k + (n-k) * y
print(ans)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n <= k :
    print(x*n)
else :
    print(x*k+y*(n-k))

Solution (Python):
n,k,x,y=int(input()),int(input()),int(input()),int(input())
if n<=k:
  print(n*x)
else:
  print(k*x+(n-k)*y)

Solution (Python):

















import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def INT(): return int(input())
N = INT()
K = INT()
X = INT()
Y = INT()

if N >= K:
    print(K * X + (N - K) * Y)
else:
    print(N * X)

Solution (Python):
n_stay = int(input())
n_p1 = int(input())
p1 = int(input())
p2 = int(input())

print(min([n_p1, n_stay]) * p1 + max([n_stay - n_p1, 0]) * p2)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if K <= N:
    fee = K*X + (N - K)*Y
else:
    fee = N*X
print(fee)

Solution (Python):
n, k, x, y = [int(input()) for i in range(4)]
if n > k:
    syogaku = k * x
    sagaku = (n - k) * y
    print(syogaku + sagaku)
else:
    syogaku = n * x
    print(syogaku)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n <= k :
  print(n * x)
else:
  print(k * x + (n - k) * y)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
a=x*(min(n,k))+y*(n-min(n,k))
print(a)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
 
if n>k:
    p = k*x + (n-k)*y
else:
    p = n*x
print(p)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
total = 0

for i in range(1, n+1):
  if i <= k:
    total += x
  else:
    total += y
print(total)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n>k:
    num = k*x + (n-k)*y
else:
    num = n*x
print(num)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>k:
    print(k*x+(n-k)*y)
else:
    print(n*x)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())

N,K,X,Y = I(),I(),I(),I()
print(min(K,N)*X + (max(K,N)-K)*Y)

Solution (Python):
total_nights = int(input())
first_nights = int(input())
first_rate = int(input())
extra_rate = int(input())

if total_nights <= first_nights:
  total = total_nights * first_rate
else:
  total = (first_nights * first_rate) + ((total_nights - first_nights) * extra_rate)
print(total)

Solution (Python):
num1 = int(input())
num2 = int(input())
num3 = int(input())
num4 = int(input())

if num1>num2:
  print(num2*num3+(num1-num2)*num4)
else:
  print(num1*num3)

Solution (Python):
def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    if n <= k:
        ans = n * x
    else:
        ans = k * x + (n-k) * y
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
s = []
for _ in range(4):
    s.append(int(input()))
p=0
for i in range(s[0]):
    if i<s[1]:
        p+=s[2]
    else:
        p+=s[3]
print(p)

Solution (Python):
def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    cost = 0
    
    if n <= k:
        cost += n * x
    elif n > k:
        cost += k * x + (n - k) * y
    print(cost)
    
  
if __name__ == '__main__':
  main()

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n <= k:
    print(n * x)
else:
    print(k * x + (n - k) * y)

Solution (Python):
N = int(input()) 
K = int(input()) 
X = int(input()) 
Y = int(input()) 
if N > K:
  print(K * X + (N - K) * Y)
else:
  print(N * X)

Solution (Python):
n, k, x, y = (int(input()) for i in range(4))
if k >= n:
  print(n*x)
else:
  print(k*x + (n-k)*y)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
bill = 0
for i in range(1,n+1):
    if i <= k:
        bill += x
    if i > k:
        bill +=y
print(bill)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(
x*min(n,k)+y*max(0,n-k)
)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(x * min(n, k) + y * max(0, n - k))

Solution (Python):


def main():
   
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())

    ans = 0

    for i in range(1, N+1):
        if i <= K:
            ans += X

        else:
            ans += Y

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, K, X, Y = [int(input()) for _ in range(4)]

ans = min(N, K) * X

print(min(N, K) * X + (N - min(N, K)) * Y)

Solution (Python):
n=int(input())
k=int(input())
p1=int(input())
p2=int(input())
if n>k:
    print(k*p1+(n-k)*p2)
else:
    print(n*p1)

Solution (Python):
def main():
    N, K, X, Y = (int(input()) for _ in range(4))
    to_pay = X * min(K, N) + Y * max(0, N - K)
    print(to_pay)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = x * min(n, k)
ans += y * max(0, n - k)
print(ans)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(x*min(n, k)+y*max(n-k, 0))

Solution (Python):
import sys
n,k,x,y = map(int,sys.stdin.read().split())
high=n-k
ans=0
if high > 0:
  ans=x*k+high*y
else:
  ans=n*x
print(ans)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n<=k:
    ans=x*n
else:
    ans=x*k+(n-k)*y
print(ans)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(n*x+max(0, n-k)*(y-x))

Solution (Python):
a = [int(input()) for _ in range(4)]
print(min(a[0], a[1])*a[2]+max(0, (a[0]-a[1])*a[3]))

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N >= K:
  total = X*K + Y*(N-K)
else:
  total = X*N
print(total)

Solution (Python):
N,K,X,Y = map(int, open(0).read().split())
if N < K:
    ans = N*X
else:
    ans = K*X + (N-K)*Y
print(ans)

Solution (Python):
n,k,x,y = (int(input()) for i in range(4))
if k < n:
    print(k*x + y*(n-k))
else:
    print(x*n)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N <= K:
  ans = N*X
else:
  ans = K*X + (N-K)*Y
print(ans)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N<=K:
    ans = X*N
else:
    ans = X*K
    ans += Y*(N-K)
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n = ini()
k = ini()
x = ini()
y = ini()


def solve():
    ans = min(k, n) * x
    if n > k:
        ans += (n - k) * y

    return ans


print(solve())

Solution (Python):
def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    print(min(k, n) * x + max(0, n - k) * y)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N<K:
  print(N*X)
else:
  print(K*X + (N-K)*Y)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n>k:
    ans = k*x + (n-k)*y
else:
    ans = n*x

print(ans)

Solution (Python):
n = int(input())
k = int(input())
a = int(input())
b = int(input())
if n<=k:
  print(n*a)
else:
  print(k*a+(n-k)*b)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, X, Y = map(int, read().split())

    if N <= K:
        ans = X * N
    else:
        ans = X * K + (N - K) * Y

    print(ans)

    return


if __name__ == '__main__':
    main()

Solution (Python):

import sys
input = sys.stdin.readline

n = int(input())
k = int(input())
x = int(input())
y = int(input())

if k<=n:
  print(k*x+(n-k)*y)
else:
  print(n*x)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

print( min(N,K)*X + max(0, N-K)*Y )

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

ans = 0

for i in range(1,N+1):
    ans += X

if K < N:
    for i in range(1, N-K+1):
        ans += Y - X

print(ans)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n > k:
    print(k*x+y*(n-k))
else:
    print(n*x)

Solution (Python):
n, k, x, y = (int(input()) for _ in range(4))
print(n * x if n <= k else k * x + (n - k) * y)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

print(X*N if N <= K else X*K + Y*(N - K))

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k:
    print(n * x)
else:
    print(k * x + (n-k)*y)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k:
    print(int(n*x))
else:
    print(int(k*x+(n-k)*y))

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if(n<=k):
    print(n*x)
else:
    print(k*x+(n-k)*y)

Solution (Python):
n, k, x, y = (int(input()) for i in [0]*4)
print(n*x-(x-y)*max(n-k,0))

Solution (Python):
N = int(input())
K = int(input())
x = int(input())
y = int(input())
if N>K:
  ans = x*K + y*(N-K)
  print(ans)
else:
  ans = x*N 
  print(ans)

Solution (Python):



import io
import sys
import math

def solve(n,k,x,y):
    
    higher = n-k
    if higher < 1:
        return n*x
    else:
        return k*x + higher*y



def main():
    
    n,k,x,y = map(int,sys.stdin.read().split())
    
    
    ans = str( solve(n,k,x,y) )
    
    
    print(ans)
    return ans
        

_DEB = 0   

_INPUT = """\
2
3
10000
9000
"""
_EXPECTED = """\
20000
"""

def logd(str):
    if _DEB: print(f"[deb] {str}")


if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Solution (Python):
N = int(input())
K = int(input())
x = int(input())
y = int(input())

if N <= K:
  print(N*x)
else:
  print(K*x + (N-K)*y)

Solution (Python):
def resolve():
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())
    if N > K:
        cost = X * K + Y * (N - K)
    else:
        cost = X * N
    print(cost)

resolve()

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if K<N:
  res = X*K+(N-K)*Y
else:
  res = X*N
print(res)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n > k:
  print(x*k + y*(n-k))
else:
  print(x*n)

Solution (Python):
l=[int(input()) for i in range(4)]

if(l[0]>l[1]):
    a=l[1]*l[2]+(l[0]-l[1])*l[3]
else:
    a=l[0]*l[2]

print(a)

Solution (Python):
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if K>N:
    print(X*N)
else:
    print(X*K+Y*(N-K))

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

ans = []
if n>k:
    for i in range(k):
        ans.append(x)

    for i in range(n-k):
        ans.append(y)
else:
    for i in range(n):
        ans.append(x)
print(sum(ans))

Solution (Python):
N = int (input ())
K = int (input ())
X = int (input ())
Y = int (input ())
if N<=K:
  print (N*X)
else:
  print (K*X+(N-K)*Y)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(x*n if n <= k else x*k+y*(n-k))

Solution (Python):
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if K<=N:
    result= (K * X )+ Y * (N-K)
else:
   result= N*X
print("% d"%result)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if K >= N:
  cost = N*X
  print(cost)
elif K < N:
  cost = K*X + (N-K)*Y
  print(cost)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N<=K:
    print(X*N)
else:
    S = N-K
    print(X*K+Y*S)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N<=K:
    print(X*N)
else:
    S = N-K
    print(X*K+Y*S)

Solution (Python):
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if N<=K:
    print(X*N)
else:
    print(X*K+Y*(N-K))

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n>=k:
  print(k*x+(n-k)*y)
else:
  print(n*x)

Solution (Python):

N = int(input())
K = int(input())
x = int(input())
y = int(input())

ans = min(N, K) * x + max((N-K), 0) * y
print(ans)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n<=k:
    print(n*x)
else:
    print(k*x + y*(n-k))

Solution (Python):
n, k, x, y = [int(input()) for _ in range(4)]
print((x * min(n, k)) + (y * max(0, n - k)))

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n<=k:
  ans=n*x
else:
  ans=k*x+y*(n-k)
print(ans)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if k < n:
  print(k*x + (n-k)*y)
else:
  print(n*x)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if (K<N):
    print( (K*X) + ((N-K)*Y) )
else:
    print(N*X)

Solution (Python):
total = int(input())
until = int(input())
fee1 = int(input())
fee2 = int(input())

if total - until > 0:
    diff = total - until
    print(until * fee1 + diff * fee2)
else:
    print(total * fee1)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

print(min(n, k)*x+max(n-k, 0)*y)

Solution (Python):
n = int(input())
k = int(input())
print(min(k,n)*int(input())+max(0,n-k)*int(input()))

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
cost = 0
for i in range(N):
    if 1+i <= K:
        cost += X
    if i+1 > K:
        cost += Y
print(cost)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())


if (n < k):
    price = n * x
else:
    price = k * x
    
    price += (n-k) * y

print(price)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n <= k:
    ans = x * n
else:
    ans = x * k + y * (n - k)
print(ans)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0
if N <= K:
  ans = N * X
else:
  ans = K * X + (N-K)*Y
print(ans)

Solution (Python):
N,K,X,Y=[int(input()) for i in range(4)]
print(N*X-(X-Y)*max(N-K,0))

Solution (Python):
n, k, x, y = [int(input()) for i in range(4)]

if n - k > 0:
    print(k * x + (n - k) * y)
else:
    print(n * x)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
c = 0
for i in range(1,N+1):
  if i <= K:
    c += X
  elif i >= K + 1:
    c += Y
    
print(c)

Solution (Python):
l=[int(input()) for i in range(4)]
print(l[0]*l[2]-max(l[0]-l[1],0)*(l[2]-l[3]))

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(min(k, n) * (x) + ((n - k) * y if n - k > 0 else 0))

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

price = 0

if N > K:
    price = K * X + (N - K) * Y
else:
    price = N * X

print(price)

Solution (Python):
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if N>=K:
  print(X*K+(N-K)*Y)
else:
  print(X*N)

Solution (Python):
n,k,x,y= int(input()),int(input()),int(input()),int(input())
if n <= k:print(n*x)
else :print(x*k + y *(n-k))

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
cost = min(n,k)*x+max(0,n-k)*y
print(cost)

Solution (Python):
N=int(input())
K=int(input())
S=int(input())
T=int(input())

if N<=K:
  sum=N*S
else:
  sum=K*S
  if N-K>0:
    sum+=(N-K)*T
print(sum)

Solution (Python):
N, K, X, Y = [int(input()) for _ in range(4)]
res = N * X
if N > K:
    res += (N - K) * (Y - X)
print(res)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
pay=0
for i in range(1,n+1):
    if i<=k:
        pay=pay+x
    else:
        pay=pay+y



print(pay)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

first = min(n, k) * x
second = max(n-k, 0) * y

print(first + second)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
sum = 0
if n>=k:
  sum = k*x + (n - k)*y
  print(sum)
	
else:
  sum = n*x
  print(sum)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
if n <= k: ans = n * x
else: ans = k * x + (n-k) * y
print(ans)

Solution (Python):

N = int(input())
K = int(input())
X = int(input())
Y = int(input())


if N <= K:
   result = X * N
else:
   result = (X * K) + (Y * (N - K))


print(result)

Solution (Python):

n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n > k:
    ans = (k*x) + (n-k)*y
else:
    ans = (n*x)
print(ans)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0
if N > K:
    ans = K * X + (N-K) * Y
else:
    ans = N * X
print(ans)

Solution (Python):
N, K, X, Y = [int(input()) for _ in range(4)]
print(X*K+Y*(N-K) if N>K else X*N)

Solution (Python):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = 0

for i in range(1,a+1):
  if i >= b+1:
    e += d
  else:
    e += c
print(e)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n<=k:
  fare=x*n
else:
  fare=x*k+y*(n-k)
print(fare)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N > K:
  print(X * K + Y * (N - K))
else:
  print(X * N)

Solution (Python):
n,k,x,y=map(int,open(0))
print(n*x-(x-y)*max(n-k,0))

Solution (Python):
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())

    print(N * X) if N <= K else print(K*X + (N-K)*Y)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n<=k:
  print(n*x)
else:
  print(k*x+(n-k)*y)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = min(N, K)*X + max(0, N-K)*Y
print(ans)

Solution (Python):
N = int(input())

K = int(input())

X = int(input())

Y = int(input())


ans = 0
for i in range(N):
  if i+1 <= K:
    ans += X
  else:
    ans += Y
      
print(ans)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n > k:
    print(k*x+(n-k)*y)
else:
    print(n*x)

Solution (Python):
i=input
N,K,X,Y = map(int,[i(),i(),i(),i()])
print(sum([X if i<K else Y for i in range(N)]))

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n > k:
  print(k * x + (n - k) * y)
else:
  print(n * x)

Solution (Python):
N, K, X, Y = [int(input()) for i in range(4)]



res = 0

for i in range(N):
    if i + 1 <= K:
        res += X
    else:
        res += Y

print(res)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N = i()
K = i()
X = i()
Y = i()
print(N*X-max(0,N-K)*(X-Y))

Solution (Python):

n=int(input())
k=int(input())
x=int(input())
y=int(input())
sum_=0
if n-k>0:
    sum_=k*x+(n-k)*y
else:
    sum_=n*x
print(sum_)

Solution (Python):
def actual(N, K, X, Y):
    if N <= K:
        return X * N

    return (X * K) + (Y * (N - K))

N = int(input())
K = int(input())
X = int(input())
Y = int(input())

print(actual(N, K, X, Y))

Solution (Python):
n = 4
total = int(0)
zenhan = int(0)
kouhan = int(0)

N, K, X, Y = [int(input()) for i in range(4) ]

kouhan = (N - K ) * Y

if (N > K):
    zenhan = K * X
    total = zenhan + kouhan
else:
    zenhan = N * X
    total = zenhan

print(total)

Solution (Python):




n = int(input())
k = int(input())
x = int(input())
y = int(input())

diff = y - x

p_x = x * n
p_y = diff * (n - k) if (n - k) > 0 else 0

print(p_x + p_y)

Solution (Python):
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>=k:
    a=k*x
    a+=(n-k)*y
else:
    a=n*x
print(a)

Solution (Python):
N,K,X,Y=int(input()),int(input()),int(input()),int(input())
print(K*X+(N-K)*Y if N > K else N*X)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

ans = 0
for i in range(n):
  if i <= k-1:
    ans += x
  else:
    ans += y
    
print(ans)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

total = 0
for i in range(1, n+1):
    if i <= k:
        total += x
    else:
        total += y
print(total)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
Z = N - K
if Z <= 0:
    print(N * X)
else:
    print(K * X + Z * Y)

Solution (Python):
def main():
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())
    if N > K:
        print((K * X) + (Y * (N - K)))
    else:
        print(N * X)
main()

Solution (Python):
N = int(input())
K = int(input())

X = int(input())
Y = int(input())

print(min(K,N)*X + max(0,(N-K))*Y)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if K < N:
    Sum = X*K + Y*(N-K)
else:
    Sum = X*N
print(Sum)

Solution (Python):

N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N > K:
    print(X*K+(N-K)*Y)
else:
    print(X*N)

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if k<n:
  print( x*k + y*(n-k))
else:
  print( n*x )

Solution (Python):
def hotel():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    first = x * k
    later = y * (n - k)
    if k > n:
        first = x * n
        later = 0
    print(first + later)

hotel()

Solution (Python):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

total = 0
if n <= k:
    total = n * x

else:
    total = k * x + (n-k) * y

print(total)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N <= K:
  print(N*X)
else:
  print(K*X+(N-K)*Y)

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    K = read_int()
    X = read_int()
    Y = read_int()
    if K >= N:
        return X*N
    cost = X*K
    N -= K
    cost += N*Y
    return cost


if __name__ == '__main__':
    print(solve())

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
k = i()
x = i()
y = i()

if k <= n:
	print(k*x + (n-k)*y)
else:
	print(n*x)

Solution (Python):
n, k, x, y = map(int, [input() for i in range(4)])

if n <= k:
  print(x*n)
else:
  print(x*k + y*(n-k))

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)

Solution (Python):
N,K,X,Y = map(int,open(0))
a = N*X

if K<N:
  print(a-(X-Y)*(N-K))
else:
  print(a)

Solution (Python):
a,b,c,d=[int(input()) for i in range(4)]
print(c*min(a,b)+d*max(a-b,0))

Solution (Python):
info = [int(input()) for i in range(4)]

n = info[0]
k = info[1]
x = info[2]
y = info[3]

money = 0

for i in range(n):
    if i >= k:
        money += y
    else:
        money += x

print(money)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

res = 0
for i in range(N):
    if i<= K-1:
        res += X
    else:
        res += Y
print(res)

Solution (Python):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
m=0
for i in range(1,N+1):
    if i<=K:
        m+=X
    else:
        m+=Y

print(m)