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;
    int x,y;
    cin>>a>>b>>c>>d>>p;
    x=a*p;
    y=b;

    if(p>c){
       y+=(p-c)*d;
    }
    
    if(x<y) cout<<x<<endl;
    else cout<<y<<endl;
}

C++: #include <stdio.h>
#include <math.h>

int main(){
	int A,B,C,D,E,P,X,Y,Z;
	scanf("%d %d %d %d %d",&A,&B,&C,&D,&P);
	X = A*P;
	Y = B;
	if(C < P){
		E = P - C;
		Y = B + E * D;
	}
	Z = fmin(X,Y);
	printf("%d\n",Z);
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int a, b, c, d, p;

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

C++: #include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,p;
    int X,Y;
    cin >> a >> b >> c >> d >> p;
    X = a*p;
    if(p<=c){
        Y = b;
    }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,n;
    cin>>a>>b>>c>>d>>p;
    n=b;
    if(p>c)
        n+=(p-c)*d;
    cout<<min(a,n)<<endl;
}

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

int main(){

	int a,b,c,d,p,x,y;
	cin >> a >> b >> c >> d >> p;

	x = p*a;

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

	return 0;
}

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

C++: #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int min( int p, int q ) {
	if( p > q ) return q;
	return p;
}

int max( int p, int q ) {
	if( p > q ) return p;
	return q;
}

int main(void){

	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;
	cout << min( a * p, max( 0, p - c ) * d + b ) << endl;

    return 0;
}

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

C++: #include <stdio.h>

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

C++: #include<iostream>

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;
	}
	if (X > Y) {
		std::cout << Y << std::endl;
	}
	else if (X < Y) {
		std::cout << X << std::endl;
	}
	else if (X == Y) {
		std::cout << X << std::endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,p;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
	printf("%d\n",min(a,b+max(0,p-c)*d));
}

C++: #include <stdio.h>
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 = (p - c)*d + b;
  }
  if(x<=y){
    printf("%d\n", x);
  }else{
     printf("%d\n", y);
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b,c,d,e; cin >> a >> b >> c >> d >> e;
	cout << min(a*e,b+max(0,e-c)*d) << endl;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define all(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define pb push_back
#define inin(x) int x; cin>>x;
#define ll long long
#define pb push_back

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

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

C++: #include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,water,x,y,ans;
	cin>>a>>b>>c>>d>>water;
	x=water*a;
	y=b;
	if(c<water)y+=(water-c)*d;
	ans=min(x,y);
	cout<<ans<<endl;
}

C++: #include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>
#include <ctype.h>

#define PI 3.1415926

void swap(int* x, int* y) {
	int a = *x;
	int b = *y;
	*x = b;
	*y = a;
}
int factorial(int n);

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

 int factorial(int n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else {
		return 1;
	}
}

C++: #include<iostream>
#include<stdio.h>
using namespace 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;
}

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

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

int main() {
    int A,B,C,D,P,x,y;
    cin >> A >> B >> C >> D >> P;
    x=A*P;
    if(C>=P) {
    y=B;
}
    else {
	y=B+(P-C)*D;
}
if(x>y) {
	cout << y << endl;
}
	else {
		cout << x << endl;
	
}
		return 0;
	}

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

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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





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