Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	N, A, B, C, D := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()

	x := (N + A - 1) / A * B
	y := (N + C - 1) / C * D

	var z int
	if x < y {
		z = x
	} else {
		z = y
	}

	fmt.Println(z)
}

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

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	cout << min((A - 1 + N) / A * B, (C - 1 + N) / C * D) << endl;
}

C++: #include<iostream>
using namespace std;
int main(){
int n,a,b,c,d,e,g;
cin >> n >> a >> b >> c >> d;
if(n%a==0)e=n/a*b;
if(n%a!=0)e=(n/a+1)*b;
if(n%c==0)g=n/c*d;
if(n%c!=0)g=(n/c+1)*d;
if(e>g)cout<<g<<endl;
if(e<g)cout<<e<<endl;
}

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

using namespace std;

int main (void)
{
	int n,a,b,c,d;

	cin >> n >> a >> b >> c >> d;

	int p = 0,q = 0;

	for (int i = 0; i < n + 1; i++)
	{
		if (i * a >= n)
		{
			p = b * i;
			break;
		}
	}
	for (int i = 0; i < n + 1; i++)
	{
		if (i * c >= n)
		{
			q = d * i;
			break;
		}
	}

	cout << min(p,q) << endl;
}

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


int main(){
  int min;
  int N,A,B,C,D;

  cin >> N >> A >> B >> C >> D;

  bool first_f = false;
  int kane = 0;
  int honsu = 0,counter = 0;
  for(int i=0; i<N/A + 1; ++i){
    for(int k=0; k<N/C + 1; ++k){
      honsu += A;
      kane += B;
      ++counter;
      if(honsu >= N){
	if(!first_f){
	  first_f = true;

	  min = kane;
	}else{
	  if(min > kane){
	    min = kane;

	    break;
	  }
	}
      }
    }
    honsu -= counter * A;
    honsu += C;
    kane -= counter * B;
    kane += D;
    counter = 0;
  }

  cout << kane / 2 << endl;
  return 0;
}

C++: #include<iostream>
using namespace std;
#define INF 100000000
int main(){
  int N,pen,kati;
  cin >> N ;
  int ans = INF;
  for(int i=0;i<2;i++){
    cin >> pen >> kati;
    int a = N / pen;
    if(N%pen>=1) a++;
    ans = min(ans,a*kati);
  }
  cout << ans << endl;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n=0;
    int a=0;
    int b=0;
    int c=0;
    int d=0;
    int allx=0;
    int amax=0;
    int ally=0;
    int amay=0;
    int x=0;
    int y=0;
    cin>>n>>a>>b>>c>>d;
    allx=n/a;
    amax=n%a;
    if(amax==0){
        x=allx*b;
    }else{
        x=(allx+1)*b;
    }
    ally=n/c;
    amay=n%c;
    if(amay==0){
        y=ally*d;
    }else{
        y=(ally+1)*d;
    }
    if(x<y){
        cout<<x<<endl;
    }else{
        cout<<y<<endl;
    }
        
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d,i=1,x,k,k1,k2,j=1,I,J;
    cin>>n>>a>>b>>c>>d;  
    if(n%a==0){
      k1=n/a;
    }
    else {
       k1=n/a+1;
    }
    if(n%c==0){
      k2=n/c;
    }
    else{
      k2=n/c+1;
    }
  if(k1*b==k2*d){
    cout<<k1*b<<endl;
  }
  else if(k1*b>k2*d){
    cout<<k2*d<<endl;
  }
  else {
    cout<<k1*b<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
main(){
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;

  int X = (n/a + n%a)*b;
  int Y = (n/c + n%c)*d;
  cout << min(X, Y) << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  int ans=0;
  for(int i=0;1;i++){
    for(int j=0;1;j++){
      if(j*c+i*a>=n){
	if(ans==0) ans=i*b+j*d;
	else if(ans>i*b+j*d) ans=i*b+j*d;
	break;
      }
    }
    if(i*a>n) break;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
  int n,a,b,c,d;
  int num1,num2;

  cin >> n >> a >> b >> c >> d;

  if(n % a == 0 && n % c == 0)
    {
      if((n/a)*b < (n/c)*d)
	{
	  cout << (n/a)*b << endl;
	}
      else
	{
	  cout << (n/c)*d << endl;
	}
    }
  else if(n % c == 0)
    {
      cout << (n/c)*d << endl;
    }
  else if(n % a == 0)
    {
      cout << (n/a)*b << endl;
    }
  else
    {
      num1= (n/a)+1;
      num2= (n/c)+1;
      if(num1*b < num2*d)
	{
	  cout << num1*b << endl;
	}
      else
	{
	  cout << num2*d << endl;
	}
    }
}

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

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

C++: #define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	cout << min((n % a ? n / a + 1 : n / a) * b, (n % c ? n / c + 1 : n / c) * d) << endl;
}

C++: #include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  assert(0);
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;

  int mx = 0;
  for(int i=0;i<n;i++){
    int j = i;
    while(j < n && A[j] == 1) j++;
    Max(mx,j - i);
  }

  cout<<mx+1<<endl;

  
  return 0;
}

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

int main(void){
    int n, a, b, c, d;
    int sum1 = 0, sum2 = 0;
    int kane1 = 0, kane2 = 0;

    cin >> n >> a >> b >> c >> d;
    
    while(sum1 < n){
        sum1 += a;
        kane1 += b; 
    }
    while(sum2 < n){
        sum2 += c;
        kane2 += d;
    }
    if(kane1 < kane2){
        cout << kane1 << endl;
    }else{
        cout << kane2 << endl;
    }
}

C++: #include <iostream>
using namespace std;
 int main(){
 int n,a,b,c,d,x=0,y=0;
 cin>>n>>a>>b>>c>>d;
 if(n%a==0)x=n/a*b;
 else x=(n/a+1)*b;
 if(n%c==0)y=n/c*d;
 else y=(n/c+1)*d;
 if(x<y)cout<<x<<endl;
 else cout<<y<<endl;
 return 0;
 }

C++: #include <iostream>
 
using namespace std;
 
int main()
{
    int  n, a, b, c, d, a1, a2;
    cin >> n >> a >> b >> c >> d;
    a1 = b * ((n / a) + 1);
    if (n%a == 0)
    {
        a1 -= b;
    }
    a2 = d * ((n / c) + 1);
    if (n%c == 0)
    {
        a2 -= d;
    }
    if (a1 < a2)
    {
        cout << a1 << endl;
    }
    else
        cout << a2 << endl;
         
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    cout <<min(n+a-1)/a*b , (n+c-1)/c*d<<endl;
    return 0;

}

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

int main() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	int ans_x = 0; int ans_y = 0; int n_x = n; int n_y = n;
	while (n_x > 0) { n_x = n_x - a; ans_x = ans_x + b; }
	while (n_y > 0) { n_y = n_y - c; ans_y = ans_y + d; }
	cout << (ans_x > ans_y ? ans_y : ans_x) << endl;
	return 0;
}