Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> m = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int getmax(string a, string b)
{
  if(a.size() != b.size())
  {
    return a.size() > b.size() ? a : b;
  }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m, 0);
    for(int i = 0; i < m; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>);
    vector<string> dp(max(n + 1, 10), "");
    for(int i = 0; i < m, i++)
    {
        dp[m[a[i]]] = getmax(dp[m[a[i]]], to_string(a[i]));
    }
    
    for(int j = 0; j < n; j++)
    {
        for(int i = 0; i < m; i++)
        {
            if(j - m[a[i]] >= 0 && dp[j - m[a[i]] != "")
            {
                dp[j] = getmax(dp[j], dp[j - m[a[i]] + to_string(a[i]));
            }
        }
    }
    cout << dp[n];
    
    return 0;
}

Compiler output:
a.cc: In function 'int getmax(std::string, std::string)':
a.cc:11:32: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int' in return
   11 |     return a.size() > b.size() ? a : b;
      |            ~~~~~~~~~~~~~~~~~~~~^~~~~~~
      |                                |
      |                                std::string {aka std::__cxx11::basic_string<char>}
a.cc: In function 'int main()':
a.cc:24:42: error: expected primary-expression before ')' token
   24 |     sort(a.begin(), a.end(), greater<int>);
      |                                          ^
a.cc:26:30: error: expected ';' before ')' token
   26 |     for(int i = 0; i < m, i++)
      |                              ^
      |                              ;
a.cc:28:13: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   28 |         dp[m[a[i]]] = getmax(dp[m[a[i]]], to_string(a[i]));
      |             ^
a.cc:28:34: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   28 |         dp[m[a[i]]] = getmax(dp[m[a[i]]], to_string(a[i]));
      |                                  ^
a.cc:35:21: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   35 |             if(j - m[a[i]] >= 0 && dp[j - m[a[i]] != "")
      |                     ^
a.cc:35:44: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   35 |             if(j - m[a[i]] >= 0 && dp[j - m[a[i]] != "")
      |                                            ^
a.cc:35:56: error: expected ']' before ')' token
   35 |             if(j - m[a[i]] >= 0 && dp[j - m[a[i]] != "")
      |                                                        ^
      |                                                        ]
a.cc:37:47: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   37 |                 dp[j] = getmax(dp[j], dp[j - m[a[i]] + to_string(a[i]));
      |                                               ^
a.cc:37:71: error: expected ']' before ')' token
   37 |                 dp[j] = getmax(dp[j], dp[j - m[a[i]] + to_string(a[i]));
      |                                                                       ^
      |                                                                       ]