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



Sample input:
5
3
10000
9000


Sample output:
48000

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0
for i in range(N):
    if i < K:
        ans += X
    else:
        ans += Y
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

res = 0
for i in range(N):
    if (i < K):
        res += x
    else:
        res += y

print(res)

Submission status: Accepted

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


if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

amount = 0

if N <= K:
    K = N
    L = 0
else:
    L = N - K



amount = K * X + L * Y

print(amount)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import sys

sys.setrecursionlimit(10000)
INF = float('inf')



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

ans =0
while K > 0 and N > 0:
    K-=1
    N-=1
    ans += X
while N > 0:
    N-=1
    ans += Y
print(ans)

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

cost = 0
day = 0
while day < N:
    if(day < K):
        cost += X
    else:
        cost += Y
    day += 1

print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def read_input():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())

    return n, k, x, y


def submit():
    n, k, x, y = read_input()

    c_x = min(n, k)
    c_y = max(0, n - k)

    print(c_x * x + c_y * y)

if __name__ == '__main__':
    submit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
x=int(input())
y=int(input())
yen = 0
for i in range(n):
  if i < k:
    yen += x
  else:
    yen += y
print(yen)

Submission status: Accepted

Solution code:
a=int(input())
b=min(a,int(input()))
print(b*int(input())+int(input())*(a-b))

Submission status: Accepted

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

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

if __name__ == '__main__':
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())
    
    solve(N,K,X,Y)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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)

Submission status: Accepted

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

n, k, x, y = [int(input()) for _ in range(4)]

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

Submission status: Accepted

Solution code:
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
print((N<=K)*N*X+(N>K)*(K*X+(N-K)*Y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a,b)*c + max(a-b,0)*d)

Submission status: Accepted

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

s=0

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())

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


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

Submission status: Accepted

Solution code:
# ABC044A - 高橋君とホテルイージー / Tak and Hotels (ABC Edit)
n, k, x, y= list(map(int, [input().rstrip() for _ in range(4)]))
print(x * n if n <= k else x * k + y * (n - k))

Submission status: Accepted

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

tot = 0
if N < K:
    tot = N * X
else:
    remainder = N - K
    tot = K * X + remainder * Y

print(tot)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
total = int(input())
limit = int(input())
first = int(input())
second = int(input())
if total > limit:
	print(limit * first + (total - limit) * second)
else:
  	print(total * first)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

money = 0

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

