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<iostream>
using namespace std;
int main(void){
    int a,b,c,d,p,x,y;
    cin >> a >> b >> c >> d >> p;
    x=p*a;
    if(p<=c){
        y=b;
        if(x<y) cout << x << endl;
        else    cout << y << endl;
    }           
    else{
        y=b+(p-c)*d;
        if(x<y) cout << x << endl;
        else    cout << y << endl;
    }
}

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;
    if(p>c){
        y = b + (p-c)*d;
    }else{
        y = b;
    }
    
    if(y>x){
        cout << x << endl;
    }else{
        cout << y << endl;
    }
}

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

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define first F
#define second S

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int a,b,c,d,p;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  cin>>p;
  cout<<min(p*a,b+max(0,(p-c)*d))<<endl;
}

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

int main() {
	int a,b,c,d,p;
	cin >> a >> b >> c >> d >> p;
	int x = a*p ;
	int y = b;
	if(p>c){
		y = b+d*(p-c);
	}
	if(x>y){
		cout << y << endl;
	}
	else{
		cout << x << endl;
	}
	
	return 0;
}

C++: //Water Rate
#include <iostream>

using namespace std;

int main() {
    int A, B, C, D, P;
    cin >> A >> B >> C >> D >> P;

    int x, y;
    x = A * P;
    y = max(B, B + D * (P - C));

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

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

int main() {
    int a, b, c, d, p; cin >> a >> b >> c >> d >> p;
    int y;
    int tmp;

    y = b + max(p - c, 0) * d;
    cout << min(a * p, y) << endl;
}

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

using namespace std;

int main(){
  int a,b,c,d,p;
  int sum=0,sum_a=0,sum_b=0;

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

  sum_a=a*p;

  if(b<=c)
    sum_b=b;
  else if (b>c)
    sum_b=b+(b-c)*d;
  
  sum=min({sum_a,sum_b});

  cout<<sum<<endl;

  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) b += d*(p - c);

	if (a*p <= b) cout << a*p << endl;

	else cout << b << endl;

}

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

int main() {
  int A, B, C, D, P;
  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;

  return 0;
}

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

C++: #include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

#define binds a, b, c, d, p

int main() {
	int binds;
	scan(binds);
	outl(min(p * a, max((p - c) * d, 0) + b));
}

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 (P<=C,S<=T){
	S=A*P;
	cout<< S << endl;
	}
	else {
		T=B+(P-C)*D;
		cout<< T << endl;
	}
	// your code goes here
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

int x(int a,int p){
    return a*p;
}

int y(int b,int c,int d,int p){
    int ret = b;
    p-=c;
    if(p<=0)return ret;
    ret+=d*p;
    return ret;
}


int main(){
    int a,b,c,d,p;
    cin>>a>>b>>c>>d>>p;
    
    cout<<min(x(a,p),y(b,c,d,p))<<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>
using namespace std;

int main() {
  int A, B, C, D, P, X, Y, Z;
  cin >> A >> B >> C >> D >> P;

	X = A*P;
	  if(P<=C){
	Y = B;
	}
	  else{
	Y = B + D*P;
	}

	if(X>=Y){
	Z = Y;
	}

	else{
	Z = X;
	}

 cout << Z << endl;

return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

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

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

	int A = a * p;
	if(c > p){
		if(b < A) cout << b << endl;
		else cout << A << endl;
	}
	else if(c < p){
		int l = p - c;
		int ans = b + (d * l);
		cout << ans << endl;
	}

	return 0;
}

C++: //q1.cpp

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;


int main(){
    int a,b,c,d,p,x,y;
    
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
    
    x=a*p;
    
    if(p<=c)
        y=b;
    else
        y=b+(p-c)*d;
    
    printf("%d\n",min(y,x));
    return 0;
}

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