malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     if (k >= (n - 1) * n / 2) {       cout <<  no solution n ;     } else {       for (int i = 1; i <= n; i++) {         cout << 0 <<     << i <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using ll = long long;   const int MV = 1e6;   const int p10[] = {1, 10, 100, 1000, 10000, 100000};   int K, Q, F[6];   ll dp[MV];   ll val(int x) {     ll f = 0;     for (int i = 0; x; ++i, x /= 10) {       int d = x % 10;       if (d % 3 == 0) f += (ll)F[i] * d / 3;     }     return f;   }   struct info {    public:     int k;     ll v;   };   std::deque<info> q;   int main() {     scanf( %d , &K);     for (int i = 0; i < 6; ++i) scanf( %d , F + i);     --K;     K *= 3;     for (int i = 0; i < MV; ++i) dp[i] = val(i);     for (int i = 0; i < 6; ++i) {       for (int j = 0; j < 3 * p10[i]; ++j) {         int mv = 1 + (MV - j - 1) / (3 * p10[i]);         std::function<ll&(int)> get = [&](int x) -> ll& {           assert(j + x * 3 * p10[i] < MV);           return dp[j + x * 3 * p10[i]];         };         for (int k = 0; k < mv; ++k) {           for (; !q.empty() && k - q.front().k > K;) q.pop_front();           for (;                !q.empty() && get(k) >= q.back().v + (ll)F[i] * (k - q.back().k);)             q.pop_back();           q.push_back({k, get(k)});           get(k) = q.front().v + (ll)F[i] * (k - q.front().k);         }         q.clear();       }     }     scanf( %d , &Q);     for (int i = 0; i < Q; ++i) {       int N;       scanf( %d , &N);       printf( %lld n , dp[N]);     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int i, j, a = 0, b = 0, n, y;     char x[10][10];     for (i = 0; i < 8; i++) scanf( %s , x[i]);     for (i = 0; i < 8; i++) {       n = 0;       for (j = 0; j < 8; j++) {         if (x[i][j] ==  B ) {           n++;         }       }       if (n == 8) a++;     }     for (i = 0; i < 8; i++) {       n = 0;       for (j = 0; j < 8; j++) {         if (x[j][i] ==  B ) {           n++;         }       }       if (n == 8) b++;     }     y = a + b;     if (a == 8) y = 8;     printf( %d , y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long c[2000], d[2000];   long long u[2000], b[2000];   int main() {     long long n, m, d;     long long lpl = 0;     cin >> n >> m >> d;     for (int i = 0; i < m; i++) {       cin >> c[i];       lpl += c[i];     }     if (lpl == n) {       cout <<  YES  << endl;       for (int i = 0; i < m; i++) {         for (int j = 0; j < c[i]; j++) {           cout << i + 1 <<    ;         }       }       cout << endl;       return 0;     }     long long st = 0;     long long flag = 0;     for (int i = 0; i < m; i++) {       long long op = c[i];       op = n - (lpl - op) - 1;       long long to = st + d;       long long ss = op - c[i] + 1;       if (to > ss) {         u[i] = ss;         st = ss + c[i] - 1;       }       if (to <= ss) {         u[i] = to;         st = to + c[i] - 1;       }       lpl -= c[i];     }     if (st + d > n) {       cout <<  YES  << endl;       for (int i = 0; i < m; i++) {         for (int j = u[i]; j < u[i] + c[i]; j++) {           b[j] = i + 1;         }       }       for (int i = 1; i <= n; i++) {         cout << b[i] <<    ;       }       cout << endl;     } else {       cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int _ = 1e4 + 5;   const long long INF = 1ll << 60;   inline long long min(long long a, long long b) { return a < b ? a : b; }   int n, c, s[_], t[_];   long long dp[2][_];   int main() {     scanf( %d %d , &n, &c);     for (int i = 1; i <= n; ++i) scanf( %d , s + i);     for (int i = 1; i <= n; ++i) scanf( %d , t + i);     for (int i = 1; i <= n; ++i) {       memset(dp[i & 1], 0x3f, sizeof dp[i & 1]);       dp[i & 1][0] = dp[(i - 1) & 1][0] + s[i];       for (int j = 1; j <= i; ++j)         dp[i & 1][j] = min(dp[(i - 1) & 1][j] + 1ll * c * j + s[i],                            dp[(i - 1) & 1][j - 1] + t[i]);     }     long long ans = INF;     for (int i = 0; i <= n; ++i) ans = min(ans, dp[n & 1][i]);     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     srand(time(NULL));     ;     int T = 1;     cin >> T;     while (T--) {       int n, r = 0, c = 0;       string s;       cin >> n >> s;       for (int i = 0; i < int(n); i++) r += s[i] ==  R ;       if (r > 0 && r < n) {         int j = 0;         while (s[(j - 1 + n) % n] ==  R  || s[j] ==  L ) j++;         s = s.substr(j, n - j) + s.substr(0, j);         char d =  R ;         for (int i = 0; i < int(n); i++) {           int j = i;           while (j < n && s[j] == d) j++;           c += (j - i) / 3;           d = (d ==  R ) ?  L  :  R ;           i = j - 1;         }         cout << c << endl;       } else         cout << (n + 2) / 3 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string first, secound;     string arr1[100], arr2[100], arr3[100], arr4[100];     int counter1 = 0, counter2 = 0, counter3 = 0, counter4 = 0;     for (int i = 0; i < n; i++) {       cin >> first >> secound;       if (secound ==  rat )         arr1[counter1++] = first;       else if ((secound ==  woman ) || (secound ==  child )) {         arr2[counter2++] = first;       } else if (secound ==  man ) {         arr3[counter3++] = first;       } else {         arr4[counter4++] = first;       }     }     for (int k = 0; k < counter1; k++) cout << arr1[k] << endl;     for (int i = 0; i < counter2; i++) {       cout << arr2[i] << endl;     }     for (int j = 0; j < counter3; j++) {       cout << arr3[j] << endl;     }     for (int m = 0; m < counter4; m++) cout << arr4[m] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300000;   long long abss(long long a) {     if (a < 0) {       a = -a;     }     return a;   }   long long n;   long long xx;   long long aa[N + 5] = {0}, su[N + 5];   long long mm[105] = {0};   int main() {     mm[0] = 1;     scanf( %lld , &n);     long long ans = 0;     su[0] = 0;     for (int i = 1; i <= n; ++i) {       scanf( %lld , &xx);       while (xx) {         if (xx & 1) {           ++aa[i];         }         xx >>= 1;       }       su[i] = su[i - 1] + aa[i];     }     long long l[2] = {1, 0};     aa[0] = 0;     for (int i = 1; i <= n; ++i) {       int bitt = su[i] & 1;       ans += l[bitt];       long long mx = aa[i];       long long rem = 0;       for (int j = i - 1; j >= 0 && j >= i - 63; --j) {         if ((su[i] - su[j]) % 2 == 0 && rem < mx) {           --ans;         }         if (mx < aa[j]) {           rem += mx;           mx = aa[j];         } else {           rem += aa[j];           ;         }       }       ++l[bitt];       ;     }     printf( %lld , ans);     ;     return 0;   }
#include <bits/stdc++.h>   int u[400000];   int v[400000];   int s[400000];   int n;   int parent[200000];   int f[200000];   int t[200001];   bool b[200000];   int tt[200000];   bool func(int x, int y) { return u[x] < u[y]; }   int main() {     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       scanf( %d%d , &u[i], &v[i]);       u[i]--;       v[i]--;       u[n + i - 1] = v[i];       v[n + i - 1] = u[i];       t[i] = -1;     }     for (int i = 0; i < 2 * n - 2; i++) {       s[i] = i;     }     t[n - 1] = -1;     std::sort(s, s + 2 * n - 2, func);     for (int i = 0; i < 2 * n - 2; i++) {       if (t[u[s[i]]] == -1) t[u[s[i]]] = i;     }     t[n] = 2 * n - 2;     f[0] = 0;     b[0] = true;     int tail = 0;     for (int i = 0; i < n; i++) {       for (int j = t[f[i]]; j < t[f[i] + 1]; j++) {         if (b[v[s[j]]]) {           continue;         }         tail++;         f[tail] = v[s[j]];         b[f[tail]] = true;         parent[f[tail]] = f[i];       }     }     long long cnt = 0;     for (int i = n - 1; i > 0; i--) {       tt[parent[f[i]]] += tt[f[i]] + 1;       cnt = cnt + (long long)(tt[f[i]] + 1) * (n - tt[f[i]] - 1);     }     for (int i = 0; i < n; i++) b[i] = false;     int pa, pb;     pa = 0;     pb = 1;     for (int i = 1; i < n; i++) {       b[f[i]] = !b[parent[f[i]]];       if (b[f[i]])         pa++;       else         pb++;     }     cnt = cnt + (long long)pa * pb;     cnt = cnt / 2;     printf( %I64d , cnt);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,unroll-loops )   #pragma GCC target( avx,avx2,fma )   using namespace std;   const long long sz = 3e3 + 10, mod = 998244353;   char s[sz], t[sz];   long long dp[sz][sz];   long long solve(long long l, long long r) {     if (l > r) return 1;     long long &ret = dp[l][r];     if (ret != -1) return ret;     long long rt = 0, idx = r - l + 1;     if (s[idx] == t[r] || t[r] ==  $ ) rt = (rt + solve(l, r - 1)) % mod;     if (s[idx] == t[l] || t[l] ==  $ ) rt = (rt + solve(l + 1, r)) % mod;     return ret = rt;   }   int main() {     scanf( %s , s + 1);     scanf( %s , t + 1);     long long n = strlen(s + 1), m = strlen(t + 1);     long long m2 = m;     while (m2 < n) t[++m2] =  $ ;     memset(dp, -1, sizeof(dp));     long long tot = 0;     for (long long i = m; i <= n; i++) tot = (tot + solve(1, i)) % mod;     cout << tot << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, d, t;   int a[1000005], b[1000005], c[1000005];   char ch[1000005], ans[1000005];   void mul(int* a, int* b) {     for (int i = 0; i < n; ++i) {       c[i] = b[a[i]];     }     for (int i = 0; i < n; ++i) {       a[i] = c[i];     }   }   int main() {     scanf( %s , ch);     n = strlen(ch);     scanf( %d , &t);     while (t--) {       scanf( %d%d , &k, &d);       int now = 0;       for (int i = 0; i < d; ++i) {         for (int j = i; j < k; j += d) {           a[j] = now++;         }       }       for (int i = k; i < n; ++i) {         a[i] = i;       }       for (int i = 0; i < n; ++i) {         a[i] = (a[i] - 1 + n) % n;       }       for (int i = 0; i < n; ++i) {         b[i] = i;       }       now = (n - k + 1);       while (now) {         if (now & 1) {           mul(b, a);         }         mul(a, a);         now >>= 1;       }       for (int i = 0; i < n; ++i) {         ans[(b[i] + n - k + 1) % n] = ch[i];       }       for (int i = 0; i < n; ++i) {         ch[i] = ans[i];       }       printf( %s n , ch);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long M[110000 * 4];   long long lazy[110000 * 4];   void down(int x) {     if (lazy[x] != -1) {       M[x * 2] = max(M[x * 2], lazy[x]);       M[x * 2 + 1] = max(M[x * 2 + 1], lazy[x]);       lazy[x * 2] = max(lazy[x], lazy[x * 2]);       lazy[x * 2 + 1] = max(lazy[x], lazy[x * 2 + 1]);       lazy[x] = -1;     }   }   void up(int x) { M[x] = max(M[x * 2], M[x * 2 + 1]); }   void cover(int now, int l, int r, int x, int y, long long v) {     down(now);     if (x <= l && r <= y) {       M[now] = v;       lazy[now] = v;       return;     }     int mid = (l + r) >> 1;     if (x <= mid) cover(now * 2, l, mid, x, y, v);     if (y > mid) cover(now * 2 + 1, mid + 1, r, x, y, v);     up(now);   }   long long ask(int now, int l, int r, int x, int y) {     down(now);     if (x <= l && r <= y) return M[now];     int mid = (l + r) >> 1;     long long res = 0;     if (x <= mid) res = max(res, ask(now * 2, l, mid, x, y));     if (y > mid) res = max(res, ask(now * 2 + 1, mid + 1, r, x, y));     return res;   }   int main() {     memset(lazy, -1, sizeof lazy);     int n, m;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       int v;       scanf( %d , &v);       cover(1, 1, n, i, i, v);     }     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       int w, h;       scanf( %d%d , &w, &h);       long long res = ask(1, 1, n, 1, w);       printf( %I64d n , res);       cover(1, 1, n, 1, w, h + res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fre() {     freopen( c://test//input.in ,  r , stdin);     freopen( c://test//output.out ,  w , stdout);   }   template <class T1, class T2>   inline void gmax(T1 &a, T2 b) {     if (b > a) a = b;   }   template <class T1, class T2>   inline void gmin(T1 &a, T2 b) {     if (b < a) a = b;   }   const int N = 4040, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;   int n, m;   int y, x;   int ln[1010], ls[1010];   vector<int> a[N];   int p[N];   bool e[N];   int hungary(int x) {     e[x] = 1;     for (int i = a[x].size() - 1; ~i; i--) {       int y = a[x][i];       if (p[y] == -1) {         p[y] = x;         return 1;       }     }     for (int i = a[x].size() - 1; ~i; i--) {       int y = a[x][i];       if (!e[p[y]] && hungary(p[y])) {         p[y] = x;         return 1;       }     }     return 0;   }   void ins(int x, int y) { a[x].push_back(y); }   int main() {     while (~scanf( %d%d , &n, &m)) {       memset(ln, 1, sizeof(ln));       memset(ls, 1, sizeof(ls));       int n2 = n * 2;       int n3 = n * 3;       int n4 = n * 4;       for (int i = 1; i <= n4; ++i) a[i].clear();       for (int i = 1; i <= m; ++i) {         scanf( %d%d , &y, &x);         ln[y] = 0;         ls[x] = 0;       }       for (int i = 2; i < n; ++i)         if (ln[i]) {           ins(i, i + n);           ins(i + n, i);           if (ls[i]) {             ins(i, i + n2);             ins(i + n2, i);           }           if (ls[n + 1 - i]) {             ins(i, i + n3);             ins(i + n3, i);           }           if (ls[n + 1 - i]) {             ins(i + n, i + n3);             ins(i + n3, i + n);           }           if (ls[n + 1 - i]) {             ins(i + n, n + 1 - i + n2);             ins(n + 1 - i + n2, i + n);           }         }       for (int j = 2; j < n; ++j)         if (ls[j]) {           ins(n + n + j, n + n + n + j);           ins(n + n + n + j, n + n + j);         }       memset(p, -1, sizeof(p));       int ans = 0;       for (int i = 1; i <= n4; i++) {         memset(e, 0, sizeof(e));         if (hungary(i)) ans++;       }       ans /= 2;       if (n & 1) {         if (ln[n / 2 + 1] && ls[n / 2 + 1]) --ans;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> vv[3001];   int graf[3001][3001];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int f, t;       cin >> f >> t;       vv[f].push_back(t);       graf[f][t] = 1;     }     long long ans(0);     for (int a = 1; a <= n; a++)       for (int c = 1; c <= n; c++) {         if (a == c) continue;         int cnt(0);         for (int i = 0; i < vv[a].size(); i++) {           int b = vv[a][i];           if (graf[b][c]) {             cnt++;           }         }         ans += 1LL * cnt * (cnt - 1) / 2;       }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = LLONG_MAX;   const long long base = 1e9;   const double PI = acos(-1);   const long long MOD = 1e9 + 7;   const long long N = 1e5 + 10;   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     if (a[0] != 0) {       cout <<  1  << endl;       return 0;     }     long long mx = 0;     for (int i = 1; i < n; i++) {       mx = max(mx, a[i - 1]);       if (a[i] - mx > 1) {         cout << i + 1 << endl;         return 0;       }     }     cout <<  -1  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 755, M = 10000005;   char s[M];   bool e[N][N];   int n;   struct ACAutomaton {     int trie[M][2], id[M], idx, pos[M], fa[M];     void ins(char *s, int t) {       int cur = 0, l = strlen(s + 1);       for (int i = 1; i <= l; i++) {         if (!trie[cur][s[i] -  a ]) trie[cur][s[i] -  a ] = ++idx, fa[idx] = cur;         cur = trie[cur][s[i] -  a ];       }       id[cur] = t;       pos[t] = cur;     }     int fail[M];     void build_fail() {       queue<int> q;       for (int i = 0; i < 2; i++)         if (trie[0][i]) q.push(trie[0][i]);       while (!q.empty()) {         int nd = q.front();         q.pop();         for (int i = 0; i < 2; i++)           if (trie[nd][i])             fail[trie[nd][i]] = trie[fail[nd]][i], q.push(trie[nd][i]);           else             trie[nd][i] = trie[fail[nd]][i];       }     }     int f[M];     int getf(int v) { return f[v] == v ? v : f[v] = getf(f[v]); }     void build_tr() {       for (int i = 1; i <= idx; i++) f[i] = id[i] ? i : fail[i];       for (int i = 1; i <= n; i++) {         int p = pos[i];         if (id[getf(fail[p])]) e[i][id[getf(fail[p])]] = 1;         p = fa[pos[i]];         while (p) {           if (id[p]) {             e[i][id[p]] = 1;             break;           }           if (id[getf(p)]) e[i][id[getf(p)]] = 1;           p = fa[p];         }       }     }   } t;   int mat[N], mat2[N];   bool vis[N];   int find(int pos) {     if (vis[pos]) return 0;     vis[pos] = 1;     for (int i = 1; i <= n; i++)       if (e[pos][i] && (!mat[i] || find(mat[i]))) {         mat[i] = pos;         return 1;       }     return 0;   }   bool vis1[N], vis2[N];   void dfs(int pos) {     if (vis1[pos]) return;     vis1[pos] = 1;     for (int i = 1; i <= n; i++)       if (e[pos][i] && mat2[pos] != i && !vis2[i]) {         vis2[i] = 1;         if (mat[i]) dfs(mat[i]);       }   }   int ans[N], idx;   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) cin >> (s + 1), t.ins(s, i);     t.build_fail();     t.build_tr();     for (int k = 1; k <= n; k++)       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++) e[i][j] |= e[i][k] & e[k][j];     for (int i = 1; i <= n; i++) memset(vis, 0, sizeof(vis)), find(i);     for (int i = 1; i <= n; i++)       if (mat[i]) mat2[mat[i]] = i;     for (int i = 1; i <= n; i++)       if (!mat2[i]) dfs(i);     for (int i = 1; i <= n; i++)       if (vis1[i] && !vis2[i]) ans[++idx] = i;     cout << idx << endl;     for (int i = 1; i <= idx; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   int n, ans, lst[5010][2];   int comp(const void *a, const void *b) {     int x = ((int *)a)[0] - ((int *)b)[0];     if (x) return x;     return ((int *)a)[1] - ((int *)b)[1];   }   int main() {     int i;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d%d , &lst[i][0], &lst[i][1]);     qsort(lst + 1, n, sizeof(lst[0]), comp);     for (i = 1; i <= n; i++) {       if (lst[i][1] >= ans)         ans = lst[i][1];       else         ans = lst[i][0];     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   int ATTENTION() {   http:     return 0;   }   using namespace std;   const int iinf = 0x7fffffff;   const long long linf = ~(1LL << 63);   template <typename T>   inline T gcd(T a, T b) {     if (a < 0) return gcd(-a, b);     if (b < 0) return gcd(a, -b);     if (a < b) return gcd(b, a);     if (b == 0) return a;     return gcd(b, a % b);   }   long long qpow(long long a, long long n, long long mod) {     a %= mod;     long long ans = 1LL;     while (n) {       if (n & 1) ans = (ans * a % mod);       a = (a * a % mod);       n >>= 1;     }     return ans;   }   inline long long rev(long long a, long long p) { return qpow(a, p - 2, p); }   template <typename T>   inline void BPS(T* DST, T* SRC, int N, int s = 0) {     DST[s] = SRC[s];     for (int i = 1; i < N; i++) DST[s + i] = DST[s + i - 1] + SRC[s + i];   }   inline int in() {     int x;     cin >> x;     return x;   }   inline void tic() {}   inline void toc() {}   bitset<100000001> is_prime;   int n, A, B, C, D;   void unset_prime(unsigned int v) { is_prime.reset(v / 3); }   unsigned int f(unsigned int x) {     return ((((unsigned int)A * x + (unsigned int)B)) * x + (unsigned int)C) * x +            (unsigned int)D;   }   int main() {     scanf( %u%u%u%u%u , &n, &A, &B, &C, &D);     is_prime.set();     unsigned int res = 0;     unsigned int t = n;     unsigned int p2 = 2;     unsigned int fp = f(2);     while (t >= p2) {       res += t / p2 * fp;       p2 *= 2;     }     p2 = 3;     fp = f(3);     while (t >= p2) {       res += t / p2 * fp;       p2 *= 3;     }     for (unsigned int i = 5; i <= n; i += 2) {       if (is_prime[i / 3] == 0) {         if (i % 3 == 1) i += 2;         continue;       }       for (unsigned int j = 5 * i, k = 5; j <= n; j += 2 * i, k += 2) {         unset_prime(j);         if (k % 3 == 1) {           k += 2;           j += 2 * i;         }       }       t = n;       long long pi = i;       fp = f(i);       while (t >= pi) {         res += t / pi * fp;         pi *= i;       }       if (i % 3 == 1) i += 2;     }     printf( %u n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     long long int i;     while (t--) {       string a, b, c;       cin >> a >> b >> c;       long long int n = a.length(), f = 0;       for (i = 0; i < n; i++) {         if (a[i] != c[i] && b[i] != c[i]) {           cout <<  NO n ;           f = 1;           break;         } else if (a[i] == c[i])           swap(b[i], c[i]);         else           swap(a[i], c[i]);       }       if (f != 1) cout <<  YES n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200005];   int main() {     long long k, sum, subs, di;     int i, n, rel;     cin >> n >> k;     int n1 = n;     for (i = 1; i <= n; i++) cin >> a[i];     i = 1;     sum = 0;     rel = 1;     while (1) {       if (i > n1) break;       subs = (n - rel) * a[i] * (rel - 1);       di = sum - subs;       if (di < k) {         n--;         rel--;         printf( %d n , i);       } else {         sum = sum + a[i] * (rel - 1);       }       i++;       rel++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 500 + 10;   const int INF = 0x3f3f3f3f;   const int mod = 1000000007;   int n, m;   int a[maxn][maxn], b[maxn][maxn];   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> a[i][j];       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> b[i][j];         a[i][j] ^= b[i][j];       }     }     int flag = 0;     for (int i = 1; i <= n; i++) {       int tm = 0;       for (int j = 1; j <= m; j++) {         tm += a[i][j];       }       if (tm % 2) flag = 1;     }     for (int i = 1; i <= m; i++) {       int tm = 0;       for (int j = 1; j <= n; j++) {         tm += a[j][i];       }       if (tm % 2) flag = 1;     }     if (flag)       cout <<  No n ;     else       cout <<  Yes n ;     return 0;   }
#include <bits/stdc++.h>   long long INF = (long long)1e18;   struct node {     int n;     double rat;   };   bool operator<(const node& n1, const node& n2) { return n1.rat > n2.rat; }   std::vector<int> edge[100010];   int ch[100010], ne[100010];   int main() {     int x, a, b, k, n, m, q, t, num, in = 0, to, i;     double d, s;     scanf( %d%d%d , &n, &m, &q);     for (k = 1; k <= q; k++) {       scanf( %d , &x);       ch[x] = -1;     }     for (k = 1; k <= m; k++) {       scanf( %d%d , &a, &b);       edge[a].push_back(b);       edge[b].push_back(a);     }     double max = -1;     std::priority_queue<node> PQ;     for (k = 1; k <= n; k++) {       if (ch[k] == -1) continue;       t = 0;       for (i = 0; i < edge[k].size(); i++) {         int j = edge[k][i];         if (ch[j] == 0) t++;       }       ne[k] = t;       PQ.push(node{k, (double)t / (double)edge[k].size()});     }     num = n - q;     in = 1;     while (num != 0) {       a = PQ.top().n;       d = PQ.top().rat;       PQ.pop();       if (ch[a] != 0) continue;       ch[a] = in++;       if (d > max) {         max = d;         to = in;       }       num--;       for (i = 0; i < edge[a].size(); i++) {         int j = edge[a][i];         if (ch[j] != 0) continue;         ne[j]--;         s = (double)ne[j] / (double)edge[j].size();         PQ.push(node{j, s});       }     }     int ans = 0;     for (k = 1; k <= n; k++) {       if (ch[k] >= to - 1) ans++;     }     printf( %d n , ans);     for (k = 1; k <= n; k++) {       if (ch[k] >= to - 1) printf( %d  , k);     }   }