print(money)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print([n*x,k*x+(n-k)*y][n>k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
#input=stdin.readline().strip()
input=[]
for i in range(4):
  input.append(stdin.readline().strip())

end_t=int(input[0].strip())
start_t=int(input[1].strip())
start_c=int(input[2].strip())
end_c=int(input[3].strip())
sum=0
if end_t>start_t:
  sum=start_t*start_c+(end_t-start_t)*end_c
else:
  sum=end_t*start_c
print(sum)

Submission status: Accepted

Solution code:
n, k, x, y = eval("int(input())," * 4)
if n > k:
	print(k * x + (n - k) * y)
else:
	print(n * x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
sum = 0
for i in range(n):
  if i+1 <= k:
    sum += x
  else:
    sum += y
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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)

Submission status: Accepted

Solution code:
A, B, C, X = map(int, open(0).read().split())
if A-B <= 0:
  print(A*C)
else:
  print(B*C + (A-B)*X)

Submission status: Accepted

Solution code:
from sys import stdin

a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a < b:
  print(a*c)
else:
  print(b*c+d*(a-b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
max = int(input())
sam = int(input())
sam_num = int(input())
sam_later= int(input())

if(max<sam):
  print(sam_num*max)
else:
  print(sam_num * sam + sam_later * (max-sam))

Submission status: Accepted

Solution code:
n,k,x,y=map(int,open(0));print(min(n,k)*x+max(n-k,0)*y)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(en)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def tak_and_hotels(N: int, K: int, X: int, Y: int) -> int:
    return min(N, K) * X + max(0, N - K) * Y


if __name__ == "__main__":
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())
    ans = tak_and_hotels(N, K, X, Y)
    print(ans)

Submission status: Accepted

Solution code:
a =int(input())
b =int(input())
c =int(input())
d =int(input())
if a<=b:
  print(a*c)
else:
  print(b*c+(a-b)*d)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

Solution code:
# N,K,X,Y = map(int, input().split())
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

yado = 0
for i in range(1, N+1):
    if i <= K:
        yado += X
    elif i > K:
        yado += Y
print(yado)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if b > a:
  print(a * c)
else:
  print((b * c)+(a - b) * d)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
sum1 = 0
 
 
for i in range(N):
    if K>=i+1:
        sum1 += X
    else:
        sum1 += Y
 
print(sum1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline
N, K, X, Y = [int(input().rstrip()) for _ in range(4)]
if N <= K:
	print(N * X)
else:
	print(X * K + (N-K) * Y)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
p1= int(input())
p2= int(input())

c = a - b

print(a*p1 if a<b else b*p1 + c*p2)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())
    charge = 0
    charge1 = 0
    charge2 = 0
    charge3 = 0
    if K <= N:
        charge1 += K*X
        charge2 += (N-K)*Y
        charge = charge1 + charge2
    else:
        charge3 += N*X
        charge = charge3
    print(charge)
main()

Submission status: Accepted

Solution code:
from functools import reduce

def main():
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    N = int(input().rstrip())
    K = int(input().rstrip())
    X = int(input().rstrip())
    Y = int(input().rstrip())
    ans = 0
    if(N>K):
        ans = K*X + (N-K)*Y
    else:
        ans = N*X
    print(ans)   
   
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K,X,Y = eval('int(input()),'*4)
print(K*X+(N-K)*Y if (N-K) > 0 else N*X)

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>k:
    print(int(k*x+(n-k)*y))
elif n<=k:
    print(int(n*x))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
n,k,x,y = IR(4)
print(min(k,n)*x+max(n-k,0)*y)
#B

#C
"""
n,a = LI()
x = LI()
s = sum(x)
dp = [[[0 for i in range(s+1)] for j in range(n+1)] for k in range(n+1)]
for i in range(n+1):
    dp[i][0][0] = 1
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(s+1):
            if k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]]
            else:
                dp[i][j][k] = dp[i-1][j][k]
ans = 0
for i in range(1,n+1):
    if a*i <= s:
        ans += dp[n][i][a*i]
print(ans)
"""

#D
"""
def f(b,n):
    m = n
    res = 0
    while m > 0:
        res += m%b
        m //= b
    return res
n,s = IR(2)
if n == s:
    print(n+1)
    quit()
if n == 1:
    print(-1)
    quit()
k = int(n**0.5)
for b in range(2,k+1):
    if f(b,n) == s:
        print(b)
        quit()
for p in range(1,k+1)[::-1]:
    if (n-s)%p == 0:
        b = (n-s)//p+1
        if b != 0:
            if f(b,n) == s:
                print(b)
                quit()
print(-1)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
  a = [int(input()) for i in range(4)]
  if a[0]>a[1]:
    print(a[1]*a[2]+(a[0]-a[1])*a[3])
  else:
    print(a[0]*a[2])
  
if __name__=='__main__':main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

sum = 0

for i in range(1, N+1):
	if i >= K +1:
		sum += Y
	else:
		sum +=X

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
args = []
for _ in range(4):
    args.append(int(input()))

N, K, X, Y = args


def solve():
    if N <= K:
        return N * X

    first = K
    second = N - first

    return first * X + second * Y

res = solve()
print(res)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
k = int(input())
x = int(input())
y = int(input())

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

print(fee)

Submission status: Accepted

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

res = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k,x,y = [int(input()) for _ in '1'*4]
print(x*n - (x-y)*([0,n-k][n-k>0]))

Submission status: Accepted

Solution code:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N<=K:
    print(X*N)
else:
    print(X*K+max(0,N-K)*Y)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: UTF-8

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)

Submission status: Accepted

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

# K個までの和，N-K個からの和
## print(min(N, K)*X+max(0, N-K)*Y)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main() -> None:
    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(4)]
ans = 0

for i in range(1,a[0]+1):
  if i<=a[1]:
    ans += a[2]
  else:
    ans += a[3]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations, product


def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)


def get(fmt):
    ps = input().split()
    r = []
    for p, t in zip(ps, fmt):
        if t == "i":
            r.append(int(p))
        if t == "f":
            r.append(float(p))
        if t == "s":
            r.append(p)
    if len(r) == 1:
        r = r[0]
    return r

def put(*args, **kwargs):
    print(*args, **kwargs)


def rep(n, f, *args, **kwargs):
    return [f(*args, **kwargs) for _ in range(n)]
    
def rep_im(n, v):
    return rep(n, lambda: v)
    
YES_NO = ["NO", "YES"]


N, K, X, Y = rep(4, get, "i")

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

put(p)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
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)

Submission status: Accepted

Solution code:
a,b,c,d=eval('int(input()),'*4);print(c*min(a,b)+d*max(a-b,0))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n,k,x,y=eval('int(input()),'*4);print(n*x-(x-y)*max(n-k,0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
k=int(input())
x=int(input())
y=int(input())
#li=input().split()
#li=list(map(int,input().split()))
#n=input()
if n>=k:
    ans=x*k+y*(n-k)
else:
    ans=n*x
print(ans)