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++: // JOI14-quest1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <stdio.h>


int main(void)
{
	int x_money, y_standard, y_max, y_money, joi_use;

	scanf("%d", &x_money);
	scanf("%d", &y_standard);
	scanf("%d", &y_max);
	scanf("%d", &y_money);
	scanf("%d", &joi_use);

	int x_total = 0, y_total = 0;

	x_total = x_money * joi_use;

	if (joi_use <= y_max) {
		y_total = y_standard;
	}
	else {
		y_total = y_standard + (y_money * (joi_use - y_max));
	}

	int small = 0;

	if (x_total <= y_total) {
		small = x_total;
	}
	else {
		small = y_total;
	}

	printf("%d\n", small);

	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) {
		if(P*A > B + D * (P - C)){
			cout<< B + D * (P - C) <<endl;
		} else {
			cout<< P * A <<endl;
		}
	} else{
		if(B > A * P){
			cout<<A * P<<endl;
		} else {
			cout<< B<<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<<min(a*p,n)<<endl;
}

C++: #include <iostream>

int main() {
        // This seems trivial so I probably understood the problem statement wrong...
        int a, b, c, d, p;
        std::cin >> a >> b >> c >> d >> p;
        int px = a * p;
        int py = b;
        if (p > c) {
                py += (p - c) * d;
        }
        std::cout << std::min(px, py) << '\n';
}

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