Language: C++

#ifdef LOCAL
    #define _GLIBCXX_DEBUG
    #define __clock__
#else
    #pragma GCC optimize("Ofast")
#endif
#include<bits/stdc++.h>
using namespace std;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// using ll = long long;
using ll = Bint;

using ld = long double;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair
#define p_yes() p("Yes")
#define p_no() p("No")

ll SUM(VI& V){
  return accumulate(ALL(V), 0LL);
}

ll MIN(VI& V){return *min_element(ALL(V));}
ll MAX(VI& V){return *max_element(ALL(V));}

void print_vector(VI& V){
  ll n = V.size();
  rep(i, n){
    if(i) cout << ' ';
    cout << V[i];
  }
  cout << endl;
}

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

// long double
using ld = long double;
#define EPS (1e-14)
#define equals(a,b) (fabs((a)-(b)) < EPS)

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

map<ll,ll> mp;
ll N,A,B,C,D;
ll cost[10];
VI M = {5,3,2};

ll f(ll a){
  if(mp.count(a)) return mp[a];
  if(a==1) return D;
  if(a==0) return 0;

  VI V; // candidate

  if(a<=1e9){
    V.push_back(a*D);
  }

  if(a==2) V.push_back(2*D);
  if(a==3) V.push_back(3*D);
  if(a==5) V.push_back(5*D);

  for(ll m : M){
    ll c = cost[m];
    if(a%m==0){
      V.push_back(f(a/m) + c);
    }else{
      ll r = a%m;
      // upper
      ll add = m-r;
      ll right = a + add;
      V.push_back(f(right/m) + c + add*D);
      // lower
      ll left = a - r;
      V.push_back(f(left/m) + c + r*D);
    }
  }
  return mp[a] = MIN(V);
}

void solve(){
  cin>>N>>A>>B>>C>>D;
  debug(N,A,B,C,D);
  cost[2] = A;
  cost[3] = B;
  cost[5] = C;

  mp.clear();
  ll ans = f(N);
  p(ans);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N; 
    cin>>N;
    
    while(N--)solve();
    
    return 0;
}

Compiler output:
a.cc:12:16: error: 'boost' has not been declared
   12 | namespace mp = boost::multiprecision;
      |                ^~~~~
a.cc:12:23: error: 'multiprecision' is not a namespace-name
   12 | namespace mp = boost::multiprecision;
      |                       ^~~~~~~~~~~~~~
a.cc:14:14: error: 'mp' does not name a type; did you mean 'p'?
   14 | using Bint = mp::cpp_int;
      |              ^~
      |              p
a.cc:16:12: error: 'Bint' does not name a type; did you mean 'uint'?
   16 | using ll = Bint;
      |            ^~~~
      |            uint
a.cc:19:19: error: 'll' was not declared in this scope; did you mean 'ld'?
   19 | using VI = vector<ll>;
      |                   ^~
      |                   ld
a.cc:19:21: error: template argument 1 is invalid
   19 | using VI = vector<ll>;
      |                     ^
a.cc:19:21: error: template argument 2 is invalid
a.cc:20:19: error: 'VI' was not declared in this scope
   20 | using VV = vector<VI>;
      |                   ^~
a.cc:20:21: error: template argument 1 is invalid
   20 | using VV = vector<VI>;
      |                     ^
a.cc:20:21: error: template argument 2 is invalid
a.cc:22:18: error: 'll' was not declared in this scope; did you mean 'ld'?
   22 | using PII = pair<ll, ll>;
      |                  ^~
      |                  ld
a.cc:22:22: error: 'll' was not declared in this scope; did you mean 'ld'?
   22 | using PII = pair<ll, ll>;
      |                      ^~
      |                      ld
a.cc:22:24: error: template argument 1 is invalid
   22 | using PII = pair<ll, ll>;
      |                        ^
