malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class L, class R>   ostream &operator<<(ostream &os, pair<L, R> P) {     return os <<  (  << P.first <<  ,  << P.second <<  ) ;   }   template <class T>   ostream &operator<<(ostream &os, vector<T> V) {     os <<  [ ;     for (auto vv : V) os << vv <<  , ;     return os <<  ] ;   }   template <class TH>   void _dbg(const char *sdbg, TH h) {     cerr << sdbg <<  =  << h <<   n ;   }   template <class TH, class... TA>   void _dbg(const char *sdbg, TH h, TA... a) {     while (*sdbg !=  , ) cerr << *sdbg++;     cerr <<  =  << h <<  , ;     _dbg(sdbg + 1, a...);   }   const long long N = 4e5 + 7;   long long n, a[N], pre[N], ansLen, ansIdx;   double ans = -1.0;   double sum(long long l, long long r) {     return pre[r] - (l > 0 ? pre[l - 1] : 0);   }   double f(long long len, long long idx) {     double ret = pre[idx] - pre[idx - len - 1];     ret += pre[n] - pre[n - len];     ret /= len + len + 1;     ret -= a[idx];     if (ret > ans) {       ans = ret;       ansIdx = idx;       ansLen = len;     }     return ret;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     cin >> n;     for (long long i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + n + 1);     for (long long i = 1; i <= n; i++) pre[i] = a[i] + pre[i - 1];     for (long long i = 1; i <= n; i++) {       long long cnt = min(i - 1, n - i);       long long lo = 0, hi = cnt;       while (hi - lo > 3) {         long long m1 = lo + (hi - lo) / 3, m2 = hi - (hi - lo) / 3;         if (f(m1, i) < f(m2, i))           lo = m1;         else           hi = m2;       }       for (long long k = lo; k <= hi; k++) f(k, i);     }     cout << 2 * ansLen + 1 <<   n ;     for (long long i = ansIdx; i >= ansIdx - ansLen; i--) cout << a[i] <<    ;     for (long long i = n - ansLen + 1; i <= n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, n, a, j, b, m, s = 0, t = 0;     int x[105] = {0};     cin >> n >> m;     for (i = 1; i <= m; ++i) {       cin >> a;       for (j = a; j <= n; ++j) {         if (x[j] != 0) break;         x[j] = a;       }     }     for (i = 1; i <= n; ++i) cout << x[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 100;   const int MAXM = 15;   int N, Q, M;   int log2(int v) {     int r = 1;     while (v >>= 1) r++;     return r;   }   int a[MAXN];   int t[2][MAXN];   struct ST {     int v[3 * MAXN][2][MAXM];     int l[3 * MAXN], r[3 * MAXN];     bool lz[3 * MAXN];     int NXT;     int sz;     void updv(const int& n) {       assert(n != -1 and l[n] != -1 and r[n] != -1);       for (int i = 0; i <= M; i++)         for (int j = 0; j < 2; j++) v[n][j][i] = v[l[n]][j][v[r[n]][j][i]];     }     void init(int n, int nl, int nr) {       assert(n != -1 and nl < nr);       lz[n] = false;       l[n] = r[n] = -1;       if (nr - nl == 1) {         for (int i = 0; i < M; i++)           for (int j = 0; j < 2; j++) v[n][j][i] = i + 1;         v[n][a[nl]][M] = M, v[n][!a[nl]][M] = 0;       }       if (nr - nl > 1) {         int m = nl + ((nr - nl) >> 1);         init(l[n] = NXT++, nl, m);         init(r[n] = NXT++, m, nr);         updv(n);       }     }     ST() {}     ST(const int& s, bool ini) {       sz = s;       NXT = 0;       if (ini) init(NXT++, 0, sz);     }     void prop(int n, int nl, int nr) {       if (!lz[n]) return;       for (int i = 0; i <= M; i++) swap(v[n][0][i], v[n][1][i]);       if (nr - nl > 1) {         lz[l[n]] = !lz[l[n]];         lz[r[n]] = !lz[r[n]];       }       lz[n] = false;     }     void upd(int n, int nl, int nr, int gl, int gr) {       if (gl <= nl and gr >= nr) {         lz[n] = !lz[n];         prop(n, nl, nr);         return;       }       if (nr - nl > 1) {         prop(n, nl, nr);         int m = nl + ((nr - nl) >> 1);         if (gl < m)           upd(l[n], nl, m, gl, gr);         else           prop(l[n], nl, m);         if (gr > m)           upd(r[n], m, nr, gl, gr);         else           prop(r[n], m, nr);         updv(n);         return;       }       assert(false);     }     void upd(int gl, int gr) { upd(0, 0, sz, gl, gr); }     int qry(int n, int nl, int nr, int gl, int gr, int c = M) {       prop(n, nl, nr);       if (gl <= nl and gr >= nr) {         return v[n][0][c];       }       if (nr - nl > 1) {         int m = nl + ((nr - nl) >> 1);         if (gr > m) c = qry(r[n], m, nr, gl, gr, c);         if (gl < m) c = qry(l[n], nl, m, gl, gr, c);         return c;       }       assert(false);       return -1;     }     int qry(int gl, int gr) { return qry(0, 0, sz, gl, gr); }   } st;   void q1() {     int l, r, v;     scanf( %d%d%d , &l, &r, &v);     if (v & 1) st.upd(--l, r);   }   void q2() {     int l, r;     scanf( %d%d , &l, &r);     printf( %d n , (st.qry(--l, r) == 0 ? 2 : 1));   }   int main() {     scanf( %d%d%d , &N, &M, &Q);     for (int i = 0, v; i < N; i++) {       scanf( %d , &v);       a[i] = v & 1;     }     st = *(new ST(N, true));     for (int i = 0, type; i < Q; i++) {       scanf( %d , &type);       if (type == 1)         q1();       else if (type == 2)         q2();     }     return 0;   }
#include <bits/stdc++.h>   const int N = (int)2e5 + 5;   const int MOD = (int)1e9 + 7;   const bool MULTI_TEST = true;   const double PI = acos(-1.0);   using namespace std;   void solve() {     int n;     cin >> n;     int a[n];     int max = 0, index = -1;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] > max) {         max = a[i];       }     }     if (*min_element(a, a + n) == max)       cout <<  -1 n ;     else {       for (int i = 0; i < n - 1; i++) {         if (a[i] == max && a[i] > a[i + 1]) index = i + 1;       }       if (index != -1) {         cout << index <<   n ;         return;       } else {         for (int i = 1; i < n; i++) {           if (a[i] == max && a[i] > a[i - 1]) index = i + 1;         }       }       cout << index << endl;     }   }   int main() {     ios_base::sync_with_stdio(false);     int t = 1;     if (MULTI_TEST) cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100500], c[300], dp[100500][305], z, cnt, tmp, e, s, l, r, n, m, x,       y, k, j, p, k1, k2, i, cur, rez;   vector<long long> f[100500];   long long Abs(long long x) {     if (x < 0) return -x;     return x;   }   int main() {     cin >> n >> m >> s >> e;     for (i = 0; i < n; i++) cin >> a[i];     for (j = 0; j < m; j++) {       cin >> x;       f[x].push_back(j);     }     for (i = 0; i <= n; i++)       for (j = 0; j <= s / e; j++) dp[i][j] = m + 1;     dp[0][0] = -1;     for (i = 0; i < n; i++) {       for (j = 0; j <= s / e; j++)         if (dp[i][j] != m + 1) {           long long tmp = upper_bound(f[a[i]].begin(), f[a[i]].end(), dp[i][j]) -                           f[a[i]].begin();           if (tmp != f[a[i]].size())             dp[i + 1][j + 1] = min(dp[i + 1][j + 1], f[a[i]][tmp]);           dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);         }     }     rez = 0;     for (i = 0; i <= n; i++) {       for (j = 0; j <= s / e; j++) {         if (i + dp[i][j] + 1 + j * e <= s && dp[i][j] != m + 1) rez = max(rez, j);       }     }     cout << rez << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct data {     float x, a;   } h[1005];   bool cmp(data a, data b) { return a.x < b.x; };   int main() {     int n, ans = 2;     float t, d;     cin >> n >> t;     for (int i = 1; i <= n; i++) cin >> h[i].x >> h[i].a;     sort(h + 1, h + n + 1, cmp);     for (int i = 1; i < n; i++) {       d = h[i + 1].x - h[i].x - h[i].a / 2 - h[i + 1].a / 2;       if (d > t) ans += 2;       if (abs(d - t) < 1e-6) ans++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     cin >> n;     int ans = 0;     if (n % 2 == 0) {       ans = 3 * (n / 2);     } else {       ans = 3 * (n / 2) + 1;     }     cout << ans << endl;     for (int i = 1; i <= n; i++) {       if (!(i % 2)) cout << i <<    ;     }     for (int i = 1; i <= n; i++) {       if (i % 2) cout << i <<    ;     }     for (int i = 1; i <= n; i++) {       if (!(i % 2)) cout << i <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   using minpq = priority_queue<T, vector<T>, greater<T>>;   const int N = 5e5 + 5;   int n;   long long a[N], x;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = (0); i < ((n + 1) / 2); i++) cin >> a[i];     cin >> x;     long long sum = 0, mn = n / 2 + 1, mx = n;     vector<pair<long long, long long>> ve;     for (int i = (n + 1) / 2 - 1; i >= 0; i--) {       sum += a[i];       if (x > 0) {         if (sum <= 0) {           mn = max(mn,                    min((long long)n - i + 1, (-sum + x) / x + (n + 1) / 2 - i));         }       } else if (x < 0) {         if (sum > 0) {           long long val = (sum - x - 1) / -x - 1 + (n + 1) / 2 - i;           if (n - i + 1 > val) {             ve.emplace_back(val + 1, n - i);           }         } else {           mn = max(mn, (long long)n - i + 1);         }       } else if (sum <= 0) {         mn = max(mn, (long long)n - i + 1);       }     }     reverse((ve).begin(), (ve).end());     for (auto &p : ve) {       if (p.first <= mx && mx <= p.second) {         mx = p.first - 1;       }     }     if (mn <= mx) {       cout << mx <<   n ;     } else {       cout <<  -1 n ;     }   }
#include <bits/stdc++.h>   const long long Inf = 1e18;   const long double eps = 1e-7;   long long LINF = (long long)2e18;   using namespace std;   long long mod = 1e9 + 7;   long long mod5 = 1e9 + 9;   long long mod3 = 998244353;   long long mod4 = 1000003;   long long mod2 = 1e9 + 123;   const int MAXN = 10100000;   const int INF = 1000000000;   vector<vector<int> > a;   int n, m;   vector<pair<int, int> > mx;   int rec(int pos, vector<int> mxs) {     if (pos == m) {       int ss = 0;       for (long long(i) = 0; (i) < n; (i)++) {         ss += mxs[i];       }       return ss;     }     int cur = 0;     int ss = 0;     for (long long(i) = 0; (i) < n; (i)++) {       cur += mxs[i];       ss += mxs[i];     }     int ans = cur;     for (long long(i) = 0; (i) < n; (i)++) {       cur = ss;       vector<int> lol = mxs;       for (long long(j) = 0; (j) < n; (j)++) {         if (a[(i + j) % n][mx[pos].second] > mxs[j]) {           cur += a[(i + j) % n][mx[pos].second] - mxs[j];           lol[j] = a[(i + j) % n][mx[pos].second];         }       }       ans = max(ans, rec(pos + 1, lol));     }     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.setf(ios::fixed);     cout.precision(20);     int tt;     cin >> tt;     while (tt--) {       cin >> n >> m;       a.clear();       a.resize(n, vector<int>(m));       for (long long(i) = 0; (i) < n; (i)++) {         for (long long(j) = 0; (j) < m; (j)++) {           cin >> a[i][j];         }       }       mx.clear();       for (long long(i) = 0; (i) < m; (i)++) {         int cur = -1;         for (long long(j) = 0; (j) < n; (j)++) {           cur = max(cur, a[j][i]);         }         mx.push_back({cur, i});       }       sort((mx).rbegin(), (mx).rend());       mx.resize(min(4, m));       m = min(m, 4);       vector<int> kek(n, 0);       cout << rec(0, kek) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long M = 1000000007;   int main() {     int n, x, y;     cin >> n >> x >> y;     string s;     cin >> s;     int ans = 0;     for (int i = 0; i < x; i++) {       int pos = n - i - 1;       char current =  0 ;       if (i == y) {         current =  1 ;       }       if (current != s[pos]) {         ans++;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10, OO = 0x3f3f3f3f;   int dx[] = {1, 0, -1, 0};   int dy[] = {0, 1, 0, -1};   int tc, n, m;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     cin >> tc;     while (tc--) {       cin >> n >> m;       cin >> s;       vector<long long> freq(n + 1, 0);       vector<int> indx(m);       for (int i = 0; i < int(m); i++) {         cin >> indx[i];         freq[0]++;         freq[indx[i]]--;       }       freq[0]++;       for (int i = int(1); i <= int(n - 1); i++) freq[i] += freq[i - 1];       vector<long long> karakter(26, 0);       for (int i = 0; i < int(n); i++) karakter[s[i] -  a ] += freq[i];       for (int i = 0; i < int(26); i++) cout << karakter[i] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int a[N];   int sum[11];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       sum[a[i]]++;     }     while (1) {       int i, aa[11];       memset(aa, 0, sizeof(aa));       for (i = 1; i < 11; ++i) aa[i] = sum[i];       sort(aa, aa + 11);       for (i = 0; i < 11; ++i)         if (aa[i]) break;       if (aa[10] - aa[i] > 1) {         if (aa[i] == 1) {           if (aa[i + 1] == aa[10]) {             cout << n;             break;           }         }       } else if (aa[i] == aa[10]) {         if (aa[i] == 1 || i == 10) {           cout << n;           break;         }       } else {         if (aa[i] == 1) {           if (aa[i + 1] == aa[10]) {             cout << n;             break;           }         }         if (aa[i] == aa[9]) {           cout << n;           break;         }       }       sum[a[n]]--;       n--;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool umin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool umax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   long long a, b, c, type, ric[300007], par[300007], cost[300007], d[300007], n,       m, lvl[300007], P[300007][20 * 2];   vector<pair<long long, long long> > E[300007];   pair<pair<long long, long long>, long long> way[300007];   long long atabul(long long x) {     if (ric[x] == x) return x;     return ric[x] = atabul(ric[x]);   }   void dfs(long long x, long long y, long long z) {     lvl[x] = lvl[y] + 1;     P[x][0] = y;     cost[x] = z;     if (z == 1) {       ric[x] = y;       atabul(x);     }     for (int i = 0; i < int(E[x].size()); i++)       if (E[x][i].first != y) dfs(E[x][i].first, x, E[x][i].second);   }   void build_table() {     for (int j = 1; j <= 20; j++)       for (int i = 1; i <= n; i++)         if (P[i][j - 1] > 0) P[i][j] = P[P[i][j - 1]][j - 1];   }   void form_LCA() {     for (int i = 0; i <= n; i++)       for (int j = 0; j <= 20; j++) P[i][j] = -1;     dfs(1, 0, 0);     build_table();   }   long long LCA(long long x, long long y) {     if (lvl[x] < lvl[y]) swap(x, y);     for (int i = 20; i >= 0; i--)       if (lvl[x] - (1 << i) >= lvl[y]) x = P[x][i];     if (x == y) return x;     for (int i = 20; i >= 0; i--)       if (P[x][i] > 0 && P[x][i] != P[y][i]) x = P[x][i], y = P[y][i];     return P[x][0];   }   int main() {     scanf( %lld%lld , &n, &m);     ric[n] = n;     for (int i = 1; i < n; i++) {       scanf( %lld%lld%lld , &a, &b, &c);       E[a].push_back(make_pair(b, c));       E[b].push_back(make_pair(a, c));       ric[i] = i;       way[i] = {{a, b}, c};     }     form_LCA();     while (m--) {       scanf( %lld , &type);       if (type == 1) {         scanf( %lld%lld%lld , &a, &b, &c);         long long tr = LCA(a, b);         while (atabul(a) != atabul(tr) && c > 0) {           if (cost[a] == 1) {             a = atabul(a);             continue;           }           c /= cost[a];           a = P[a][0];         }         while (atabul(b) != atabul(tr) && c > 0) {           if (cost[b] == 1) {             b = atabul(b);             continue;           }           c /= cost[b];           b = P[b][0];         }         printf( %lld n , c);       } else {         scanf( %lld%lld , &a, &b);         long long qm = way[a].first.first, gr = way[a].first.second;         if (lvl[qm] < lvl[gr]) swap(qm, gr);         cost[qm] = b;         if (b == 1) {           ric[qm] = gr;           atabul(qm);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int in() {     int32_t x;     scanf( %d , &x);     return x;   }   inline string get() {     char ch[1000010];     scanf( %s , ch);     return ch;   }   const int MAX_LG = 60;   const long long maxn = 1e6 + 100;   const long long base = 29;   const long long mod = 1e9 + 7;   const long long INF = 1e18 + 100;   struct state {     long long a = 0, b = 0, tp = 0;     state() {}     state(long long a, long long b, long long tp) : a(a), b(b), tp(tp) {}   };   long long cnt[maxn];   long long di[51][51][2];   long long C[51][51];   long long ways[51][51][2];   queue<state> q;   int32_t main() {     long long n = in(), k = in();     for (long long i = 0; i < n; i++) cnt[in() / 51]++;     q.push({cnt[0], cnt[1], 0});     for (long long i = 0; i <= 50; i++)       for (long long j = 0; j <= 50; j++) di[i][j][0] = di[i][j][1] = INF;     for (long long i = 0; i <= 50; i++) {       for (long long j = 0; j <= i; j++) {         if (j == 0)           C[i][j] = 1;         else           C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;       }     }     di[cnt[0]][cnt[1]][0] = 0;     ways[cnt[0]][cnt[1]][0] = 1;     while (q.empty() == false) {       state now = q.front();       q.pop();       long long a2 = cnt[0] - now.a;       long long b2 = cnt[1] - now.b;       for (long long i = 0; i <= now.a; i++) {         for (long long j = 0; j <= now.b; j++) {           if (i + j == 0) continue;           if (i * 50 + j * 100 > k) continue;           long long d2 = di[now.a][now.b][now.tp] + 1;           long long *d3 = &di[a2 + i][b2 + j][now.tp ^ 1];           if (*d3 == INF) {             *d3 = d2;             q.push({a2 + i, b2 + j, now.tp ^ 1});           }           if (*d3 == d2) {             ways[a2 + i][b2 + j][now.tp ^ 1] += ways[now.a][now.b][now.tp] *                                                 C[now.a][i] % mod * C[now.b][j] %                                                 mod;             if (ways[a2 + i][b2 + j][now.tp ^ 1] > mod)               ways[a2 + i][b2 + j][now.tp ^ 1] -= mod;           }         }       }     }     if (ways[cnt[0]][cnt[1]][1] == 0)       return cout << -1 <<   n  << 0 <<   n , 0;     else {       cout << di[cnt[0]][cnt[1]][1] <<   n ;       cout << ways[cnt[0]][cnt[1]][1] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long modulo(long long base, long long exponent, long long modulus);   long long choose(long long n, long long k);   long long inverse(long long a, long long m);   void build();   void fileio();   long long ncr(long long n, long long r);   const int nax = 1e6 + 10;   const int LG = log2(nax) + 1;   vector<long long> fact(nax);   long long dp[1LL << 20];   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     string s;     cin >> s;     long long freq[m][m];     memset(freq, 0, sizeof(freq));     for (int i = 1; i < n; i++) {       freq[s[i] -  a ][s[i - 1] -  a ]++;       freq[s[i - 1] -  a ][s[i] -  a ]++;     }     for (int i = 0; i < (1LL << m); i++) dp[i] = 1000000000000000;     for (int mask = 0; mask < (1LL << m); mask++) {       long long cost = 0;       for (int i = 0; i < m; i++) {         for (int j = i + 1; j < m; j++) {           if ((mask >> i & 1) ^ (mask >> j & 1)) {             cost += freq[i][j];           }         }       }       for (int i = 0; i < m; i++) {         if ((mask & (1LL << i)) == 0) continue;         dp[mask] = min(dp[mask], dp[mask ^ (1LL << i)] + cost);         if ((mask ^ (1LL << i)) == 0) dp[mask] = cost;       }     }     long long ans = dp[(1LL << m) - 1];     cout << ans <<   n ;     return 0;   }   long long ncr(long long n, long long r) {     if (r > n || r < 0 || n < 0) return 0;     long long ans = fact[n];     long long temp = (fact[n - r] * fact[r]) % 1000000007;     ans = (ans * inverse(temp, 1000000007)) % 1000000007;     return ans;   }   void fileio() {     freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);   }   void build() {     fact[0] = 1;     for (long long i = 1; i < nax; i++) fact[i] = (fact[i - 1] * i) % 1000000007;   }   long long modulo(long long base, long long exponent, long long modulus) {     if (modulus == 1) return 0;     long long result = 1;     base = base % modulus;     while (exponent > 0) {       if (exponent % 2 == 1) {         result = (result * base) % modulus;       }       exponent = exponent >> 1;       base = (base * base) % modulus;     }     return result;   }   long long choose(long long n, long long k) {     if (k == 0) return 1;     return (n * choose(n - 1, k - 1)) / k;   }   void EE(long long a, long long b, long long &co1, long long &co2) {     if (a % b == 0) {       co1 = 0;       co2 = 1;       return;     }     EE(b, a % b, co1, co2);     long long temp = co1;     co1 = co2;     co2 = temp - co2 * (a / b);   }   long long inverse(long long a, long long m) {     long long x, y;     EE(a, m, x, y);     if (x < 0) x += m;     return x;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[100500];   int c[100500];   int n;   bool vis[100500];   bool dfs(int u, int cu) {     if (vis[u]) return 0;     vis[u] = 1;     bool r = 0;     if (c[u] != cu) return 1;     for (int v : g[u]) r |= dfs(v, cu);     return r;   }   int main() {     scanf( %d , &n);     for (int i = 0, qwe = n - 1; i < qwe; ++i) {       int u, v;       scanf( %d%d , &u, &v);       u--;       v--;       g[u].push_back(v);       g[v].push_back(u);     }     for (int i = 0, qwe = n; i < qwe; ++i) scanf( %d , c + i);     int u = -1, sz = 0;     for (int i = 0, qwe = n; i < qwe; ++i) {       set<int> s;       for (int v : g[i])         if (c[i] != c[v]) s.insert(v);       if (s.size() > sz) u = i, sz = s.size();     }     if (u == -1) {       puts( YES n1 );       return 0;     }     vis[u] = 1;     for (int i = 0, qwe = g[u].size(); i < qwe; ++i)       if (dfs(g[u][i], c[g[u][i]])) {         puts( NO );         return 0;       }     printf( YES n%d n , u + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int a[105][105];   int main() {     scanf( %d %d , &n, &m);     if (n + m == 3 or n + m == 4)       printf( -1 n );     else {       int num = 2;       if (n >= m) {         for (int i = 1; i <= n; i++)           for (int j = 1; j <= m; j++) {             if (num > m * n) num = 1;             a[i][j] = num;             num += 2;           }       } else         for (int j = 1; j <= m; j++)           for (int i = 1; i <= n; i++) {             if (num > m * n) num = 1;             a[i][j] = num;             num += 2;           }       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) {           printf( %d , a[i][j]);           if (j == m)             printf(  n );           else             printf(   );         }     }     return 0;   }