malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<vector<int>> adj;   bool vis[200000 + 9];   int cntnode;   map<int, int> colorcnt;   int c[200000 + 9];   int mx;   void dfs(int node) {     if (vis[node]) {       return;     }     cntnode++;     colorcnt[c[node]]++;     mx = max(mx, colorcnt[c[node]]);     vis[node] = 1;     for (int i = 0; i < (int)adj[node].size(); i++) {       int ch = adj[node][i];       dfs(ch);     }   }   int main() {     int n, m, k;     cin >> n >> m >> k;     adj.resize(n);     for (int i = 0; i < n; i++) {       cin >> c[i];     }     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       adj[x - 1].push_back(y - 1);       adj[y - 1].push_back(x - 1);     }     int sum = 0;     for (int i = 0; i < n; i++) {       cntnode = 0;       colorcnt.clear();       mx = 0;       if (!vis[i]) {         dfs(i);       }       sum += (cntnode - mx);     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct vertex {     long long inside, edge;     int size = 1;     vector<int> child;   };   int ans = 0;   multiset<long long> st;   vertex g[100009];   void dfs(int v, bool flag, long long deep) {     if (flag) {       for (int i = 0; i < g[v].child.size(); i++) {         dfs(g[v].child[i], 1, 0);         g[v].size += g[g[v].child[i]].size;       }       return;     }     if (deep - g[v].inside > *st.begin()) flag = 1;     st.insert(deep);     for (int i = 0; i < g[v].child.size(); i++) {       dfs(g[v].child[i], flag, deep + g[g[v].child[i]].edge);       g[v].size += g[g[v].child[i]].size;     }     if (flag) ans += g[v].size;     flag = 0;     st.erase(deep);   }   int main() {     ios_base::sync_with_stdio(0);     int n;     st.insert(100000000000000000);     cin >> n;     for (int i = 1; i <= n; i++) cin >> g[i].inside;     for (int i = 2, c; i <= n; i++) {       cin >> c >> g[i].edge;       g[c].child.push_back(i);     }     dfs(1, 0, 0);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100001], b[100001], c[100001], x;   map<int, int> a1, b1, c1;   int main() {     srand(time(NULL));     cin >> n;     for (int i = 1; i <= n; ++i) cin >> a[i], a1[a[i]]++;     for (int i = 1; i < n; ++i) cin >> b[i], b1[b[i]]++, a1[b[i]]--;     for (int i = 1; i < n - 1; ++i) cin >> c[i], b1[c[i]]--;     for (int i = 1; i <= n; ++i)       if (a1[a[i]] != 0) cout << a[i] << endl, a1[a[i]]--;     for (int i = 1; i < n; ++i)       if (b1[b[i]] != 0) cout << b[i], b1[b[i]]--;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   const double pi = 3.141593;   int main() {     ios::sync_with_stdio(false);     int n, t = 0, ans = 0;     map<int, int> m;     cin >> n;     for (int i = 0; i < 2 * n; i++) {       int x;       cin >> x;       m[x]++;       t++;       if (m[x] == 2) t -= 2;       ans = max(ans, t);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   int main() {     int n, m;     cin >> n >> m;     vector<vector<pair<int, int>>> mat(m, vector<pair<int, int>>(3));     set<int> white, red, blue;     for (int i = 0; i < m; i++) {       int x, y, z;       cin >> x >> y >> z;       mat[i][0].first = x;       mat[i][1].first = y;       mat[i][2].first = z;       bool xWhite = (white.find(x) != white.end());       bool xRed = (red.find(x) != red.end());       bool xBlue = (blue.find(x) != blue.end());       bool yWhite = (white.find(y) != white.end());       bool yRed = (red.find(y) != red.end());       bool yBlue = (blue.find(y) != blue.end());       bool zWhite = (white.find(z) != white.end());       bool zRed = (red.find(z) != red.end());       bool zBlue = (blue.find(z) != blue.end());       if (xWhite) {         white.insert(x);         red.insert(y);         blue.insert(z);       } else if (xRed) {         red.insert(x);         white.insert(y);         blue.insert(z);       } else if (xBlue) {         blue.insert(x);         white.insert(y);         red.insert(z);       } else if (yWhite) {         white.insert(y);         red.insert(x);         blue.insert(z);       } else if (yRed) {         red.insert(y);         white.insert(x);         blue.insert(z);       } else if (yBlue) {         blue.insert(y);         white.insert(x);         red.insert(z);       } else if (zWhite) {         white.insert(z);         red.insert(x);         blue.insert(y);       } else if (zRed) {         red.insert(z);         blue.insert(x);         white.insert(y);       } else if (zBlue) {         blue.insert(z);         red.insert(x);         white.insert(y);       } else {         debug() <<   [                  <<  x                      :                   << (x)                 <<  ]                        [                  <<  y                      :                   << (y)                 <<  ]                        [                  <<  z                      :                   << (z) <<  ]  ;         white.insert(x);         red.insert(y);         blue.insert(z);       }     }     for (int i = 1; i <= n; i++) {       if (white.find(i) != white.end()) {         cout <<  1  ;       } else if (red.find(i) != red.end()) {         cout <<  2  ;       } else {         cout <<  3  ;       }     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     string s, t, ss;     cin >> n >> s;     ss = s;     t =  abacaba ;     int cnt = 0;     for (int i = 0; i < n - 6; i++) {       int j, k = 0;       for (j = i; j < i + 7; j++) {         if (s[j] != t[k]) break;         k++;       }       if (j == i + 7) cnt++;     }     if (cnt == 1) {       cout <<  Yes             <<   n ;       for (int i = 0; i < n; i++) {         if (s[i] ==  ? ) s[i] =  z ;       }       cout << s <<   n ;     } else if (cnt > 1) {       cout <<  No             <<   n ;       return;     } else {       cnt = 0;       for (int i = 0; i < n - 6; i++) {         cnt = 0;         int j, k = 0;         for (j = i; j < i + 7; j++) {           if (s[j] != t[k] && s[j] !=  ? ) break;           s[j] = t[k];           k++;         }         if (j == i + 7) {           for (int x = 0; x < n - 6; x++) {             int y, z = 0;             for (y = x; y < x + 7; y++) {               if (s[y] != t[z]) break;               z++;             }             if (y == x + 7) cnt++;           }           if (cnt == 1) {             cout <<  Yes                   <<   n ;             for (int i = 0; i < n; i++) {               if (s[i] ==  ? ) s[i] =  z ;             }             cout << s <<   n ;             return;           } else {             for (int i = 0; i < n; i++) s[i] = ss[i];           }         } else {           for (int i = 0; i < n; i++) s[i] = ss[i];         }       }       cout <<  No             <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long tt;     cin >> tt;     while (tt--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> id(n + 1);     for (int i = 0; i < n; i++) {       int x;       cin >> x;       id[x] = i;     }     vector<int> dp(n + 1, 1);     for (int i = 2; i <= n; i++) {       if (id[i] > id[i - 1]) {         dp[i] += dp[i - 1];       }     }     cout << n - *max_element(dp.begin(), dp.end());   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   long long dp[1010][2100][4];   int main() {     int n, k;     scanf( %d%d , &n, &k);     dp[1][1][0] = 1, dp[1][2][1] = 1, dp[1][2][2] = 1, dp[1][1][3] = 1;     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= k; j++) {         dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1] + dp[i - 1][j][2] +                        dp[i - 1][j - 1][3]) %                       MOD;         dp[i][j][1] =             (dp[i - 1][j - 1][0] + dp[i - 1][j][1] + dp[i - 1][j - 1][3]) % MOD;         if (j >= 2) dp[i][j][1] = (dp[i][j][1] + dp[i - 1][j - 2][2]) % MOD;         dp[i][j][2] =             (dp[i - 1][j - 1][0] + dp[i - 1][j][2] + dp[i - 1][j - 1][3]) % MOD;         if (j >= 2) dp[i][j][2] = (dp[i][j][2] + dp[i - 1][j - 2][1]) % MOD;         dp[i][j][3] = (dp[i - 1][j - 1][0] + dp[i - 1][j][1] + dp[i - 1][j][2] +                        dp[i - 1][j][3]) %                       MOD;       }     }     printf( %lld n ,            (dp[n][k][0] + dp[n][k][1] + dp[n][k][2] + dp[n][k][3]) % MOD);   }
#include<bits/stdc++.h>   #define fo(i,a,b) for(int i=a;i<=b;i++)   #define fd(i,a,b) for(int i=a;i>=b;i--)   using namespace std;      typedef long long LL;   typedef pair<int,int> pr;      const int maxn=505;      int n,m;   char mp[maxn][maxn];      int T;   int main()   {    scanf( %d ,&T);    while (T--)    {     scanf( %d %d ,&n,&m);     fo(i,1,n) scanf( %s ,mp[i]+1);          fo(i,1,n) if (i%3==1)      fo(j,1,m) mp[i][j]= X ;     fo(i,1,n) if (i%3==1 && i+3<=n)     {      bool pd=0;      fo(j,1,m) if (mp[i+1][j]== X )      {       mp[i+2][j]= X ;       pd=1;       break;      }      if (pd) continue;      fo(j,1,m) if (mp[i+2][j]== X )      {       mp[i+1][j]= X ;       pd=1;       break;      }      if (pd) continue;      mp[i+1][1]=mp[i+2][1]= X ;     }     if (n%3==0)     {      fo(j,1,m) if (mp[n][j]== X ) mp[n-1][j]= X ;     }          fo(i,1,n) printf( %s n ,mp[i]+1);    }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T sqr(T x) {     return x * x;   }   const double EPS = 1e-6;   const int INF = 0x3fffffff;   const long long LINF = INF * 1ll * INF;   const double PI = acos(-1.0);   using namespace std;   char g[505][505];   int cnt[505];   int dp[2][505][505];   int C[505][505];   int mod;   void Add(int &ans, int v) {     ans += v;     if (ans >= mod) ans -= mod;   }   int main(void) {     int n, m;     scanf( %d %d %d , &n, &m, &mod);     C[0][0] = 1;     for (int i = 1; i <= n; i++) {       C[i][0] = 1;       for (int j = 1; j <= i; j++)         C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;     }     for (int i = 0; i < (m); ++i) {       scanf( %s , g[i]);       for (int j = 0; j < (n); ++j) cnt[j] += g[i][j] -  0 ;     }     int cnt0 = 0, cnt1 = 0;     for (int i = 0; i < (n); ++i) {       if (cnt[i] > 2) {         puts( 0 );         return 0;       }       if (cnt[i] == 1)         cnt1++;       else if (cnt[i] == 0)         cnt0++;     }     int now = 0;     dp[now][cnt0][cnt1] = 1;     for (int i = m; i < n; i++) {       memset(dp[now ^ 1], 0, sizeof(dp[now ^ 1]));       for (int j = 0; j <= n; j++) {         for (int k = 0; k + j <= n; k++) {           if (dp[now][j][k] == 0) continue;           if (j >= 2)             Add(dp[now ^ 1][j - 2][k + 2], 1ll * C[j][2] * dp[now][j][k] % mod);           if (k >= 2)             Add(dp[now ^ 1][j][k - 2], 1ll * C[k][2] * dp[now][j][k] % mod);           if (j && k)             Add(dp[now ^ 1][j - 1][k],                 1ll * C[k][1] * C[j][1] % mod * dp[now][j][k] % mod);         }       }       now ^= 1;     }     printf( %d n , dp[now][0][0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 21;   const long long MOD = 1000000007;   int n;   long long m;   long long C[MAXN][MAXN];   long long g[MAXN], s[MAXN], ten[MAXN], eight[MAXN];   inline void update(long long& x, long long y) { y %= MOD, x += y, x %= MOD; }   inline long long P(const long long& x, int y) {     if (x < y) return 0;     long long res = 1;     for (long long i = x; i >= x - y + 1; --i) res = (res * i) % MOD;     return res;   }   inline pair<int, int> get(long long num, int x) {     int res4 = 0, res7 = 0;     for (int i = 1; i <= x; ++i) num /= 10;     for (long long i = num; i > 0; i /= 10)       if (i % 10 == 4)         res4++;       else if (i % 10 == 7)         res7++;     return pair<int, int>(res4, res7);   }   inline long long F(const long long& num, int x, int a, int b) {     pair<int, int> p = get(num, x);     a -= p.first, b -= p.second;     if (a < 0 || b < 0 || a + b > x) return 0;     return (((C[x][a] * C[x - a][b]) % MOD) * eight[x - a - b]) % MOD;   }   inline long long G(long long num, int x, int a, int b) {     long long res = 0;     for (; num + ten[x] <= m; num += ten[x]) update(res, F(num, x, a, b));     if (x > 0) {       if (num <= m) update(res, G(num, x - 1, a, b));     } else       update(res, F(num, x, a, b));     return res;   }   inline void preProcess() {     ten[0] = eight[0] = 1;     for (int i = 1; i < MAXN; ++i)       ten[i] = ten[i - 1] * 10, eight[i] = eight[i - 1] * 8;     while (ten[n] <= m) n++;     C[0][0] = 1;     for (int i = 1; i < MAXN; ++i) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; ++j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;     }     for (int i = 0; i <= n; ++i)       for (int j = 0; j <= i; ++j) update(g[i], G(0, n - 1, j, i - j));     g[0]--;   }   inline long long dp(int s, int x, int y, int z) {     if (y < 0 || z < 0) return 0;     if (x == s) return (y == 0) ? 1 : 0;     long long res = 0;     for (int i = 0; i <= y; ++i) {       long long k = (C[y][i] * P(g[x], i)) % MOD;       update(res, k * dp(s, x + 1, y - i, z - i * x));     }     return res;   }   int main() {     scanf( %I64d n , &m);     preProcess();     long long res = 0;     for (int s = 1; s <= n; ++s) update(res, g[s] * dp(s, 0, 6, s - 1));     printf( %I64d n , res);     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3)   using namespace std;   const int Mod = 1e9 + 7;   const int N = 5e5 + 100;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3f;   inline long long dpow(long long a, long long b) {     long long r = 1, t = a;     while (b) {       if (b & 1) r = (r * t) % Mod;       b >>= 1;       t = (t * t) % Mod;     }     return r;   }   inline long long fpow(long long a, long long b) {     long long r = 1, t = a;     while (b) {       if (b & 1) r = (r * t);       b >>= 1;       t = (t * t);     }     return r;   }   struct node {     int id, w;     bool operator<(const node &oth) const { return w > oth.w; }   };   struct Ask {     int op, x;   } qi[N];   pair<int, int> eg[N];   set<node> s[N];   int fa[N], sz[N], n, m, q;   int a[N];   bool vis[N];   stack<pair<int, int> > st;   void Init() {     for (int i = 1; i <= n; i++) fa[i] = i, sz[i] = 1;   }   int Find(int x) {     while (x != fa[x]) x = fa[x];     return x;   }   void Merge(int x, int y) {     x = Find(x);     y = Find(y);     if (x == y) {       st.push({0, 0});       return;     }     if (sz[x] > sz[y]) swap(x, y);     fa[x] = y;     st.push({x, y});     sz[y] += sz[x];     for (auto it : s[x]) s[y].insert(it);   }   void Cancle() {     int x = st.top().first, y = st.top().second;     st.pop();     if (!x && !y) return;     fa[x] = x;     sz[y] -= sz[x];     for (auto it : s[x]) {       if (s[y].find(it) != s[y].end()) s[y].erase(it);     }   }   int main() {     cin >> n >> m >> q;     Init();     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), s[i].insert({i, a[i]});     for (int i = 1; i <= m; i++) scanf( %d %d , &eg[i].first, &eg[i].second);     for (int i = 1; i <= q; i++) {       scanf( %d %d , &qi[i].op, &qi[i].x);       if (qi[i].op == 2) vis[qi[i].x] = true;     }     for (int i = 1; i <= m; i++)       if (!vis[i]) Merge(eg[i].first, eg[i].second);     for (int i = q; i >= 1; i--) {       if (qi[i].op == 1) continue;       int u = eg[qi[i].x].first;       int v = eg[qi[i].x].second;       Merge(u, v);     }     for (int i = 1; i <= q; i++) {       int op = qi[i].op, x = qi[i].x;       if (op == 1) {         int u = Find(x);         while (!s[u].empty() && !a[s[u].begin()->id]) s[u].erase(s[u].begin());         if (s[u].empty())           puts( 0 );         else {           printf( %d n , s[u].begin()->w);           a[s[u].begin()->id] = 0;         }       } else         Cancle();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 1e6 + 1;   const int Mod = 1e9 + 7;   const long long int MOD = 1000000007LL;   const long long int MAX = 100010LL;   template <typename T>   T gcd(T a, T b) {     if (b == 0) return a;     return gcd(b, a % b);   }   template <typename T>   T power(T x, T y, long long int m = MOD) {     T ans = 1;     x %= m;     while (y > 0) {       if (y & 1ll) ans = (ans * x) % m;       y >>= 1ll;       x = (x * x) % m;     }     return ans % m;   }   template <typename T, typename T1>   T mod(T x, T1 p) {     x %= p;     if (x < 0) x += p;     return x;   }   void leastPrimeFactor(vector<int> &least_prime, int n) {     least_prime[1] = 1;     for (int i = 2; i <= n; i++) {       if (least_prime[i] == 0) {         least_prime[i] = i;         for (int j = 2 * i; j <= n; j += i)           if (least_prime[j] == 0) least_prime[j] = i;       }     }   }   bool dfs(vector<vector<int>> &graph, vector<int> &g, int i) {     int prev = 0;     queue<int> q;     q.push(i);     while (!q.empty()) {       int n = q.size();       while (n--) {         int t = q.front();         q.pop();         if (g[t] == -1) {           g[t] = prev;           for (int j : graph[t]) q.push(j);         }         if (g[t] != prev) return 0;       }       prev ^= 1;     }     return 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<vector<int>> adj(n);     vector<vector<int>> mat(n, vector<int>(n, 0));     int cnt = n;     for (int j = 0; j < n; j++) {       string s;       cin >> s;       for (int i = 0; i < s.size(); i++)         if (s[i] ==  1 ) adj[j].push_back(i);     }     int m;     cin >> m;     vector<int> p(m);     for (int i = 0; i < m; i++) cin >> p[i], p[i]--;     for (int i = 0; i < n; i++) {       queue<int> q;       q.push(i);       int dis = 0;       vector<int> vis(n, 0);       vis[i] = 1;       while (!q.empty()) {         int nu = q.size();         while (nu--) {           int no = q.front();           q.pop();           mat[i][no] = dis;           for (int &ne : adj[no])             if (!vis[ne]) vis[ne] = 1, q.push(ne);         }         dis++;       }     }     vector<int> ans;     ans.push_back(p[0]);     int i = 0;     while (i < p.size()) {       int next = i + 1;       for (int j = 0; j < n; j++)         if (i + mat[p[i]][j] < p.size() && p[i + mat[p[i]][j]] == j)           next = max(next, i + mat[p[i]][j]);       if (next < p.size()) ans.push_back(p[next]);       i = next;     }     cout << ans.size() << endl;     for (int &i : ans) cout << i + 1 <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t;     cin >> n;     set<long long int> s;     while (n--) {       cin >> t;       s.insert(t);     }     if (s.size() >= 4)       cout <<  NO ;     else {       if (s.size() == 3) {         auto it1 = s.begin();         auto it2 = it1;         auto it3 = it2;         it2++;         it3++;         it3++;         if (2 * (*it2) == *it1 + *it3)           cout <<  YES ;         else           cout <<  NO ;       } else         cout <<  YES ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long exp(long long x, long long y, long long p) {     long long res = 1;     while (y) {       if (y % 2) res = (res * x % p) % p;       x = (x * x) % p;       y /= 2;     }     return res;   }   long long exp(long long x, long long y) {     long long res = 1;     while (y) {       if (y % 2) res = (res * x);       x = (x * x);       y /= 2;     }     return res;   }   int main() {     long long a, b, c;     long long sum1 = 0, sum2 = 0, sum3 = 0;     long long t;     cin >> t;     while (t--) {       cin >> a >> b >> c;       sum1 += a;       sum2 += b;       sum3 += c;     }     if (!sum1 && !sum2 && !sum3)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, k, flag = 0;     cin >> n >> k;     if (3 * n > k) {       cout << 3 * n - k <<   n ;     } else {       cout <<  0             <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int a, ord;   } p[10005];   int b[10005];   bool cmp(node a, node b) { return a.a < b.a; }   int main() {     int n;     while (~scanf( %d , &n)) {       memset(b, 0, sizeof(b));       for (int i = 0; i < n; i++) {         scanf( %d , &p[i].a);         b[p[i].a]++;         p[i].ord = i + 1;       }       sort(p, p + n, cmp);       int sum = 1;       int ss[2], A = 0;       int sss = -1;       int flag = 1;       int i;       for (i = 1; i < n; i++) {         if (p[i].a == p[i - 1].a)           flag++;         else {           if (flag >= 3) {             sss = p[i - 1].a;             flag = -1;             break;           } else if (flag == 2)             ss[A++] = p[i - 1].a;           flag = 1;           if (A == 2) {             flag = -2;             break;           }         }       }       if (flag >= 3) {         sss = p[i - 1].a;         flag = -1;       } else if (flag == 2)         ss[A++] = p[i - 1].a;       flag = 1;       if (A == 2) {         flag = -2;       }       if (sss != -1) flag = -1;       if (flag > 0)         cout <<  NO  << endl;       else {         cout <<  YES  << endl;         if (flag == -1) {           for (int i = 0; i < 3; i++) {             flag = 1;             for (int j = 0; j < n; j++) {               if (j != 0) printf(   );               if (flag && p[j].a == sss) {                 if (i == 0)                   printf( %d %d %d , p[j].ord, p[j + 1].ord, p[j + 2].ord);                 else if (i == 1)                   printf( %d %d %d , p[j + 1].ord, p[j + 2].ord, p[j].ord);                 else                   printf( %d %d %d , p[j + 2].ord, p[j].ord, p[j + 1].ord);                 j += 2;                 flag = 0;               } else                 printf( %d , p[j].ord);             }             printf(  n );           }         } else {           for (int i = 0; i < 3; i++) {             for (int j = 0; j < n; j++) {               if (j != 0) printf(   );               if (i == 0 && p[j].a == ss[0]) {                 printf( %d %d , p[j].ord, p[j + 1].ord);                 j++;               } else if (i == 1 && p[j].a == ss[0]) {                 printf( %d %d , p[j + 1].ord, p[j].ord);                 j++;               } else if (i == 2 && p[j].a == ss[1]) {                 printf( %d %d , p[j + 1].ord, p[j].ord);                 j++;               } else                 printf( %d , p[j].ord);             }             printf(  n );           }         }       }     }     return 0;   }