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++: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int x_price_per_liter;
  while(~scanf("%d",&x_price_per_liter)){
    int y_base_price;
    int y_upper_limit;
    int y_additional_price;
    int consumption_amount;
    scanf("%d",&y_base_price);
    scanf("%d",&y_upper_limit);
    scanf("%d",&y_additional_price);
    scanf("%d",&consumption_amount);
    printf("%d\n",min(consumption_amount * x_price_per_liter,
                    y_base_price + (consumption_amount <= y_upper_limit ? 0 : (consumption_amount - y_upper_limit) * y_additional_price)));
  }
}

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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll a, b, c, d, p;
  cin >> a >> b >> c >> d >> p;
  ll res1 = p*a, res2;
  if (p <= c) {
    res2 = b;
  } else {
    res2 = b + (p-c)*d;
  }
  cout << min(res1, res2) << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int a, b, c, d, p; cin >> a >> b >> c >> d >> p;
    int X = p*a;
    int Y;
    if(p <= c) Y = b;
    else Y = b + (p - c)*d;

    cout << min(X, Y) << '\n';
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int A,B,C,D,P;
	cin>>A>>B>>C>>D>>P;
	if(P<=C){
		if(P*A<B){
			cout<<P*A<<endl;
		}else{
			cout<<B<<endl;}
	}else{
		if(P*A<(P-C)*D+B){
			cout<<P*A<<endl;
		}else{
			cout<<(P-C)*D+B<<endl;
		}
	}
		
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = s; n > i; i++)
#define REP(i,n) rep(i,0,n)
#define MODU 33
#define Range(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
typedef long long int ll;

int main() {
	int a, b, c, p, d;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &p);
	printf("%d\n",min( p*a, b + max((p-c),0)*d));
	return 0;
}

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

	// your code goes here
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int A,B,C,D,P;
	int a,b1,b2,b;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	scanf("%d",&P);
	a=A*P;
	if(C<P){
		b1=P-C;
		b2=b1*D;
	}
	b=B+b2;
	if(a<=b){
		printf("%d\n",a);
	}
	else if(b<a){
		printf("%d\n",b);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int a, b, c, d, p;
int x, y;
int main()
{
	cin >> a >> b >> c >> d >> p;
	x=a*p;
	if(p<=c)
	{
		y=b;
	}
	else
	{
		y=b+(p-c)*d;
	}
	cout << min(x, y) << 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;
        int x,y;
        x = A*P;
        if (P<=C) y = B;
        else y = B + (P-C)*D;
        if (x<y) cout <<x <<endl;
        else cout << y <<endl;
        return 0;
}

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


	// your code goes here
	return 0;
}