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<stdio.h>
int main(void)
{
	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;
	}
	//printf("x=%d y=%d\n",x,y);
	if(y<x)	{
	printf("%d\n",y);
	}
	else	{
	printf("%d\n",x);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;

int main(){
	int a, b, c, d, e;
	in >> a >> b >> c >> d >> e;
	int ac = a*e,bc=b;
	if (e > c)bc += (e - c)*d;


	
	out << min(ac,bc) << endl;
	return 0;

}

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

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

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

int main() {
	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;
	int p1 = a * p;
	int p2 = max(p - c, 0) * d + b;
	cout << min(p1, p2) << '\n';
}

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\n", y);
	return 0;
}

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

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

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;
  int X,Y;
  X=P*A;
  if(C>=P){
    Y=B;
  }
  else{
    Y=B+D*(P-C);
  }
  if(X<=Y){
    cout<<X<<endl;
  }
  else{
    cout<<Y<<endl;
  }
}

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

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

int main(){
    int a, b, c, d, p, X, Y;
    std::cin >> a >> b >> c >> d >> p;
    X = p * a;
    
    if(p > c)
        Y = b + d * (p - c);
    else
        Y = b;

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

    return 0;
}

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 <iostream>

int main ()
{
    int a,b,c,d,e;

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> d;
    std::cin >> e;

    int cost_a,cost_b;

    cost_a = a * e;

    if (c < e) {
        cost_b = b * c + (e - c) * d;
    } else {
        cost_b = b * e;
    }

    if (cost_a < cost_b) {
        std::cout << cost_a << std::endl;
    } else {
        std::cout << cost_b << std::endl;
    }



    return 0;
}

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false); 
	int A, B, C, D, P; cin >> A >> B >> C >> D >> P;	
	cout << min(A*P, B + max(P - C, 0)*D) << endl;
}

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

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 <cstdio>
int main(){int a,b,c,d,p;scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);printf("%d\n",a*p<b+(p-c)*(c<p?d:0)?a*p:b+(p-c)*(c<p?d: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+(p-c)*d;
	}
	x=a*p;
	if(y<x){
		r=y;
	}else{
		r=x;
	}
	printf("%d\n",r);
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){

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

	cin >> a >> b >> c >> d >> p;
	
	if(p < c) res = b;
	else if(c < p) res = b + (d * (p - c));

	cout << ((a*p > res) ? res : a*p) << endl;

	return 0;
}

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

	int A,B,C,D,P;
	
	cin >> A >> B >> C >> D >> P;
		
	int planX, planY;

	planX = A * P;

	if(C > P)
		planY = B;
	else
		planY = B + D * (P - C);

	if(planX < planY)
		cout << planX << endl;
	else
		cout << planY << endl;

	/*
	int A,B,C,D,E;
	cin >> A >> B >> C >> D >> E;

	int answer;
	if(A < 0){
		answer = -A * C + D + B * E;
	}
	if(A > 0){
		answer = (B - A) * E;
	}
	cout << answer << endl;
	*/

	return 0;
}

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

int main(){

  int a[5];
  for(int i = 0;i<5;i++){
    cin >> a[i];
  }

  int x=0,y=0;

  x = a[0]*a[4];
  if(a[4] < a[2]) y = a[1];
  else{
    y = a[1] + (a[4]-a[2])*a[3];
  }
  if(x>y) cout << y << endl;
  else  cout << x << endl;


}

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

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

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

    int x=a*p;
    int y=b;
    if(c<p) y+=d*(p-c);

    cout << min(x,y) << 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\n", y);
	else printf("%d\n", x);
	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+(p-c)*d;
	}
	x=a*p;
	if(y<x){
		r=y;
	}else{
		r=x;
	}
	printf("%d\n",r);
	return 0;
}