malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = int(1e6) + 50;   char S[N], T[N];   int slen, tlen, lef[N], rig[N], cnt[255][255];   inline int getID(char c) {     if (c ==  R ) return 0;     if (c ==  G ) return 1;     if (c ==  B ) return 2;     throw;   }   int main() {     scanf( %s , S + 1);     slen = strlen(S + 1);     scanf( %s , T + 1);     tlen = strlen(T + 1);     int l = 1, r = 1;     while (l <= slen && r <= tlen) {       lef[l] = r;       r += S[l] == T[r];       ++l;     }     slen = min(slen, l - 1);     l = r = 1;     while (l <= slen && r <= tlen) {       rig[l] = r;       l += S[l] == T[r];       ++r;     }     tlen = min(tlen, r - 1);     for (int i = l + bool(rig[l]); i <= slen; ++i) {       rig[i] = tlen;     }     long long res = 0;     for (int i = 1; i <= slen; ++i) {       for (int j = max(1, lef[i - 1]); j < lef[i]; ++j) --cnt[T[j]][T[j - 1]];       for (int j = 1 + rig[i - 1]; j <= rig[i]; ++j) ++cnt[T[j]][T[j - 1]];       res += rig[i] - lef[i] + 1;       if (S[i - 1] != S[i]) res -= cnt[S[i - 1]][S[i]];     }     printf( %I64d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   long long ans;   int main() {     cin >> n >> m >> k;     if (k > n + m - 2) {       cout <<  -1  << endl;       return 0;     }     if (n >= m) swap(n, m);     if (k <= m - 1) {       ans = (long long)(m / (k + 1)) * n;     } else {       ans = (long long)(n / (k - m + 2));     }     if (k <= n - 1) {       ans = max(ans, (long long)(n / (k + 1)) * m);     } else {       ans = max(ans, (long long)(m / (k - n + 2)));     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 110;   int n, m, k;   int h[MAXN];   void load() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 0; i < n; i++) scanf( %d , h + i);   }   bool solve() {     long long sum = m;     int ind = 0;     while (ind < n - 1) {       if (h[ind] >= h[ind + 1] - k) {         int nxt = max(h[ind + 1] - k, 0);         sum += h[ind] - nxt;       } else {         if (sum + h[ind] < h[ind + 1] - k) return false;         sum -= h[ind + 1] - k - h[ind];       }       ind++;     }     return true;   }   int main() {     int t;     scanf( %d , &t);     while (t--) {       load();       if (solve())         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 10;   int n, k;   int a[MAXN], f[MAXN];   int bsL(int l, int r, int val) {     int pos = -1;     while (l <= r) {       int mid = (l + r) >> 1;       if (a[mid] >= val) {         pos = mid;         r = mid - 1;       } else         l = mid + 1;     }     return pos;   }   bool check(int x) {     f[1] = 1;     for (int i = 1, l = 1; i <= n; i++) {       while (a[i] - a[l] > x) l++;       f[i + 1] = (i >= k && f[i - k + 1] - f[l - 1] > 0);       f[i + 1] += f[i];     }     return f[n + 1] - f[n] > 0;   }   int bs(int l, int r) {     int pos = 0;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid)) {         pos = mid;         r = mid - 1;       } else         l = mid + 1;     }     return pos;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + 1 + n);     cout << bs(0, 1e9);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const double EPS = 1e-9;   const int INF = 1 << 29;   int const NN = 5e3 + 3;   int const MX = 1e9 + 9;   int a[505][505];   int mx[505][505];   int main() {     int n, m, K, q;     cin >> n >> m >> K >> q;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) a[i][j] = MX;     }     while (q--) {       int x, y, t;       cin >> x >> y >> t;       a[x][y] = t;     }     int ans = MX;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         mx[i][j] = a[i][j];         for (int k = 2; i + k - 1 <= n && k <= K; ++k) {           mx[i][j] = max(mx[i][j], a[i + k - 1][j]);         }       }     }     for (int i = 1; i + K - 1 <= n; ++i) {       for (int j = 1; j + K - 1 <= m; ++j) {         int mxx = -1;         for (int jj = j; jj <= j + K - 1; ++jj) {           mxx = max(mxx, mx[i][jj]);         }         ans = min(ans, mxx);       }     }     if (ans < MX) {       printf( %d , ans);       ;       putchar(  n );     } else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;      void solve() {       int n, k;       cin >> n >> k;       if(2 * k + 1 > n) {           cout <<  -1 n ;           return;       }       vector<int> v(n);       int p = n;       for(int i = 1; i < 1 + 2 * k; i += 2)           v[i] = p--;       p = 1;       for(int i = 0; i < n; i++) {           if(v[i])               continue;           v[i] = p++;       }       for(auto &x : v)           cout << x <<    ;       cout <<   n ;   }      int main() {       ios_base::sync_with_stdio(false);       cin.tie(0);          int t;       cin >> t;       while(t--)           solve();       }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   char S[maxn][10];   int ju(char a[], char b[]) {     int n = strlen(a), m = strlen(b);     int x = 0, y = 0;     for (int i = 0; i < n; i++) x = x * 10 + a[i] -  0 ;     for (int j = 0; j < m; j++) y = y * 10 + (b[j] ==  ?  ? 9 : b[j] -  0 );     return x < y;   }   int f(int ind) {     int m = strlen(S[ind - 1]), n = strlen(S[ind]);     if (m < n) {       for (int i = 0; i < n; i++)         if (S[ind][i] ==  ? ) {           if (i == 0)             S[ind][i] =  1 ;           else             S[ind][i] =  0 ;         }     } else if (m > n) {       return 1;     } else {       for (int i = 0; i < n; i++) {         if (S[ind][i] ==  ? )           for (int j = 0; j <= 9; j++) {             S[ind][i] =  0  + j;             if (ju(S[ind - 1], S[ind])) break;           }       }       if (!ju(S[ind - 1], S[ind])) return 1;     }     return 0;   }   int main() {     int n;     while (scanf( %d , &n) > 0) {       int si = 1;       S[0][0] =  0 ;       S[0][1] =   0 ;       for (int i = 1; i <= n; i++) {         scanf( %s , S[i]);         if (si && f(i)) si = 0;       }       if (si) {         printf( YES n );         for (int i = 1; i <= n; i++) printf( %s n , S[i]);       } else {         printf( NO n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Friend {     string name;     int x, y, z;   } f[123];   bool Isde(char *a) {     if (a[0] <= a[1]) return false;     if (a[1] <= a[3]) return false;     if (a[3] <= a[4]) return false;     if (a[4] <= a[6]) return false;     if (a[6] <= a[7]) return false;     return true;   }   bool Isiden(char *a) {     if (a[0] != a[1]) return false;     if (a[1] != a[3]) return false;     if (a[3] != a[4]) return false;     if (a[4] != a[6]) return false;     if (a[6] != a[7]) return false;     return true;   }   int main() {     int n;     while (cin >> n) {       int mx = 0, my = 0, mz = 0;       for (int i = 0; i < n; ++i) {         int m;         cin >> m >> f[i].name;         f[i].x = f[i].y = f[i].z;         char str[100];         for (int j = 0; j < m; ++j) {           cin >> str;           if (Isiden(str))             f[i].x++;           else if (Isde(str))             f[i].y++;           else             f[i].z++;         }         mx = max(f[i].x, mx);         my = max(f[i].y, my);         mz = max(f[i].z, mz);       }       bool flag = false;       cout <<  If you want to call a taxi, you should call:  ;       for (int i = 0; i < n; ++i) {         if (f[i].x == mx) {           if (flag) cout <<  ,  ;           cout << f[i].name;           flag = true;         }       }       cout <<  .  << endl;       flag = false;       cout <<  If you want to order a pizza, you should call:  ;       for (int i = 0; i < n; ++i) {         if (f[i].y == my) {           if (flag) cout <<  ,  ;           cout << f[i].name;           flag = true;         }       }       cout <<  .  << endl;       flag = false;       cout <<  If you want to go to a cafe with a wonderful girl, you should                  call:  ;       for (int i = 0; i < n; ++i) {         if (f[i].z == mz) {           if (flag) cout <<  ,  ;           cout << f[i].name;           flag = true;         }       }       cout <<  .  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int L = 0, R = 10000;   int n, vote, tot;   vector<int> p[110000];   pair<int, int> x[110000];   long long sum[110000];   long long he[4 * 110000];   int num[4 * 110000];   long long ask(int root, int l, int r, int k) {     if (k <= 0)       return 0;     else if (num[root] == k)       return he[root];     else if (l == r)       return (long long)k * l;     else {       int mid = (l + r) >> 1;       if (num[2 * root] < k) {         return ask(2 * root, l, mid, num[2 * root]) +                ask(2 * root + 1, mid + 1, r, k - num[2 * root]);       } else {         return ask(2 * root, l, mid, k);       }     }   }   void add(int root, int l, int r, int k) {     if (l > r || k < l || k > r)       return;     else if (l == r) {       num[root]++;       he[root] += k;     } else {       num[root]++;       he[root] += k;       int mid = (l + r) >> 1;       add(2 * root, l, mid, k);       add(2 * root + 1, mid + 1, r, k);     }   }   int main() {     cin >> n;     int mx = 0;     for (int i = 0, a, b; i < n; i++) {       scanf( %d%d , &a, &b);       if (a != 0)         p[a].push_back(b);       else         vote++;     }     for (int i = 1; i < 110000; i++) {       sort(p[i].begin(), p[i].end());       reverse(p[i].begin(), p[i].end());       mx = max(mx, (int)p[i].size());     }     for (int i = 1; i < 110000; i++) {       int m = (int)p[i].size();       for (int j = 0; j < m; j++) {         x[tot++] = pair<int, int>(j + 1, p[i][j]);       }     }     sort(x, x + tot);     for (int i = 0; i < tot; i++) {       if (i == 0)         sum[i] = x[i].second;       else         sum[i] = sum[i - 1] + x[i].second;     }     long long ans = 1e10;     int pre = 0;     for (int i = 0; i <= mx + 1; i++) {       int indx = upper_bound(x, x + tot, pair<int, int>(i, 1e9)) - x;       long long cans = sum[tot - 1] - sum[indx] + x[indx].second;       if (indx == tot) cans = 0;       while (pre < indx) {         add(1, L, R, x[pre].second);         pre++;       }       indx = tot - indx + vote;       if (i >= indx) {         indx = i - indx + 1;         cans += ask(1, L, R, indx);       }       ans = min(ans, cans);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int i, a, p, b, p1, p2;     cin >> a;     b = a;     p = 0;     p1 = p2 = 1;     for (i = 2; i <= sqrt(b); i++) {       if (b % i == 0) {         b = b / i;         p++;         if (p == 1) p1 = i;         if (p == 2) p2 = i;         i--;       }     }     if (p == 0) cout << 1 << endl << 0 << endl;     if (p == 1) cout << 2 << endl;     if (p >= 2) cout << 1 << endl << p1 * p2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class P, class Q>   ostream& operator<<(ostream& stream, pair<P, Q> v) {     stream <<  (  << v.first <<  ,  << v.second <<  ) ;     return stream;   }   template <class T>   ostream& operator<<(ostream& stream, const vector<T> v) {     stream <<  [  ;     for (int i = 0; i < (int)v.size(); i++) stream << v[i] <<    ;     stream <<  ] ;     return stream;   }   template <class T>   T smin(T& a, T b) {     if (a > b) a = b;     return a;   }   template <class T>   T smax(T& a, T b) {     if (a < b) a = b;     return a;   }   const long long M = 10004205361450474;   int ask(vector<long long> s) {     int sz = s.size();     cout << sz <<    ;     for (int i = 0; i < sz; ++i) cout << s[i] <<    n [i == sz - 1];     fflush(stdout);     int v = 0;     cin >> v;     if (v == -1) {       exit(0);     }     return v;   }   const int N = 1e4 + 5;   long long dp[N][6];   long long f(int A, int B) {     if (!B) return 0;     if (dp[A][B] != -1) return dp[A][B];     long long& ans = dp[A][B];     ans = 0;     const int W = A;     for (int i = 0; i < W; ++i) {       ans += f(A, B - 1) + 1;       A = min(10000ll, A + f(A, B - 1) + 1);     }     ans += f(A, B - 1);     return ans;   }   long long g(long long a, int b) { return f(min(10000ll, a), b); }   int main(void) {     memset(dp, -1, sizeof(dp));     const long long c1 = M - f(10000, 4);     const long long c2 = 2046;     const long long c3 = 6;     long long l, r;     int used = 5;     --used;     if (ask(vector<long long>{c1}) > 0) {       l = c1 + 1;       r = M;       goto shit;     }     --used;     if (ask(vector<long long>{c2}) > 0) {       l = c2 + 1;       r = c1 - 1;       goto shit;     }     --used;     if (ask(vector<long long>{c3}) > 0) {       l = c3 + 1;       r = c2 - 1;     } else {       l = 1;       r = c3 - 1;     }   shit:     for (int cs = used - 1; cs >= 0; --cs) {       vector<long long> s;       for (long long i = l; i + g(i, cs) <= r && s.size() < min(10000ll, l);            i += g(i, cs) + 1)         s.push_back(i + g(i, cs));       int v = ask(s);       if (!v) {         smin(r, s[0] - 1);       } else if (v == s.size()) {         smax(l, s.back() + 1);       } else {         smin(r, s[v] - 1);         smax(l, s[v - 1] + 1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long f[60][110][2];   long long bin[60], num[60], s, tt;   inline long long rd() {     long long x = 0;     char ch = getchar();     for (; ch <  0  || ch >  9 ; ch = getchar())       ;     for (; ch >=  0  && ch <=  9 ; ch = getchar()) x = x * 10 + ch -  0 ;     return x;   }   int main() {     s = rd();     bin[0] = 1;     for (int i = 1; i <= 51; i++) bin[i] = bin[i - 1] * 2;     long long ans = 0;     for (int h = 1; bin[h] - 1 <= s; h++) {       long long hh = s % (bin[h] - 1);       for (int j = h - 1; j; j--)         if (bin[j] - 1 <= hh) hh -= bin[j] - 1;       ans += (!hh);     }     for (int h0 = 1; h0 <= 50; h0++)       for (int h1 = 1; h1 <= 50; h1++)         if (bin[h0 + 1] + bin[h1 + 1] - 3 <= s - bin[h1] + 1) {           long long hh = (s - bin[h1] + 1) % (bin[h0 + 1] + bin[h1 + 1] - 3);           for (int n = 0; n <= h0 + h1 - 2 && n <= hh; n++) {             tt = 0;             long long now = hh + n;             if (now & 1) continue;             memset(num, 0, sizeof(num));             for (now >>= 1; now; now >>= 1) num[++tt] = now & 1;             memset(f, 0, sizeof(f));             f[0][0][0] = 1;             for (int i = 1; i <= tt; i++)               for (int j = 0; j <= n; j++)                 for (int k = 0; k < 2; k++)                   if (f[i - 1][j][k]) {                     for (int l1 = 0; l1 < 2; l1++)                       for (int l2 = 0; l2 < 2; l2++) {                         if ((i >= h0 && l1) || (i >= h1 && l2)) continue;                         int hh = l1 + l2 + k, now = j + l1 + l2;                         if ((hh & 1) == num[i])                           f[i][now][hh >> 1] += f[i - 1][j][k];                       }                   }             ans += f[tt][n][0];           }         }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int shortestPaths[100][100];   int graph[100][100];   void bfs(int start, int n) {     queue<int> q;     q.push(start);     int visited[n];     for (int i = 0; i < n; i++) {       visited[i] = 0;     }     visited[start] = 1;     int dist = 1;     while (true) {       int sz = q.size();       if (sz == 0) {         break;       }       for (int i = 0; i < sz; i++) {         int cur = q.front();         q.pop();         for (int j = 0; j < 100; j++) {           if (graph[cur][j] == 1 && visited[j] == 0) {             visited[j] = 1;             shortestPaths[start][j] = dist;             q.push(j);           }         }       }       dist++;     }   }   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 0; i < 100; i++) {       for (int j = 0; j < 100; j++) {         shortestPaths[i][j] = 0;         graph[i][j] = 0;       }     }     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (int j = 0; j < n; j++) {         graph[i][j] = (int)(s[j] -  0 );       }     }     int m;     cin >> m;     vector<int> vertices;     for (int i = 0; i < m; i++) {       int a;       cin >> a;       a--;       vertices.push_back(a);     }     for (int i = 0; i < n; i++) {       bfs(i, n);     }     vector<int> result;     result.push_back(vertices[0]);     int last = vertices[0];     int ind = 0;     for (int i = 1; i < m; i++) {       if (i != 1) {         if (shortestPaths[last][vertices[i]] < i - ind) {           result.push_back(vertices[i - 1]);           ind = i - 1;           last = vertices[i - 1];         }       }     }     result.push_back(vertices[vertices.size() - 1]);     cout << result.size() << endl;     for (int i = 0; i < result.size(); i++) {       cout << result[i] + 1 <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 111111;   long long tree[maxn * 4];   void Insert(int o, int l, int r, int k, int v) {     if (l == r) {       tree[o] = v;       return;     }     int mid = (l + r) >> 1;     if (k <= mid)       Insert(o * 2, l, mid, k, v);     else       Insert(o * 2 + 1, mid + 1, r, k, v);     tree[o] = tree[o * 2] + tree[o * 2 + 1];   }   long long Query(int o, int l, int r, int L, int R) {     if (L <= l && r <= R) return tree[o];     int mid = (l + r) >> 1;     long double ans = 0;     if (L <= mid) ans += Query(o * 2, l, mid, L, R);     if (R > mid) ans += Query(o * 2 + 1, mid + 1, r, L, R);     return ans;   }   int n, x, a[maxn], f[maxn];   int main() {     cin >> n;     long double ans = 0;     for (int i = 1; i <= n; i++) cin >> a[i], f[a[i]] = i;     for (int i = 1; i <= n; i++) {       ans += Query(1, 1, n, a[i], n);       Insert(1, 1, n, a[i], 1);     }     ans *= ((long long)n * (n + 1));     memset(tree, 0, sizeof(tree));     long long last = 0;     for (int i = 1; i <= n; i++) {       ans -= (last + Query(1, 1, n, a[i], n));       last = last + Query(1, 1, n, a[i], n);       Insert(1, 1, n, a[i], f[a[i]] * 2);     }     for (int i = 1; i <= n; i++)       ans += ((long long)(n - i + 1) * i * (i - 1) / 2);     ans /= ((long long)n * (n + 1));     cout << setprecision(15) << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[200001][22];   int p[200001];   int d[200001];   int lca(int u, int v) {     if (d[u] < d[v]) swap(u, v);     int k = d[u] - d[v];     while (k > 0) {       int t = log2(k);       k -= (1 << t);       u = a[u][t];     }     if (u == v) return v;     for (int i = 20; i >= 0; i--) {       if (a[u][i] != a[v][i]) u = a[u][i], v = a[v][i];     }     return p[v];   }   int orobitiasvla(int x, int v) {     while (x > 0) {       int t = log2(x);       v = a[v][t];       x -= (1 << t);     }     return v;   }   int main() {     int n;     cin >> n;     int cnt = 2;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= 20; j++) a[i][j] = -1;     }     d[1] = 0;     int d1 = 1, d2 = 1;     int mx = 0;     n--;     while (n--) {       int k;       cin >> k;       a[cnt][0] = k;       p[cnt] = k;       d[cnt] = d[k] + 1;       for (int i = 1; i <= 20; i++)         if (d[cnt] >= (1 << i)) a[cnt][i] = orobitiasvla((1 << i) - 1, k);       int y = lca(cnt, d1);       int cost = d[cnt] - d[y] + d[d1] - d[y];       y = lca(cnt, d2);       int cost1 = d[cnt] - d[y] + d[d2] - d[y];       if (cost1 > mx || cost > mx) {         if (cost > cost1)           d2 = cnt;         else           d1 = cnt;         mx = max(cost, cost1);       }       cout << mx <<    ;       cnt++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 6e5 + 7;   int a, b, n, ans;   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     cin >> a >> b, n = a + b;     for (int l = 1, r, s; l <= n; l = r + 1) {       s = n / l, r = n / s;       int al = (a + s) / (s + 1), ar = a / s, bl = (b + s) / (s + 1), br = b / s;       if (al <= ar && bl <= br) ans += min(ar + br, r) - max(al + bl, l) + 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a, b, c, d, s, len;   vector<long long> z, t, v[2];   map<long long, int> ma;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> a >> b >> c >> d >> s >> len;     t.assign(n + 1, -1);     v[0].assign(n + 1, s);     v[1].assign(n + 1, s);     for (int i = 0; i < n; ++i) {       int q;       cin >> t[i + 1] >> q;       v[0][i + 1] = v[0][i] + (q ? a : -b);       v[1][i + 1] = v[1][i] + (q ? c : -d);     }     int lim = 0;     ++ma[v[1][0]];     for (int i = 0; i < n + 1; ++i) {       if (v[0][i] < 0) break;       if (!(--ma[v[1][i]])) ma.erase(v[1][i]);       int be = t[i] + 1;       while (lim < n + 1 && t[lim] < be + len) {         ++ma[v[1][lim]];         ++lim;       }       if (i + 1 == lim || v[0][i] - v[1][i] + ma.begin()->first >= 0) {         cout << be << endl;         return 0;       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int A[100], L[100], n, m;     cin >> n >> m;     for (int i = 0; i < n; ++i) cin >> A[i], A[i]--;     for (int i = 0; i < m; ++i) cin >> L[i];     for (int i = 0; i < n; ++i) {       for (int j = i + 1; j <= n; ++j) {         vector<int> cnt(m + 1, 0);         for (int k = i; k < j; ++k) cnt[A[k]]++;         bool fl = true;         for (int k = 0; k < m; ++k) fl &= (L[k] == cnt[k]);         if (fl) {           cout <<  YES n ;           return 0;         }       }     }     cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, b[1000010];   int main() {     scanf( %d%d , &n, &k);     int i;     if (k * 3 > n || k == 1)       puts( -1 );     else {       for (i = 1; i <= (int)(k); ++i) b[i] = b[i + 2 * k] = i, b[i + k] = i - 1;       b[k + 1] = k;       for (i = 3 * k + 1; i <= n; ++i) b[i] = 1;       for (i = 1; i <= (int)(n); ++i) printf( %d  , b[i]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[9][5], b[8];   long long dis(int i, int j) {     long long x = a[i][0] - a[j][0], y = a[i][1] - a[j][1], z = a[i][2] - a[j][2];     return x * x + y * y + z * z;   }   bool check() {     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         if (i == j) continue;         if (j < i)           b[j] = dis(i, j);         else           b[j - 1] = dis(i, j);       }       sort(b, b + 7);       long long t1 = b[0], t2 = 2 * b[0], t3 = 3 * b[0];       if (t1 == 0 || t1 != b[1] || t1 != b[2] || t2 != b[3] || t2 != b[4] ||           t2 != b[5] || t3 != b[6])         return false;     }     return true;   }   bool is_ok(int cur) {     if (cur == 8) {       return check();     }     sort(a[cur], a[cur] + 3);     do {       if (is_ok(cur + 1)) return true;     } while (next_permutation(a[cur], a[cur] + 3));     return false;   }   int main() {     for (int i = 0; i < 8; i++) cin >> a[i][0] >> a[i][1] >> a[i][2];     if (!is_ok(0))       puts( NO );     else {       puts( YES );       for (int i = 0; i < 8; i++)         for (int j = 0; j < 3; j++) {           cout << a[i][j] <<    ;           if (j == 2) cout << endl;         }     }     return 0;   }