func_code_string: #include <bits/stdc++.h>   using namespace std;   struct pl {     int num, t1, t2, h1, h2;   };   vector<pl> h[(1 << 16) + 5];   int n, k, su;   int s[22], sum[(1 << 16) + 5], si[(1 << 16) + 5];   bitset<200000000> fl, ft;   int work(int a) {     if (a % k == 0) return work(a / k);     return a;   }   int change(int a, int b) { return a * 2001 + b; }   void find(int a, int b) {     int c = b;     for (int i = 0; i < h[a].size(); i++) {       if (h[a][i].num == c) {         b = i;         break;       }     }     if (h[a][b].t1 != -1) find(h[a][b].t1, h[a][b].h1);     if (h[a][b].t2 != -1) find(h[a][b].t2, h[a][b].h2);     if (h[a][b].t1 != -1) printf( %d %d n , h[a][b].h1, h[a][b].h2);   }   bool dfs(int a, int b) {     if (si[a] < b) return 0;     if (fl[change(a, b)] == 1) return 0;     if (ft[change(a, b)] == 1) return 1;     for (int i = 0; i < h[a].size(); i++) {       if (h[a][i].num == b) {         ft[change(a, b)] = 1;         return 1;       }     }     if (sum[a] == 1) {       fl[change(a, b)] = 1;       return 0;     }     int tmp = a;     pl ti;     ti.num = b;     while (tmp != 0) {       if (sum[tmp] * 2 <= sum[a]) {         for (int i = b; i <= si[a]; i *= k) {           for (int j = 1; j < i; j++) {             if (dfs(tmp, j) && dfs((a ^ tmp), i - j)) {               ti.t1 = tmp;               ti.t2 = (a ^ tmp);               ti.h1 = j;               ti.h2 = i - j;               h[a].push_back(ti);               ft[change(a, b)] = 1;               return 1;             }           }         }       }       tmp = (a & (tmp - 1));     }     fl[change(a, b)] = 1;     return 0;   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , &s[i]);       su += s[i];       pl tmp;       tmp.t1 = tmp.t2 = -1;       tmp.num = s[i];       h[1 << (i - 1)].push_back(tmp);     }     for (int i = 1; i < (1 << n); i++) {       int tmp = i, ti = 1;       while (tmp != 0) {         if (tmp & 1) si[i] += s[ti];         sum[i] += (tmp & 1), tmp = (tmp >> 1);         ti++;       }     }     if (k >= 50) {       int an = change((1 << n) - 1, 1);       for (int i = 1; i < (1 << n); i++) {         for (int j = 0; j < h[i].size(); j++) {           int tmp = (((1 << n) - 1) ^ i), ti = tmp;           while (tmp != 0) {             for (int k = 0; k < h[tmp].size(); k++) {               int tip = change((i | tmp), work(h[i][j].num + h[tmp][k].num));               if (fl[tip] == 1) continue;               fl[tip] = 1;               pl tp;               tp.num = work(h[i][j].num + h[tmp][k].num);               tp.t1 = i;               tp.t2 = tmp;               tp.h1 = h[i][j].num;               tp.h2 = h[tmp][k].num;               h[i | tmp].push_back(tp);               if (fl[an] == 1) break;             }             if (fl[an] == 1) break;             tmp = (ti & (tmp - 1));           }           if (fl[an] == 1) break;         }         if (fl[an] == 1) break;       }     } else       dfs((1 << n) - 1, 1);     for (int i = 0; i < h[(1 << n) - 1].size(); i++) {       if (h[(1 << n) - 1][i].num == 1) {         puts( YES );         find((1 << n) - 1, 1);         return 0;       }     }     puts( NO );     return 0;   }   