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;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> P;
	
	X = A * P;
	Y = B;
	if(C < P) Y += D * (P - C);
	
	if(X < Y) cout << X;
	else cout << Y;
	return 0;
}

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

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

C++: #include <iostream>
using namespace std;
int main(){


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


return 0;
}

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

typedef long long lli;
lli A, B, C, D, P;

lli F1() {
  return A * P;
}

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

int main() {
  while(cin >> A >> B >> C >> D >> P) {
    cout << min(F1(), F2()) << endl;
  }
  return 0;
}

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

int main(){
  int a,b,c,d,p;
  while(cin >> a >> b >> c >> d >> p){
    int x=p*a;
    int y=0;
    int ans;
    if(p-c>1){
      y=b+(p-c)*d;
    }else{
      y=b;
    }

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

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

C++: #include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

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

using namespace std;

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

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

	X = P * A;
	Y = (P > C ? B + D * (P - C) : B);

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

	return 0;
}

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

int main() {
  int xperl, ybasic, ylimit, yperl, usedl;
  cin >> xperl >>  ybasic >> ylimit>>  yperl>> usedl;
  int xcost, ycost;
  xcost = xperl * usedl;
  (usedl <= ylimit) ? (ycost = ybasic) : ycost = ybasic + yperl * (usedl - ylimit);
  cout << min(xcost, ycost) << endl;
  return 0;
}

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<<n<<endl;
}

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

int A, B, C, D, P;
int X, Y;

int main(void) {
	scanf("%d%d%d%d%d", &A, &B, &C, &D, &P);
	X = P*A;
	if (C >= P) { Y = B; }
	else { Y = B + (P - C)*D; }
	printf("%d\n", std::min(X, Y));
	return 0;
}

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

C++: #include <iostream>

using namespace std;

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

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

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

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

  if(P < C) {
    if((A * P) < B)
      cout << (A * P) << endl;
    else
      cout << B << endl;
  }
  else {
    if((A * P) < (B + ((P - C) * D)))
      cout << (A * P) << endl;
    else
      cout << (B + ((P - C) * D)) << endl;
  }
  return 0;
}

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

using namespace std;

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

	cin>>A>>B>>C>>D>>P;
	int a=0,b=0;
	a=A*P;
	b=B;
	if(P>C)b+=D*(P-C);

	int max=a;
	if(a>b)max=b;
	cout<<max<<endl;
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int a, b, c, d, p;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> p;
    
    cout << min(a * p, b + d * max(0, p - c)) << endl;
    
}

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=b+(p-c)*d;
	}
	else{
		ss=b*p;
	}
	if(s<=ss){
		printf("%d\n",s);
	}
	else{
		printf("%d\n",ss);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

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

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

 if(a>e){
 cout<<e<<endl;
 }
 else{
 cout<<a<<endl;
 }
return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a[10000], b, c, d, e, f, g, i;
	for(i=0;i<5;i++){
	scanf("%d",&a[i]);
	}
	if(a[2]>a[4]){
		b=a[1];
	}
	if(a[2]<a[4]){
		b=a[1]+a[3]*(a[4]-a[2]);
	}
	if(a[0]*a[4]>b){
		printf("%d\n",b);
	}
	if(a[0]*a[4]<b){
		printf("%d\n",a[0]*a[4]);
	}
	return 0;
}

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

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

C++: #include <iostream>
#include <cmath> 
#include <vector>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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

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

int main(int argc, char *argv[]){
  int x, base, lim_base, over, used;
  cin >> x >> base >> lim_base >> over >> used;
  int over_lit = max(0, used - lim_base);
  int ans = min(x*used, base + over_lit*over);
  std::cout << ans << std::endl;
  return 0;
}