<commit_before><commit_msg>tried D.cpp to 'D'<commit_after>#define DEBUG 1

/**
 * File    : D.cpp
 * Author  : <NAME>
 * Created : 2/16/2019, 9:07:46 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int A[10];
int need[10] = {100, 2, 5, 5, 4, 5, 6, 3, 7, 6};
map<int, int> X;
vector<vector<int>> Y;
vector<vector<int>> W;

void dfs(vector<int> L, int R)
{
  if (R == 0)
  {
    Y.push_back(L);
  }
  else
  {
    for (auto x : X)
    {
      int cost = x.first;
      if (cost >= L[L.size() - 1] && cost >= R)
      {
        L.push_back(cost);
        dfs(L, R - cost);
        L.pop_back();
      }
    }
  }
}

int max_score(vector<int> L)
{
  vector<int> F;
  for (auto x : L)
  {
    F.push_back(X[x]);
  }
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());
  string ans = "";
  for (auto i = 0; i < max(9, (int)F.size()); i++)
  {
    ans = ans + to_string(F[i]);
  }
  return stoi(ans);
}

void represent(vector<int> L)
{
  vector<int> F;
  for (auto x : L)
  {
    F.push_back(X[x]);
  }
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());
  for (auto i = 0; i < (int)F.size(); i++)
  {
    cout << F[i];
  }
}

int main()
{
  cin >> N >> M;
  for (auto i = 0; i < M; i++)
  {
    cin >> A[i];
    int n = need[A[i]];
    if (X.find(n) == X.end())
    {
      X[n] = A[i];
    }
    else
    {
      X[n] = max(X[n], A[i]);
    }
  }
  int cnt = 0;
  int cost = (*X.begin()).first;
  string base = to_string((*X.begin()).second);
  while (N > 60)
  {
    N -= cost;
    cnt++;
  }
  if (cost == 2 && N % 2 == 0)
  {
    while (N > 0)
    {
      N -= cost;
      cnt++;
    }
  }
  else if (cost == 2)
  {
    auto it = X.begin();
    while ((*it).first % 2 == 0)
    {
      it++;
    }
    cout << (*it).second;
    N -= (*it).first;
    while (N > 0)
    {
      N -= cost;
      cnt++;
    }
  }
  else
  {
    vector<int> V;
    dfs(V, N);
    int maxi = 0;
    for (auto v : Y)
    {
      maxi = max((int)v.size(), maxi);
    }
    for (auto v : Y)
    {
      if ((int)v.size() == maxi)
      {
        W.push_back(v);
      }
    }
    int maxi_score = 0;
    vector<int> ans;
    for (auto v : W)
    {
      if (maxi_score < max_score(v))
      {
        maxi_score = max_score(v);
        ans = v;
      }
    }
    represent(ans);
  }
  for (auto i = 0; i < cnt; i++)
  {
    cout << base;
  }
  cout << endl;
}
{'fraction_non_alphanumeric': 0.21084337349397592, 'fraction_numerical': 0.02650602409638554, 'mean_word_length': 2.208695652173913, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2933995', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1404, 'n_words': 342}