malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n;   int ans[200005];   void query(int nl, int nr) {     if (nl > nr) return;     printf( ? %d %d n , nl, nr);     fflush(stdout);     int x, f;     scanf( %d%d , &x, &f);     if (nr - f + 1 <= nl + f - 1) {       for (int i = nr - f + 1; i <= nl + f - 1; i++) ans[i] = x;       query(nl, nr - f);       query(nl + f, nr);     } else {       query(nl, ((nl + nr) >> 1));       query(((nl + nr) >> 1) + 1, nr);     }   }   int main() {     scanf( %d , &n);     query(1, n);     printf( ! %d , ans[1]);     for (int i = 2; i <= n; i++) printf(  %d , ans[i]);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int n = s.length();     for (int i = 0; i < n - 1; i++) {       if (s[i] == s[i + 1]) {         if (i + 2 < n) {           if (s[i + 1] ==  z  && s[i + 2] !=  a )             s[i + 1] =  a ;           else if (s[i + 1] ==  z  && s[i + 2] ==  a )             s[i + 1] =  b ;           else if (s[i + 1] !=  z  && s[i + 2] !=  z )             s[i + 1] =  z ;           else {             if (s[i + 1] ==  y )               s[i + 1] =  x ;             else               s[i + 1] =  y ;           }         } else {           if (s[i + 1] ==  z )             s[i + 1] =  a ;           else             s[i + 1] =  z ;         }       }     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   ostream& operator<<(ostream& cout, vector<T> V) {     cout <<  [  ;     for (auto v : V) cout << v <<    ;     return cout <<  ] ;   }   template <class L, class R>   ostream& operator<<(ostream& cout, pair<L, R> P) {     return cout <<  (  << P.first <<  ,  << P.second <<  ) ;   }   long long int n;   vector<long long int> a, b, c;   vector<vector<long long int>> conn;   vector<long long int> c0, c1;   long long int ans = 0;   void dfs1(long long int node, long long int par, long long int val) {     a[node] = min(a[node], val);     for (long long int i : conn[node]) {       if (i == par) continue;       dfs1(i, node, a[node]);     }   }   void dfs2(long long int node, long long int par) {     for (long long int i : conn[node]) {       if (i == par) continue;       dfs2(i, node);       c0[node] += c0[i];       c1[node] += c1[i];     }     if (b[node] == 0 && c[node] == 1) {       c0[node]++;     }     if (b[node] == 1 && c[node] == 0) {       c1[node]++;     }   }   long long int dfs3(long long int node, long long int par) {     long long int ct0 = 0, ct1 = 0;     if (b[node] == 0 && c[node] == 1) ct0 = 1;     if (b[node] == 1 && c[node] == 0) ct1 = 1;     for (long long int i : conn[node]) {       if (i == par) continue;       long long int temp = dfs3(i, node);       if (temp > 0) {         ct0 += temp;       } else {         ct1 -= temp;       }     }     long long int m = min(ct0, ct1);     ans += a[node] * m;     ct0 -= m;     ct1 -= m;     if (ct0) return ct0;     return -ct1;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     a.resize(n);     b.resize(n);     c.resize(n);     conn.resize(n);     for (long long int i = 0; i < (n); i++) cin >> a[i] >> b[i] >> c[i];     for (long long int i = 0; i < (n - 1); i++) {       long long int x;       cin >> x;       long long int y;       cin >> y;       x--, y--;       conn[x].push_back(y);       conn[y].push_back(x);     }     dfs1(0, -1, (long long int)1e18);     c0.resize(n);     c1.resize(n);     dfs2(0, -1);     if (dfs3(0, -1)) {       cout << -1 <<   n ;     } else {       cout << 2 * ans <<   n ;     }     cerr <<  Time :   << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC          <<  ms n ;     ;   }
#include <bits/stdc++.h>   long long n, md;   void rid(int n, int m) {     int i;     long long sol = 1, p = 1;     for (i = 0, p = n; i <= 30; i++) {       if ((m & (1 << i)) == (1 << i)) {         sol = (long long)sol * p;         sol = (long long)sol % md;       }       p = (long long)p * p;       p = (long long)p % md;     }     if (sol == 0)       sol = md - 1;     else       sol--;     printf( %I64d , sol);   }   int main() {     scanf( %I64d%I64d , &n, &md);     rid(3, n);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 510;   char g[maxn][maxn];   int col[maxn][maxn], v[maxn * maxn], b[maxn * maxn], cnt, n, k, sum;   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   void dfs(int x, int y, int c) {     col[x][y] = c;     ++cnt;     for (int i = 0; i < 4; ++i) {       int tx = x + dx[i], ty = y + dy[i];       if (tx < 0 || ty < 0 || tx >= n || ty >= n || g[tx][ty] ==  X  ||           col[tx][ty])         continue;       dfs(tx, ty, c);     }   }   void add(int x, int y) {     if (col[x][y] && ++v[col[x][y]] == 1) sum += b[col[x][y]];   }   void dec(int x, int y) {     if (col[x][y] && --v[col[x][y]] == 0) sum -= b[col[x][y]];   }   int main() {     scanf( %d %d , &n, &k);     for (int i = 0; i < n; ++i) scanf( %s , g[i]);     int c = 1;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j)         if (g[i][j] ==  .  && !col[i][j]) {           cnt = 0;           dfs(i, j, c);           b[c++] = cnt;         }     }     int ans = 0;     for (int i = 0; i + k <= n; ++i) {       memset(v, 0, sizeof v);       sum = 0;       for (int x = 0; x < k; ++x) {         for (int y = 0; y < k; ++y) {           add(x + i, y);           if (!col[x + i][y]) ++sum;         }         if (i + k < n) add(i + k, x);         if (k < n) add(x + i, k);         if (i) add(i - 1, x);       }       ans = max(ans, sum);       for (int j = 1; j + k <= n; ++j) {         if (i) {           if (j - 1 >= 0) dec(i - 1, j - 1);           add(i - 1, j + k - 1);         }         if (i + k < n) {           if (j - 1 >= 0) dec(i + k, j - 1);           add(i + k, j + k - 1);         }         if (j - 1 >= 0)           for (int t = 0; t < k; ++t)             if (!col[i + t][j - 1]) --sum;         if (j - 2 >= 0)           for (int t = 0; t < k; ++t) dec(i + t, j - 2);         if (j + k - 1 < n)           for (int t = 0; t < k; ++t)             if (!col[i + t][j + k - 1]) ++sum;         if (j + k <= n)           for (int t = 0; t < k; ++t) add(i + t, j + k);         ans = max(ans, sum);       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000100;   int N;   long long K;   long long arr[MAXN], anew[MAXN], tcur[MAXN], tnew[MAXN];   int main() {     scanf( %d %I64d , &N, &K);     arr[0] = 0;     for (int i = 1; i < N; i++) {       int p;       long long w;       scanf( %d %I64d , &p, &w);       p--;       arr[i] = arr[p] ^ w;     }     sort(arr, arr + N);     for (int i = 0; i < N; i++) anew[i] = arr[i];     long long ans = 0;     for (int i = 61; i >= 0; i--) {       for (int j = 0; j < N; j++) {         tcur[j] = (arr[j] >> i);         tnew[j] = (anew[j] >> i);       }       long long pp = 0;       int lloc = 0, rloc = 0;       while (lloc < N) {         long long cv = tcur[lloc];         while (rloc < N && tnew[rloc] < cv) rloc++;         long long nl = 0, nr = 0;         while (lloc < N && tcur[lloc] == cv) {           lloc++;           nl++;         }         while (rloc < N && tnew[rloc] == cv) {           rloc++;           nr++;         }         pp += nl * nr;       }       if (pp < K) {         ans += (1LL << i);         K -= pp;         for (int j = 0; j < N; j++) anew[j] ^= (1LL << i);         for (int j = 0; j < N - 1; j++) {           if (anew[j] > anew[j + 1]) {             int cj = j, ej = j + 1;             while (cj && anew[cj - 1] > anew[j + 1]) cj--;             while (ej < N - 1 && anew[ej + 1] < anew[j]) ej++;             reverse(anew + cj, anew + j + 1);             reverse(anew + j + 1, anew + ej + 1);             reverse(anew + cj, anew + ej + 1);           }         }       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> by;   vector<int> sl;   int main() {     long long int a, b, c, d, m, n, ck = 0, ans, s, r;     cin >> n >> m >> r;     for (int i = 0; i < n; i++) {       cin >> s;       by.push_back(s);     }     sort(by.begin(), by.end());     for (int j = 0; j < m; j++) {       cin >> b;       sl.push_back(b);     }     sort(sl.begin(), sl.end(), greater<int>());     long long int buy = r / by[0];     long long int rem = r % by[0];     long long int sell = buy * sl[0];     ans = sell + rem;     if (ans > r) {       cout << ans << endl;     } else {       cout << r << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   long long int M = 1e9 + 7;   long long int MOD = 998244353;   const double PI = 3.141592653589793238460;   long long int power(long long int a, long long int b) {     long long int res = 1;     if (a == 0) return 0;     if (a == 1) return 1;     for (; b > 0; b >>= 1) {       if (b & 1) {         res = (res * a);         if (res > M) res %= M;       }       a = (a * a);       if (a > M) a = a % M;     }     return res;   }   int main() {     long long int maxi = -1e18;     long long int n;     cin >> n;     long long int a[n], b[n];     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     for (int i = 0; i < n; i++) {       long long int x = a[i];       long long int y = b[i];       for (int j = i; j < n; j++) {         x |= (a[j]);         y |= (b[j]);         maxi = max(maxi, x + y);       }     }     cout << maxi;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     int arr[n][n];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) cin >> arr[i][j];     }     a[0] = 0;     for (int j = 1; j < n; j++) {       a[0] = a[0] | arr[0][j];       a[j] = arr[0][j];     }     for (int i = 1; i < n; i++) {       for (int j = i + 1; j < n; j++) {         a[i] = a[i] | arr[i][j];         a[j] = arr[i][j] | a[j];       }     }     for (int i = 0; i < n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long a, long long p, long long mod) {     long long ret = 1;     while (p) {       if (p & 1) ret = (ret * a) % mod;       a = (a * a) % mod;       p /= 2;     }     return ret;   }   long long DP[1000];   int A[1000];   int main() {     int n;     cin >> n;     for (__typeof((__typeof(n))0) i((__typeof(n))0); i < n; i++) {       cin >> A[i];       A[i]--;     }     for (int i = 0; i < n; i++) {       DP[i] = 2;       for (int j = A[i]; j < i; j++) DP[i] = (DP[i] + DP[j]) % 1000000007;     }     long long ans = 0;     for (int i = 0; i < n; i++) ans = (ans + DP[i]) % 1000000007;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1511, M = 3010100, inf = 0x7fffffff;   const long long llinf = 0x7fffffff7fffffffll;   long long x[N], y[N], r[N];   long long c[N];   double dist(int i, int j) {     return sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));   }   double area(int i) {     return 3.14159265358979323846264338327950288 * r[i] * r[i];   }   int main(int argc, const char* argv[]) {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> x[i] >> y[i] >> r[i];     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         if (r[i] < r[j] && dist(i, j) <= r[j]) {           ++c[i];         }       }     }     double sum = 0;     for (int i = 1; i <= n; ++i) {       if (c[i] == 0) {         sum += area(i);       } else if (c[i] % 2 == 1) {         sum += area(i);       } else {         sum -= area(i);       }     }     printf( %.10f , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> prices;   enum State { name, price };   double to_num(string s) {     double n = 0;     int dots = 0, dot = 0;     bool frac = false;     for (char c : s)       if (c ==  . ) ++dots;     if (s[s.size() - 3] ==  . ) frac = true;     for (int i = 0; i < s.size(); ++i) {       if (s[i] >=  0  && s[i] <=  9 ) {         n *= 10;         n += s[i] -  0 ;       } else if (s[i] ==  . )         ++dot;       if (dot == dots && frac) {         n += double(s[i + 1] -  0 ) / 10.;         n += double(s[i + 2] -  0 ) / 100.;         break;       }     }     return n;   }   string to_price(double n) {     string s = to_string(n);     string fraction;     int dot = 0;     for (int i = 0; i < s.size(); ++i)       if (s[i] ==  . ) dot = i;     if (s[dot + 1] !=  0  || s[dot + 2] !=  0 ) {       fraction.push_back( . );       fraction.push_back(s[dot + 1]);       fraction.push_back(s[dot + 2]);     }     string c = s.substr(0, dot);     s = c;     string integer = to_string(int(n));     string res;     for (int i = integer.size() - 1, k = 0; i >= 0; --i) {       ++k;       res.push_back(integer[i]);       if (k % 3 == 0 && i != 0) res.push_back( . );     }     reverse(res.begin(), res.end());     res += fraction;     return res;   }   int main() {     string input;     getline(cin, input);     string s;     State state = name;     for (char c : input) {       if (isalpha(c) && state == name)         continue;       else if (!isalpha(c) && state == name) {         state = price;         s.push_back(c);       } else if (!isalpha(c) && state == price)         s.push_back(c);       else if (isalpha(c) && state == price) {         state = name;         prices.push_back(s);         s.clear();       }     }     prices.push_back(s);     double sum = 0;     for (int i = 0; i < prices.size(); ++i) sum += to_num(prices[i]);     cout << to_price(sum);   }
#include <bits/stdc++.h>   using namespace std;   struct dot {     int value, i, j;   };   bool operator<(dot a, dot b) { return a.value < b.value; }   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n, m;       scanf( %d %d , &n, &m);       int num[n][m];       priority_queue<dot> pq;       for (int i = 0; i < n; ++i) {         for (int j = 0; j < m; ++j) {           scanf( %d , &num[i][j]);           pq.push({num[i][j], i, j});         }       }       dot d[n];       for (int i = 0; i < n; ++i) {         d[i] = pq.top();         pq.pop();       }       if (n == 4) {         bool did = false;         dot dsave;         if (d[0].j == d[1].j && d[2].j == d[3].j && d[0].j != d[2].j) {           bool b1 = abs(d[0].i - d[1].i) == 2;           bool b2 = abs(d[2].i - d[3].i) == 2;           if (b1 ^ b2) {             dsave = d[3];             d[3] = pq.top();             did = true;           }         } else if (d[0].j == d[2].j && d[1].j == d[3].j && d[0].j != d[1].j) {           bool b1 = abs(d[0].i - d[2].i) == 2;           bool b2 = abs(d[1].i - d[3].i) == 2;           if (b1 ^ b2) {             dsave = d[3];             d[3] = pq.top();             did = true;           }         } else if (d[0].j == d[3].j && d[1].j == d[2].j && d[0].j != d[1].j) {           bool b1 = abs(d[0].i - d[3].i) == 2;           bool b2 = abs(d[1].i - d[2].i) == 2;           if (b1 ^ b2) {             dsave = d[3];             d[3] = pq.top();             did = true;           }         }         if (did) {           bool done = true;           if (d[0].j == d[1].j && d[2].j == d[3].j && d[0].j != d[2].j) {             bool b1 = abs(d[0].i - d[1].i) == 2;             bool b2 = abs(d[2].i - d[3].i) == 2;             if (b1 ^ b2) done = false;           } else if (d[0].j == d[2].j && d[1].j == d[3].j && d[0].j != d[1].j) {             bool b1 = abs(d[0].i - d[2].i) == 2;             bool b2 = abs(d[1].i - d[3].i) == 2;             if (b1 ^ b2) done = false;           } else if (d[0].j == d[3].j && d[1].j == d[2].j && d[0].j != d[1].j) {             bool b1 = abs(d[0].i - d[3].i) == 2;             bool b2 = abs(d[1].i - d[2].i) == 2;             if (b1 ^ b2) done = false;           }           if (done) {           } else {             d[2] = dsave;           }         }       }       int ret = 0;       for (int i = 0; i < n; ++i) {         ret += d[i].value;       }       printf( %d n , ret);     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, sum, ans;   int cnt[1000010], pre[1000010];   char a[1000010], b[1000010];   int main() {     scanf( %s%s , a + 1, b + 1);     n = strlen(a + 1);     m = strlen(b + 1);     for (int i = 1; i < n; i++)       if (a[i] != a[i + 1]) cnt[i] = 1;     for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + cnt[i];     for (int i = 1; i <= m; i++) {       if (a[i] != b[i]) sum++;     }     if (sum % 2 == 0) ans = 1;     for (int i = m + 1; i <= n; i++) {       sum += pre[i - 1] - pre[i - m - 1];       if (sum % 2 == 0) ans++;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j, sum, count;     cin >> n;     int a[n][n];     int row[n], col[n];     for (i = 0; i < n; i++) {       sum = 0;       for (j = 0; j < n; j++) {         cin >> a[i][j];         sum += a[i][j];       }       row[i] = sum;     }     for (j = 0; j < n; j++) {       sum = 0;       for (i = 0; i < n; i++) {         sum += a[i][j];       }       col[j] = sum;     }     count = 0;     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++) {         if (col[i] > row[j]) count++;       }     }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, q;   pair<int, int> a[400004];   long long ans[200004], d[400004], sum;   int fa[400004], l[400004], r[400004], s[400004];   vector<pair<int, int> > v, ask;   int F(int x) { return fa[x] == x ? x : fa[x] = F(fa[x]); }   long long got(int v) { return d[r[v]] - d[r[v] - s[v]]; }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= n + m; i++) scanf( %d , &a[i].first), a[i].second = i;     sort(a + 1, a + n + m + 1);     for (int i = 1; i <= n + m; i++) {       d[i] = d[i - 1] + a[i].first;       fa[i] = i, s[i] = (a[i].second <= n), l[i] = r[i] = i;       if (s[i] == 1) sum += a[i].first;       if (i > 1) v.push_back({a[i].first - a[i - 1].first, i});     }     for (int i = 1; i <= q; i++) {       int k;       scanf( %d , &k);       ask.push_back({k, i});     }     sort(v.begin(), v.end());     sort(ask.begin(), ask.end());     int it = 0;     for (auto qr : ask) {       while (it < v.size() && v[it].first <= qr.first) {         int p = v[it].second;         int U = F(p - 1), V = F(p);         sum -= got(U) + got(V);         fa[U] = V, s[V] += s[U], l[V] = l[U];         sum += got(V);         it++;       }       ans[qr.second] = sum;     }     for (int i = 1; i <= q; i++) printf( %lld n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned int n, c, i, ans = 1, arr[100001];     cin >> n >> c;     for (i = 0; i < n; i++) {       cin >> arr[i];     }     for (i = 1; i < n; i++) {       if (arr[i] - arr[i - 1] <= c)         ans++;       else         ans = 1;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 111 * 1000;   int par[MAXN], sz[MAXN];   int find(int i) {     if (par[i] == i) return i;     return par[i] = find(par[i]);   }   void un(int a, int b) {     sz[find(a)] += sz[find(b)];     par[find(b)] = find(a);   }   int n;   int mark[MAXN];   int sum[MAXN], tot[MAXN];   vector<int> adj[MAXN];   int dfs(int pos, int par = -1) {     if (mark[pos]) return 0;     mark[pos]++;     for (__typeof((adj[pos]).begin()) it = (adj[pos]).begin();          it != (adj[pos]).end(); ++it)       if (*it != par) sum[pos] += dfs(*it, pos);     return sum[pos];   }   void stot(int pos, int val) {     if (mark[pos] != 1) return;     mark[pos]++;     tot[pos] = val;     for (__typeof((adj[pos]).begin()) it = (adj[pos]).begin();          it != (adj[pos]).end(); ++it)       stot(*it, val);   }   int main() {     for (register int i = (0); i < (int)(MAXN); ++i) par[i] = i, sz[i] = 1;     cin >> n;     vector<pair<pair<int, int>, pair<int, int> > > E(n - 1);     for (register int i = (0); i < (int)(n - 1); ++i)       cin >> E[i].second.first >> E[i].second.second >> E[i].first.first,           E[i].second.first--, E[i].second.second--, E[i].first.second = i + 1;     sort((E).begin(), (E).end());     int lo = 0;     long long mb = 0;     vector<long long> res;     while (lo < ((int)(E).size())) {       int hi = lo;       while (hi < ((int)(E).size()) && E[lo].first.first == E[hi].first.first)         hi++;       set<int> st;       for (register int i = (lo); i < (int)(hi); ++i) {         int x = find(E[i].second.first), y = find(E[i].second.second);         if (x != y) {           st.insert(x);           st.insert(y);           adj[x].push_back(y);           adj[y].push_back(x);           sum[x] = sz[x];           sum[y] = sz[y];         }       }       for (__typeof((st).begin()) it = (st).begin(); it != (st).end(); ++it) {         if (!mark[*it]) {           int tmp = dfs(*it);           stot(*it, tmp);         }       }       for (__typeof((st).begin()) it = (st).begin(); it != (st).end(); ++it)         mark[*it] = false, adj[*it].clear();       for (register int i = (lo); i < (int)(hi); ++i) {         int x = E[i].second.first, y = E[i].second.second;         if (find(x) == find(y)) continue;         int mn = min(sum[find(x)], sum[find(y)]);         long long cnt = 2LL * mn * (tot[find(x)] - mn);         if (cnt > mb) {           mb = cnt;           res.clear();         }         if (cnt == mb) res.push_back(E[i].first.second);       }       for (register int i = (lo); i < (int)(hi); ++i) {         int x = E[i].second.first, y = E[i].second.second;         if (find(x) == find(y)) continue;         un(x, y);       }       lo = hi;     }     cout << mb <<     << ((int)(res).size()) << endl;     for (register int i = (0); i < (int)(((int)(res).size())); ++i)       cout << res[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cout << x; }   void __print(long x) { cout << x; }   void __print(long long x) { cout << x; }   void __print(unsigned x) { cout << x; }   void __print(unsigned long x) { cout << x; }   void __print(unsigned long long x) { cout << x; }   void __print(float x) { cout << x; }   void __print(double x) { cout << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cout <<      << x <<     ; }   void __print(const char *x) { cout <<     << x <<    ; }   void __print(const string &x) { cout <<     << x <<    ; }   void __print(bool x) { cout << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cout <<  { ;     __print(x.first);     cout <<  , ;     __print(x.second);     cout <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cout <<  { ;     for (auto &i : x) cout << (f++ ?  ,  :   ), __print(i);     cout <<  } ;   }   void _print() { cout <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cout <<  ,  ;     _print(v...);   }   void c_p_c();   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int testcase = 1;     while (testcase--) c_p_c();     return 0;   }   void c_p_c() {     long long int n, m;     cin >> n >> m;     vector<vector<long long int>> a(n, vector<long long int>(m, 0));     ;     vector<vector<long long int>> b(n, vector<long long int>(m, 1));     ;     for (long long int i = 0; i < n; ++i) {       for (long long int j = 0; j < m; ++j) {         cin >> a[i][j];         if (!a[i][j]) {           for (long long int k = 0; k < n; ++k) {             b[k][j] = 0;           }           for (long long int k = 0; k < m; ++k) {             b[i][k] = 0;           }         }       }     }     for (long long int i = 0; i < n; ++i) {       for (long long int j = 0; j < m; ++j) {         if (a[i][j]) {           long long int ans = 0;           for (long long int k = 0; k < n; ++k) {             ans += b[k][j];           }           for (long long int k = 0; k < m; ++k) {             ans += b[i][k];           }           if ((bool)(ans) == 0) {             cout <<  NO ;             return;           }         }       }     }     cout <<  YES n ;     for (long long int i = 0; i < n; ++i) {       for (long long int j = 0; j < m; ++j) {         cout << (bool)(b[i][j]) <<    ;       }       cout << endl;     }   }