malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct box {     int a, o;     int id;   };   int n;   box x[201000];   int cmp(box a, box b) { return a.a < b.a; }   int used[201000];   int main() {     int t;     scanf( %d , &t);     for (int tt = 0; tt < t; tt++) {       scanf( %d , &n);       n = 2 * n - 1;       for (int i = 1; i <= n; i++) used[i] = 0;       for (int i = 1; i <= n; i++) {         scanf( %d%d , &x[i].a, &x[i].o);         x[i].id = i;       }       printf( YES n );       if (n == 1) {         printf( 1 n );         continue;       }       sort(x + 1, x + n + 1, cmp);       for (int i = 1; i < n; i++)         if (x[i].o <= x[i + 1].o) {           printf( %d  , x[i + 1].id);           used[i] = 1, used[i + 1] = 1, i++;         }       int tk = 0;       for (int i = 1; i <= n; i++)         if (!used[i]) {           tk++;           if (tk % 2 == 1) printf( %d  , x[i].id);         }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( -O2 )   using namespace std;   void err(istream_iterator<string> it) { cerr << endl; }   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a <<   t ;     err(++it, args...);   }   template <typename T1, typename T2>   ostream& operator<<(ostream& c, pair<T1, T2>& v) {     c <<  (  << v.first <<  ,  << v.second <<  ) ;     return c;   }   template <template <class...> class TT, class... T>   ostream& operator<<(ostream& out, TT<T...>& c) {     out <<  {  ;     for (auto& x : c) out << x <<    ;     out <<  } ;     return out;   }   const int LIM = 1.5e3 + 5, MOD = 998244353;   const long double EPS = 1e-9;   int read() {     int xx = 0, ff = 1;     char ch = getchar();     while (ch >  9  || ch <  0 ) {       if (ch ==  - ) ff = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       xx = (xx << 3) + (xx << 1) + ch -  0 ;       ch = getchar();     }     return xx * ff;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   int n;   int link[LIM], sz[LIM], edges[LIM];   long long poly[LIM][LIM];   int find(int x) {     if (x == link[x]) return x;     return link[x] = find(link[x]);   }   void polymul(int a, int b) {     long long temp[LIM] = {0};     for (int i = 0; i < n + 1; ++i) {       for (int j = 0; j + i <= n; j++) {         temp[i + j] += (poly[a][i] * poly[b][j]) % MOD;       }     }     for (int i = 0; i < LIM; ++i) {       poly[a][i] = temp[i] % MOD;     }     return;   }   void unite(int a, int b) {     a = find(a);     b = find(b);     if (sz[a] < sz[b]) swap(a, b);     if (a == b) {       edges[a]++;       if (edges[a] == sz[a] * (sz[a] - 1) / 2) {         poly[a][1]++;       }       return;     }     link[b] = a;     sz[a] += sz[b];     polymul(a, b);     edges[a]++;     edges[a] += edges[b];     if (edges[a] == sz[a] * (sz[a] - 1) / 2) {       poly[a][1]++;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; ++i) {       poly[i][1] = 1;       link[i] = i;       sz[i] = 1;     }     vector<tuple<int, int, int>> v;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         int x;         cin >> x;         if (i < j) {           v.push_back({x, i, j});         }       }     }     sort(v.begin(), v.end());     for (auto& r : v) {       int cost, first, second;       tie(cost, first, second) = r;       unite(first, second);     }     int a = find(0);     for (int i = 1; i < n + 1; ++i) {       cout << poly[a][i] % MOD <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;      typedef long long int ll;   #define M 1000000007      int main() {       std::ios_base::sync_with_stdio(false);       cin.tie(NULL);       cout.tie(NULL);              int t;       cin>>t;       while(t--)       {           string s;           cin>>s;           for(int i=0; i<s.length(); i++)           {               if(i%2==0)               {                   if(s[i] !=  a )                       s[i] =  a ;                   else                       s[i] =  b ;               }               else               {                   if(s[i] !=  z )                       s[i] =  z ;                   else                       s[i] =  y ;               }           }           cout<<s<<endl;       }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxlen = 2e5 + 2;   long long ans;   long long lt[Maxlen], ls[2 * Maxlen];   int n, m, dpt[Maxlen], dps[Maxlen];   char ct[Maxlen], cs[2 * Maxlen];   long long cmp(int pos) {     if (cs[0] != ct[pos] || ls[0] > lt[pos]) return 0;     if (m == 1) return lt[pos] - ls[0] + 1;     pos++;     int p1 = 1;     while (p1 < m && pos < n && cs[p1] == ct[pos] && ls[p1] == lt[pos]) {       pos++;       p1++;     }     if (p1 < m && pos < n && cs[p1] == ct[pos] && ls[p1] < lt[pos]) p1++;     if (p1 == m) return 1;     return 0;   }   int kmp() {     int res = 0;     for (int i = 1; i < n + m; i++) {       int j = dps[i - 1];       if (j == m - 2 && cs[i] == cs[j] && ls[i] >= ls[j]) res++;       while (j > 0 && (cs[i] != cs[j] || ls[i] != ls[j])) j = dps[j - 1];       if (cs[j] == cs[i])         if (ls[j] == ls[i] || (j == 0 && ls[i] >= ls[j])) ++j;       dps[i] = j;     }     return res;   }   int main() {     scanf( %d%d , &n, &m);     scanf( %d-%c , &lt[0], &ct[0]);     for (int i = 1; i < n; i++) {       scanf( %d-%c , &lt[i], &ct[i]);       if (ct[i] == ct[i - 1]) {         lt[i - 1] += lt[i];         n--;         i--;       }     }     scanf( %d-%c , &ls[0], &cs[0]);     for (int i = 1; i < m; i++) {       scanf( %d-%c , &ls[i], &cs[i]);       if (cs[i] == cs[i - 1]) {         ls[i - 1] += ls[i];         m--;         i--;       }     }     if (m == 1) {       for (int i = 0; i < n; i++) ans = ans + cmp(i);     } else {       cs[m++] =  # ;       for (int i = 0; i < n; i++) {         cs[m + i] = ct[i];         ls[m + i] = lt[i];       }       ans = kmp();     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1500;   const int MOD = 1e9 + 9;   int ing[128];   long long dp[1005][105][15];   int n, m;   struct ac_auto {     int nxt[maxn][4], fail[maxn], ed[maxn], q[maxn];     int L = 0;     void inserta(char buf[]) {       int now = 0;       int len = strlen(buf);       for (int i = 0; buf[i]; i++) {         int son = ing[(int)buf[i]];         if (!nxt[now][son]) nxt[now][son] = ++L;         now = nxt[now][son];       }       ed[now] = len;     }     void getfail() {       int front = 0, back = 0, now = 0;       for (int i = 0; i < 4; i++)         if (nxt[now][i]) q[++back] = nxt[now][i];       while (front < back) {         now = q[++front];         for (int i = 0; i < 4; i++) {           if (nxt[now][i]) {             fail[nxt[now][i]] = nxt[fail[now]][i];             q[++back] = nxt[now][i];           } else             nxt[now][i] = nxt[fail[now]][i];           ed[nxt[now][i]] = max(ed[nxt[now][i]], ed[nxt[fail[now]][i]]);         }       }     }     void work() {       memset(dp, 0, sizeof dp);       dp[0][0][0] = 1;       for (int i = 0; i < n; i++) {         for (int j = 0; j <= L; j++) {           for (int k = 0; k <= 10; k++)             for (int f = 0; f < 4; f++) {               if (ed[nxt[j][f]] > k) {                 dp[i + 1][nxt[j][f]][0] += dp[i][j][k];                 dp[i + 1][nxt[j][f]][0] %= MOD;               } else {                 dp[i + 1][nxt[j][f]][k + 1] += dp[i][j][k];                 dp[i + 1][nxt[j][f]][k + 1] %= MOD;               }             }         }       }       long long ans = 0;       for (int i = 0; i <= L; i++) {         ans += dp[n][i][0];         ans %= MOD;       }       cout << ans << endl;     }   } ac;   char ss[15];   int main() {     ing[ A ] = 0, ing[ T ] = 1, ing[ C ] = 2, ing[ G ] = 3;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %s , ss);       ac.inserta(ss);     }     ac.getfail();     ac.work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int r[100005], g[100005], b[100005], nr, ng, nb, pos;   long long ans = 9e18;   long long calc(long long a, long long b, long long c) {     long long temp = (a - b) * (a - b) + (a - c) * (a - c) + (b - c) * (b - c);     return temp;   }   int bsearch(int a[], int len, int k) {     int l = 1, r = len, mid, ans = 0;     while (l < r) {       mid = (l + r) >> 1;       if (a[mid] > k)         r = mid;       else if (a[mid] == k)         return mid;       else {         if (a[mid + 1] > k)           return mid;         else if (a[mid + 1] == k)           return mid + 1;         else           l = mid + 1;       }     }     return l;   }   void check(int a[], int b[], int c[], int lena, int lenb, int lenc) {     int i, aa, bb, cc1, cc2, pos;     for (i = 1; i <= lena; i++) {       aa = a[i];       pos = lower_bound(b + 1, b + lenb + 1, aa) - b;       if (!(pos >= 1 && pos <= lenb && b[pos] >= aa)) continue;       bb = b[pos];       int mid = (aa + bb) / 2;       pos = lower_bound(c + 1, c + lenc + 1, mid) - c;       if (pos >= 1 && pos <= lenc && c[pos] >= mid) {         cc1 = c[pos];         ans = min(ans, calc((long long)aa, (long long)bb, (long long)cc1));       }       pos = bsearch(c, lenc, mid);       if (pos <= lenc && pos >= 1 && c[pos] <= mid) {         cc2 = c[pos];         ans = min(ans, calc((long long)aa, (long long)bb, (long long)cc2));       }     }   }   int main() {     int t;     cin >> t;     while (t--) {       ans = 9e18;       int i;       scanf( %d%d%d , &nr, &ng, &nb);       for (i = 1; i <= nr; i++) scanf( %d , &r[i]);       for (i = 1; i <= ng; i++) scanf( %d , &g[i]);       for (i = 1; i <= nb; i++) scanf( %d , &b[i]);       sort(r + 1, r + nr + 1), sort(g + 1, g + ng + 1), sort(b + 1, b + nb + 1);       check(r, g, b, nr, ng, nb);       check(r, b, g, nr, nb, ng);       check(g, r, b, ng, nr, nb);       check(g, b, r, ng, nb, nr);       check(b, r, g, nb, nr, ng);       check(b, g, r, nb, ng, nr);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100005], f[100005];   int l[100005], r[100005];   int main() {     int n;     while (cin >> n) {       memset(a, 0, sizeof(a));       memset(f, 0, sizeof(f));       for (int i = 0; i < n; i++) {         cin >> a[i];       }       int m;       cin >> m;       for (int i = 0; i < m; i++) {         cin >> f[i];       }       memset(l, 0, sizeof(l));       memset(r, 0, sizeof(r));       for (int i = 0; i < n; i++) {         if (l[a[i]] == 0) {           l[a[i]] = i;         }       }       for (int i = n - 1; i >= 0; i--) {         if (r[a[i]] == 0) {           r[a[i]] = n - i;         }       }       long long count1 = 0, count2 = 0;       for (int i = 0; i < m; i++) {         count1 = count1 + l[f[i]] + 1;       }       for (int i = 0; i < m; i++) {         count2 = count2 + r[f[i]];       }       cout << count1 <<     << count2 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   string s, t;   vector<char> vv;   int main() {     cin >> n >> m;     cin >> s;     for (int i = 0; i < n; i++) vv.push_back(s[i]);     sort(vv.begin(), vv.end());     if (((int)(s).size()) < m) {       t = s;       for (int i = ((int)(s).size()); i < m; i++) t += vv[0];       cout << t << endl;       return 0;     } else if (((int)(s).size()) == m) {       t = s;       int k = 1;       while (1) {         if (s[((int)(s).size()) - k] == vv[((int)(vv).size()) - 1]) {           t[((int)(s).size()) - k] = vv[0];           k++;           continue;         }         int bb = upper_bound((vv).begin(), (vv).end(), t[((int)(s).size()) - k]) -                  vv.begin();         t[((int)(s).size()) - k] = vv[bb];         break;       }       cout << t << endl;       return 0;     } else {       t = s.substr(0, m);       int k = 1;       while (1) {         if (s[m - k] == vv[((int)(vv).size()) - 1]) {           t[m - k] = vv[0];           k++;           continue;         }         int bb = upper_bound((vv).begin(), (vv).end(), t[m - k]) - vv.begin();         t[m - k] = vv[bb];         break;       }       cout << t << endl;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<int> a(n), b(m);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < m; i++) cin >> b[i];     sort(a.begin(), a.end());     sort(b.begin(), b.end());     if (a[n - 1] > b[0]) {       cout << -1 << endl;       return 0;     }     long long sum = 0LL;     for (int i = 0; i < m; i++) sum = sum + 1LL * b[i];     for (int i = 0; i < n - 1; i++) sum = sum + 1LL * m * a[i];     if (n > 1 && b[0] > a[n - 1]) sum = sum + a[n - 1] - a[n - 2];     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000;   const double eps = 1e-15;   int n;   double p[N + 9], q[N + 9];   void into() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %lf , &p[i]);     for (int i = 1; i <= n; ++i) scanf( %lf , &q[i]);   }   double a[N + 9], b[N + 9];   double Get_root(double a, double b, double c) {     return fabs(a) <= eps ? -c / b                           : (sqrt(max(b * b - 4 * a * c, 0.0)) - b) / (2 * a);   }   void Get_ans() {     for (int i = 1; i <= n; ++i) {       double x = p[i] + a[i - 1] * b[i - 1];       double y = p[i] + q[i] + a[i - 1] + b[i - 1];       b[i] = Get_root(1, -y, x);       a[i] = y - b[i];     }     for (int i = n; i >= 1; --i) a[i] -= a[i - 1], b[i] -= b[i - 1];   }   void work() { Get_ans(); }   void outo() {     for (int i = 1; i <= n; ++i) printf( %.10lf  , a[i]);     puts(  );     for (int i = 1; i <= n; ++i) printf( %.10lf  , b[i]);     puts(  );   }   int main() {     int T = 1;     for (; T--;) {       into();       work();       outo();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int OO = (int)1e6;   set<pair<int, int> > nods;   map<pair<int, int>, bool> vis;   pair<int, int> fr, sc;   int n, r, a, p, ans, sz;   bool ok = true;   int rx[] = {1, 1, 1, 0, 0, -1, -1, -1};   int ry[] = {1, 0, -1, 1, -1, 1, 0, -1};   bool val(pair<int, int> per) { return nods.find(per) != nods.end(); }   void fun(pair<int, int> pos) {     pair<int, int> cur;     queue<pair<int, int> > q;     ans = 0;     q.push(pos);     vis[pos] = true;     sz = 1;     ok = true;     for (; !q.empty() && ok; sz = q.size(), ans++) {       while (ok && sz--) {         pos = q.front();         q.pop();         for (int i = 0; ok && i < 8; i++) {           cur.first = (pos.first) + rx[i];           cur.second = (pos.second) + ry[i];           if (val(cur) && !vis[cur]) {             q.push(cur);             vis[cur] = true;             if (cur == sc) ok = false;           }         }       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> fr.first >> fr.second >> sc.first >> sc.second >> n;     for (int i = 0; i < n; i++) {       cin >> r >> a >> p;       for (int j = a; j <= p; j++) {         nods.insert({r, j});         vis[{r, j}] = false;       }     }     fun(fr);     if (!ok)       cout << ans << endl;     else       cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int in() {     int x;     scanf( %d , &x);     return x;   }   template <typename T>   istream &operator>>(istream &in, vector<T> &vec) {     for (int i = 0; i < vec.size(); ++i) in >> vec[i];     return in;   }   template <typename T>   ostream &operator<<(ostream &out, const vector<T> &vec) {     for (int i = 0; i < vec.size(); ++i) out << vec[i] <<    ;     return out;   }   const int INT = 1e6 + 1;   long long eds = 0;   int main() {     long long a = in(), b = in(), c, n = 0, jac = 1;     vector<int> x(a);     vector<int> y(a);     vector<bool> f(a);     priority_queue<pair<long long, int>> qu;     for (int i = 0; i < a; ++i) {       x[i] = in();     }     for (int i = 0; i < a; ++i) {       y[i] = in();     }     for (int i = 0; i < a; ++i) {       if (x[i] % 100) {         qu.push(make_pair(-(100 - x[i] % 100) * y[i], i));         b -= x[i] % 100;         if (b < 0) {           n += -(qu.top().first);           f[qu.top().second] = true;           qu.pop();           b += 100;         }       }     }     cout << n << endl;     for (int i = 0; i < a; ++i) {       cout << f[i] + x[i] / 100 <<     << (f[i] ? 0 : x[i] % 100) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 2e5 + 5;   const int mod = 998244353;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int t;     cin >> t;     while (t--) {       int n, x;       cin >> n >> x;       vector<int> g[n + 1];       for (int i = 1; i < n; i++) {         int u, v;         cin >> u >> v;         g[u].push_back(v);         g[v].push_back(u);       }       if (g[x].size() == 1) {         cout <<  Ayush n ;         continue;       }       vector<int> flag(n + 1);       for (int k : g[x]) {         flag[k] = 1;       }       int sz = g[x].size();       int cnt = 0;       for (int i = 1; i <= n; i++) {         if (i != x and flag[i] == 0) cnt++;       }       4;       int total = cnt + sz - 1;       if (total % 2 == 1) {         cout <<  Ashish n ;       } else         cout <<  Ayush n ;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> mark[4];   string sins[4];   int cost[5];   int sta[1010];   int dp[1010][0xffff + 1];   int main() {     int n;     cin >> n;     for (int i = 0; i < 4; i++) cin >> cost[i];     for (int i = 0; i < 4; i++) cin >> sins[i];     for (int j = 0; j < n; j++) {       sta[j] = 0;       for (int i = 0; i < 4; i++) {         sta[j] |= (sins[i][j] ==  * ) ? (1 << i) : 0;       }     }     int S = 0;     for (int i = 0; i < 4; i++) {       S |= sta[i] << (i * 4);       sta[n + i] = 0;     }     for (int i = 0; i < 4; i++) {       for (int j = 3; j >= i; j--) {         int t = 0xffff;         for (int k = 0; k <= i; k++) {           for (int y = j; y >= j - i; y--) t ^= 1 << (4 * k + y);         }         mark[i].push_back(t);       }     }     memset(dp, 0x7f, sizeof(dp));     dp[0][S] = 0;     for (int i = 0; i < n; i++) {       for (int j = 0xffff; j >= 0; j--) {         if (dp[i][j] == 0x7f7f7f7f) continue;         if ((j & 0xf) == 0) {           int S = (((j & 0xffff) >> 4) | (0xf000 & (sta[i + 4] << 12)));           dp[i + 1][S] = min(dp[i + 1][S], dp[i][j]);         }         for (int k = 0; k < 4 && k + i < n; k++) {           vector<int>::iterator y;           for (y = mark[k].begin(); y != mark[k].end(); y++) {             dp[i][j & (*y)] = min(dp[i][j & (*y)], dp[i][j] + cost[k]);           }         }       }     }     cout << dp[n][0] << endl;   }
#include <bits/stdc++.h>   using namespace std;   enum { DUNNO = -1, AB, BA };   vector<pair<int, int> > E[200010];   map<pair<int, int>, int> edge_id;   int dir[200010];   int val[200010];   bool vis[200010];   int main() {     int N, M;     cin >> N >> M;     memset(val, 0, sizeof(val));     memset(vis, 0, sizeof(vis));     memset(dir, DUNNO, sizeof(dir));     int a, b, c;     for (int j = (1); j <= (M); ++j) {       scanf( %d%d%d , &a, &b, &c);       E[a].push_back(make_pair(b, c));       E[b].push_back(make_pair(a, c));       edge_id[make_pair(a, b)] = j;       edge_id[make_pair(b, a)] = -j;       val[a] += c;       val[b] += c;     }     for (int i = (2); i <= (N - 1); ++i) val[i] /= 2;     queue<int> Q;     val[1] = 0;     Q.push(1);     while (!Q.empty()) {       int i = Q.front();       Q.pop();       if (vis[i]) continue;       vis[i] = true;       assert(val[i] == 0);       int numE = E[i].size();       for (int x = 0; x < (numE); ++x) {         int j = E[i][x].first;         int c = E[i][x].second;         if (vis[j]) continue;         int e = edge_id[make_pair(i, j)];         if (dir[abs(e)] != DUNNO) continue;         if (e > 0)           dir[e] = 0;         else           dir[-e] = 1;         val[j] -= c;         if (!val[j]) Q.push(j);       }     }     for (int j = (1); j <= (M); ++j) cout << dir[j] << endl;   }
#include <bits/stdc++.h>   int main() {     int n, a, b, c, t, i, m, ans = 0;     scanf( %d%d%d%d%d , &n, &a, &b, &c, &t);     ans = n * a;     for (i = 0; i < n; i++) {       scanf( %d , &m);       ans += (t - m) * (c - b);     }     if (b >= c)       printf( %d , n * a);     else       printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename... T>   void read(T &...args) {     ((cin >> args), ...);   }   template <typename... T>   void write(T... args) {     ((cout << args <<    ), ...);   }   const long long MOD = 1000000007;   const long long INF = 1000000050;   const long long BIG = (long long)2e18 + 50;   const long long MX = 200010;   const double EPS = 1e-9;   long long a[MX];   bool good;   long long m;   vector<long long> g[MX];   long long sz[MX];   long long cnt[MX];   long long mx = 0;   void dfs(long long v) {     if (g[v].size() == 0)       cnt[v] = 1;     else       cnt[v] = 0;     sz[v] = a[v];     for (auto &to : g[v]) {       dfs(to);       cnt[v] += cnt[to];       sz[v] += sz[to];     }     mx = max(mx, (sz[v] + cnt[v] - 1) / cnt[v]);   }   void solve() {     long long n;     cin >> n;     long long arr[n];     for (long long i = 0; i < n; i++) cin >> arr[i];     if (n == 1) {       cout << 0 <<   n ;       return;     }     sort(arr, arr + n);     long long mid = n / 2;     long long ret1 = 0;     long long ret2 = 0;     long long arr_val[n];     for (long long i = 0; i < n; i++) {       arr_val[i] = arr[mid] - mid + i;     }     if (arr_val[0] <= 0) {       long long val = 1 - arr_val[0];       for (long long i = 0; i < n; i++) arr_val[i] += val;     }     for (long long i = 0; i < n; i++) {       ret1 += abs(arr_val[i] - arr[i]);     }     write(  n );     for (long long i = 0; i < n; i++) write(arr_val[i]);     if (n % 2 == 0) {       mid--;       for (long long i = 0; i < n; i++) {         arr_val[i] = arr[mid] - mid + i;       }       if (arr_val[0] <= 0) {         long long val = 1 - arr_val[0];         for (long long i = 0; i < n; i++) arr_val[i] += val;       }       for (long long i = 0; i < n; i++) {         ret2 += abs(arr_val[i] - arr[i]);       }     }     write(  n );     for (long long i = 0; i < n; i++) write(arr_val[i]);     if (n % 2 == 0)       cout << min(ret1, ret2);     else       cout << ret1;     cout <<   n ;   }   long long arr[201];   long long dp[201][405];   long long n;   long long recur(long long index, long long time) {     if (index == n) return 0;     if (dp[index][time] != -1) return dp[index][time];     long long ret = INT_MAX;     for (long long i = time + 1; i <= 405; i++) {       ret = min(ret, abs(arr[index] - i) + recur(index + 1, i));     }     return dp[index][time] = ret;   }   void solveA() {     cin >> n;     memset(dp, -1, sizeof(dp));     for (long long i = 0; i < n; i++) cin >> arr[i];     sort(arr, arr + n);     cout << recur(0, 0) <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     srand(chrono::high_resolution_clock::now().time_since_epoch().count());     long long x;     cin >> x;     while (x--) {       solveA();     }   }