Language: C++

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cmath>

#define MAX 12

using namespace std;

vector<int> split(const string &str, char delim){
    istringstream iss(str); string tmp; vector<int> res;
    while(getline(iss, tmp, delim)) {
        int i;
        std::istringstream iss(tmp);
        iss >> i;
        res.push_back(i);
    }
    return res;
}

float d[MAX][MAX];
float dp[1 << MAX][MAX];
int size;

float rec(int S, int v) {
    if (dp[S][v] >= 0) return dp[S][v];

    if (S == (1 << size) -1 && v == 0) {
        return dp[S][v] = 0;
    }

    float res = 99999;
    for (int u = 0; u < size; u++) {
        if(!(S >> u & 1))
            res = min(res, rec(S | 1 << u, u) + d[v][u]);
    }

    return dp[S][v] = res;
}


int main(int argc, char const* argv[])
{
    string line;
    while(getline(cin, line)) {

        vector<int> params = split(line, ' ');
        vector<int> cakes;

        int weight = params.front();
        for (vector<int>::iterator it = params.begin(); it != params.end(); it++) {
            if(it == params.begin()) {weight = *it; continue;}
            cakes.push_back(*it);
        }

        size = cakes.size();
        for (int i = 0; i < size; i++) {
            for (int j = i; j < size; j++) {
                int i_r = cakes.at(i);
                int j_r = cakes.at(j);
                float sq = sqrt(pow(i_r + j_r, 2.0) - pow(i_r - j_r, 2.0));
                if (i_r == j_r) sq = i_r + j_r;
                d[i][j] = sq;
                d[j][i] = sq;
            }
        }

        memset(dp, -1, sizeof(dp));

        float min_val = 99999;
        for (int i = 0; i < size; i++) {
            float rec_val = rec(0,i);
            if (rec_val == 0) continue;
            min_val = min(rec_val, min_val);
        }

        if (min_val > weight) {
            std::cout << "NA" << std::endl;
        } else {
            std::cout << "OK" << std::endl;
        }


    }
    return 0;
}

Compiler output:
a.cc: In function 'float rec(int, int)':
a.cc:29:20: error: reference to 'size' is ambiguous
   29 |     if (S == (1 << size) -1 && v == 0) {
      |                    ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:24:5: note:                 'int size'
   24 | int size;
      |     ^~~~
a.cc:34:25: error: reference to 'size' is ambiguous
   34 |     for (int u = 0; u < size; u++) {
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:24:5: note:                 'int size'
   24 | int size;
      |     ^~~~
a.cc: In function 'int main(int, const char**)':
a.cc:57:9: error: reference to 'size' is ambiguous
   57 |         size = cakes.size();
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:24:5: note:                 'int size'
   24 | int size;
      |     ^~~~
a.cc:58:29: error: reference to 'size' is ambiguous
   58 |         for (int i = 0; i < size; i++) {
      |                             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:24:5: note:                 'int size'
   24 | int size;
      |     ^~~~
a.cc:59:33: error: reference to 'size' is ambiguous
   59 |             for (int j = i; j < size; j++) {
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:24:5: note:                 'int size'
   24 | int size;
      |     ^~~~
a.cc:69:9: error: 'memset' was not declared in this scope
   69 |         memset(dp, -1, sizeof(dp));
      |         ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <cmath>
  +++ |+#include <cstring>
    6 | 
a.cc:72:29: error: reference to 'size' is ambiguous
   72 |         for (int i = 0; i < size; i++) {
      |                             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:24:5: note:                 'int size'
   24 | int size;
      |     ^~~~