func_code_string: #include <bits/stdc++.h>   using namespace std;   bitset<16 * 2002> dp[1 << 16];   int n, k;   int a[16];   int weight[16];   int calc(int &x) {     int c = 0;     while (x % k == 0) x /= k, c++;     return c;   }   int _calc(int x) {     int c = 0;     while (x % k == 0) x /= k, c++;     return c;   }   void dfs(int s, int x) {     if (__builtin_popcount(s) == 1) return;     int y = x, z = x;     while (y < 16 * 2002) {       if (dp[s][y]) z = y;       y = y * k;     }     if (z != x) {       for (int i = 0; i < n; i++)         if ((1 << i) & s) weight[i] += _calc(z / x);       dfs(s, z);     } else {       for (int i = 0; i < n; i++)         if ((1 << i) & s and x >= a[i] and dp[s ^ (1 << i)][x - a[i]]) {           dfs(s ^ (1 << i), x - a[i]);           break;         }     }   }   signed main() {     dp[0][0] = 1;     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 1; i < (1 << n); i++) {       for (int j = 0; j < n; j++)         if (i & (1 << j)) dp[i] |= (dp[i - (1 << j)] << a[j]);       for (int j = 16 * 2000 / k; j >= 0; j--)         if (dp[i][j * k]) dp[i][j] = 1;     }     if (!dp[(1 << n) - 1][1]) return puts( NO ) * 0;     puts( YES );     dfs((1 << n) - 1, 1);     int cnt = n - 1;     while (cnt--) {       int f1 = -1, f2 = -1;       for (int i = 0; i < n; i++) {         if (f1 == -1 or weight[i] > weight[f1])           f2 = f1, f1 = i;         else if (f2 == -1 or weight[i] > weight[f2])           f2 = i;       }       printf( %d %d n , a[f1], a[f2]);       a[f1] += a[f2];       weight[f2] = -1e9;       weight[f1] -= calc(a[f1]);     }     return 0;   }   