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, cost_X, cost_Y;
    cin >> A >> B >> C >> D >> P;
    
    cost_X = P*A;
    
    if(P<C){
        cost_Y = B;
    }
    else cost_Y = B + (P-C)*D;
    
    if(cost_X < cost_Y){
        cout << cost_X << endl;
    }
    else cout << cost_Y << endl;
    return 0;
    
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#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;

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

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=min( x_moni , y_moni );
	
	cout << moni << endl;
	
	return 0;
}

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

int a, b, c, d, e;

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

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*e,b+max(0,e-c)*d)<<endl;
	return 0;
}

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

int main(){
    int a,b,d,c,p;
    cin>>a>>b>>c>>d>>p;
    cout<<min(p*a,p<=c?b:b+(p-c)*d)<<endl;
    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(c<=p)
	{
		y=b;
	}
	else
	{
		y=b+(p-c)*d;
	}
	cout << max(x, y) << endl;
	return 0;
}

C++: #include <stdio.h>

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

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

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

		if (y < x){
			cout << y << endl;
		}
		else{
			cout << x << endl;
		}

	return 0;
}

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

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{
			p - c;
			Y = c*d + b;
		}

		if (Y < X){
			cout << Y << endl;
		}
		else{
			cout << X << endl;
		}

	return 0;
}

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

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cstdio>
#include <float.h>
#include <ctype.h>
 using namespace std;
 int main(void) {
		int a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s, t, u, v, w, x, y, z;
		scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
		f = a * e;
		if (e<=c) {
			g = b;
		}
		else {
			h = e - c;
			g = h*d+b;
		}
		if (f < g) {
			printf("%d\n", f);
		}
		else if(g<f){
			printf("%d\n", g);
		}
		return 0;
 }

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

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define all(v) v.begin(), v.end()
#ifdef LOCAL
  #define de(e) cout << "L" << __LINE__ << ": " << e << "\n" // debug echo
  #define dr(e) cout << "L" << __LINE__ << ": " << #e << " -> " << e << "\n" // debug repr
#else
  #define de(e)
  #define dr(e)
#endif
#define out(fmt, ...) printf(fmt, __VA_ARGS__); printf("\n")
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

//
// Implementation
//

int main() {
  int A, B, C, D, P;
  scanf("%d %d %d %d %d", &A, &B, &C, &D, &P);
  int X = A*P;
  int Y = B + max(P-C, 0)*D;
  if (X < Y) {
    out("%d", X);
  } else {
    out("%d", Y);
  }
}

C++: #include<bits/stdc++.h>
#define loop(a,b) for(int a=0;a<b;a++)
#define lout(a,b) for(int i=0;i<b;i++){if(i!=0) cout<<" ";cout<<a[i];}cout<<endl;
using namespace std;
int main(){
  int a,b,c,d,p;
  cin>>a>>b>>c>>d>>p;
  int x,y;
  x=a*p;
  if(p<=c) y=b;
  else{
    y=b+d*(p-c);
  }
  if(x>y) cout<<y<<endl;
  else cout<<x<<endl;
  return 0;
}

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

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

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

int main(){
  int A, B, C, D, P;
  cin >> A >> B >> C >> D >> P;
  int X = A * P;
  int Y = B + D * max(0, P - C);

  cout << min(X, Y) << endl;
}

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 <bits/stdc++.h>

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 * P, B + max(0, P - C) * D));

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

  a = a*p > b ? a*p : b;

  cout << a << 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){
            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;}
            }
return(0);
        }