Language: C++

const lli INFl = (lli)(9e18) + 1;
// const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
 
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)
 
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
const vector<int> data = {2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<bool> can(9);
 
using vs = vector<string>;
//using vss = vector<vs>;
vs DP(10010, "a");
 
bool compare(string a, string b){
  if(a.size() > b.size()) return true;
  if(a.size() < b.size()) return false;
  return a > b;
}
 
void dp(int i){
  if(i == 0){
    DP.at(0) = "";
    return;
  }
  if(DP.at(i) != "a") return;
  DP.at(i) = "";
  REP(j, 9) if(can.at(j)){
    int u = data.at(j);
    if(i >= u){
      dp(i - u);
      if(DP.at(i - u) != "IMPOSSIBLE"){
        string tmp = DP.at(i - u) + (char)('1' + j);
        if(compare(tmp, DP.at(i))) DP.at(i) = tmp;
      }
    }
  }
  if(DP.at(i) == "") DP.at(i) = "IMPOSSIBLE";
}
 
int main(void){
  int n, m; cin >> n >> m;
  REP(i, m){
    int a; cin >> a;
    can.at(a - 1) = true;
  }
  dp(n);
  /*
  REP(i, n + 1){
    cout << i << " : " << DP.at(i) << "\n";
  }*/
  cout << DP.at(n) << "\n";
  return 0;
}

Compiler output:
a.cc:1:7: error: 'lli' does not name a type
    1 | const lli INFl = (lli)(9e18) + 1;
      |       ^~~
a.cc:15:7: error: 'vector' does not name a type
   15 | const vector<int> data = {2, 5, 5, 4, 5, 6, 3, 7, 6};
      |       ^~~~~~
a.cc:16:1: error: 'vector' does not name a type
   16 | vector<bool> can(9);
      | ^~~~~~
a.cc:18:12: error: 'vector' does not name a type
   18 | using vs = vector<string>;
      |            ^~~~~~
a.cc:20:1: error: 'vs' does not name a type
   20 | vs DP(10010, "a");
      | ^~
a.cc:22:14: error: 'string' was not declared in this scope
   22 | bool compare(string a, string b){
      |              ^~~~~~
a.cc:22:24: error: 'string' was not declared in this scope
   22 | bool compare(string a, string b){
      |                        ^~~~~~
a.cc:22:32: error: expression list treated as compound expression in initializer [-fpermissive]
   22 | bool compare(string a, string b){
      |                                ^
a.cc: In function 'void dp(int)':
a.cc:30:5: error: 'DP' was not declared in this scope; did you mean 'dp'?
   30 |     DP.at(0) = "";
      |     ^~
      |     dp
a.cc:33:6: error: 'DP' was not declared in this scope; did you mean 'dp'?
   33 |   if(DP.at(i) != "a") return;
      |      ^~
      |      dp
a.cc:34:3: error: 'DP' was not declared in this scope; did you mean 'dp'?
   34 |   DP.at(i) = "";
      |   ^~
      |   dp
a.cc:35:16: error: 'can' was not declared in this scope
   35 |   REP(j, 9) if(can.at(j)){
      |                ^~~
a.cc:36:13: error: 'data' was not declared in this scope
   36 |     int u = data.at(j);
      |             ^~~~
a.cc:40:9: error: 'string' was not declared in this scope
   40 |         string tmp = DP.at(i - u) + (char)('1' + j);
      |         ^~~~~~
a.cc:41:20: error: 'tmp' was not declared in this scope
   41 |         if(compare(tmp, DP.at(i))) DP.at(i) = tmp;
      |                    ^~~
a.cc:41:33: error: 'compare' cannot be used as a function
   41 |         if(compare(tmp, DP.at(i))) DP.at(i) = tmp;
      |                                 ^
a.cc: In function 'int main()':
a.cc:49:13: error: 'cin' was not declared in this scope
   49 |   int n, m; cin >> n >> m;
      |             ^~~
a.cc:52:5: error: 'can' was not declared in this scope
   52 |     can.at(a - 1) = true;
      |     ^~~
a.cc:59:3: error: 'cout' was not declared in this scope
   59 |   cout << DP.at(n) << "\n";
      |   ^~~~
a.cc:59:11: error: 'DP' was not declared in this scope; did you mean 'dp'?
   59 |   cout << DP.at(n) << "\n";
      |           ^~
      |           dp