malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   inline void add(long long &a, long long b) {     a += b;     a %= MOD;   }   inline void sub(long long &a, long long b) {     a -= b;     a %= MOD;   }   inline long long mul(long long a, long long b) {     return (long long)a * b % MOD;   }   const int N = 1e6 + 10;   struct pnt {     long long x, y;     pnt(long long _x = 0, long long _y = 0) : x(_x), y(_y) {}     inline pnt operator+(const pnt &p) const { return pnt(x + p.x, y + p.y); }     inline pnt operator-(const pnt &p) const { return pnt(x - p.x, y - p.y); }     inline pnt &operator+=(const pnt &p) {       add(x, p.x), add(y, p.y);       return *this;     }     inline pnt &operator-=(const pnt &p) {       sub(x, p.x), sub(y, p.y);       return *this;     }     inline pnt operator*(const int &k) const { return pnt(x * k, y * k); }     inline pnt operator/(const int &k) const { return pnt(x / k, y / k); }     inline long long operator*(const pnt &p) const { return x * p.y - y * p.x; }     inline long long operator^(const pnt &p) const { return x * p.x + y * p.y; }     void out() { printf( (%lld,%lld)  , x, y); }   } p[3 * N];   long long get(int i, int j, int k) { return (p[j] - p[i]) * (p[k] - p[j]); };   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < (int)(n); i++) cin >> p[i].x >> p[i].y;     long long s = 0;     for (int i = 0; i < (int)(n); i++) s += p[i] * p[(i + 1) % n];     if (s < 0) {       s = -s;       reverse(p, p + n);     }     for (int i = 0; i < (int)(n); i++) p[i + 2 * n] = p[i + n] = p[i];     struct Calc {       long long sum, s;       pnt diff, diff2;       Calc() : sum(0), s(0) {}       void inc_r(int l, int r) {         s += get(l, r, r + 1);         assert(s >= 0);         add(sum, s);         diff2 += p[r + 1] - p[r];         diff -= diff2;       }       void inc_l(int l, int r) {         s -= get(l, l + 1, r);         pnt dp = p[l + 1] - p[l];         diff2 -= dp;         diff += dp * (r - l);         add(sum, dp * diff);       }     } c1, c2;     long long res = 0;     int r1 = 0, r2 = 0;     for (int l = 0; l < (int)(n); l++) {       while (r1 - l < n && abs(c1.s + get(l, r1, r1 + 1)) <= s / 2) {         c1.inc_r(l, r1++);       }       assert(r1 - l <= n - 2);       while (r2 - l < n - 2) c2.inc_r(l, r2++);       long long mid = (2 * c1.s == s ? s / 2 : 0LL);       long long big = c2.sum - c1.sum;       long long small = (c1.sum - mid);       add(res, big - small);       c1.inc_l(l, r1);       c2.inc_l(l, r2);     }     cout << ((res) % MOD + MOD) % MOD << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, l[1000005], dp[1000005][2][2];   char s[1000005];   void Calc(int k) {     if (s[k] ==  0 )       dp[k][0][0] = 1;     else if (s[k] ==  1 )       dp[k][1][1] = 1;     else {       dp[k][1][0] = 1;       dp[k][0][1] = 1;     }   }   void Change(int x, int L, int R, int O) {     int tmp[2][2] = {0};     for (int a = 0; a < 2; a++)       for (int b = 0; b < 2; b++)         if (dp[L][a][b])           for (int c = 0; c < 2; c++)             for (int d = 0; d < 2; d++)               if (dp[R][c][d])                 if (s[O] ==  & )                   tmp[a & c][b & d] = 1;                 else if (s[O] ==  | )                   tmp[a | c][b | d] = 1;                 else                   tmp[a ^ c][b ^ d] = 1;     for (int a = 0; a < 2; a++)       for (int b = 0; b < 2; b++) dp[x][a][b] = tmp[a][b];   }   int Dfs(int l) {     int r = l + 1, L = -1, O = -1;     while (s[r] !=  ) ) {       if ((s[r] ==  ?  || s[r] ==  0  || s[r] ==  1 ) && L == -1)         Calc(r), L = r, O = r + 1;       if (s[r] ==  ( ) r = Dfs(r);       r++;       if (r - l >= 3 && s[r] !=  ( ) {         if (s[r] ==  ?  || s[r] ==  1  || s[r] ==  0 ) {           Calc(r);           if (L != -1) Change(r, L, r, O);           L = r;           O = r + 1;           r++;         } else {           if (L != -1) Change(r - 1, L, r - 1, O);           L = r - 1;           O = r;         }         O = r;       }     }     for (int a = 0; a < 2; a++)       for (int b = 0; b < 2; b++) dp[r][a][b] = dp[r - 1][a][b];     return r;   }   int main() {     scanf( %d , &n);     scanf( %s , &s);     int n = strlen(s) - 1, flag = 0;     for (int i = 0; i <= n; i++)       if (s[i] ==  ? ) flag = 1;     if (n == 0) {       if (s[0] ==  0  || s[0] ==  1 )         puts( NO );       else         puts( YES );       return 0;     }     Dfs(0);     if (((dp[n][0][1] || dp[n][1][0]) && flag) || n == 0)       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 10, mod = 1e9 + 7;   int rd() {     int x = 0, w = 1;     char ch = 0;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + (ch ^ 48);       ch = getchar();     }     return x * w;   }   int prm[N], pm[N], tt, n, a[N], c[N][2];   bool v[N];   int main() {     for (int i = 2; i <= N - 5; ++i) {       if (!pm[i]) pm[i] = prm[++tt] = i;       for (int j = 1; i * prm[j] <= N - 5; ++j) {         pm[i * prm[j]] = prm[j];         if (i % prm[j] == 0) break;       }     }     n = rd();     for (int i = 1; i <= n; ++i) a[i] = rd();     sort(a + 1, a + n + 1), reverse(a + 1, a + n + 1);     for (int i = 1; i <= n; ++i) {       if (!c[a[i]][0])         v[i] = 1, c[a[i]][0] = c[a[i]][1] = 1;       else {         int x = a[i] - 1;         while (x > 1) {           int np = pm[x], cn = 0;           while (pm[x] == np) ++cn, x /= np;           if (c[np][0] < cn)             c[np][0] = cn, c[np][1] = 1;           else             c[np][1] += c[np][0] == cn;         }       }     }     int ans = 1;     for (int i = 2; i <= N - 5; ++i)       for (int j = 1; j <= c[i][0]; ++j) ans = 1ll * ans * i % mod;     for (int i = 1; i <= n; ++i)       if (!v[i]) {         int x = a[i] - 1, o = 1;         while (x > 1) {           int np = pm[x], cn = 0;           while (pm[x] == np) ++cn, x /= np;           o &= cn < c[np][0] || c[np][1] > 1;         }         if (o) {           ans = (ans + o) % mod;           break;         }       }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> edges[(200 * 1000 + 5)];   vector<int> f;   vector<int> a;   int dp[(200 * 1000 + 5)][5];   void read_data() {     cin >> n;     int u, v;     for (int i = 1; i < n; i++) {       scanf( %d %d , &u, &v);       edges[u].push_back(v);       edges[v].push_back(u);     }   }   void bfs() {     int qf, ql;     a.resize(n);     f.resize(n + 1);     vector<int> isv;     isv.resize(n + 1);     qf = ql = 0;     a[ql++] = 1;     isv[1] = true;     while (qf != ql) {       int u = a[qf++];       for (auto &v : edges[u])         if (!isv[v]) {           f[v] = u;           isv[v] = true;           a[ql++] = v;         }     }   }   void deal() {     int sum[5];     for (int i = n - 1; i > 0; i--) {       int u = a[i];       if (edges[u].size() == 1 && u != 1) {         memset(dp[u], 0, sizeof(dp[u]));         dp[u][0] = 1;         dp[u][1] = 0;         dp[u][2] = 1;       } else {         memset(sum, 0, sizeof(sum));         for (auto &v : edges[u])           if (v != f[u]) {             sum[2] += dp[v][2];             sum[1] += dp[v][1];           }         memset(dp[u], 0xff, sizeof(dp[u]));         dp[u][1] = sum[2];         dp[u][0] = sum[1] + 1;         for (auto &v : edges[u])           if (v != f[u]) {             if (dp[u][2] == -1) {               dp[u][2] = sum[2] - dp[v][2] + dp[v][0];             } else {               dp[u][2] = min(dp[u][2], sum[2] - dp[v][2] + dp[v][0]);             }           }         dp[u][2] = min(dp[u][2], dp[u][0]);         dp[u][1] = min(dp[u][1], dp[u][2]);       }     }     int ans = 0;     for (auto &v : edges[1]) ans += dp[v][0];     ans -= edges[1].size();     cout << ans << endl;   }   int main() {     read_data();     bfs();     deal();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void _print(int32_t t) { cerr << t; }   void _print(int64_t t) { cerr << t; }   void _print(string t) { cerr << t; }   void _print(char t) { cerr << t; }   void _print(long double t) { cerr << t; }   void _print(double t) { cerr << t; }   void _print(unsigned long long t) { cerr << t; }   template <class T, class V>   void _print(pair<T, V> p);   template <class T>   void _print(vector<T> v);   template <class T>   void _print(set<T> v);   template <class T, class V>   void _print(map<T, V> v);   template <class T>   void _print(multiset<T> v);   template <class T, class V>   void _print(pair<T, V> p) {     cerr <<  { ;     _print(p.first);     cerr <<  , ;     _print(p.second);     cerr <<  } ;   }   template <class T>   void _print(vector<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(set<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(multiset<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T, class V>   void _print(map<T, V> v) {     cerr <<  [  ;     for (auto i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   int64_t find(int64_t mid) {     int64_t ans = 0;     while (mid != 0) {       mid /= 2;       ans++;     }     return ans;   }   void solve() {     int64_t n, k;     cin >> n >> k;     int64_t low = 1, high = 1;     for (int64_t i = 0; i < n - 1; i += 1) {       high *= 2;       high++;     }     while (low <= high) {       int64_t mid = (low + high) / 2;       if (mid == k) {         cout << find(high - low + 1);         return;       }       if (mid > k) {         high = mid - 1;       }       if (mid < k) low = mid + 1;     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int64_t t = 1;     while (t--) {       solve();       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> s[100005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, i, j, a, b;     cin >> n >> m;     if (n == 1 && m == 1) {       cout <<  YES n  << 1;     } else if (n == 1 && m == 2) {       cout <<  NO ;     } else if (n == 2 && m == 1) {       cout <<  NO ;     } else if (n == 1 && m == 3) {       cout <<  NO ;     } else if (n == 3 && m == 1) {       cout <<  NO ;     } else if (n == 1 && m == 4) {       cout <<  YES n ;       cout <<  2 4 1 3 ;     } else if (n == 4 && m == 1) {       cout <<  YES n ;       cout <<  2 n4 n1 n3 ;     } else if (n == 2 && m == 2) {       cout <<  NO ;     } else if ((n == 2 && m == 3) || (n == 3 && m == 2)) {       cout <<  NO ;     } else if (n == 3 && m == 3) {       cout <<  YES n ;       cout <<  6 1 8 n7 5 3 n2 9 4 ;     } else if (n == 1 && m >= 5) {       vector<int> res;       for (i = 1; i <= m; i += 2) {         res.push_back(i);       }       for (i = 2; i <= m; i += 2) {         res.push_back(i);       }       cout <<  YES n ;       for (i = 0; i < m; i++) {         cout << res[i] <<    ;       }     } else if (n >= 5 && m == 1) {       vector<int> res;       for (i = 1; i <= n; i += 2) {         res.push_back(i);       }       for (i = 2; i <= n; i += 2) {         res.push_back(i);       }       cout <<  YES n ;       for (i = 0; i < n; i++) {         cout << res[i] <<   n ;       }     } else if (2 <= n && 4 <= m) {       a = 1;       for (i = 1; i <= n; i++) {         for (j = 1; j <= m; j++) {           s[i].push_back(a);           a++;         }       }       for (i = 2; i <= n; i += 2) {         a = s[i][0];         b = s[i][1];         for (j = 0; j < m - 2; j++) {           s[i][j] = s[i][j + 2];         }         s[i][m - 2] = a;         s[i][m - 1] = b;       }       for (i = 1; i < m; i += 2) {         a = s[1][i];         for (j = 1; j <= n - 1; j++) {           s[j][i] = s[j + 1][i];         }         s[n][i] = a;       }       cout <<  YES n ;       for (i = 1; i <= n; i++) {         for (j = 0; j < m; j++) {           cout << s[i][j] <<    ;         }         cout <<   n ;       }     } else {       a = 1;       for (i = 1; i <= n; i++) {         for (j = 1; j <= m; j++) {           s[i].push_back(a);           a++;         }       }       for (i = 1; i < m; i += 2) {         a = s[1][i];         b = s[2][i];         for (j = 1; j <= n - 2; j++) {           s[j][i] = s[j + 2][i];         }         s[n - 1][i] = a;         s[n][i] = b;       }       for (i = 2; i <= n; i += 2) {         a = s[i][0];         for (j = 0; j < m - 1; j++) {           s[i][j] = s[i][j + 1];         }         s[i][m - 1] = a;       }       cout <<  YES n ;       for (i = 1; i <= n; i++) {         for (j = 0; j < m; j++) {           cout << s[i][j] <<    ;         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void printVector(vector<string> &v) {     for (auto x : v) cout << x <<   n ;   }   void printVector(vector<int> &v) {     for (auto x : v) cout << x <<    ;     cout <<   n ;   }   int main() {     cin.tie(0);     cout.tie(0);     ios::sync_with_stdio(0);     int t;     t = 1;     while (t--) {       int n, k, x;       cin >> n >> k >> x;       vector<int> freq(1024, 0);       vector<int> upd(1024, 0);       vector<int> calc(1024);       for (int i = 0; i < 1024; i++) {         calc[i] = i xor x;       }       for (int i = 0; i < n; i++) {         int a;         cin >> a;         freq[a]++;       }       for (int i = 0; i < k; i++) {         int sum = 0;         for (int j = 0; j < 1024; j++) {           int s = freq[j];           if (sum % 2 == 0) s++;           s /= 2;           upd[calc[j]] += s;           sum += freq[j];           freq[j] -= s;         }         for (int j = 0; j < 1024; j++) {           freq[j] += upd[j];           upd[j] = 0;         }       }       int mn, mx;       for (int j = 0; j < 1024; j++) {         if (freq[j] > 0) {           mn = j;           break;         }       }       for (int j = 1023; j >= 0; j--) {         if (freq[j] > 0) {           mx = j;           break;         }       }       cout << mx <<     << mn <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int len, l, r;     bool operator<(const node &a) const { return len > a.len; }   };   int day[200010];   int m[200010];   int main() {     int n, k, c, i, j;     scanf( %d %d , &n, &k);     c = 0;     for (i = 0; i < n; i++) {       scanf( %d , &day[i]);       if (day[i] < 0) c++;     }     if (c > k) {       printf( -1 n );       return 0;     }     int turn = 0;     bool f = 0;     priority_queue<node> q;     for (i = 0; i < n; i++) {       if (day[i] < 0) {         m[i] = 1;         k--;       }       if (!f && day[i] < 0) {         turn++;         f = 1;       }       if (f && day[i] >= 0) {         turn++;         f = 0;       }     }     int l = 0, r = 0;     i = 0;     while (m[i] == 0 && i < n) i++;     for (; i < n; i++) {       if (m[i] == 0) {         l = i;         while (m[i] == 0 && i < n) i++;         r = i - 1;         node tp;         tp.l = l, tp.r = r;         tp.len = r - l + 1;         q.push(tp);         i = i - 1;       }     }     int tt = turn, kk = k;     while (!q.empty()) {       node x = q.top();       q.pop();       if (k < x.len && kk < x.len)         break;       else {         if (k >= x.len) {           k -= x.len;           if (x.r != n - 1) {             turn -= 2;           } else             turn--;         }         if (kk >= x.len) {           if (x.r != n - 1) {             kk -= x.len;             tt -= 2;           }         }       }     }     printf( %d n , min(turn, tt));   }
#include <bits/stdc++.h>   using namespace std;   inline void OPEN(const string &s) {     freopen((s +  .in ).c_str(),  r , stdin);     freopen((s +  .out ).c_str(),  w , stdout);   }   int main() {     int n;     scanf( %d , &n);     int art;     scanf( %d , &art);     int alex;     scanf( %d , &alex);     int ans[110] = {0};     for (int i = 0; i < art; i++) {       int temp;       scanf( %d , &temp);       if (ans[temp] == 0) ans[temp] = 1;     }     for (int i = 0; i < alex; i++) {       int temp;       scanf( %d , &temp);       if (ans[temp] == 0) ans[temp] = 2;     }     for (int i = 1; i < n + 1; i++) {       if (ans[i] == 0)         printf( 1  );       else         printf( %d  , ans[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   int M[2002][2002];   struct TA {     int a[2002], n;     void init(int _n) {       n = _n;       memset(a, 0, sizeof a);     }     int get(int p) {       int ret = 0;       for (p++; p > 0; p -= p & -p) ret ^= a[p - 1];       return ret;     }     void change(int l) {       for (l++; l <= n; l += l & -l) a[l - 1] ^= 1;     }     void change(int l, int r) {       change(l);       change(r + 1);     }   } R[2002], C[2002];   void put(int r, int c) {     R[r].change(min(r, c), max(r, c));     C[c].change(min(r, c), max(r, c));     M[r][c] ^= 1;   }   int get(int r, int c) { return R[r].get(c) ^ C[c].get(r) ^ M[r][c]; }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       scanf(   );       for (int j = 0; j < n; ++j) {         M[i][j] = getchar() ==  1 ;       }       R[i].init(n);       C[i].init(n);     }     int ans = 0;     for (int i = 0; i < n; ++i) {       for (int r = n - 1; r > i; --r) {         if (get(r, i)) {           ++ans;           put(r, i);         }       }       for (int c = n - 1; c > i; --c) {         if (get(i, c)) {           ++ans;           put(i, c);         }       }       if (get(i, i)) {         ++ans;         put(i, i);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class MinHeap {     vector<long long int> arr;     long long int size;       public:     MinHeap() { size = 0; }     long long int parent(long long int i) { return (i - 1) / 2; }     long long int lchild(long long int i) { return 2 * i + 1; }     long long int rchild(long long int i) { return 2 * i + 2; }     long long int minimum() { return arr[0]; }     long long int length() { return size; }     void insert(long long int i) {       size++;       arr.push_back(i);       long long int index = size - 1;       while (i != 0 && arr[parent(index)] > arr[index]) {         swap(arr[parent(index)], arr[index]);         index = parent(index);       }     }     void minheapify_down(long long int i) {       while (i < size) {         long long int l = lchild(i);         long long int r = rchild(i);         long long int small = i;         if (l < size) small = arr[small] < arr[l] ? small : l;         if (r < size) small = arr[small] < arr[r] ? small : r;         swap(arr[i], arr[small]);         if (i == small) break;         i = small;       }     }     void minheapify_up(long long int i) {       long long int index = i;       while (i != 0 && arr[parent(index)] > arr[index]) {         swap(arr[parent(index)], arr[index]);         index = parent(index);       }     }     void extractmin() {       long long int min = arr[0];       swap(arr[0], arr[size - 1]);       arr.pop_back();       size--;       minheapify_down(0);     }     void changekey(long long int i, long long int value) {       if (value > arr[i]) {         arr[i] = value;         minheapify_down(i);       } else {         arr[i] = value;         minheapify_up(i);       }     }     void deletekey(long long int i) {       changekey(i, LLONG_MIN);       extractmin();     }   };   int main() {     ;     ios::sync_with_stdio(0);     cin.tie(0);     ;     long long int n, k, t, b, ans = 0, count = 0, sum = 0;     cin >> n >> k;     vector<vector<long long int>> beauti(1000001);     for (long long int i = 0; i < n; i++) {       cin >> t >> b;       beauti[b].push_back(t);     }     MinHeap length;     for (long long int i = 1000000; i >= 1; i--) {       if (beauti[i].size() != 0) {         for (long long int j = 0; j < beauti[i].size(); j++) {           sum += beauti[i][j];           length.insert(beauti[i][j]);           count++;           if (count > k) {             long long int ele = length.minimum();             sum -= ele;             length.deletekey(0);             count--;           }         }         ans = max(ans, i * sum);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> invi(long long n) {     int x;     vector<long long> a;     for (long long i = 0; i < n; i++) {       cin >> x;       a.push_back(x);     }     return a;   }   void solve();   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t--) solve();   }   void solve() {     long long n, k;     cin >> n >> k;     vector<long long> jobcho = invi(n);     vector<long long> time = invi(n);     vector<long long> ind;     vector<long long> task;     for (long long i = 0; i < k; i++) {       task.push_back(0);       ind.push_back(n + 1);     }     for (long long i = 0; i < n; i++) {       if (task[jobcho[i] - 1] < time[i]) {         task[jobcho[i] - 1] = time[i];         ind[jobcho[i] - 1] = i;       }     }     for (long long i = 0; i < k; i++) {       if (ind[i] < (n + 1)) time[ind[i]] = 1e10;     }     long long jbleft = 0;     for (long long i = 0; i < k; i++) {       if (task[i] == 0) {         jbleft++;       }     }     sort(time.begin(), time.end());     long long sum = 0;     for (long long i = 0; i < jbleft; i++) {       sum += time[i];     }     cout << sum <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char prev[26], next[26];     for (int i = 0; i < 26; i++) prev[i] = next[i] = -1;     int n;     cin >> n;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       if (prev[s[0] -  a ] == -1) prev[s[0] -  a ] = 0;       if (next[s[(int)s.size() - 1] -  a ] == -1)         next[s[(int)s.size() - 1] -  a ] = 0;       for (int j = 1; j < (int)s.size(); j++) {         prev[s[j] -  a ] = s[j - 1];         next[s[j - 1] -  a ] = s[j];       }     }     for (int i = 0; i < 26; i++) {       if (prev[i] == 0) {         char cur =  a  + i;         while (cur) {           printf( %c , cur);           cur = next[cur -  a ];         }       }     }     return 0;   }
#include <bits/stdc++.h>   int n, a[100000], sum = 0;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       sum += a[i];     }     if (sum % n != 0)       printf( %d n , n - 1);     else       printf( %d n , n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INFint = 2147483547;   const long long INF = 9223372036854775807ll;   const long long MOD = 1000000007ll;   const long double EPS = 1e-13;   string min_cyclic_shift(string s) {     s += s;     int n = (int)s.length();     int i = 0, ans = 0;     while (i < n / 2) {       ans = i;       int j = i + 1, k = i;       while (j < n && s[k] <= s[j]) {         if (s[k] < s[j])           k = i;         else           ++k;         ++j;       }       while (i <= k) i += j - k;     }     return s.substr(ans, n / 2);   }   int main() {     ios_base::sync_with_stdio(0);     vector<string> a(2), b(2);     for (int i = 0; i < 2; i++) cin >> a[i];     for (int i = 0; i < 2; i++) cin >> b[i];     string s;     for (int i = 0; i < 2; i++) {       if (a[0][i] ==  X ) continue;       s += a[0][i];     }     for (int i = 1; i > -1; i--) {       if (a[1][i] ==  X ) continue;       s += a[1][i];     }     string s1;     for (int i = 0; i < 2; i++) {       if (b[0][i] ==  X ) continue;       s1 += b[0][i];     }     for (int i = 1; i > -1; i--) {       if (b[1][i] ==  X ) continue;       s1 += b[1][i];     }     if (min_cyclic_shift(s) == min_cyclic_shift(s1)) {       cout <<  YES ;     } else       cout <<  NO ;     fprintf(stderr,   nTIME = %lf n , 1.0 * clock() / CLOCKS_PER_SEC);     ;     return 0;   }