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

C++: //↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
//typedef complex<double>P;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int aa = a * e, bb;
	if (e <= c) {
		bb = b;
	}
	else {
		bb = b + (e - c)*d;
	}
	cout << min(aa, bb) << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int Y_company(int B, int C, int D, int P)
{
	if(P<=C) return B;
	else return B+(P-C)*D;
}
int main(void)
{
	int A, B, C, D, P;
	cin >> A >> B >> C >> D >> P;
	ll ans = min(P*A, Y_company(B, C, D, P));
	cout << ans << endl;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int a;
	int b,c,d;
	int p;
	
	int x_moni;
	int y_moni;
	
	int moni;
	
	cin >> a >> b >> c >> d >> p;
	
	x_moni=p*a;
	
	y_moni=b;
	if(p>c)
	{
		p-=c;
		y_moni+=d*p;
	}
	
	moni=max( x_moni , y_moni );
	
	cout << moni << endl;
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>

int main() {

	int a, b, c, d, p;

	std::cin >> a >> b >> c >> d >> p;

	int X = a * p;

	int Y;

	if (p <= c) {
		Y = b;
	}
	else {
		Y = b + (p - c) * d;
	}
	std::cout << std::min(X, Y) << std::endl;

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main() {
    
    int A, B, C, D, P;
    cin >> A >>B >> C >> D >> P;
    
    cout << min(A  * P, B + (max(P - C, 0) * D));
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b,c,d,p,y;
  cin>>a>>b>>c>>d>>p;
  if(p < c){// unlimit c
    y = b;
  } else {
    y = b + (p-c) * d;
  }
  cout<<min(a * p, y)<<endl;


}

C++: #include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int A, B, C, D, P;
    cin >> A >> B >> C >> D >> P;

    cout << min(A * P, B + max(0, P - C) * D) << endl;
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,p,n;
	cin>>a>>b>>c>>d>>p;
	a=a*p;
	//cout<<a<<endl;
	while(p-c>0){
		b+=d;
		p--;
		//cout<<b<<endl;
	}
	cout<<min(a,b)<<endl;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define ll long long
using namespace std;

int main() {
    int a, b, c, d, p;
    cin >> a >> b >> c >> d >> p;
    int A = a * p, B;
    if(p <= c)
        B = b;
    else {
        int o = p - c;
        B = b + o * d;
    }

    if(A >= B)
        cout << B << endl;
    else
        cout << A << endl;
}

C++: #include <iostream>
using namespace std;
int main() {
	int A,B,C,D,P,S=0,T=0;
	cin >> A >> B >> C >> D>> P;
	S=A*P;
	T=B+(P-C)*D;
	if (S<=T){
		cout<< S << endl;
	}
	else {
		cout<< T << endl;
	}
	// your code goes here
	return 0;
}

C++: #include<iostream>
#include<string>
int main()
{
	int A; //X
	int B; //Y
	int C; //Y=
	int D; //Y+
	int P; //JOI
	int X, Y;
	std::cin >> A >> B >> C >> D >> P;
	X = P * A;
	if (P > C) {
		Y = B + (P - C)*D;
	}
	else if (P < C) {
		Y = B;
	}
	if (X > Y) {
		std::cout << Y << std::endl;
	}
	else if (X < Y) {
		std::cout << X << std::endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int a,b,c,d,p;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>p;
	if(p<=c){
		if(a*p<b){
			cout<<a*p<<endl;
		}else{
			cout<<b<<endl;
		}
	}else{
		if(a*p<b+(p-c)*d){
			cout<<a*p<<endl;
		}else{
			cout<<(p-c)*d<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int A,B,C,D,P,X,Y;
	cin>>A>>B>>C>>D>>P;
	X=A*P;
	Y=min(B,B+D*(P-C));
	cout<<min(X,Y)<<endl;
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int a, b, c, d, p;
    int x, y;

    cin >> a >> b >> c >> d >> p;

    x = a * p;

    p <= c ? y = b : y = b + ((p - c) * d);

    cout << (x < y ? x : y) << endl;
}

C++: #include <stdio.h>

int main(void) {
  int X_A = 0;
  int Y_B = 0;
  int C = 0;
  int Y_D = 0;
  int P = 0;

  int costX = 0;
  int costY = 0;

  scanf("%d", &X_A);
  scanf("%d", &Y_B);
  scanf("%d", &C);
  scanf("%d", &Y_D);
  scanf("%d", &P);

  costX = X_A * P;
  costY = Y_B;  
    
  if (P > C) {
    costY += (P - C) * Y_D;
  }

  if (costX < costY) {
    printf("%d", costX);
  } else {
    printf("%d", costY);
  }
  
  return 0;
}

C++: #include<iostream>
namespeace using std;
int main(){
	int a,b,c,d,p;
	cin>>a>>b>>c>>d>>p;
	if(a*c>b+d*(p-c)){
		printf("%d",b+d*(p-c));
	}
	else{
		printf("%d",a*c);
	}
	return 0;
}