func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int lowbit(int x) { return x & (-x); }   int n, K, a[16], sum[1 << 16], mp[1 << 16], b[16], fac[2001], vl[2001];   bitset<2001> f[1 << 16];   vector<int> v[16];   void construct(int cur, int sum) {     if (!cur) return;     if (sum * K <= 2000 && f[cur][sum * K]) {       for (int j = 0; j < n; j++)         if ((cur >> j) & 1) b[j]++;       construct(cur, sum * K);     } else {       for (int j = 0; j < n; j++) {         if (((cur >> j) & 1) && sum >= a[j] && f[cur ^ (1 << j)][sum - a[j]]) {           construct(cur ^ (1 << j), sum - a[j]);           return;         }       }     }   }   int main() {     scanf( %d%d , &n, &K);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 1; i * K <= 2000; i++) fac[i * K] = fac[i] + 1;     for (int i = 1; i <= 2000; i++) {       vl[i] = i;       for (int j = 0; j < fac[i]; j++) vl[i] /= K;     }     for (int i = 0; i < n; i++) mp[1 << i] = i;     for (int i = 1; i < (1 << n); i++) {       int t = lowbit(i);       sum[i] = sum[i ^ t] + a[mp[t]];     }     f[0][0] = 1;     for (int i = 0; i < (1 << n); i++) {       for (int j = sum[i] / K * K; j >= 0; j -= K)         f[i][j / K] = f[i][j / K] | f[i][j];       for (int j = 0; j < n; j++)         if (!((i >> j) & 1)) f[i | (1 << j)] |= f[i] << a[j];     }     if (f[(1 << n) - 1][1]) {       puts( YES );       construct((1 << n) - 1, 1);       int bpos = 0;       for (int i = 0; i < n; i++) bpos = max(bpos, b[i]), v[b[i]].push_back(a[i]);       for (int i = 1; i < n; i++) {         while (v[bpos].empty()) bpos--;         int x = v[bpos].size();         printf( %d %d n , v[bpos][x - 1], v[bpos][x - 2]);         int cur = v[bpos][x - 1] + v[bpos][x - 2];         v[bpos].pop_back();         v[bpos].pop_back();         v[bpos - fac[cur]].push_back(vl[cur]);       }     } else       puts( NO );     return 0;   }   