Language: C++

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

const int INF = 1e9;

int cost[11]={0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
bool num[11];

int N, M;
bool flg = false;
vector<int> select;
void dfs(int sum, vector<int>& x){
    if(sum==N){
        flg=true;
        return;
    }
    else if(sum>N) return;

    for(int i : x)
    {
        if(flg)break;
        if(!flg){
            select.push_back(i);
            dfs(sum+i, x);
            if(!flg)select.pop_back();
        }
    }
    return;
}

int main() {
    cin>>N>>M;
    vector<int> A(M), use;
    for(int i = 0; i < M; i++)
    {
        cin>>A[i];
        num[A[i]]=true;
        use.push_back(cost[A[i]]);
    }

    sort(all(use));
    use.erase(unique(use.begin(), use.end()), use.end());
    
    dfs(0, use);
    
    map<int, int> h;
    for(auto i : select){
        h[i]++;
    }

    string ans;
    int cnt = 0;
    vector<pair<int, int>> p;
    for(int i = 9; i >= 1; i--)
    {
        if(cnt==h.size())break;
        if(!num[i])continue;
        for(auto x : h){
            if(cost[i]==x.first){
                p.push_back({i, x.second});
                cnt++;
                break;
            }
        }
    }
    
    for(int i = 0;i<sz(p); i++){
        for(int j = 0;j<p[i].second;j++)ans+=to_string(p[i].first);
    }
    cout<<ans<<endl;

    return 0;
}

Compiler output:
a.cc:18:13: error: 'std::vector<int> select' redeclared as different kind of entity
   18 | 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/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/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 dfs(int, std::vector<int>&)':
a.cc:30:20: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   30 |             select.push_back(i);
      |                    ^~~~~~~~~
a.cc:32:28: error: request for member 'pop_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   32 |             if(!flg)select.pop_back();
      |                            ^~~~~~~~
a.cc: In function 'int main()':
a.cc:54:18: error: 'begin' was not declared in this scope
   54 |     for(auto i : select){
      |                  ^~~~~~
a.cc:54:18: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:54:18: error: 'end' was not declared in this scope
   54 |     for(auto i : select){
      |                  ^~~~~~
a.cc:54:18: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~