func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   using ll = long long;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   using vi = vector<int>;   using vll = vector<ll>;   const int kMaxN = 110;   bool can_reach[kMaxN][kMaxN * kMaxN];   bool is_ordered[kMaxN][kMaxN * kMaxN];   int num_children[kMaxN][kMaxN * kMaxN];   void Preproc() {     can_reach[1][1] = true;     for (int len = 1; len < kMaxN; ++len) {       for (int nintvs = 1; nintvs <= len * len; ++nintvs) {         if (!can_reach[len][nintvs]) {           continue;         }         for (int k = 2; len + k <= kMaxN; ++k) {           const int new_len = len + k - 1;           const int new_nintvs = nintvs + k * (k + 1) / 2 - 1;           can_reach[new_len][new_nintvs] = true;           is_ordered[new_len][new_nintvs] = true;           num_children[new_len][new_nintvs] = k;         }         for (int k = 4; len + k <= kMaxN; ++k) {           const int new_len = len + k - 1;           const int new_nintvs = nintvs + k;           can_reach[new_len][new_nintvs] = true;           is_ordered[new_len][new_nintvs] = false;           num_children[new_len][new_nintvs] = k;         }       }     }   }   void Construct(int len, int nintvs) {     vector<int> roots(len);     const int init_len = len;     iota((roots).begin(), (roots).end(), 0);     vector<bool> node_ordered(len);     vector<vi> node_children(len);     while (len > 1) {       assert(can_reach[len][nintvs]);       const int k = num_children[len][nintvs];       const int new_root = ((int)(node_children).size());       vi children(roots.end() - k, roots.end());       roots.erase(roots.end() - k, roots.end());       node_children.push_back(children);       roots.push_back(new_root);       if (is_ordered[len][nintvs]) {         node_ordered.push_back(true);         len -= (k - 1);         nintvs -= k * (k + 1) / 2 - 1;       } else {         node_ordered.push_back(false);         len -= (k - 1);         nintvs -= k;       }     }     debug() <<   [              <<  node_children                  :               << (node_children) <<  ]  ;     debug() <<   [              <<  node_ordered                  :               << (node_ordered) <<  ]  ;     assert(len == 1 && nintvs == 1);     assert(((int)(roots).size()) == 1);     vi answer;     function<void(int, bool)> Dfs = [&](int v, bool ordered_inc) {       if (v < init_len) {         answer.push_back(v + 1);       } else if (node_ordered[v]) {         if (ordered_inc) {           for (int child : node_children[v]) {             Dfs(child, !ordered_inc);           }         } else {           const int sz = ((int)(node_children[v]).size());           for (int i = sz - 1; i >= 0; --i) {             Dfs(node_children[v][i], !ordered_inc);           }         }       } else {         const int sz = ((int)(node_children[v]).size());         vi order;         for (int start : {1, 0}) {           for (int i = start; i < sz; i += 2) {             order.push_back(i);           }         }         if (sz % 2 == 1) {           swap(order[sz - 2], order[sz - 1]);         }         for (int i : order) {           Dfs(node_children[v][i], !ordered_inc);         }       }     };     Dfs(roots[0], true);     for (int v : answer) {       cout << v <<    ;     }     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout << fixed << setprecision(11);     cerr << fixed << setprecision(6);     Preproc();     int q;     cin >> q;     while (q--) {       int n, k;       cin >> n >> k;       if (!can_reach[n][k]) {         cout <<  NO n ;       } else {         cout <<  YES n ;         Construct(n, k);       }     }   }   