malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   int t, n, cnt = 0, ans = 0, tot = 0, num[maxn] = {}, zz[maxn] = {},             b[maxn] = {};   vector<int> k[maxn];   int powmod(int a, int b) {     int ans = 1;     for (; b; b >>= 1, a = a * a)       if (b & 1) ans = ans * a;     return ans;   }   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   void div(int n) {     int m = n;     for (int i = 2; i * i <= n; i++) {       if (m % i == 0) {         zz[++cnt] = i, num[cnt] = 0;         while (m % i == 0) m /= i, num[cnt]++;       }     }     if (m > 1) zz[++cnt] = m, num[cnt] = 1;   }   void dfs(int x, int y, int z) {     if (x > cnt) {       if (y != 1) k[z].push_back(y);       return;     }     dfs(x + 1, y, z);     if (z == 0) z = x;     for (int i = 1; i <= num[x]; i++) dfs(x + 1, y * powmod(zz[x], i), z);   }   void calc() {     for (int i = 1; i < tot; i++)       if (gcd(b[i], b[i + 1]) == 1) ans++;     if (gcd(b[tot], b[1]) == 1) ans++;   }   int main() {     scanf( %d , &t);     while (t--) {       ans = tot = cnt = 0;       scanf( %d , &n);       div(n);       for (int i = 1; i <= cnt; i++) k[i].clear();       dfs(1, 1, 0);       for (int i = 1; i <= cnt; i++) {         int x = -1, y = -1;         for (int j = 0; j < k[i].size(); j++) {           if (k[i][j] % zz[((i + cnt - 2) % cnt + cnt) % cnt + 1] == 0) {             x = k[i][j], k[i].erase(k[i].begin() + j);             break;           }         }         for (int j = 0; j < k[i].size(); j++) {           if (k[i][j] % zz[i % cnt + 1] == 0) {             y = k[i][j], k[i].erase(k[i].begin() + j);             break;           }         }         if (x != -1) b[++tot] = x;         for (int j = 0; j < k[i].size(); j++) b[++tot] = k[i][j];         if (y != -1) b[++tot] = y;       }       for (int i = 1; i <= tot; i++) printf( %d  , b[i]);       calc();       printf(  n%d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[101][101];   int n, i, j;   int main() {     cin >> n;     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++) cin >> a[i][j];     }     for (i = 0; i < n - 2; i++) {       if (a[i][0] ==  # ) {         cout <<  NO  << endl;         return 0;       }       for (j = 1; j < n; j++) {         if (a[i][j] ==  # ) {           if (a[i + 1][j] ==  #  && a[i + 1][j - 1] ==  #  &&               a[i + 1][j + 1] ==  #  && a[i + 2][j] ==  # ) {             a[i + 1][j] =  . ;             a[i + 1][j - 1] =  . ;             a[i + 1][j + 1] =  . ;             a[i + 2][j] =  . ;           } else {             cout <<  NO  << endl;             return 0;           }         }       }     }     for (; i < n; i++) {       for (j = 0; j < n; j++) {         if (a[i][j] ==  # ) {           cout <<  NO  << endl;           return 0;         }       }     }     cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, x, y;     cin >> n >> x >> y;     long long a = y - n + 1;     long long b = x - n + 1;     for (long long i = a; i >= 1; i--) {       long long c = i * i;       if (c >= b) {         for (int j = 1; j <= n - 1; j++) cout <<  1  << endl;         cout << i << endl;         return 0;       }     }     cout <<  -1  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     cin >> a >> b;     if (b == 1 && a == 9) {       cout <<  9 10  << endl;     } else if (b - a == 1) {       cout << a <<     << b << endl;     } else if (a == b) {       cout << a <<  1   << b <<  2  << endl;     } else {       cout <<  -1  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int L = 1;   int R = 0;   int cnt[300005];   int a[300005];   int big[300005][2];   int is1 = 0;   int ap[300005];   vector<int> st;   void in(int id) {     id = a[id];     if (++cnt[id] == 1)       is1++;     else if (cnt[id] == 2)       is1--;   }   void out(int id) {     id = a[id];     if (--cnt[id] == 1)       is1++;     else if (cnt[id] == 0)       is1--;   }   void update(int l, int r) {     while (R < r) in(++R);     while (L > l) in(--L);     while (L < l) out(L++);     while (R > r) out(R--);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     a[0] = n + 1;     a[n + 1] = n + 1;     int res = 0;     st.push_back(n + 1);     for (int i = 1; i <= n; i++) {       cin >> a[i];       while (st.back() < a[i]) st.pop_back();       big[i][0] = ap[st.back()];       st.push_back(a[i]);       ap[a[i]] = i;     }     st.clear();     st.push_back(n + 1);     ap[n + 1] = n + 1;     for (int i = n; i >= 1; i--) {       while (st.back() < a[i]) st.pop_back();       big[i][1] = ap[st.back()];       st.push_back(a[i]);       ap[a[i]] = i;     }     for (int i = 1; i <= n; i++) {       int l = max(i - a[i] + 1, big[i][0] + 1);       int r = min(l + a[i] - 1, big[i][1] - 1);       if (l + a[i] - 1 != r) continue;       for (; l <= i; l++) {         update(l, r);         if (is1 == a[i]) res++;         if (++r == big[i][1]) break;       }     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> usedTrains;   vector<vector<pair<long long, long long>>> gNoTrain;   vector<vector<pair<long long, long long>>> gYesTrain;   vector<long long> disNoTrain;   vector<long long> disYesTrain;   unordered_set<long long> tracks;   void no_train_dijkstra(int s) {     priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,                    greater<pair<long long, long long>>>         Q;     Q.push(make_pair(0, s));     disNoTrain[s] = 0;     while (!Q.empty()) {       pair<long long, long long> p = Q.top();       Q.pop();       int currV = (int)p.second;       if (disNoTrain[currV] != p.first) continue;       for (pair<long long, long long>& edge : gNoTrain[currV]) {         int u = (int)edge.first;         long long w = edge.second;         if (disNoTrain[currV] + w < disNoTrain[u]) {           disNoTrain[u] = disNoTrain[currV] + w;           Q.push(make_pair(disNoTrain[u], u));         }       }     }   }   void yes_train_dijkstra(int s) {     priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,                    greater<pair<long long, long long>>>         Q;     Q.push(make_pair(0, s));     disYesTrain[s] = 0;     while (!Q.empty()) {       pair<long long, long long> p = Q.top();       Q.pop();       int currV = (int)p.second;       if (disYesTrain[currV] != p.first) continue;       for (pair<long long, long long>& edge : gYesTrain[currV]) {         int u = (int)edge.first;         long long w = edge.second;         if (currV != 0 && disYesTrain[currV] + w == disYesTrain[u]) {           tracks.erase(u);         }         if (disYesTrain[currV] + w < disYesTrain[u]) {           if (currV != 0) tracks.erase(u);           disYesTrain[u] = disYesTrain[currV] + w;           Q.push(make_pair((long long)disYesTrain[u], u));         }       }     }   }   int n, m, k;   int main() {     cin >> n >> m >> k;     usedTrains = vector<long long>(k, 0);     gNoTrain = vector<vector<pair<long long, long long>>>(         n, vector<pair<long long, long long>>());     gYesTrain = vector<vector<pair<long long, long long>>>(         n, vector<pair<long long, long long>>());     disNoTrain = vector<long long>(n, 100000000000l);     disYesTrain = vector<long long>(n, 100000000000l);     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       gNoTrain[u - 1].push_back({(long long)v - 1, (long long)w});       gNoTrain[v - 1].push_back({(long long)u - 1, (long long)w});       gYesTrain[u - 1].push_back({(long long)v - 1, (long long)w});       gYesTrain[v - 1].push_back({(long long)u - 1, (long long)w});     }     no_train_dijkstra(0);     for (int i = 0; i < k; i++) {       int v, w;       cin >> v >> w;       gYesTrain[0].push_back({(long long)v - 1, (long long)w});       gYesTrain[v - 1].push_back({0, (long long)w});       if (w < disNoTrain[v - 1]) tracks.insert(v - 1);     }     no_train_dijkstra(0);     yes_train_dijkstra(0);     cout << (k - (long long)tracks.size()) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300000 + 15;   int n;   int a[N];   char c[N];   int flag, st, bb, rr, ll, cc, dd, ee, hh;   int main() {     scanf( %d , &n);     for (int i(1); i <= (n); ++i) scanf( %d %c , a + i, c + i);     long long ans = 0;     for (int i(1); i <= (n); ++i)       if (c[i] ==  B ) {         if (!bb) bb = i;         dd = a[i] - a[ll] > dd ? a[i] - a[ll] : dd;         ll = i;       } else if (c[i] ==  R ) {         if (!rr) rr = i;         ee = a[i] - a[cc] > ee ? a[i] - a[cc] : ee;         cc = i;       } else {         if (flag) {           int tmp1 = a[i] - a[hh];           int tmp2 = (ee ? a[i] - a[hh] - max(a[i] - a[cc], ee) : 0) +                      (dd ? a[i] - a[hh] - max(a[i] - a[ll], dd) : 0);           ans += a[i] - a[hh] + min(tmp1, tmp2);         } else           ans += (bb ? a[i] - a[bb] : 0) + (rr ? a[i] - a[rr] : 0);         flag = 1;         hh = cc = ll = i;         ee = dd = 0;       }     if (!flag)       printf( %lld n , 0ll + a[cc] - a[rr] + a[ll] - a[bb]);     else       printf( %lld n ,              ans + (cc > hh ? a[cc] - a[hh] : 0) + (ll > hh ? a[ll] - a[hh] : 0));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[5005];   int times[5005];   int maxn, val;   int valcnt[5005];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     for (int i = 1; i <= n; i++) {       memset(times, 0, sizeof(times));       maxn = -1;       val = 0;       for (int j = i; j <= n; j++) {         times[a[j]]++;         if (times[a[j]] == maxn && a[j] < val) {           maxn = times[a[j]];           val = a[j];         } else if (times[a[j]] > maxn) {           maxn = times[a[j]];           val = a[j];         }         valcnt[val]++;       }     }     for (int i = 1; i <= n; i++) printf( %d  , valcnt[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   const long long mod = 998244353;   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   int n, m, k;   vector<int> a;   int f(int off) {     int q = 0;     int left = m - 1;     int at_w = k;     for (int i = off; i < n; i++) {       if (at_w - a[i] >= 0) {         at_w -= a[i];         q++;       } else {         if (left == 0) break;         at_w = k - a[i];         q++;         left--;       }     }     return q == (n - off);   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     a.resize(n);     {       for (auto &_re : a) cin >> _re;     };     int l = 0, r = n, mid;     int ans = 0;     while (l <= r) {       mid = l + r >> 1;       if (f(mid)) {         ans = mid;         r = mid - 1;       } else         l = mid + 1;     }     cout << n - ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     cin >> n >> m;     bool flg = false;     int a;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         cin >> a;         if (a == 1 && (i == 0 || i == n - 1 || j == 0 || j == m - 1)) flg = true;       }     if (flg)       cout << 2 << endl;     else       cout << 4 << endl;     return 0;   }
#include <bits/stdc++.h>   const int inf = 2e9;   using namespace std;   int dp[505][505], change[505][505];   pair<int, int> parent[505][505];   string second;   int calc(int l, int r) {     int ans = 0;     while (l < r) {       if (second[l] != second[r]) ans++;       l++;       r--;     }     return ans;   }   void _try(int l, int r) {     while (l < r) {       if (second[l] != second[r]) second[r] = second[l];       l++;       r--;     }   }   int main() {     ios_base::sync_with_stdio(0);     int k;     cin >> second >> k;     int n = second.length();     for (int i = 0; i < 505; i++)       for (int j = 0; j < 505; j++) {         dp[i][j] = inf;         parent[i][j] = make_pair(i, j);       }     for (int i = 0; i < n; i++)       for (int j = i; j < n; j++) {         change[i][j] = calc(i, j);       }     for (int pos = 0; pos < n; pos++)       for (int cnt = 1; cnt <= k; cnt++) {         if (cnt == 1) {           dp[pos][cnt] = change[0][pos];         } else {           for (int pos1 = 0; pos1 < pos; pos1++) {             int new_v = dp[pos1][cnt - 1] + change[pos1 + 1][pos];             if (dp[pos][cnt] > new_v) {               dp[pos][cnt] = new_v;               parent[pos][cnt] = make_pair(pos1, cnt - 1);             }           }         }       }     int ansi = 1;     for (int i = 2; i <= k; i++) {       if (dp[n - 1][i] < dp[n - 1][ansi]) ansi = i;     }     int pos = n - 1, j = ansi;     vector<pair<int, int> > split;     while (parent[pos][j] != make_pair(pos, j)) {       pair<int, int> next = parent[pos][j];       pos = next.first;       j = next.second;       split.push_back(make_pair(pos, j));     }     reverse(split.begin(), split.end());     cout << dp[n - 1][ansi] << endl;     int l = 0;     if (split.empty()) {       _try(0, n - 1);       cout << second;       return 0;     }     for (int i = 0; i < split.size(); i++) {       _try(l, split[i].first);       for (int j = l; j <= split[i].first; j++) {         cout << second[j];         cout.flush();       }       cout <<  + ;       l = split[i].first + 1;     }     _try(l, n - 1);     for (int i = l; i < n; i++) {       cout << second[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     long long n;     cin >> n;     vector<pair<long long, long long>> a((size_t)n);     for (long long i = 0; i < n; i++) {       cin >> a[i].first;       a[i].second = i;     }     sort(a.rbegin(), a.rend());     vector<long long> b((size_t)n);     for (long long i = 0; i < n; i++) {       b[i] = a[i].second * 2;       if (i >= 1) {         cout << b[i - 1] + 1 <<     << b[i] + 1 <<   n ;       }     }     for (long long i = 0; i < n; i++) {       cout << a[i].second * 2 + 1 + 1 <<     << b[i + a[i].first - 1] + 1 <<   n ;       if (i + a[i].first - 1 == (long long)b.size() - 1) {         b.push_back(a[i].second * 2 + 1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int P = 1e9 + 7, INF = 0x3f3f3f3f;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long qpow(long long a, long long n) {     long long r = 1 % P;     for (a %= P; n; a = a * a % P, n >>= 1)       if (n & 1) r = r * a % P;     return r;   }   long long inv(long long first) {     return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;   }   inline int rd() {     int first = 0;     char p = getchar();     while (p <  0  || p >  9 ) p = getchar();     while (p >=  0  && p <=  9 ) first = first * 10 + p -  0 , p = getchar();     return first;   }   const int N = 1e6 + 50;   int n, m, w[N], dep[N];   vector<pair<int, int>> g[N];   vector<pair<int, long long>> route[N];   void dfs(int first, int d) {     dep[first] = d;     for (auto &e : g[first]) dfs(e.first, d + e.second);   }   int p(int f, int first) {     if (first == f * 2) return first + 1;     return first - 1;   }   long long qry(int a, int h, int c) {     if (a > n || c > h) return 0;     auto p = --upper_bound(route[a].begin(), route[a].end(),                            pair<int, long long>(h - c, 1e18));     long long cnt = p - route[a].begin() + 1;     return cnt * (h - c) - p->second;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 2; i <= n; ++i) {       int u = i / 2, v = i;       scanf( %d , w + i);       g[u].push_back({v, w[i]});     }     dfs(1, 0);     for (int i = 1; i <= n; ++i) {       int j = i;       route[i].push_back({0, 0ll});       while (j != 1) {         j /= 2;         route[j].push_back({dep[i] - dep[j], 0ll});       }     }     for (int i = 1; i <= n; ++i) {       sort(route[i].begin(), route[i].end());       int sz = route[i].size();       for (int j = 1; j <= sz - 1; ++j)         route[i][j].second = route[i][j].first + route[i][j - 1].second;     }     while (m--) {       int a, h;       scanf( %d%d , &a, &h);       long long ans = qry(a, h, 0);       int c = 0;       while (1) {         c += w[a];         if (a == 1 || c > h) break;         int t = p(a / 2, a);         ans += qry(t, h, c + w[t]);         ans += h - c;         a /= 2;       }       printf( %lld n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   priority_queue<long long, vector<long long>, greater<long long>> pq1, pq2;   long long power(long long a, long long b) {     long long res = 1;     while (b > 0) {       res *= a;       b--;     }     return res;   }   long long parent[200005], sz[200005], visit[200005] = {0}, cnt[200005] = {0};   vector<pair<long long, long long>> vt[200005];   vector<long long> v[200005];   struct Test {     long long a, b, c;   };   bool comp(const Test &p1, const Test &p2) { return p1.a < p2.a; }   long long find_parent(long long a) {     if (a == parent[a])       return a;     else       return parent[a] = find_parent(parent[a]);   }   long long dfs(long long a) {     visit[a] = 1;     cnt[a]++;     for (int i = 0; i < v[a].size(); ++i) {       long long b = v[a][i];       if (visit[b] == 0) {         dfs(b);       }     }     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, m, x, y, st1, st2, z;     vector<Test> w;     cin >> n >> m;     long long cnt1 = 0;     for (int i = 0; i < m; ++i) {       cin >> x >> y >> z;       vt[x].push_back({y, z});       vt[y].push_back({x, z});       if (cnt1 == 0) {         w.push_back({0, x, y});         st1 = x;         st2 = y;       } else         w.push_back({z, x, y});       cnt1++;     }     for (int i = 1; i < n + 1; ++i) {       sz[i] = 0;       parent[i] = i;     }     sort(w.begin(), w.end(), comp);     for (int i = 0; i < w.size(); ++i) {       long long p1 = w[i].b;       long long p2 = w[i].c;       long long par1 = find_parent(p1);       long long par2 = find_parent(p2);       if (par1 != par2) {         v[p1].push_back(p2);         v[p2].push_back(p1);         if (sz[par1] <= sz[par2]) {           sz[par2] += sz[par1];           parent[par1] = par2;         } else {           sz[par1] += sz[par2];           parent[par2] = par1;         }       }     }     if (v[st1].size() == 1) {       if (vt[st1].size() == 1)         cout <<  1000000000  << endl;       else {         long long mn = 1000000000;         for (int j = 0; j < vt[st1].size(); ++j) {           if (v[st1][j] == st2) continue;           mn = min(mn, vt[st1][j].second);         }         cout << mn << endl;       }     } else {       visit[st1] = 1;       dfs(st2);       long long mn = 1000000000;       for (int i = 1; i < n + 1; ++i) {         if (cnt[i] > 0) {           for (int j = 0; j < vt[i].size(); ++j) {             if (i == st2 && vt[i][j].first == st1) continue;             if (cnt[vt[i][j].first] == 0) mn = min(mn, vt[i][j].second);           }         }       }       cout << mn << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const int N = 1000005;   class cmp {    public:     bool operator()(long long &A, long long &B) { return A > B; }   };   bool by_sec(pair<long long, long long> &A, pair<long long, long long> &B) {     return A.second < B.second;   }   bool is(pair<long long, long long> a, pair<long long, long long> b) {     return !((a.first > b.second && a.second > b.second) ||              (a.first < b.first && a.second < b.first));   }   long double dist(pair<long long, long long> p1, pair<long long, long long> p2) {     return (long double)sqrt(         (long double)(p1.first - p2.first) * (p1.first - p2.first) +         (long double)(p1.second - p2.second) * (p1.second - p2.second));   }   pair<bool, vector<long long> > is_in(vector<long long> v, long long sum) {     long long n = v.size();     bool dp[30][1000];     memset(dp, 0, sizeof(dp));     ;     for (int i = 0; i < sum + 1; i++) dp[0][i] = 0;     for (int i = 0; i < n + 1; i++) dp[i][0] = 1;     for (int i = 1; i < n + 1; i++)       for (int j = 1; j < sum + 1; j++) {         dp[i][j] = dp[i - 1][j];         if (v[i - 1] <= j) dp[i][j] = dp[i][j] | dp[i - 1][j - v[i - 1]];       }     long long i = n;     long long currSum = sum;     vector<long long> set1, set2;     if (!dp[n][sum]) return (make_pair(dp[n][sum], set1));     while (i > 0 && currSum >= 0) {       if (dp[i - 1][currSum]) {         i--;         set2.push_back(v[i]);       } else {         i--;         currSum -= v[i];         set1.push_back(v[i]);       }     }     return make_pair(dp[n][sum], set1);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     bool mp[8000 + 5];     long long t;     cin >> t;     while (t--) {       long long n;       memset(mp, 0, sizeof(mp));       ;       cin >> n;       vector<long long> v(n);       for (int i = 0; i < n; i++) cin >> v[i], mp[v[i]] = 1;       for (int i = 0; i < n; i++) {         long long s = v[i];         for (int j = i + 1; j < n; j++) {           s += v[j];           if (s <= n && mp[s]) mp[s] = 0;         }       }       long long cnt = 0;       for (int i = 0; i < n; i++)         if (!mp[v[i]]) cnt++;       cout << cnt <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long mnr = 1e9, mxl = -1e9;       for (long long i = 0; i < n; i++) {         long long l, r;         cin >> l >> r;         mnr = min(mnr, r);         mxl = max(mxl, l);       }       cout << (n == 1 ? 0 : max(mxl - mnr, 0ll)) <<   n ;     }   }
#include <bits/stdc++.h>   std::vector<int> G[200006];   int check, a, i, x, y, D, o[200006], z[200006], par[200006], d[200006];   void dfs(int p) {     d[p] = D;     for (int k = 0; k < G[p].size(); k++) {       if (d[G[p][k]] == 0) {         D++;         dfs(G[p][k]);         D--;       } else         par[p] = G[p][k];     }   }   int main() {     scanf( %d , &a);     for (i = 1; i < a; i++) {       scanf( %d%d , &x, &y);       G[x].push_back(y);       G[y].push_back(x);     }     D = 1;     dfs(1);     for (i = 1; i <= a; i++) {       scanf( %d , &z[i]);       o[z[i]] = i;     }     for (i = 1; i < a; i++) {       if (d[z[i]] > d[z[i + 1]])         check = 1;       else if (d[z[i]] == d[z[i + 1]]) {         if (o[par[z[i]]] > o[par[z[i + 1]]]) check = 1;       }     }     if (check == 1)       puts( No );     else       puts( Yes );   }