malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int a, n;   int main() {     scanf( %d %d , &n, &a);     int res = 0;     if (a % 2 == 1)       printf( %d n , a / 2 + a % 2);     else       printf( %d n , n / 2 - a / 2 + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }   int main() {     int n;     long long k, sum2, sum3;     int a[100005], c[100005];     long long b[100005];     int i, j, count;     cin >> n;     cin >> k;     for (i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     count = 0;     for (i = 0; i < n; i++) {       j = i;       while (a[j] == a[i] && j < n) j++;       b[count] = j - i;       c[count] = a[i];       count++;       i = j - 1;     }     sum2 = 0;     for (i = 0; i < count; i++) {       if (sum2 + b[i] * n >= k) {         sum3 = 0;         for (j = 0; j < count; j++) {           sum3 += (b[i] * b[j]);           if (sum2 + sum3 >= k) {             printf( %d %d , c[i], c[j]);             return 0;           }         }       } else         sum2 += (b[i] * n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x, y, z, t1, t2, t3;   int main() {     scanf( %lld%lld%lld%lld%lld%lld , &x, &y, &z, &t1, &t2, &t3);     puts(abs(x - y) * t1 >= abs(x - y) * t2 + abs(x - z) * t2 + 3 * t3 ?  YES                                                                         :  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, l, r, k, c, i;   string s;   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     if (n == 0) {       cout <<  a             <<   n ;       return 0;     }     while (n > 0) {       l = 1;       r = 100000;       k++;       while (l < r) {         c = (l + r) / 2;         if (c * (c - 1) / 2 > n)           r = c;         else           l = c + 1;       }       if (l * (l - 1) / 2 > n) l--;       n -= (l * (l - 1) / 2);       for (i = 1; i <= l; i++) s += char(96 + k);     }     cout << s <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   const long long MAX = 100005;   const long double PI = 3.14159265359;   const long double G = 9.807;   const long long INF = 1e18;   const long double EPS = 1e-6;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   bool isprime(long long a) {     if (a == 2) return 1;     if (!(a & 1)) return 0;     for (long long i = 3; i * i <= a; i += 2)       if (a % i == 0) return 0;     return 1;   }   long long mpow(long long base, long long exponent, long long modulus) {     if (modulus == 1) return 0;     long long result = 1;     base = base % modulus;     while (exponent) {       if (exponent % 2 == 1) result = (result * base) % modulus;       exponent = exponent >> 1;       base = (base * base) % modulus;     }     return result;   }   long long minv(long long a, long long mod) {     long long _gcd = gcd(a, mod);     assert(_gcd == 1);     return mpow(a, mod - 2, mod);   }   long long t;   long long dp[35];   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> t;     while (t--) {       long long d, mod;       cin >> d >> mod;       long long temp = d;       long long mxb = 0;       memset(dp, 0, sizeof dp);       for (long long i = 0; i <= 32; ++i) {         long long p = (1LL << i);         if (p > temp) {           mxb = i;           break;         }       }       long long ans = 1 % mod;       dp[1] = 1 % mod;       for (long long i = 2; i <= mxb; ++i) {         long long nums = mpow(2LL, i - 1, mod);         if (i == mxb) {           nums = d - mpow(2LL, i - 1, mod) + 1;           nums += mod;           nums %= mod;         }         dp[i] += nums;         dp[i] %= mod;         for (long long j = i - 1; j >= 1; --j) {           dp[i] += dp[j] * nums % mod;           dp[i] %= mod;         }         ans += dp[i];         ans %= mod;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char* argv[]) {     ios_base::sync_with_stdio(false);     std::cin.tie(NULL);     std::cout.tie(NULL);     ;     string s;     getline(cin, s);     long long int ans = 0, cur = 0;     int sg = +1;     for (int i = (0); i < (int((s).size())); i += (1)) {       if (s[i] ==  +  || s[i] ==  - ) {         ans += sg * cur;         cur = 0;       }       if (s[i] ==  + ) sg = +1;       if (s[i] ==  - ) sg = -1;       cur = (cur * 10) + (s[i] -  0 );       if (i == int((s).size()) - 1) {         ans += sg * cur;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 2e5 + 5;   int mark[2][M];   int h[2][M];   int32_t main() {     ios_base::sync_with_stdio(false);     ;     int n, k;     cin >> n >> k;     for (int i = 0; i < 2; i++) {       string s;       cin >> s;       for (int j = 0; j < n; j++)         if (s[j] ==  X ) mark[i][j] = 1;     }     mark[0][0] = 1;     queue<pair<int, int> > q;     q.push(make_pair(0, 0));     while (q.size()) {       int x = (q.front()).first;       int y = (q.front()).second;       if (y >= n) return cout <<  YES  << endl, 0;       int t = h[x][y];       for (int i = 0; i < 2; i++)         if (!mark[i][t]) mark[i][t] = 1;       if (!mark[x][y + 1]) {         h[x][y + 1] = h[x][y] + 1;         mark[x][y + 1] = 1;         q.push(make_pair(x, y + 1));       }       if (y > 0 && !mark[x][y - 1]) {         h[x][y - 1] = h[x][y] + 1;         mark[x][y - 1] = h[x][y] + 1;         q.push(make_pair(x, y - 1));       }       if (!mark[1 - x][y + k]) {         h[1 - x][y + k] = h[x][y] + 1;         mark[1 - x][y + k] = 1;         q.push(make_pair(1 - x, y + k));       }       q.pop();     }     return cout <<  NO  << endl, 0;   }
#include <bits/stdc++.h>   using namespace std;   using pii = pair<int, int>;   int n;   vector<int> a[200];   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;     cin >> n;     int k = (1 + sqrt(1 + 8 * n)) / 2, x = 1;     cout << k << endl;     for (int i = 1; i <= k; i++) {       for (int j = i + 1; j <= k; j++) {         a[i].push_back(x);         a[j].push_back(x);         x++;       }     }     for (int i = 1; i <= k; i++) {       int m = a[i].size();       for (int j = 0; j < m; j++) {         cout << a[i][j] << (j == m - 1 ?   n  :    );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> adj[100000];   vector<int> hs;   bool possible(int wantvalue, int maxcost) {     const int nhs = hs.size();     long long cost = 0;     int i = 0;     for (int j = 0; j <= nhs; j++) {       while (j - i > wantvalue) {         cost -= (hs[j - 1] - hs[i]);         i++;       }       if (j - i >= wantvalue && cost <= (long long)maxcost) return true;       if (j - i > 0 && j < nhs) {         cost += (long long)(hs[j] - hs[j - 1]) * (j - i);       }     }     return false;   }   void dfs(int v, int parent, int height) {     if (parent != -1) hs.push_back(height);     for (int i = 0; i < (int)adj[v].size(); i++) {       int v2 = adj[v][i];       if (v2 == parent) continue;       dfs(v2, v, height + 1);     }   }   int main(int argc, char** argv) {     int m, k, p;     scanf( %d %d %d , &m, &k, &p);     for (int i = 0; i < m - 1; i++) {       int a, b;       scanf( %d %d , &a, &b);       a--, b--;       adj[a].push_back(b);       adj[b].push_back(a);     }     dfs(0, -1, 0);     sort(hs.begin(), hs.end());     int l = 0, r = k;     while (l < r) {       int mid = (l + r + 1) / 2;       if (possible(mid, p))         l = mid;       else         r = mid - 1;     }     printf( %d n , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double Ax, Ay, Bx, By, Cx, Cy, a11, a12, a21, a22, det;   bool flag;   void f(double x, double y) {     double tx, ty;     tx = a11 * x + a12 * y;     ty = a21 * x + a22 * y;     cerr << tx <<     << ty <<   n ;     tx = fabs(tx);     ty = fabs(ty);     tx += 1e-11;     ty += 1e-11;     tx -= (long long)tx;     ty -= (long long)ty;     if (flag) {       tx = x;       ty = y;     }     if (fabs(tx) < 1e-10 && fabs(ty) < 1e-10) {       cout <<  YES n ;       exit(0);     }   }   int main() {     cin >> Ax >> Ay >> Bx >> By >> Cx >> Cy;     det = Cx * Cx + Cy * Cy;     flag = fabs(det) < 1e-10;     a11 = Cx / det;     a12 = Cy / det;     a21 = -Cy / det;     a22 = Cx / det;     f(Bx - Ax, By - Ay);     f(Bx - Ay, By + Ax);     f(Bx + Ax, By + Ay);     f(Bx + Ay, By - Ax);     cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a, b, d1, d2;   int main() {     int n, l;     cin >> n >> l;     a.resize(n);     b.resize(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     for (int i = 0; i < n; ++i) {       cin >> b[i];     }     a.push_back(l + a[0]);     b.push_back(l + b[0]);     for (int i = 1; i <= n; ++i) {       d1.push_back(a[i] - a[i - 1]);       d2.push_back(b[i] - b[i - 1]);     }     for (int i = 0; i < n; i++) {       bool flag = 1;       for (int j = 0; j < n; j++) {         if (d1[j] != d2[(j + i) % n]) {           flag = 0;           break;         }       }       if (flag) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long dp[11][2][1010][1010];   string s, t;   long long bt(int K, bool f, int a, int b) {     if (K == 0) return 0;     long long& ref = dp[K][f][a][b];     if (ref != -1) return ref;     ref = INT_MIN;     if (f) {       ref = bt(K - 1, 0, a, b);       if (a < s.size() && b < t.size() && s[a] == t[b])         ref = max(ref, 1 + bt(K, 1, a + 1, b + 1));     } else {       if (a < s.size()) ref = bt(K, 0, a + 1, b);       if (b < t.size()) ref = max(ref, bt(K, 0, a, b + 1));       if (a < s.size() && b < t.size() && s[a] == t[b])         ref = max(ref, 1 + bt(K, 1, a + 1, b + 1));     }     return ref;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int N, M, K;     cin >> N >> M >> K;     cin >> s >> t;     memset(dp, -1, sizeof dp);     assert(bt(K, 0, 0, 0) >= K);     cout << bt(K, 0, 0, 0) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void model(vector<int>& a, const vector<pair<int, int> >& v) {     for (pair<int, int> p : v) swap(a[p.first], a[p.second]);   }   bool check(int n, const vector<pair<int, int> >& v) {     vector<int> a(n);     for (int i = 0; i < n; ++i) a[i] = i;     model(a, v);     for (int i = 0; i < n; ++i)       if (a[i] != i) return false;     return true;   }   vector<pair<int, int> > sol0, sol1;   void solve(int n, vector<pair<int, int> >& res) {     if (n < 4) return;     solve(n - 4, res);     for (int i = 0; i + 1 < n - 4; i += 2) {       res.push_back(pair<int, int>(i, n - 4));       res.push_back(pair<int, int>(i + 1, n - 3));       res.push_back(pair<int, int>(i + 1, n - 4));       res.push_back(pair<int, int>(i, n - 3));       res.push_back(pair<int, int>(i, n - 2));       res.push_back(pair<int, int>(i + 1, n - 1));       res.push_back(pair<int, int>(i + 1, n - 2));       res.push_back(pair<int, int>(i, n - 1));     }     if (n % 2) {       res.push_back(pair<int, int>(n - 5, n - 4));       res.push_back(pair<int, int>(n - 5, n - 3));       res.push_back(pair<int, int>(n - 5, n - 2));       res.push_back(pair<int, int>(n - 4, n - 1));       res.push_back(pair<int, int>(n - 5, n - 1));       for (pair<int, int> p : sol1) {         res.push_back(pair<int, int>(p.first + n - 4, p.second + n - 4));       }     } else {       for (pair<int, int> p : sol0) {         res.push_back(pair<int, int>(p.first + n - 4, p.second + n - 4));       }     }     assert(res.size() == n * (n - 1) / 2);   }   void solve0() {     vector<pair<int, int> > v;     for (int i = 0; i < 4; ++i)       for (int j = i + 1; j < 4; ++j) v.push_back(pair<int, int>(i, j));     do {       if (check(4, v)) {         sol0 = v;         break;       }     } while (next_permutation(v.begin(), v.end()));     assert(!sol0.empty());   }   void solve1() {     vector<pair<int, int> > v;     for (int i = 0; i < 4; ++i)       for (int j = i + 1; j < 4; ++j)         if (pair<int, int>(i, j) != pair<int, int>(0, 3))           v.push_back(pair<int, int>(i, j));     do {       vector<int> st = {3, 0, 1, 2};       vector<int> en = {0, 1, 2, 3};       model(st, v);       if (st == en) {         sol1 = v;         break;       }     } while (next_permutation(v.begin(), v.end()));     assert(!sol1.empty());   }   int main() {     std::ios::sync_with_stdio(false);     solve0();     solve1();     int n;     cin >> n;     if (n * (n - 1) / 2 % 2) {       cout <<  NO n ;       return 0;     }     cout <<  YES n ;     vector<pair<int, int> > res;     solve(n, res);     for (int i = 0; i < res.size(); ++i) {       cout << min(res[i].first, res[i].second) + 1 <<                << max(res[i].first, res[i].second) + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t;   long long x, y;   int main() {     cin >> t;     while (t--) {       cin >> x >> y;       if (x == y)         cout << x << endl;       else if (x > y)         cout << x + y << endl;       else         cout << y - y % x / 2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int q;     cin >> q;     for (long long int l = 0; l < q; l++) {       long long int n;       cin >> n;       long long int ans = 0;       while (n != 1) {         long long int track = ans;         while (n % 2 == 0) {           n = n / 2;           ans++;         }         while (n % 3 == 0) {           n = 2 * n / 3;           ans++;         }         while (n % 5 == 0) {           n = 4 * n / 5;           ans++;         }         if (track == ans) break;       }       if (n != 1)         cout << -1 << endl;       else         cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t, n, i, j;     cin >> t;     while (t--) {       cin >> n;       if (n % 2 == 0) {         cout << n / 2 <<     << n / 2;       } else {         for (i = 3, j = 0; i * i <= n; i++) {           if (n % i == 0) {             cout << n / i <<     << n - (n / i);             j = 1;             break;           }         }         if (j == 0) cout << 1 <<     << n - 1;       }       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2E5 + 10;   const int P = 1E9 + 7;   int n, q;   struct node {     int l, r, id;   } qu[MAXN];   int a[MAXN], pri[1100], cnt;   int num[1000001];   long long ans[MAXN];   long long bin[MAXN];   vector<int> dir[1000001];   vector<int> rec[MAXN];   int pow(int a, int n) {     long long b = a;     long long ret = 1;     while (n) {       if (n & 1) ret = ret * b % P;       b = b * b % P;       n >>= 1;     }     return ret;   }   bool cmp(node n1, node n2) {     if (n1.l != n2.l)       return n1.l < n2.l;     else       return n1.r < n2.r;   }   bool prime(int p) {     for (int i = 0; pri[i] * pri[i] <= p; i++)       if (!(p % pri[i])) return false;     return true;   }   void init() {     pri[cnt = 0] = 2;     for (int i = 3; i < 100000; i++)       if (prime(i)) pri[++cnt] = i;     cnt++;     for (int i = 0; i < MAXN; i++) rec[i].clear();     for (int i = 0; i < MAXN; i++) bin[i] = 1;     for (int i = 0; i < 1000001; i++) dir[i].clear();     memset(num, 0, sizeof(num));   }   int exgcd(long long a, long long b, long long &x, long long &y) {     if (a == 0) {       x = 0;       y = 1;       return b;     } else {       long long tx, ty;       long long d = exgcd(b % a, a, tx, ty);       x = ty - (b / a) * tx;       y = tx;       return d;     }   }   int inverse(int k) {     long long a = k, b = P, x, y;     exgcd(a, b, x, y);     return (x % P + P) % P;   }   int main() {     int temp, l, u, v;     init();     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     scanf( %d , &q);     for (int i = 0; i < q; i++) {       scanf( %d%d , &qu[i].l, &qu[i].r);       qu[i].id = i;     }     sort(qu, qu + q, cmp);     for (int i = 1; i <= n; i++) {       for (int j = 0; pri[j] * pri[j] <= a[i]; j++) {         while (a[i] % pri[j] == 0) {           a[i] /= pri[j];           if (dir[pri[j]].empty())             temp = pri[j] - 1;           else             temp = pri[j];           dir[pri[j]].push_back(i);           rec[i].push_back(pri[j]);           for (int k = i; k <= n; k += k & -k) bin[k] = bin[k] * temp % P;         }       }       if (a[i] != 1) {         if (dir[a[i]].empty())           temp = a[i] - 1;         else           temp = a[i];         dir[a[i]].push_back(i);         rec[i].push_back(a[i]);         for (int k = i; k <= n; k += k & -k) bin[k] = bin[k] * temp % P;       }     }     l = 1;     for (int i = 0; i < q; i++) {       for (; l < qu[i].l; l++) {         for (int j = 0; j < rec[l].size(); j++) {           u = rec[l][j];           if (num[u] < dir[u].size() - 1)             v = dir[u][++num[u]];           else             v = n + 1;           temp = (long long)(u - 1) * inverse(u) % P;           for (int k = v; k <= n; k += k & -k) bin[k] = bin[k] * temp % P;         }       }       temp = qu[i].id;       ans[temp] = 1;       for (int k = qu[i].l - 1; k > 0; k -= k & -k)         ans[temp] = ans[temp] * bin[k] % P;       ans[temp] = inverse(ans[temp]);       for (int k = qu[i].r; k > 0; k -= k & -k) {         ans[temp] = ans[temp] * bin[k] % P;       }     }     for (int i = 0; i < q; i++) printf( %lld n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i;     string a[3];     cin >> a[0] >> a[1] >> a[2];     for (i = 0; i < 3; i++) {       if ((a[i] ==  rock ) && (a[(i + 1) % 3] ==  scissors ) &&           (a[(i + 2) % 3] ==  scissors )) {         break;       }       if ((a[i] ==  scissors ) && (a[(i + 1) % 3] ==  paper ) &&           (a[(i + 2) % 3] ==  paper )) {         break;       }       if ((a[i] ==  paper ) && (a[(i + 1) % 3] ==  rock ) &&           (a[(i + 2) % 3] ==  rock )) {         break;       }     }     if (i == 0) {       cout <<  F  << endl;     } else if (i == 1) {       cout <<  M  << endl;     } else if (i == 2) {       cout <<  S  << endl;     } else {       cout <<  ?  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, pos, lo, hi;     while (cin >> n >> pos >> lo >> hi) {       int cnt = 0;       if (lo == 1 && hi == n) {         cout <<  0  << endl;         continue;       }       int xlo = abs(pos - lo);       int xhi = abs(pos - hi);       if (lo - 1 >= 1 && hi + 1 <= n) {         cnt += 2;         if (xlo < xhi) {           cnt += xlo;         } else           cnt += xhi;         cnt += hi - lo;       } else if (lo - 1 >= 1) {         cnt += xlo;         cnt++;       } else {         cnt += xhi;         cnt++;       }       cout << cnt << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const int M = 1e5 + 5;   int main() {     ios_base::sync_with_stdio(false);     int tt;     cin >> tt;     while (tt--) {       int n, i, j;       cin >> n;       vector<long long> v[N];       for (i = 0; i < n; i++) {         int m;         long long p;         cin >> m >> p;         v[m].push_back(p);       }       int want[N];       int cnt = 0;       for (i = 0; i < n; i++) {         int lu = v[i].size();         if (lu == 0) continue;         want[i] = max(0, i - cnt);         cnt += lu;       }       multiset<long long> st;       long long ans = 0;       int taken = 0;       for (i = n - 1; i >= 0; i--) {         int lu = v[i].size();         if (lu == 0) continue;         for (j = 0; j < lu; j++) {           st.insert(v[i][j]);         }         int fu = st.size();         int req = min(max(0, want[i] - taken), fu);         for (j = 0; j < req; j++) {           ans += *(st.begin());           taken++;           st.erase(st.begin());         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300010;   const int MOD = 1000000007;   int n, m;   int a[N], b[N];   char mm[10010];   vector<int> f[N];   long long w[2010];   int RM(int a) {     if (!m) return 0;     int t;     for (int i = m - 1; i >= 0; i--) {       t = w[i] % a;       w[i] /= a;       if (i) w[i - 1] += t * 1000000000ll;     }     while (m && !w[m - 1]) m--;     return t;   }   int main() {     scanf( %d , &n);     for (int i = 2; i <= n; i++) scanf( %d , &a[i]);     a[1] = 1;     a[n + 1] = 1000000000;     for (int i = 1; i <= n; i++) scanf( %d , &b[i]);     scanf( %s , mm);     for (int i = strlen(mm) - 1; i >= 0; i -= 9, m++)       for (int j = max(0, i - 8); j <= i; w[m] = w[m] * 10 + mm[j++] -  0 )         ;     f[1].push_back(1);     for (int i = 1; i <= n; i++) {       int s = f[i].size(), sum = 0, md = 0;       if (a[i + 1] != 1) md = RM(a[i + 1]);       for (int j = 0; j < s + b[i]; j++) {         if (j < s) (sum += f[i][j]) %= MOD;         if (j > b[i]) (sum += MOD - f[i][j - b[i] - 1]) %= MOD;         if (j % a[i + 1] == md) f[i + 1].push_back(sum);       }     }     printf( %d n , m ? 0 : f[n + 1].size() == 0 ? 0 : f[n + 1][0]);   }
#include <bits/stdc++.h>   using namespace std;   char s[500005], t[500005];   long long ans;   int n, k, now, tmp;   int main() {     scanf( %d %d n , &n, &k);     fread(s + 1, 1, n, stdin);     getchar();     fread(t + 1, 1, n, stdin);     s[n + 1] =  # ;     if (k == 1) return printf( %d n , n), 0;     for (now = 1; s[now] == t[now]; now++)       ;     if (now > n) return printf( %d n , n), 0;     ans = now + 1;     for (int i = now + 1; i <= n; i++) {       tmp = tmp << 1;       if (s[i] ==  a ) tmp++;       if (t[i] ==  b ) tmp++;       tmp = min(k - 2, tmp);       ans += tmp + 2;     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   template <typename TF>   void write_debug_output(ostream &out, TF const &f) {     out << f << std::endl;   }   template <typename TF, typename... TR>   void write_debug_output(ostream &out, TF const &f, TR const &...rest) {     out << f <<    ;     write_debug_output(out, rest...);   }   using ll = long long;   using ull = unsigned long long;   using ld = long double;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   using pdd = pair<double, double>;   using vi = vector<int>;   using vii = vector<pii>;   using vll = vector<ll>;   using vs = vector<string>;   const int DR[] = {-1, 0, 1, 0, -1, 1, 1, -1};   const int DC[] = {0, -1, 0, 1, -1, -1, 1, 1};   const double PI = acos(-1.0);   const double EPS = 1e-9;   const int MOD = 1e9 + 7;   const int INF = 1073741823;   const ll INFLL = 4e18;   const int MAX = 100;   int N, M, aa[MAX + 5], bb[MAX + 5];   void read() {     cin >> N >> M;     for (int i = 0; i < (int)N; i++) cin >> aa[i];     for (int i = 0; i < (int)M; i++) cin >> bb[i];   }   void solve() {     int xorA = 0, xorB = 0;     for (int i = 0; i < (int)N; i++) xorA ^= aa[i];     for (int i = 0; i < (int)M; i++) xorB ^= bb[i];     if (xorA != xorB) {       cout <<  NO n ;       return;     }     cout <<  YES n ;     int b = bb[1];     int c = aa[1];     int a = aa[0] ^ bb[1] ^ (xorB ^ bb[0] ^ bb[1]);     for (int i = 0; i < (int)N; i++) {       for (int j = 0; j < (int)M; j++) {         if (i == 0 && j == 0)           cout << a <<    ;         else if (i == 0 && j == 1)           cout << b <<    ;         else if (i == 1 && j == 0)           cout << c <<    ;         else if (i == 0)           cout << bb[j] <<    ;         else if (j == 0)           cout << aa[i] <<    ;         else           cout <<  0  ;       }       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int TC = 1;     for (int tc = (int)1; tc <= (int)TC; tc++) {       read();       solve();     }   }