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++: #include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e;
int main() {
	cin >> a >> b >> c >> d >> e;
	cout << min(a * e, max(b, b + (p - c) * d)) << endl;
	return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

void solve()
{
	int A, B, C, D, P;
	cin >> A >> B >> C >> D >> P;
	int sumA = A * P;
	int sumB = B;
	if (P > C)
	{
		sumB += (P - C) * D;
	}
	cout << min(sumA, sumB) << endl;
}

int main()
{
	solve();
	return(0);
}

C++: #include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long
#define vi vector<int>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

int main(){
	int a,b,c,d,p;
	cin>>a>>b>>c>>d>>p;
	cout<<min(p*a,b+((p<c)?0:d*(p-c)))<<"\n";
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int a,b,c,d,p;
    cin >> a >> b >> c >> d >> p;
    int x=p*a;
    int y=p>c?b+(p-c)*d:b;
    cout << min(x,y) << endl;
}

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


int main(){
  int A,B,C,D,P;
  int ansX, ansY;

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

  ansX = P * A;

  if(P <= C){
    ansY = B;
  }else{
    ansY = B;
    ansY += (P - C) * D;
  }

  if(ansX > ansY){
    cout << ansY << endl;
  }else{
    cout << ansX << endl;
  }
  return 0;
}

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

C++: #include <iostream>

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

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

C++: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vl a(5);
	cin>>a;
	puta(min(a[0]*a[4],a[1]+a[3]*max(0,a[4]-a[2])));
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int a, b, c, d, p, ans, tmp;

int main(){

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

	ans += b;
	if (p > c) {
		tmp = p - c;
		ans += tmp * d;
	}
	ans = min(a * p, ans);

	cout << ans << endl;

	return 0;
}

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

int A, B, C, D, P;

int main() {
    cin >> A >> B >> C >> D >> P;
    int X = A * P;
    int Y = B;
    if (P > C) Y += (P - C) * D;
    cout << min(X, Y) << 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, p*b + (c < b) ? (b-c)*d : 0));
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std ;
int main()
{
    int x = 0 ;
    int y = 0 ;
    int money[5] = {0} ; //{ X_money , Y_money , Y_Little , Y_over , JOI }
    for ( int i = 0 ; i < 5 ; i++ )
    {
        cin >> money[i] ;
    }
    x = money[0] * money[4] ;
    y = money[1] + abs(money[2]-money[4]) * money[3] ;
    if ( money[2]-money[4] > 0 ) y = money[1] ;

    cout << min( x,y ) << endl ;
    return 0 ;
}