malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   double x1, yy1, x2, y2, v, t, vx, vy, wx, wy, l, r, mid, x, y, dis;   int main() {     scanf( %lf%lf , &x1, &yy1);     scanf( %lf%lf , &x2, &y2);     scanf( %lf%lf , &v, &t);     scanf( %lf%lf , &vx, &vy);     scanf( %lf%lf , &wx, &wy);     l = 0.0;     r = 1e9;     for (int i = 1; i <= 1000; ++i) {       mid = (l + r) / 2;       x = x2 - x1 - min(t, mid) * vx - max(0.0, mid - t) * wx;       y = y2 - yy1 - min(t, mid) * vy - max(0.0, mid - t) * wy;       dis = sqrt(x * x + y * y);       if (v * mid > dis)         r = mid;       else         l = mid;     }     printf( %.10lf n , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 2;   struct {     int x;     int last;     string it;   } a;   struct kek {     string w, e, r, t;   };   map<char, int> bak;   vector<string> st[N + 5][7], q;   vector<pair<string, string> > be, en;   vector<kek> ans;   int n, m;   string ins;   char c;   bool frog = false;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     bak[ u ] = 1;     bak[ a ] = 2;     bak[ o ] = 3;     bak[ e ] = 4;     bak[ i ] = 5;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> ins;       m = ins.length();       a.x = 0;       a.last = 0;       for (int j = 0; j < m; j++) {         if (ins[j] ==  u  || ins[j] ==  a  || ins[j] ==  o  || ins[j] ==  e  ||             ins[j] ==  i ) {           a.x++;           c = ins[j];           a.last = bak[c];         }       }       a.it = ins;       st[a.x][a.last].push_back(ins);     }     for (int i = 1; i <= N; i++) {       q.clear();       for (int j = 1; j <= 5; j++) {         int k;         for (k = 1; k < st[i][j].size(); k += 2) {           en.push_back({st[i][j][k], st[i][j][k - 1]});         }         if (k == st[i][j].size()) {           q.push_back(st[i][j][k - 1]);         }       }       for (int j = 1; j < q.size(); j += 2) {         be.push_back({q[j], q[j - 1]});       }     }     while (!be.empty() && !en.empty()) {       ans.push_back(           {be.back().first, en.back().first, be.back().second, en.back().second});       en.pop_back();       be.pop_back();     }     for (int i = 1; i < en.size(); i += 2) {       ans.push_back(           {en[i].first, en[i - 1].first, en[i].second, en[i - 1].second});     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); ++i) {       cout << ans[i].w <<     << ans[i].e << endl            << ans[i].r <<     << ans[i].t << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int N = 300009;   void swap(char *p, char *q) {     char temp = *p;     *p = *q;     *q = temp;     return;   }   long long int powxy(long long int x, long long int y) {     if (y == 0) return 1;     if (y % 2 == 1) return (x * powxy(x, y - 1)) % MOD;     long long int t = powxy(x, y / 2) % MOD;     return (t * t) % MOD;   }   vector<pair<int, int> > adj[N];   int dp[500005];   vector<int> ans[500001];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       int ans = 1;       string s;       long long int n;       cin >> n >> s;       string temp = s;       for (int i = 0; i < n; i++) {         if ((i + 1) % 2 != 0) {           string q = s.substr(0, i);           if ((n - i + 1) % 2 == 0) reverse(q.begin(), q.end());           string p = s.substr(i, n - i) + q;           if (p < temp) {             temp = p;             ans = i + 1;           }         } else {           string q = s.substr(0, i);           reverse(q.begin(), q.end());           if ((n - i + 1) % 2 != 0) reverse(q.begin(), q.end());           string p = s.substr(i, n - i) + q;           if (p < temp) {             temp = p;             ans = i + 1;           }         }       }       cout << temp <<   n ;       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &a) {     register int b = 1, c = getchar();     a = 0;     for (; !isdigit(c); c = getchar())       if (c == 45) b *= -1;     for (; isdigit(c); c = getchar()) a = (a << 3) + (a << 1) + c - 48;     a *= b;   }   const int maxn = 105;   const int maxm = 1 << 18;   long long dp[maxm][maxn];   string str;   int len;   int m;   int main() {     cin >> str;     len = int((str).size());     read(m);     dp[0][0] = 1;     for (int msk = 0; msk < int(1 << len); msk++) {       for (int rem = 0; rem < int(m); rem++) {         for (int j = 0; j < int(len); j++)           if (!(msk & (1 << j))) {             int nwrem = (rem * 10 + str[j] -  0 ) % m;             int nwmsk = msk | (1 << j);             if (!msk && str[j] ==  0 ) continue;             dp[nwmsk][nwrem] += dp[msk][rem];           }       }     }     long long ans = dp[(1 << len) - 1][0];     for (int i = 0; i < int(10); i++) {       int cnt = 0;       for (int j = 0; j < int(len); j++) {         if (str[j] == i + 48) cnt++;       }       long long fac = 1;       for (int j = 1; j <= cnt; j++) fac *= j;       ans /= fac;     }     printf( %I64d n , ans);     return 0;   }
#include<bits/stdc++.h>   #define ll long long int   using namespace std;       int main()    {     int t;     cin>>t;     while(t--)     {      ll a, b, c;      cin>>a>>b>>c;            if((a+b+c)%9 == 0 && min(a, min(b,c)) >= (a+b+c)/9)       cout<< YES <<endl;      else       cout<< NO <<endl;     }    }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     if (k % 2 == 1) {       cout << 1 << endl;       return 0;     }     long long x = log2(k);     long long y = pow(2, x) - k;     while (y != 0) {       x = log2(y);       y = pow(2, x) - y;     }     cout << x + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1000000007;   const long long N = 1e5;   long long expo(long long x, long long y) {     long long res = 1;     x = x % M;     while (y > 0) {       if (y & 1) res = (res * x) % M;       y = y >> 1;       x = (x * x) % M;     }     return (res) % M;   }   string binary(long long n) {     if (n == 0) return  0 ;     string s;     while (n > 0) {       if (n & 1)         s +=  1 ;       else         s +=  0 ;       n >>= 1;     }     reverse(s.begin(), s.end());     return s;   }   bool isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i = i + 6) {       if (n % i == 0 || n % (i + 2) == 0) return false;     }     return true;   }   long long ncr(long long n, long long r) {     if (r > n - r) r = n - r;     long long ans = 1;     for (long long k = 0; k < r; k++) {       ans *= (n - k);       ans /= (k + 1);     }     return ans;   }   void solve() {     long long n, d;     cin >> n >> d;     if (n >= d) {       cout <<  YES n ;       return;     }     long long val = n / 2 + ceil(d / (1.0 * (n / 2 + 1)));     if (val <= n) {       cout <<  YES n ;     } else {       cout <<  NO n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     ;     long long test = 1;     cin >> test;     while (test--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = (int)1e9 + 207;   const int N = (int)1e6 + 2;   long long n, m, s, t;   long long cnt1[N], cnt2[N];   long long D1[N], D2[N];   vector<pair<long long, long long> > G1[N], G2[N];   vector<pair<long long, pair<long long, long long> > > edge;   void solve1() {     priority_queue<pair<long long, long long>,                    vector<pair<long long, long long> >,                    greater<pair<long long, long long> > >         pq;     for (int i = 0; i <= n; i++) D1[i] = 1e14;     D1[s] = 0;     cnt1[s] = 1;     pq.push(pair<long long, long long>(D1[s], s));     while (!pq.empty()) {       long long du = pq.top().first;       long long u = pq.top().second;       pq.pop();       if (du != D1[u]) continue;       for (int i = 0; i < G1[u].size(); i++) {         long long v = G1[u][i].first;         long long w = G1[u][i].second;         if (D1[v] > du + w) {           D1[v] = du + w;           cnt1[v] = cnt1[u];           pq.push(pair<long long, long long>(D1[v], v));         } else if (D1[v] == du + w) {           cnt1[v] += cnt1[u];         }         cnt1[v] %= mod;       }     }   }   void solve2() {     priority_queue<pair<long long, long long>,                    vector<pair<long long, long long> >,                    greater<pair<long long, long long> > >         pq;     for (int i = 0; i <= n; i++) D2[i] = 1e14;     D2[t] = 0;     cnt2[t] = 1;     pq.push(pair<long long, long long>(D2[t], t));     while (!pq.empty()) {       long long du = pq.top().first;       long long u = pq.top().second;       pq.pop();       if (du != D2[u]) continue;       for (int i = 0; i < G2[u].size(); i++) {         long long v = G2[u][i].first;         long long w = G2[u][i].second;         if (D2[v] > du + w) {           D2[v] = du + w;           cnt2[v] = cnt2[u];           pq.push(pair<long long, long long>(D2[v], v));         } else if (D2[v] == du + w) {           cnt2[v] += cnt2[u];         }         cnt2[v] %= mod;       }     }   }   int main() {     cin >> n >> m >> s >> t;     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       edge.push_back(pair<long long, pair<long long, long long> >(           w, pair<long long, long long>(u, v)));       G1[u].push_back(pair<long long, long long>(v, w));       G2[v].push_back(pair<long long, long long>(u, w));     }     solve1();     solve2();     for (int i = 0; i < m; i++) {       long long u = edge[i].second.first;       long long v = edge[i].second.second;       long long w = edge[i].first;       if (D1[u] + w + D2[v] == D1[t] &&           ((1LL * cnt1[u] * cnt2[v]) % mod) == cnt1[t]) {         cout <<  YES n ;       } else if (D1[u] + D2[v] + 1 < D1[t]) {         cout <<  CAN   << w - (D1[t] - D1[u] - D2[v] - 1) <<   n ;       } else         cout <<  NO n ;     }   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, w = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) w = -1;       c = getchar();     }     while (c <=  9  && c >=  0 ) {       x = (x << 1) + (x << 3) + c -  0 ;       c = getchar();     }     return w == 1 ? x : -x;   }   int r[40][40], v[40][40], n, m, ans = -1e9, bin[40];   inline int F(int x, int y) { return r[x][y] ? -v[x][y] : v[x][y]; }   inline int query(int x, int y, int d) {     r[x][y] = d;     r[x + m][y] = r[m][y] ^ d;     r[x][y + m] = r[x][m] ^ d;     r[x + m][y + m] = r[m][y + m] ^ r[x][y + m];     return F(x, y) + F(x + m, y) + F(x, y + m) + F(x + m, y + m);   }   inline int query(int y, int d) {     int res = 0;     r[m][y] = d;     r[m][y + m] = r[m][m] ^ d;     res += F(m, y) + F(m, y + m);     for (int x = 1; x < m; x++) res += max(query(x, y, 0), query(x, y, 1));     return res;   }   inline int calc() {     int res = 0;     for (int x = 1; x <= n; x++) res += F(x, m);     for (int y = 1; y < m; y++) res += max(query(y, 0), query(y, 1));     return res;   }   int main() {     n = read();     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) v[i][j] = read();     m = (n + 1) >> 1;     ans = -1e9;     bin[0] = 1;     for (int i = 1; i <= m + 1; i++) bin[i] = bin[i - 1] << 1;     for (int zt = 0; zt < bin[m]; zt++) {       for (int x = 1; x <= m; x++) r[x][m] = zt >> (x - 1) & 1;       for (int x = 1; x < m; x++) r[x + m][m] = r[m][m] ^ r[x][m];       ans = max(ans, calc());     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const int maxn = 1e5 + 5;   const int Inf = 1e9 + 7;   int main() {     int a, b;     while (cin >> a >> b) {       if (a == 0 && b == 0) {         printf( NO n );       } else if (abs(a - b) <= 1) {         printf( YES n );       } else {         printf( NO n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   void ran() { srand(chrono::steady_clock::now().time_since_epoch().count()); }   long long get_rand() {     long long a = rand();     long long b = rand();     return a * (RAND_MAX + 1ll) + b;   }   void solve() {     int n, m;     cin >> n >> m;     vector<int> subs[n + 1], inc[n + 1];     int labels[n + 1];     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       subs[a].push_back(b);       inc[b].push_back(a);     }     vector<int> rem;     for (int i = 1; i <= n; i++) {       int from0 = 0, from1 = 0, from2 = 0, total = 0;       for (auto x : inc[i]) {         total++;         if (labels[x] == 0) {           from0++;         } else if (labels[x] == 1) {           from1++;         } else {           from2++;         }       }       if (from2 == total) {         labels[i] = 0;       } else if (from1 == 0) {         labels[i] = 1;       } else {         rem.push_back(i);         labels[i] = 2;       }     }     cout << rem.size() << endl;     for (auto x : rem) cout << x <<    ;     cout << endl;   }   signed main() {     ran();     fast();     int t = 1;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   int main() {     long n, k, a, b, a2 = {0}, a3 = {0}, a5 = {0}, b2 = {0}, b3 = {0}, b5 = {0};     scanf( %d %d , &a, &b);     k = 1;     while (k == 1) {       if (a % 2 == 0) {         a = a / 2;         a2++;       } else         k = 0;     }     k = 1;     while (k == 1) {       if (a % 3 == 0) {         a = a / 3;         a3++;       } else         k = 0;     }     k = 1;     while (k == 1) {       if (a % 5 == 0) {         a = a / 5;         a5++;       } else         k = 0;     }     k = 1;     while (k == 1) {       if (b % 2 == 0) {         b = b / 2;         b2++;       } else         k = 0;     }     k = 1;     while (k == 1) {       if (b % 3 == 0) {         b = b / 3;         b3++;       } else         k = 0;     }     k = 1;     while (k == 1) {       if (b % 5 == 0) {         b5++;         b = b / 5;       } else         k = 0;     }     if (a != b)       printf( -1 );     else       printf( %d , abs(a2 - b2) + abs(a3 - b3) + abs(a5 - b5));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct segment {     int pos;     int len;     int type;   };   struct segmentByLength {     segment seg;     bool operator<(segmentByLength o) const {       segment seg2 = o.seg;       if (seg.len != seg2.len)         return seg.len > seg2.len;       else {         return seg.pos < seg2.pos;       }     }   };   struct segmentByPosition {     segment seg;     bool operator<(segmentByPosition o) const {       segment seg2 = o.seg;       return seg.pos < seg2.pos;     }   };   set<segmentByLength> lengthSet;   set<segmentByPosition> positionSet;   void add_segment(segment s) {     lengthSet.insert({s});     positionSet.insert({s});   }   void remove_segment(segment s) {     lengthSet.erase({s});     positionSet.erase({s});   }   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     a.push_back(1000000001);     int start = 0;     for (int i = 0; i < a.size(); i++) {       if (i > 0 and a[i] != a[i - 1]) {         segment s = {start, (i - 1) - start + 1, a[i - 1]};         lengthSet.insert({{s}});         positionSet.insert({{s}});         start = i;       }     }     int sol = 0;     while (!lengthSet.empty()) {       segment s = (*lengthSet.begin()).seg;       segment left, right;       bool leftExists = true, rightExists = true;       auto lbIterator = positionSet.lower_bound({s});       if (lbIterator != positionSet.begin()) {         --lbIterator;         left = (*lbIterator).seg;       } else {         leftExists = false;       }       auto ubIterator = positionSet.upper_bound({s});       if (ubIterator != positionSet.end()) {         right = (*ubIterator).seg;       } else {         rightExists = false;       }       remove_segment(s);       if (leftExists and rightExists and left.type == right.type) {         segment merged = {left.pos, left.len + right.len, left.type};         remove_segment(left);         remove_segment(right);         add_segment(merged);       }       sol++;     }     cout << sol <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long input[(long long)1e5 + 1];   long long ans = 0;   long long n;   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> input[i];     for (int i = n - 2; i >= 0; i--) {       if (input[i] > input[i + 1]) ans += input[i] - input[i + 1];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 5;   int a[MAXN], x, f, b, n;   vector<int> v;   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     cin >> f >> b;     sort(a, a + n);     n = unique(a, a + n) - a;     for (int i = 0; i < n; i++) v.push_back(a[i]);     int tmp;     while (f != b) {       tmp = f - 1;       for (int i = v.size() - 1; ~i; i--) {         if (f - f % v[i] < b)           v.erase(v.begin() + i);         else           tmp = min(tmp, f - f % v[i]);       }       x++;       f = tmp;     }     cout << x;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long d = 20;   long long n, m, dsu[80], cc[80], al[40], dp[1ll << d];   long long fd(long long x) {     if (dsu[x] != x) {       dsu[x] = fd(dsu[x]);     }     return dsu[x];   }   int main() {     long long i, ii, k, l, mk, mk2, z[4] = {1, 1, 1, 0};     scanf( %lld%lld , &n, &m);     if (!m) {       printf( 0 n );       return 0;     }     for (i = 0; i < n * 2; i++) {       dsu[i] = i;       cc[i] = 1;     }     for (i = 0; i < m; i++) {       scanf( %lld%lld , &k, &l);       k--;       l--;       for (ii = 0; ii < 2; ii++) {         if (fd(k) != fd(n + l)) {           cc[fd(k)] += cc[fd(n + l)];           dsu[fd(n + l)] = fd(k);         }         al[k] |= 1ll << l;         swap(k, l);       }     }     for (i = 0; i < n * 2; i++) {       z[0] *= i >= n || fd(i) != fd(n + i);     }     for (i = 0; i < n; i++) {       if (fd(i) != fd(n + i)) {         cc[fd(i)] += cc[fd(n + i)];         dsu[fd(n + i)] = fd(i);       }     }     for (i = 0; i < n * 2; i++) {       if (fd(i) == i) {         z[0] *= 2;         z[1] *= 2;         z[2] *= 1 + (fd(i) == i && cc[i] == 2);       }     }     for (mk = 0; mk < 1ll << min(d, n); mk++) {       for (i = 0; i < min(d, n); i++) {         if ((mk >> i & 1) && (mk & al[i])) {           break;         }       }       dp[mk] += i >= min(d, n);     }     for (i = 0; i < min(d, n); i++) {       for (mk = (1ll << min(d, n)) - 1; mk + 1; mk--) {         dp[mk] += dp[mk ^ 1ll << i] * (mk >> i & 1);       }     }     for (mk = 0; mk < 1ll << n; mk += 1ll << min(d, n)) {       for (i = min(d, n); i < n; i++) {         if ((mk >> i & 1) && (mk & al[i])) {           break;         }       }       if (i < n) {         continue;       }       mk2 = 0;       for (i = 0; i < min(d, n); i++) {         mk2 |= (long long)!(mk & al[i]) << i;       }       z[3] += dp[mk2];     }     printf( %lld n , (1ll << n) - z[1] - z[3] * 2 + z[0] + z[2] * 2);   }
#include <bits/stdc++.h>   using namespace std;   int g[100010];   int main(void) {     int A, T, N, M;     scanf( %d , &N);     for (int i = (int)(3); i <= (int)(N); i++) {       set<int> st;       A = 2000000000;       for (int j = (int)(2); j <= (int)(N); j++) {         int k = i - j * (j + 1) / 2;         if (k < 0) break;         if (k % j != 0) continue;         int l = 1 + k / j, r = j + k / j, nim = 0;         while (l <= r) {           nim = nim ^ g[l++];         }         st.insert(nim);         if (nim == 0) A = min(A, j);       }       int res = 0;       while (st.find(res) != st.end()) res++;       g[i] = res;     }     if (g[N])       printf( %d n , A);     else       printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int n, m;   char ch[20][120];   int l[20], r[20], visit[20], dp[20][2];   int main() {     while (~scanf( %d%d , &n, &m)) {       memset(visit, 0, sizeof visit);       memset(r, 0, sizeof r);       memset(l, 0, sizeof l);       for (int i = n; i >= 1; i--) {         scanf( %s , ch[i] + 1);         for (int j = 2; j <= m + 1; j++)           if (ch[i][j] ==  1 ) {             l[i] = j;             visit[i] = 1;             break;           }         for (int j = m + 1; j >= 2; j--)           if (ch[i][j] ==  1 ) {             r[i] = j;             break;           }       }       int x = n;       while (!visit[x--] && x >= 1) n--;       if (n == 1) {         printf( %d n , r[1] ? r[1] - 1 : 0);         continue;       }       memset(dp, INF, sizeof dp);       dp[1][0] = r[1] ? (r[1] - 1) * 2 : 0, dp[1][1] = m + 1;       for (int i = 2; i < n; i++) {         if (!visit[i]) {           dp[i][0] = dp[i - 1][0] + 1;           dp[i][1] = dp[i - 1][1] + 1;           continue;         }         dp[i][0] = min(dp[i - 1][0] + 2 * (r[i] - 1) + 1, dp[i][0]);         dp[i][0] = min(dp[i - 1][1] + m + 1 + 1, dp[i][0]);         dp[i][1] = min(dp[i - 1][1] + 2 * (m + 2 - l[i]) + 1, dp[i][1]);         dp[i][1] = min(dp[i - 1][0] + m + 1 + 1, dp[i][1]);       }       int ans = min(dp[n - 1][0] + r[n], dp[n - 1][1] + 1 + m + 2 - l[n]);       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void pr(vector<T> &v) {     for (int i = 0; i < (int)(v).size(); i++) cout << v[i] <<    ;     cout << endl;   }   template <typename T>   void pr(vector<vector<T>> &v) {     for (int i = 0; i < (int)(v).size(); i++) {       pr(v[i]);     }   }   template <typename T>   void re(T &first) {     cin >> first;   }   template <typename T>   void re(vector<T> &a) {     for (int i = 0; i < (int)(a).size(); i++) re(a[i]);   }   template <class Arg, class... Args>   void re(Arg &first, Args &...rest) {     re(first);     re(rest...);   }   template <typename T>   void pr(T first) {     cout << first << endl;   }   template <class Arg, class... Args>   void pr(const Arg &first, const Args &...rest) {     cout << first <<    ;     pr(rest...);     cout << endl;   }   void ps() { cout << endl; }   template <class T, class... Ts>   void ps(const T &t, const Ts &...ts) {     cout << t;     if (sizeof...(ts)) cout <<    ;     ps(ts...);   }   int n;   vector<int> cur;   int cnt(vector<int> &v, int mn) {     int a = 0;     for (int i = 0; i < (int)(v).size(); i++) {       if (mn < n && v[i] == cur[mn]) {         mn++;         a++;       }     }     return (int)(v).size() - a;   }   int rec(vector<int> v, int mn) {     if ((int)(v).size() == 0) return 0;     int ind = 0;     for (int i = 0; i < (int)(v).size(); i++) {       if (v[i] == cur[mn]) ind = i;     }     int xx = cnt(v, mn);     v.erase(v.begin() + ind);     int yy = 1 + rec(v, mn + 1);     int ack = min(xx, yy);     return ack;   }   void solve() {     re(n);     vector<int> a(n);     re(a);     cur.clear();     cur = a;     sort(cur.begin(), cur.end());     pr(rec(a, 0));   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     re(t);     for (int tt = 0; tt < t; tt++) {       solve();     }   }