malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 10;   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(0);     int x[4], y[4];     for (int i = 1; i <= 3; i++) {       cin >> x[i] >> y[i];     }     pair<int, pair<int, int> > e = make_pair(INF, make_pair(INF, INF));     for (int i = 0; i <= 1000; i++) {       for (int j = 0; j <= 1000; j++) {         int w = 0;         for (int u = 1; u <= 3; u++) {           w += abs(x[u] - i) + abs(y[u] - j) + 1;         }         e = min(e, make_pair(w - 2, make_pair(i, j)));       }     }     cout << e.first << endl;     for (int i = 1; i <= 3; i++) {       if (x[i] == e.second.first && y[i] == e.second.second) {         continue;       }       cout << x[i] <<     << y[i] << endl;       while (x[i] > e.second.first) {         x[i]--;         if (x[i] == e.second.first && y[i] == e.second.second) {           break;         }         cout << x[i] <<     << y[i] << endl;       }       while (x[i] < e.second.first) {         x[i]++;         if (x[i] == e.second.first && y[i] == e.second.second) {           break;         }         cout << x[i] <<     << y[i] << endl;       }       while (y[i] > e.second.second) {         y[i]--;         if (x[i] == e.second.first && y[i] == e.second.second) {           break;         }         cout << x[i] <<     << y[i] << endl;       }       while (y[i] < e.second.second) {         y[i]++;         if (x[i] == e.second.first && y[i] == e.second.second) {           break;         }         cout << x[i] <<     << y[i] << endl;       }     }     cout << e.second.first <<     << e.second.second;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[100010];   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     unsigned long long ans = 0;     for (int i = 0; i < n; i++) {       unsigned long long j, k = 0;       for (j = i; j < n; j++) {         if (a[i] != a[j]) break;         k++;       }       ans += (k * (k + 1)) / 2;       i = j - 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dp[5][5005];   double p[5005], subp[5005];   int t[5005];   double qpow(double a, int k) {     double res = 1;     while (k) {       if (k & 1) res *= a;       a *= a;       k >>= 1;     }     return res;   }   int main(int argc, const char* argv[]) {     int n, T;     scanf( %d%d , &n, &T);     for (int i = 1; i <= n; ++i) {       scanf( %lf%d , &p[i], &t[i]);       p[i] /= 100;       subp[i] = 1 - p[i];     }     int cur = 1;     dp[cur ^ 1][0] = 1;     double ans = 0;     for (int i = 1; i <= n; ++i, cur ^= 1) {       double pp = qpow(subp[i], t[i] - 1);       dp[cur][0] = 0;       for (int j = 1; j <= T; ++j) {         double tmp = dp[cur][j - 1];         if (j - 1 >= t[i]) tmp -= dp[cur ^ 1][j - 1 - t[i]] * pp;         tmp *= subp[i];         if (j >= t[i]) tmp += dp[cur ^ 1][j - t[i]] * subp[i] * pp;         tmp += dp[cur ^ 1][j - 1] * p[i];         dp[cur][j] = tmp;         ans += tmp;       }     }     printf( %.10f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 110000;   vector<int> adj[N];   long long p[N], s[N];   int main() {     ios::sync_with_stdio(0);     int n;     cin >> n;     for (int i = 2; i <= n; i++) cin >> p[i];     for (int i = 1; i <= n; i++) cin >> s[i];     for (int i = 1; i <= n; i++) {       if (~s[i]) {         int j = p[p[i]];         int k = p[i];         if (s[i] < s[j]) return puts( -1 ), 0;         adj[k].push_back(s[i] - s[j]);       }     }     long long dap = s[1];     for (int i = 1; i <= n; i++) {       if (!adj[i].empty()) {         sort(adj[i].begin(), adj[i].end());         dap += adj[i][0];         for (int x : adj[i]) dap += (x - adj[i][0]);       }     }     cout << dap << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAX_N = 200 * 1000 + 24, INF = (1 << 30);   int n;   int a[MAX_N], cnt[MAX_N], mark[MAX_N];   vector<int> G[MAX_N], vec, avb;   int main() {     cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i], a[i]--, cnt[a[i]]++;     for (int i = 0; i < n; i++)       if (cnt[i] == 0) vec.push_back(i);     for (int i = 0; i < n; i++) {       if (cnt[a[i]] > 1) {         G[a[i]].push_back(i), avb.push_back(i);         mark[a[i]] = true;       }     }     memset(mark, 0, sizeof mark);     int j = 0;     for (int i = 0; i < avb.size(); i++) {       int p = avb[i];       if (mark[a[p]] == false and           (a[p] < vec[j] or p == G[a[p]][G[a[p]].size() - 1])) {         mark[a[p]] = true;       } else {         a[p] = vec[j++];       }     }     cout << vec.size() << endl;     for (int i = 0; i < n; i++) {       cout << a[i] + 1 <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   void sublime() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   int main() {     sublime();     long long n, i, j;     cin >> n;     long long arr[n];     for (i = 0; i < n; i++) cin >> arr[i];     if (n <= 2) {       cout << 0 <<   n ;       for (i = 0; i < n; i++) cout << arr[i] <<    ;       cout <<   n ;       return 0;     } else {       sort(arr, arr + n);       vector<long long> v;       i = 0, j = (n - 1) / 2;       if (n & 1) {         while (i < (n - 1) / 2 || j < n) {           v.push_back(arr[j]);           j++;           if (i < (n - 1) / 2) {             v.push_back(arr[i]);             i++;           }         }       } else {         j = n / 2;         while (i < (n - 1) / 2 || j < n) {           v.push_back(arr[j]);           j++;           if (i < (n - 1) / 2) {             v.push_back(arr[i]);             i++;           }         }         v.push_back(arr[(n - 1) / 2]);       }       long long ans = 0;       for (i = 1; i < v.size() - 1; i += 2) {         if (v[i] < v[i + 1] && v[i] < v[i - 1]) ans++;       }       cout << ans <<   n ;       for (auto x : v) cout << x <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T modinv(T a, T n) {     T i = n, v = 0, d = 1;     while (a > 0) {       T t = i / a, x = a;       a = i % x;       i = x;       x = d;       d = v - t * x;       v = x;     }     return (v + n) % n;   }   long long modpow(long long n, long long k, long long mod) {     long long ans = 1;     while (k > 0) {       if (k & 1) ans = (ans * n) % mod;       k >>= 1;       n = (n * n) % mod;     }     return ans % mod;   }   template <class T>   string str(T Number) {     string Result;     ostringstream convert;     convert << Number;     Result = convert.str();     return Result;   }   int StringToNumber(const string &Text) {     istringstream ss(Text);     int result;     return ss >> result ? result : 0;   }   template <class T>   inline vector<pair<T, int> > FACTORISE(T n) {     vector<pair<T, int> > R;     for (T i = 2; n > 1;) {       if (n % i == 0) {         int C = 0;         for (; n % i == 0; C++, n /= i)           ;         R.push_back(make_pair(i, C));       }       i++;       if (i > n / i) i = n;     }     if (n > 1) R.push_back(make_pair(n, 1));     return R;   }   template <class T>   inline T TOTIENT(T n) {     vector<pair<T, int> > R = FACTORISE(n);     T r = n;     for (int i = 0; i < R.size(); i++) r = r / R[i].first * (R[i].first - 1);     return r;   }   template <class T>   inline T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   double rnd(float d) { return floor(d + 0.49); }   int edge[3300][3300], Pairs[3300][3300];   int match[3300];   bool seen[3300];   vector<pair<int, int> > groups;   bool bfs(int v) {     seen[v] = 1;     for (int i = 0; i < ((int)(groups).size()); i++) {       if (edge[v][i] && !seen[i]) {         seen[i] = 1;         if (match[i] == -1 || bfs(match[i])) {           match[v] = i;           match[i] = v;           return true;         }       }     }     seen[v] = 0;     return false;   }   int main() {     int n, m;     cin >> n >> m;     vector<int> A(n);     for (int i = 0; i < n; i++) {       cin >> A[i];       int x = A[i];       for (int j = 2; j * j <= A[i]; j++) {         if (j > x) break;         while (x % j == 0) {           x = x / j;           groups.push_back(make_pair(j, i));         }       }       if (x > 1) groups.push_back(make_pair(x, i));     }     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       --a, --b;       Pairs[a][b] = 1, Pairs[b][a] = 1;     }     memset(edge, 0, sizeof(edge));     for (int i = 0; i < ((int)(groups).size()); i++)       for (int j = i + 1; j < ((int)(groups).size()); j++) {         if (Pairs[groups[i].second][groups[j].second] &&             groups[i].first == groups[j].first)           edge[i][j] = 1, edge[j][i] = 1;       }     memset(match, -1, sizeof(match));     int matchings = 0;     for (int i = 0; i < ((int)(groups).size()); i++) {       if (match[i] != -1) continue;       memset(seen, false, sizeof(seen));       if (bfs(i)) matchings++;     }     cout << matchings << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int dp[205][205][205];   long long int recur(string &a, string &b, long long int index, long long int k,                       long long int curr) {     if (index == a.size()) {       return 0;     }     if (dp[index][k][curr] != -1) {       return dp[index][k][curr];     }     if (k > 0) {       if (a[index] == b[0]) {         return dp[index][k][curr] =                    max(recur(a, b, index + 1, k, curr + 1),                        curr + recur(a, b, index + 1, k - 1, curr));       } else if (a[index] == b[1]) {         return dp[index][k][curr] = max(curr + recur(a, b, index + 1, k, curr),                                         recur(a, b, index + 1, k - 1, curr + 1));       } else {         return dp[index][k][curr] =                    max(recur(a, b, index + 1, k, curr),                        max(curr + recur(a, b, index + 1, k - 1, curr),                            recur(a, b, index + 1, k - 1, curr + 1)));       }     } else {       if (a[index] == b[1]) {         return dp[index][k][curr] = curr + recur(a, b, index + 1, k, curr);       } else if (a[index] == b[0]) {         return dp[index][k][curr] = recur(a, b, index + 1, k, curr + 1);       } else {         return dp[index][k][curr] = recur(a, b, index + 1, k, curr);       }     }   }   void solve() {     long long int n, k;     cin >> n >> k;     string a, b;     cin >> a >> b;     memset(dp, -1, sizeof(dp));     if (b[0] == b[1]) {       long long int curr = 0;       for (int i = 0; i < a.size(); i++) {         if (a[i] == b[0]) {           curr++;         }       }       curr = min(curr + k, n);       long long int res = (curr) * (curr - 1);       res = res >> 1;       cout << res <<   n ;     } else {       cout << recur(a, b, 0, k, 0) <<   n ;     }     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 70 + 10;   int n, dist[MAXN * MAXN * MAXN], u[3];   char arr[MAXN][MAXN];   int a[MAXN * MAXN * MAXN], b[MAXN * MAXN * MAXN];   struct node {     int v[3] = {-1, -1, -1};     int A = -1, B = -1;     node(int v1 = -1, int v2 = -1, int v3 = -1, int A_ = -1, int B_ = -1) {       v[0] = v1;       v[1] = v2;       v[2] = v3;       A = A_;       B = B_;       sort(this->v, this->v + 3);     }     int number() { return v[0] + n * v[1] + n * n * v[2]; }     vector<node> adj() {       vector<node> adj_;       for (int j = 0; j < n; j++) {         if (j == v[0] || j == v[1] || j == v[2]) continue;         if (arr[v[1]][v[2]] == arr[v[0]][j])           adj_.push_back(node(v[1], v[2], j, v[0], j));         if (arr[v[0]][v[2]] == arr[v[1]][j])           adj_.push_back(node(v[0], v[2], j, v[1], j));         if (arr[v[1]][v[0]] == arr[v[2]][j])           adj_.push_back(node(v[1], v[0], j, v[2], j));       }       return adj_;     }   } Q[MAXN * MAXN * MAXN], par[MAXN * MAXN * MAXN];   int main() {     ios::sync_with_stdio(0);     cin >> n;     cin >> u[0] >> u[1] >> u[2];     u[0]--;     u[1]--;     u[2]--;     memset(dist, 63, sizeof(dist));     dist[node(u[0], u[1], u[2]).number()] = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> arr[i][j];       }     }     int L = 0, R = 0;     Q[R++] = node(u[0], u[1], u[2]);     while (L < R) {       node tp = Q[L++];       for (auto i : tp.adj())         if (dist[i.number()] == dist[MAXN * MAXN * MAXN - 1]) {           dist[i.number()] = dist[tp.number()] + 1;           Q[R++] = i;           par[i.number()] = tp;           a[i.number()] = i.A;           b[i.number()] = i.B;         }     }     if (dist[node(0, 1, 2).number()] != dist[MAXN * MAXN * MAXN - 1]) {       cout << dist[node(0, 1, 2).number()] <<   n ;       vector<pair<int, int>> answer;       node me = node(0, 1, 2);       for (int i = 0; i < dist[node(0, 1, 2).number()]; i++) {         answer.push_back(pair<int, int>(a[me.number()], b[me.number()]));         me = par[me.number()];       }       reverse(answer.begin(), answer.end());       for (auto i : answer) cout << i.first + 1 <<     << i.second + 1 <<   n ;     } else       cout << -1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> prime;   int y;   int checker(int n) {     for (int i = 0; i < y && i < n; i++) {       if (prime[i] + prime[i + 1] + 1 == n) return 1;       if (prime[i] + prime[i + 1] + 1 > n) return 0;     }   }   int isprime(int n) {     int x = sqrt(n);     for (int i = 2; i <= x; i++) {       if (n % i == 0) return 0;     }     return 1;   }   int main() {     int n, k, counter = 0;     cin >> n >> k;     prime.push_back(2);     prime.push_back(3);     prime.push_back(5);     y = 3;     for (int i = 7; i <= n; i++) {       if (isprime(i)) {         prime.push_back(i);         y++;         if (checker(i)) counter++;         if (counter >= k) break;       }     }     if (counter >= k)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, m, r, l, h, i, ii, j, x[1000001], y[1000001], z, g, a, b, c, d,       k, mod = 1e9 + 7, q;   vector<long long> v;   vector<pair<long long, long long> > vv;   queue<pair<long long, long long> > qq;   pair<long long, long long> p[1000001];   map<long long, long long> mp, mpp, mppp;   set<pair<long long, long long> > se[1000001];   multiset<long long> sw;   multiset<long long>::iterator it;   string s;   char cc;   int main() {     ios::sync_with_stdio(0);     cin >> t;     while (t--) {       mp.clear();       cin >> n;       b = 0;       for (i = 0; i < n; i++) cin >> x[i];       sort(x, x + n);       for (i = 0; i < n; i++) {         mp[x[i] % 2]++;         if (x[i] == x[i - 1] + 1 && i > 0) b = 1;       }       a = mp[0] % 2;       c = mp[1] % 2;       if ((a == c && a == 0) || (a == c && a == 1 && b == 1))         cout <<  YES ;       else         cout <<  NO ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool comp1(int& a, int& b);   int64_t gcd(int64_t a, int64_t b);   bool comp2(int& a, int& b);   bool comp3(pair<int, int>& a, pair<int, int>& b);   bool comp4(pair<int, int>& a, pair<int, int>& b);   bool isPrime(int& x);   void input(vector<int>& v, int& n) {     for (int i = 0; i < n; ++i) {       cin >> v[i];     }   }   int sum(vector<int>& v) {     int s = 0;     for (auto& el : v) {       s += el;     }     return s;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     int64_t ans = 1;     set<char> simbols;     int cntQ = 0;     ;     for (size_t i = 0; i < s.size(); ++i) {       if (s[i] ==  ? ) {         cntQ++;       } else if (s[i] >=  A  && s[i] <=  J ) {         simbols.insert(s[i]);       }     }     int k = 10;     int size = simbols.size();     if (s[0] ==  ? ) {       ans = 9;       cntQ--;     } else if (s[0] >=  A  && s[0] <=  J ) {       size--;       k--;       ans = 9;     }     for (int i = 0; i < size; ++i) {       ans *= k;       k--;     }     string g;     while (ans > 0) {       g += (ans % 10 +  0 );       ans /= 10;     }     reverse(g.begin(), g.end());     for (int i = 0; i < cntQ; ++i) {       g +=  0 ;     }     cout << g;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, ara[500005], k, ara2[500005];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long l, h, i, j, m, z, t, o, a, b;     cin >> n >> k;     a = 0;     for (i = 0; i < n; i++) cin >> ara[i];     l = 1;     h = 10000000000;     z = 0;     while (l < h) {       m = (l + h) / 2;       t = 0;       for (i = 0; i < n; i++) t += max(m - ara[i], z);       if (t <= k)         l = m + 1;       else         h = m - 1;     }     o = 1;     for (j = (max(o, l - 50)); j < l + 50; j++) {       t = 0;       for (i = 0; i < n; i++) t += max(j - ara[i], z);       if (t > k) {         if (j == 1)           l = j;         else           l = j - 1;         break;       }     }     t = 0;     for (i = 0; i < n; i++) {       t += max(l - ara[i], z);       ara[i] = max(ara[i], l);     }     for (i = 0; i < n; i++) {       if (ara[i] == l && k != t) {         ara[i]++;         t++;       }     }     l = 1;     h = 10000000000;     z = 0;     while (l < h) {       m = (l + h) / 2;       t = 0;       for (i = 0; i < n; i++) t += max(ara[i] - m, z);       if (t <= k)         h = m;       else         l = m + 1;     }     for (j = h + 50; j >= max(o, h - 50); j--) {       t = 0;       for (i = 0; i < n; i++) t += max(ara[i] - j, z);       if (t > k) {         l = j + 1;         break;       }     }     t = 0;     for (i = 0; i < n; i++) {       t += max(ara[i] - l, z);       ara[i] = min(ara[i], l);     }     for (i = 0; i < n; i++) {       if (ara[i] == l && k != t) {         ara[i]--;         t++;       }     }     sort(ara, ara + n);     cout << ara[n - 1] - ara[0];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 7;   const long long mxN = 1e5 + 1;   vector<long long> dat;   long long arr[4000], n;   bool dp[2001];   void solve() {     cin >> n;     n *= 2;     long long p = 0, temp = 0;     for (long long i = 0; i < n; i++) {       cin >> arr[i];     }     dat.clear();     long long i = 0;     while (i < n) {       long long j = i + 1;       while (j < n && arr[i] > arr[j]) {         j++;       }       dat.push_back(j - i);       i = j;     }     memset(dp, 0, sizeof(dp));     dp[0] = true;     for (long long i = 0; i < dat.size(); i++) {       for (long long j = n / 2; j >= 0; j--) {         if (j + dat[i] <= n / 2) dp[j + dat[i]] = dp[j] | dp[j + dat[i]];       }     }     dp[n / 2] ? cout <<  YES n  : cout <<  NO n ;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long T = 1, t = 0;     cin >> T;     while (t++ < T) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int a[10000], b[10000], f[10000000];   int main() {     int n, ans = 0;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       f[a[i]] = 1;     }     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       f[b[i]] = 1;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (f[a[i] ^ b[j]]) ans++;       }     }     if (ans % 2 == 0)       printf( Karen n );     else       printf( Koyomi n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double CHANGE = 1e-8;   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;     }   };   int main() {     puts( YES );     int n;     scanf( %d , &n);     while (n--) {       int x1, y1, x2, y2;       scanf( %d%d%d%d , &x1, &y1, &x2, &y2);       int ans = 0;       if (abs(min(x1, x2)) % 2) ans ^= 1;       if (abs(min(y1, y2)) % 2) ans ^= 2;       printf( %d n , ans + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     if (n % 2 == 0) {       cout <<  NO  <<   n ;       return 0;     }     int arr[200005] = {0};     deque<int> d;     for (int i = 0; i < 2 * n; i++) d.push_back(i + 1);     for (int i = 0; i < n; i++) {       if (i % 2 == 0) {         arr[i] = d.front();         d.pop_front();         arr[i + n] = d.front();         d.pop_front();       } else {         arr[i] = d.back();         d.pop_back();         arr[i + n] = d.back();         d.pop_back();       }     }     cout <<  YES  <<   n ;     for (int i = 0; i < 2 * n; i++) cout << arr[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   int n;   int fa[maxn];   bool vis[maxn];   int cnt_loop = 0;   vector<int> loop[maxn];   void get(int x, int id) {     vis[x] = 1;     loop[id].push_back(x);     if (vis[fa[x]]) return;     get(fa[x], id);   }   bool num[maxn];   int rid[maxn];   int main() {     scanf( %d , &n);     for (register int i = 1; i <= n; i++) {       scanf( %d , &fa[i]);     }     for (register int i = 1; i <= n; i++) {       if (!vis[i]) get(i, ++cnt_loop);     }     bool fg2 = 0;     for (register int i = 1; i <= cnt_loop; i++) {       num[loop[i].size()] = 1;       rid[loop[i].size()] = i;       if (((int)loop[i].size()) & 1) {         fg2 = 1;       }     }     if (num[1]) {       printf( YES n );       for (register int i = 1; i <= cnt_loop; i++) {         if (rid[1] == i) continue;         for (register int j = 0; j < (int)loop[i].size(); j++) {           printf( %d %d n , loop[rid[1]][0], loop[i][j]);         }       }     } else if (num[2] && !fg2) {       printf( YES n );       for (register int i = 1; i <= cnt_loop; i++) {         if (rid[2] == i) {           printf( %d %d n , loop[i][0], loop[i][1]);           continue;         }         for (register int j = 0; j < (int)loop[i].size(); j++) {           printf( %d %d n , loop[rid[2]][j & 1], loop[i][j]);         }       }     } else {       printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   template <typename T>   inline T Bigmod(T base, T power, T MOD) {     T ret = 1;     while (power) {       if (power & 1) ret = (ret * base) % MOD;       base = (base * base) % MOD;       power >>= 1;     }     return ret;   }   bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {     return (a.first > b.first);   }   int main() {     ios::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       map<int, int> ind;       for (int i = 0; i < n; i++) {         cin >> arr[i];         ind[arr[i]] = i + 1;       }       int l, r;       l = ind[1];       string s;       s.push_back( 1 );       if (n > 1) {         int in = ind[2];         if (in > l)           r = in;         else {           r = l;           l = in;         }         if ((r - l) <= 1)           s.push_back( 1 );         else           s.push_back( 0 );       }       for (int i = 3; i <= n; i++) {         int in = ind[i];         if (in < l) {           if ((r - in) < i) {             s.push_back( 1 );           } else {             s.push_back( 0 );           }           l = in;         } else if (in > r) {           if ((in - l) < i) {             s.push_back( 1 );           } else {             s.push_back( 0 );           }           r = in;         } else {           if ((r - l) < i)             s.push_back( 1 );           else             s.push_back( 0 );         }       }       cout << s << endl;     }     return 0;   }