a.cc:22:24: error: template argument 2 is invalid
a.cc:131:1: error: 'll' does not name a type; did you mean 'ld'?
  131 | ll SUM(VI& V){
      | ^~
      | ld
a.cc:135:1: error: 'll' does not name a type; did you mean 'ld'?
  135 | ll MIN(VI& V){return *min_element(ALL(V));}
      | ^~
      | ld
a.cc:136:1: error: 'll' does not name a type; did you mean 'ld'?
  136 | ll MAX(VI& V){return *max_element(ALL(V));}
      | ^~
      | ld
a.cc:138:6: error: variable or field 'print_vector' declared void
  138 | void print_vector(VI& V){
      |      ^~~~~~~~~~~~
a.cc:138:19: error: 'VI' was not declared in this scope; did you mean 'VS'?
  138 | void print_vector(VI& V){
      |                   ^~
      |                   VS
a.cc:138:23: error: 'V' was not declared in this scope; did you mean 'VS'?
  138 | void print_vector(VI& V){
      |                       ^
      |                       VS
a.cc:147:1: error: 'll' does not name a type; did you mean 'ld'?
  147 | ll gcd(ll a,ll b){
      | ^~
      | ld
a.cc:152:1: error: 'll' does not name a type; did you mean 'ld'?
  152 | ll lcm(ll a,ll b){
      | ^~
      | ld
a.cc:165:7: error: 'll' does not name a type; did you mean 'ld'?
  165 | const ll mod = 1e9 + 7;
      |       ^~
      |       ld
a.cc:166:7: error: 'll' does not name a type; did you mean 'ld'?
  166 | const ll inf = 1e18;
      |       ^~
      |       ld
a.cc:169:5: error: 'll' was not declared in this scope; did you mean 'ld'?
  169 | map<ll,ll> mp;
      |     ^~
      |     ld
a.cc:169:8: error: 'll' was not declared in this scope; did you mean 'ld'?
  169 | map<ll,ll> mp;
      |        ^~
      |        ld
a.cc:169:10: error: template argument 1 is invalid
  169 | map<ll,ll> mp;
      |          ^
a.cc:169:10: error: template argument 2 is invalid
a.cc:169:10: error: template argument 3 is invalid
a.cc:169:10: error: template argument 4 is invalid
a.cc:170:1: error: 'll' does not name a type; did you mean 'ld'?
  170 | ll N,A,B,C,D;
      | ^~
      | ld
a.cc:171:1: error: 'll' does not name a type; did you mean 'ld'?
  171 | ll cost[10];
      | ^~
      | ld
a.cc:172:1: error: 'VI' does not name a type; did you mean 'VS'?
  172 | VI M = {5,3,2};
      | ^~
      | VS
a.cc:174:1: error: 'll' does not name a type; did you mean 'ld'?
  174 | ll f(ll a){
      | ^~
      | ld
a.cc: In function 'void solve()':
a.cc:208:8: error: 'N' was not declared in this scope
  208 |   cin>>N>>A>>B>>C>>D;
      |        ^
a.cc:208:11: error: 'A' was not declared in this scope
  208 |   cin>>N>>A>>B>>C>>D;
      |           ^
a.cc:208:14: error: 'B' was not declared in this scope
  208 |   cin>>N>>A>>B>>C>>D;
      |              ^
a.cc:208:17: error: 'C' was not declared in this scope
  208 |   cin>>N>>A>>B>>C>>D;
      |                 ^
a.cc:208:20: error: 'D' was not declared in this scope
  208 |   cin>>N>>A>>B>>C>>D;
      |                    ^
a.cc:210:3: error: 'cost' was not declared in this scope; did you mean 'cosl'?
  210 |   cost[2] = A;
      |   ^~~~
      |   cosl
a.cc:214:6: error: request for member 'clear' in 'mp', which is of non-class type 'int'
  214 |   mp.clear();
      |      ^~~~~
a.cc:215:3: error: 'll' was not declared in this scope; did you mean 'ld'?
  215 |   ll ans = f(N);
      |   ^~
      |   ld
a.cc:216:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
  216 |   p(ans);
      |     ^~~
a.cc:120:21: note: in definition of macro 'p'
  120 | #define p(s) cout<<(s)<<'\n'
      |                     ^
a.cc: In function 'int main()':
a.cc:225:5: error: 'll' was not declared in this scope; did you mean 'ld'?
  225 |     ll N;
      |     ^~
      |     ld
a.cc:226:10: error: 'N' was not declared in this scope
  226 |     cin>>N;
      |          ^