Language: C++

#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

vector<vector<int> > select;
void manju(vector<int>& a, int prev, int sum, const vector<int>& x)
{
    if(sum > 10)
        return;
    if(sum == 10){
        if(accumulate(a.begin(), a.end(), 0) > 2)
            select.push_back(a);
        return;
    }

    for(int i=prev; i<=9; ++i){
        if(x[i] == 0)
            continue;
        ++ a[i];
        sum += i;
        manju(a, i, sum, x);
        sum -= i;
        -- a[i];
    }
}

vector<map<vector<int>, int> > memo;
int solve(const vector<int>& x, int k)
{
    if(k >= select.size())
        return 0;

    if(memo[k].find(x) != memo[k].end())
        return memo[k][x];

    int ret = solve(x, k+1);

    vector<int> y = x;
    bool ok = true;
    for(int i=1; i<=9; ++i){
        y[i] -= select[k][i];
        if(y[i] < 0)
            ok = false;
    }
    if(ok)
        ret = max(ret, solve(y, k) + 1);

    return memo[k][x] = ret;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> x(10, 0);
        for(int i=0; i<n; ++i){
            int y;
            cin >> y;
            if(x[10-y] > 0)
                -- x[10-y];
            else
                ++ x[y];
        }

        select.clear();
        vector<int> a(10, 0);
        manju(a, 1, 0, x);

        memo.assign(select.size(), map<vector<int>, int>());
        cout << solve(x, 0) << endl;
    }
}

Compiler output:
a.cc:20:22: error: 'std::vector<std::vector<int> > select' redeclared as different kind of entity
   20 | vector<vector<int> > select;
      |                      ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                 from /usr/include/stdlib.h:514,
                 from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 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:2:
/usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
  102 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |            ^~~~~~
a.cc: In function 'void manju(std::vector<int>&, int, int, const std::vector<int>&)':
a.cc:27:20: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   27 |             select.push_back(a);
      |                    ^~~~~~~~~
a.cc: In function 'int solve(const std::vector<int>&, int)':
a.cc:45:20: error: request for member 'size' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   45 |     if(k >= select.size())
      |                    ^~~~
a.cc:56:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   56 |         y[i] -= select[k][i];
      |                         ^
a.cc:56:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   56 |         y[i] -= select[k][i];
      |                            ^
a.cc:56:14: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to binary 'operator-'
   56 |         y[i] -= select[k][i];
a.cc:56:14: note:   in evaluation of 'operator-=(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}, int (*)(int, struct fd_set*, struct fd_set*, struct fd_set*, struct timeval*))'
a.cc: In function 'int main()':
a.cc:84:16: error: request for member 'clear' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   84 |         select.clear();
      |                ^~~~~
a.cc:88:28: error: request for member 'size' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   88 |         memo.assign(select.size(), map<vector<int>, int>());
      |                            ^~~~