Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	scanner.Split(bufio.ScanWords)

	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	p := nextInt()

	priceA := a * p
	priceB := 0
	if p <= c {
		priceB = b
	} else {
		priceB = b + (p-c)*d
	}
	fmt.Println(min(priceA, priceB))
}

Python: # AOJ 0608: Water Rate
# Python3 2018.7.2 bal4u

import sys
from sys import stdin
input = stdin.readline

a, b, c, d, p = [int(input()) for i in range(5)]
pa, pb = p*a, b
if p > c: pb += (p-c)*d
print(min(pa, pb))

Python: a, b, c, d, e = int(input()), int(input()), int(input()), int(input()), int(input())
print(min(a * e, b + max(e - c, 0) * d))

Python: A=int(input())
B=int(input())
C=int(input())
D=int(input())
P=int(input())
print(min(A*P,B+(D*(max(P-C,0)))))

Python: # -*- coding: utf-8 -*-
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

X = A * P
if P <= C:
    Y = B
else:
    Y = B + D * (P - C)
print(min(X,Y))

Python: a = []
for i in range(5):
  a.append(int(input()))

x = a[0] * a[4]
y = a[1] + max(a[4] - a[2], 0) * a[3]

print(min(x, y))

Python: A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

X_price = 0
X_price = A * P

Y_price = 0
Y_price += B

if P > C:
    Y_price += (P - C) * D

print(min(Y_price, X_price))

Python: # -*- coding: utf-8 -*-

import sys
import os
import math

x_per_liter = int(input())
y_base_cost = int(input())
y_limit = int(input())
y_addition = int(input())
liter = int(input())

x_cost = x_per_liter * liter
if liter <= y_limit:
    y_cost = y_base_cost
else:
    y_cost = y_base_cost + y_addition * (liter - y_limit)

print(min(x_cost, y_cost))

Python: A,B,C,D,P=[int(input())for i in range(5)]
print(min(A*P,B+((P-C if P>C else 0)*D)))

Python: A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

print(min(P * A, B if P <= C else (B + (P - C) * D)))

Python: a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x = a * p
y = b + max((p-c) * d, 0)

print(min(x, y))

Python: l = [int(input()) for i in range(5)]
x = l[0] * l[4]

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

print(min(x,y))

Python: A, B, C, D, P = [int(input()) for _ in range(5)]

charge_x = A * P
charge_y = B + (P-C) * D if P >= C else B

print(min(charge_x, charge_y))

Python: A,B,C,D,P=[int(input())for i in range(5)]
print(min(A*P,B+((P-C if P>C else 0)*D)))

Python: a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())
x=a*p
y=0
if p>c:
    y=b+(p-c)*d
else:
    y=b
if x>y:
    print(y)
else:
    print(x)

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

Python: a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x = a * p
y = b + max(0,p-c)*d
print(min(x,y))

Python: a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x = a * p
if p <= c:
    y = b
else:
    y = b + (p-c) * d

print(min(x, y))

Python: a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())
ans = p*a
ans = min(ans, b+max(p-c,0)*d)
print(ans)

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

Python: a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())
costx = a * p
costy = b if p <= c else b + (p - c) * d
print(min(costx, costy))

Python: A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C <= P else B+(P-C)*D))

Python: A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C >= P else B+(P-C)*D))

Python: a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x_price = p*a
y_price = b 
if p>c:
    y_price += d*(p-c)

if x_price<y_price:
    print(x_price)
else:
    print(y_price)

Python: a=[]

for i in range(4):
    x=int(input())
    a.append(x)

p=int(input())
r1=p*a[0]
r2=0

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

print(min(r1,r2))

Python: A=int(input())
B=int(input())
C=int(input())
D=int(input())
P=int(input())
X=P*A
if P<C:
    Y=B
else:
    Y=(P-C)*D+B
print(min(X,Y))

Python: # coding: utf-8

A, B, C, D, P = [int(input()) for i in range(5)]
cost = B + max(0, P - C)*D
cost = A*P if A*P < cost else cost
print(cost)

Python: a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x = a*p
if c >= p:
    y = b
else:
    y = b + (p-c)*d

print(min([x, y]))

Python: a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())
x=a*p
y=b
if p>c:
    y+=(p-c)*d
print(min(x,y))

Python: #A問題
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

p1 = P*A
p2 = 0
if P > C:
    p2 = B + (P-C)*D
else:
    p2 = B
    
print(min(p1,p2))

Python: # solve problem
def solve(n, m, targets, games):
    counter = [0 for i in range(n+1)]

    for i in range(m):
        for j in range(n):
            if games[i][j] == targets[i]:
                counter[j+1] += 1
            else:
                counter[targets[i]] += 1

    return counter


# main function
if __name__ == '__main__':
    n = int(input())
    m = int(input())
    tmp_targets = input().split()

    targets = []
    for i in range(m):
        targets.append(int(tmp_targets[i]))

    games = [[0 for i in range(n)] for j in range(m)]
    tmp_games = []
    for i in range(m):
        tmp_games = input().split()
        for j in range(n):
            games[i][j] = int(tmp_games[j])

    results = solve(n, m, targets, games)
    for i in range(1, n+1, 1):
        print(results[i])

Python: a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())

x=a*p

if c>=p:
    y=b
else:
    y=b+(p-c)*d

print(min(x,y))

Python: A, B, C, D, P = [int(input()) for i in range(5)]
print(min(A * P, B + max(0, (P - C) * D)))

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

Python: A,B,C,D,P=[int(input())for i in range(5)]
print(min(A*P,B+((P-C if P>C else 0)*D)))

Python: A, B, C, D, P = [int(input()) for i in range(5)]
print(min(A*P, B+max(0, P-C)*D))

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

x = a * e
if e < c:
  y = b
else:
  y = b + d *(e-c)

p=[x,y]
print(min(p))

Python: A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

X = P * A
Y = B
if P > C:
	Y = Y + D * (P - C)

if X > Y:
	print(int(Y))
else:
	print(int(X))

Python: A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B+abs(C-P)*D))

Python: a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
print(min(a*e,[b,b+(e-c)*d][c<e]))

Python: num_list = [] #空リスト作成
for _ in range(5): #5回繰り返す
    num_list.append(int(input())) #標準入力をしてそのままリストに格納
num1 = num_list[0] * num_list[4] #X社の料金計算
if num_list[2] < num_list[4]: #Y社の制限を超えるか
    num2 = num_list[4] - num_list[2] #何L超えるか
    num2 = num2 * num_list[3] + num_list[1] #超えた時のY社の料金計算
else:num2 = num_list[1] #超えなかった時のY社の料金計算
print(min(num1,num2)) #2社の料金が安い方を出力

Python: import sys
import math
a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())
x=a*p
y=b
if(c<p):
    ryo=p-c
    y=y+(ryo*d)
if(x<=y):
    chap=x
else:
    chap=y
print(chap)

Python: A,B,C,D,P=[int(input())for i in range(5)]
print(min(A*P,B+((P-C if P>C else 0)*D)))