malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   char s[2000];   int n, len, ans;   int dpmin[120][55][2], dpmax[120][55][2];   bool u[120][55][2];   int inf = 10005000;   bool go(int i, int n, int d) {     if (i == len) {       if (n % 2 == 0) return 1;       return 0;     }     if (u[i][n][d]) return 1;     u[i][n][d] = 1;     dpmin[i][n][d] = inf;     dpmax[i][n][d] = -inf;     if (s[i] ==  F ) {       if (go(i + 1, n, d)) {         dpmin[i][n][d] = min(dpmin[i][n][d], (d ? -1 : 1) + dpmin[i + 1][n][d]);         dpmax[i][n][d] = max(dpmax[i][n][d], (d ? -1 : 1) + dpmax[i + 1][n][d]);       }       if (n > 0 && go(i + 1, n - 1, d ^ 1)) {         dpmin[i][n][d] = min(dpmin[i][n][d], dpmin[i + 1][n - 1][d ^ 1]);         dpmax[i][n][d] = max(dpmax[i][n][d], dpmax[i + 1][n - 1][d ^ 1]);       }     } else {       if (n > 0 && go(i + 1, n - 1, d)) {         dpmin[i][n][d] =             min(dpmin[i][n][d], (d ? -1 : 1) + dpmin[i + 1][n - 1][d]);         dpmax[i][n][d] =             max(dpmax[i][n][d], (d ? -1 : 1) + dpmax[i + 1][n - 1][d]);       }       if (go(i + 1, n, d ^ 1)) {         dpmin[i][n][d] = min(dpmin[i][n][d], dpmin[i + 1][n][d ^ 1]);         dpmax[i][n][d] = max(dpmax[i][n][d], dpmax[i + 1][n][d ^ 1]);       }     }     return 1;   }   int main() {     scanf( %s%d , s, &n);     len = strlen(s);     go(0, n, 0);     ans = max(-dpmin[0][n][0], dpmax[0][n][0]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e09 + 5e3;   const long long linf = 2e18 + 5e3;   const int mxn = 5e2 + 5;   void solve() {     int n;     cin >> n;     vector<int> a(n), b(n);     vector<pair<int, int> > as, bs;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       cin >> b[i];     }     long long out = 1;     if (n & 1) out = a[n / 2] == b[n / 2];     for (int i = 0, j = n - 1; i < n / 2; i++, j--) {       as.emplace_back(min(a[i], a[j]), max(a[i], a[j]));       bs.emplace_back(min(b[i], b[j]), max(b[i], b[j]));     }     sort((as).begin(), (as).end());     sort((bs).begin(), (bs).end());     cout << (out && as == bs ?  Yes  :  No ) <<   n ;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long n;   long long a[100005];   long long preA[100005];   int main() {     cin >> n;     for (long long i = 0; i < n; ++i) {       cin >> a[i];     }     preA[0] = 0;     for (long long i = 1; i < n; ++i) {       preA[i] = preA[i - 1] + a[i];     }     set<long long> nos;     map<long long, long long> freq;     for (long long i = 0; i < n; ++i) {       if (nos.find(preA[i]) != nos.end()) {         freq[preA[i]]++;       } else {         nos.insert(preA[i]);         freq[preA[i]] = 1;       }     }     long long maxFreq = -1;     for (set<long long>::iterator it = nos.begin(); it != nos.end(); ++it) {       if (maxFreq < freq[*it]) {         maxFreq = freq[*it];       }     }     cout << n - maxFreq;   }
#include <bits/stdc++.h>   int n, a[100001], i, d = 0, s = 0;   int main() {     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     std::sort(a, a + n);     for (i = 0; i < n; i++)       if (a[i] >= s) {         d++;         s += a[i];       }     printf( %d , d);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1001001001;   const long long INFL = 1001001001001001001LL;   template <typename T>   void pv(T a, T b) {     for (T i = a; i != b; ++i) cout << *i <<    ;     cout << endl;   }   template <class T>   bool uin(T &a, T b) {     return a > b ? (a = b, true) : false;   }   template <class T>   bool uax(T &a, T b) {     return a < b ? (a = b, true) : false;   }   int in() {     int x;     cin >> x;     return x;   }   double fin() {     double x;     cin >> x;     return x;   }   string sin() {     string x;     cin >> x;     return x;   }   char chin() {     char x;     cin >> x;     return x;   }   long long lin() {     long long x;     cin >> x;     return x;   }   struct card {     int a, b, c;   };   bool comp(card &a, card &b) { return a.a > b.a; }   int n, p, q, r;   long long sum[500011];   vector<pair<int, int> > bounds;   vector<card> cards;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.setf(ios::fixed);     cout.precision(20);     cin >> n >> p >> q >> r;     cards.resize(n);     for (int i = 0; i < (int)(n); ++i) {       cin >> cards[i].a >> cards[i].b >> cards[i].c;       bounds.push_back({cards[i].b, cards[i].c});     }     sort((cards).begin(), (cards).end(), comp);     sort((bounds).rbegin(), (bounds).rend());     int ind = -1;     for (int i = 0; i < bounds.size(); i++) {       if (ind == -1 || bounds[ind].second < bounds[i].second) {         bounds[++ind] = bounds[i];       }     }     bounds.resize(ind + 1);     bounds.push_back({0, r});     reverse((bounds).begin(), (bounds).end());     bounds.push_back({q, 0});     for (int i = 1; i < bounds.size(); i++) {       sum[i] = sum[i - 1] + (long long)(bounds[i - 1].second - bounds[i].second) *                                 (q - bounds[i - 1].first);     }     int bb = p;     int minb = 0, minc = 0;     int pbnd = 0, pcnd = bounds.size() - 1;     long long sol = 0;     cards.push_back({0, 0, 0});     for (int i = 0; i <= n; i++) {       if (bb > cards[i].a) {         while (pbnd < bounds.size() && bounds[pbnd].first < minb) pbnd++;         while (pcnd > 0 && bounds[pcnd].second < minc) pcnd--;         if (pbnd > pcnd) {           sol += (long long)(bb - cards[i].a) * (q - minb) * (r - minc);         } else {           sol += (long long)(bb - cards[i].a) *                  (sum[pcnd] - sum[pbnd] +                   (long long)(bounds[pcnd].second - minc) *                       (q - bounds[pcnd].first) +                   (long long)(q - minb) * (r - bounds[pbnd].second));         }         bb = cards[i].a;       }       uax(minb, cards[i].b);       uax(minc, cards[i].c);     }     cout << sol << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool bSearch(int* toys, int item, int from, int to) {     if (from > to)       return false;     else {       int midPoint = (from + to) / 2;       if (item < toys[midPoint])         return bSearch(toys, item, from, midPoint - 1);       else if (item == toys[midPoint])         return true;       else         return bSearch(toys, item, midPoint + 1, to);     }   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     int toys[n];     for (int i = 0; i < n; i++) {       scanf( %d , &toys[i]);     }     sort(toys, toys + n);     long long int counter = 0;     vector<int> v;     for (int i = 1; i <= 1000000000 && i <= m && counter < m; i++) {       if (!bSearch(toys, i, 0, n - 1)) {         counter += i;         if (counter <= m) v.push_back(i);       }     }     printf( %d n , v.size());     for (int i = 0; i < v.size(); i++) {       printf( %d  , v[i]);     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   int a, b, n, p;   int main() {     cin >> a >> b >> n;     for (int x = -1000; x < 1001; x++) {       p = 1;       for (int i = 0; i < n && p <= 1000; i++) p *= x;       if (a * p == b) {         cout << x;         return 0;       }     }     cout <<  No solution ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int j1 = 0; j1 < t; j1++) {       long long int n;       cin >> n;       long long int arr[n];       long long int sum1 = 0;       long long int sum2 = 0;       for (int j = 0; j < (n / 2); j++) {         arr[j] = ((2 * j) + 2);         sum1 += arr[j];       }       long long int p = 1;       for (int k = n / 2; k < n - 1; k++) {         arr[k] = (2 * p - 1);         p++;         sum2 += (arr[k]);       }       arr[n - 1] = sum1 - sum2;       if (n % 4 == 0) {         cout <<  YES  << endl;         for (int m = 0; m < n; m++) {           cout << arr[m] <<    ;         }         cout << endl;       } else {         cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 2 * acos(0);   void _R(int &x) { scanf( %d , &x); }   void _R(int64_t &x) { scanf( %lld , &x); }   void _R(double &x) { scanf( %lf , &x); }   void _R(char &x) { scanf(  %c , &x); }   void _R(char *x) { scanf( %s , x); }   int main() {     long long x, n, s = 0, a, i;     cin >> n >> x;     for (i = 1; i <= n; i++) {       if (x % i == 0 && x / i <= n) {         s++;       }     }     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   constexpr int N = 1e5 + 5;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int n, k, m;     cin >> n >> k >> m;     vector<int> in(k);     for (int &e : in) cin >> e;     sort(begin(in), end(in));     const int A = accumulate(begin(in), end(in), 0);     int ans = 0;     for (int i = 0; i <= n; i++) {       if (i * A > m) break;       int points = i * (k + 1);       int have = m - i * A;       int g = n - i;       for (int x : in) {         int t = min(g, have / x);         points += t;         have -= t * x;       }       ans = max(ans, points);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-9;   const int INF = 2147483647;   const long long LLINF = 9223372036854775807LL;   template <class T>   T gcd(T a, T b) {     if (a < b) swap(a, b);     if (b == 0) return a;     return gcd(b, a % b);   }   template <class T>   T lcm(T a, T b) {     return (a * b) / gcd(a, b);   }   int dp[510001];   int main() {     int d, n;     cin >> n >> d;     vector<int> c(n);     for (int i = 0; i < (n); i++) cin >> c[i];     for (int i = 0; i < (n); i++) {       for (int j = (510000); j >= (c[i]); j--) {         dp[j] = max(dp[j], c[i] + dp[j - c[i]]);       }     }     int ans = 0, lAns = -1, days = -1;     while (ans != lAns) {       lAns = ans;       ans = dp[ans + d];       days++;     }     if (ans == 0)       cout << 0 <<     << 0 << endl;     else       cout << ans <<     << days << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   inline long long read() {     long long f = 1, x = 0;     char s = getchar();     while (s <  0  || s >  9 ) {       if (s ==  - ) f = -1;       s = getchar();     }     while (s >=  0  && s <=  9 ) {       x = x * 10 -  0  + s;       s = getchar();     }     return x * f;   }   int zxy = 1e9 + 7;   int n, m, i, j, s, o, k, h;   int a[2005];   int dl[2005], dr[2005];   double dp[2005][2005][2][2], P;   bool f[2005][2005][2][2];   double DP(int l, int r, int f1, int f2) {     if (l > r) return 0.0;     if (f[l][r][f1][f2]) return dp[l][r][f1][f2];     f[l][r][f1][f2] = 1;     double dpp = 0.0;     dpp += 0.5 * P * (min(a[l] - a[l - 1] - h * f1, h) + DP(l + 1, r, 0, f2));     dpp += 0.5 * (1.0 - P) *            (min(a[r + 1] - a[r] - h * f2, h) + DP(l, r - 1, f1, 0));     int L = dr[l], R = dl[r];     if (L < r)       dpp += 0.5 * (1.0 - P) * (a[L] - a[l] + h + DP(L + 1, r, 1, f2));     else       dpp += 0.5 * (1.0 - P) * (a[r] - a[l] + min(a[r + 1] - a[r] - h * f2, h));     if (R > l)       dpp += 0.5 * P * (a[r] - a[R] + h + DP(l, R - 1, f1, 1));     else       dpp += 0.5 * P * (a[r] - a[l] + min(a[l] - a[l - 1] - h * f1, h));     return dp[l][r][f1][f2] = dpp;   }   signed main() {     n = read();     h = read();     scanf( %lf , &P);     for (int i = 1; i <= n; i++) a[i] = read();     sort(a + 1, a + 1 + n);     a[0] = -0x7f7f7f7f;     a[n + 1] = 0x7f7f7f7f;     dr[n] = n;     dl[1] = 1;     for (int i = 2; i <= n; i++) {       if (a[i] - a[i - 1] < h)         dl[i] = dl[i - 1];       else         dl[i] = i;     }     for (int i = n - 1; i > 0; i--) {       if (a[i + 1] - a[i] < h)         dr[i] = dr[i + 1];       else         dr[i] = i;     }     printf( %.10lf n , DP(1, n, 0, 0));     return 0;   }
#include <bits/stdc++.h>   int n, m, k;   std::unordered_set<int> G[100123];   int deg[100123];   inline bool CheckClique(int x) {     std::vector<int> V({x});     for (int y : G[x]) V.emplace_back(y);     for (int u : V)       for (int v : V)         if (u < v && (!G[u].count(v))) return false;     return true;   }   inline void Solve() {     for (int i = 1; i <= n; ++i) G[i].clear();     memset(deg, 0, sizeof(deg));     scanf( %d%d%d , &n, &m, &k);     std::vector<std::pair<int, int>> input;     for (int i = 1, u, v; i <= m; ++i) {       scanf( %d%d , &u, &v);       input.emplace_back(std::make_pair(u, v));     }     if ((1LL * k * (k - 1) / 2) > m) return puts( -1 ), void();     for (auto& p : input) {       G[p.first].insert(p.second);       G[p.second].insert(p.first);       ++deg[p.first];       ++deg[p.second];     }     int cnt = 0;     std::queue<int> q;     for (int i = 1; i <= n; ++i)       if (deg[i] < k) {         if (deg[i] == k - 1 && CheckClique(i)) {           puts( 2 );           for (int x : G[i]) printf( %d  , x);           printf( %d n , i);           return;         }         q.push(i);         ++cnt;       }     while (!q.empty()) {       int u = q.front();       q.pop();       for (int v : G[u]) {         G[v].erase(u);         if ((--deg[v]) == k - 1) {           if (CheckClique(v)) {             puts( 2 );             for (int x : G[v]) printf( %d  , x);             printf( %d n , v);             return;           }           q.push(v);           ++cnt;         }       }     }     if (cnt < n) {       std::vector<int> ans;       for (int i = 1; i <= n; ++i)         if (deg[i] >= k) ans.emplace_back(i);       printf( 1 n%d n , static_cast<int>(ans.size()));       for (int i : ans) printf( %d  , i);       puts(  );     } else       puts( -1 );   }   int main() {     int T;     scanf( %d , &T);     while (T--) Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int long long n, c = 0;     cin >> n;     for (int long long i = 1; i < n; i++) {       if (n % i == 0) {         c++;       }     }     cout << (c);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 105;   long long f[MAXN][MAXN][MAXN];   int a[MAXN];   string s;   int n;   long long solve(int l, int r, int pf) {     if (l >= r) return 0;     if (r - l == 1) return a[pf];     long long &cur = f[l][r][pf];     if (cur > 0) return cur;     cur = max(cur, solve(l + 1, r, 1) + a[pf]);     for (int i = l + 1; i < r; i++)       if (s[l] == s[i]) cur = max(cur, solve(l + 1, i, 1) + solve(i, r, pf + 1));     return cur;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> s;     for (int i = 1; i <= n; i++) cin >> a[i];     cout << solve(0, n, 1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int absi(int a) { return (a > 0) ? a : -a; }   const int md = 51123987;   inline void add(int &a, int b) {     a += b;     if (a >= md) a -= md;   }   int a[155];   int tmp[4];   int nxt[155][4];   int dp[155][55][55][55];   int main(void) {     int n, mx;     scanf( %d , &n);     mx = (n + 2) / 3;     char c = getchar();     while (c == 10 || c == 32) c = getchar();     for (int i = 1; i <= n; ++i) {       a[i] = c -  a  + 1;       c = getchar();     }     memset(tmp, 255, sizeof(tmp));     for (int i = n; i; --i) {       tmp[a[i]] = i;       memcpy(nxt[i], tmp, sizeof(tmp));     }     int res = 0;     dp[1][0][0][0] = 1;     for (int i = 1; i <= n; ++i) {       for (int j = 0; j <= mx; ++j) {         for (int k = 0; k <= mx; ++k) {           for (int l = 0; l <= mx; ++l) {             if (j + k + l > n) break;             int val = dp[i][j][k][l];             if (j + k + l == n) {               if (absi(j - k) <= 1 && absi(j - l) <= 1 && absi(k - l) <= 1) {                 add(res, val);               }               continue;             }             if (~nxt[i][1]) {               add(dp[nxt[i][1]][j + 1][k][l], val);             }             if (~nxt[i][2]) {               add(dp[nxt[i][2]][j][k + 1][l], val);             }             if (~nxt[i][3]) {               add(dp[nxt[i][3]][j][k][l + 1], val);             }           }         }       }     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T[5000000], sl[5000000], sr[5000000], a[200005], rt[200005], la[200005],       pos[200005];   int i, j, n, num, tmp, ans;   void build(int l, int r, int &node) {     node = ++num;     if (l == r) return;     int mid = (l + r) >> 1;     build(l, mid, sl[node]);     build(mid + 1, r, sr[node]);   }   void Insert(int l, int r, int x, int y, int node) {     int k = ++num;     if (l == r) {       T[k] = T[node] + y;       return;     }     int mid = (l + r) >> 1;     if (x <= mid) {       sl[k] = num + 1, sr[k] = sr[node];       Insert(l, mid, x, y, sl[node]);     } else {       sl[k] = sl[node], sr[k] = num + 1;       Insert(mid + 1, r, x, y, sr[node]);     }     T[k] = T[sl[k]] + T[sr[k]];   }   int ask(int l, int r, int k, int node) {     if (l == r) return l;     int mid = (l + r) >> 1, now = T[sl[node]];     if (now >= k) return ask(l, mid, k, sl[node]);     return ask(mid + 1, r, k - now, sr[node]);   }   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     build(1, n + 1, rt[0]);     rt[1] = num + 1, Insert(1, n + 1, n + 1, 1, rt[0]);     tmp = 1;     for (i = n; i; i--) {       if (pos[a[i]])         rt[tmp + 1] = num + 1, Insert(1, n + 1, pos[a[i]], -1, rt[tmp++]);       rt[tmp + 1] = num + 1, Insert(1, n + 1, i, 1, rt[tmp++]);       la[i] = tmp;       pos[a[i]] = i;     }     for (i = 1; i <= n; i++) {       ans = 0;       j = 1;       while ((j = ask(1, n + 1, i + 1, rt[la[j]])) <= n) ans++;       printf( %d  , ans + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     char c;     bool nega = 0;     while ((!isdigit(c = getchar())) && c !=  - )       ;     if (c ==  - ) {       c = getchar();       nega = 1;     }     x = c - 48;     while (isdigit(c = getchar())) x = x * 10 + c - 48;     if (nega) x = -x;   }   inline void update(int64_t &A, int64_t B) {     if (A > B) A = B;   }   int64_t dp[2][500][500][2];   vector<pair<int, int>> robot[500][500];   bool good[500000][4];   int d[500000], e[500000];   signed main() {     int n, m, k;     read(n);     read(m);     read(k);     vector<int> dx = {0, 1, 1, 0}, dy = {0, -1, 0, 1};     int cap = max(m, n);     for (int i = 0; i < k; i++) {       int x, y, t;       read(x);       read(y);       read(d[i]);       read(t);       read(e[i]);       for (int zi = 0; zi < 4; zi++) {         int nx = x + dx[zi] * d[i], ny = y + dy[zi] * d[i];         if (zi + t <= nx + ny && (zi + t) % 4 == (nx + ny) % 4) {           robot[nx][ny].push_back({i, zi});           good[i][zi] = 1;         }       }     }     for (int X = 0; X < 2; X++)       for (int Y = 0; Y < m; Y++)         for (int W = 0; W < cap; W++)           for (int vert = 0; vert < 2; vert++) dp[X][Y][W][vert] = LLONG_MAX;     dp[0][0][0][0] = dp[0][0][0][1] = 0;     int64_t ans = LLONG_MAX;     for (int X = 0; X < n; X++) {       int cur = X & 1;       int nxt = 1 - cur;       for (int Y = 0; Y < m; Y++) {         for (int W = 0; W < cap; W++) {           for (int vert = 0; vert < 2; vert++) {             if (W > (vert ? X : Y) || dp[cur][Y][W][vert] == LLONG_MAX) break;             if (Y < m - 1) {               int right = (vert ? 0 : W) + 1;               int64_t smash = 0;               for (auto &[id, zi] : robot[X][Y + 1]) {                 if (zi == 2 && right >= d[id] && good[id][1]) continue;                 if (zi == 3 && right >= d[id] && good[id][0]) continue;                 smash += e[id];               }               update(dp[cur][Y + 1][right][0], dp[cur][Y][W][vert] + smash);               update(dp[cur][Y + 1][0][1], dp[cur][Y][W][vert] + smash);             }             if (X < n - 1) {               int down = (vert ? W : 0) + 1;               int64_t smash = 0;               for (auto &[id, zi] : robot[X + 1][Y]) {                 if (zi == 2 && down >= d[id] && good[id][0]) continue;                 smash += e[id];               }               update(dp[nxt][Y][down][1], dp[cur][Y][W][vert] + smash);               update(dp[nxt][Y][0][0], dp[cur][Y][W][vert] + smash);             }           }         }       }       if (X == n - 1) {         for (int W = 0; W < cap; W++)           for (int vert = 0; vert < 2; vert++)             update(ans, dp[cur][m - 1][W][vert]);         break;       }       for (int Y = 0; Y < m; Y++)         for (int W = 0; W < cap; W++)           for (int vert = 0; vert < 2; vert++) dp[cur][Y][W][vert] = LLONG_MAX;     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int x1, x2, y1, y2, xmin, xmax, ymin, ymax;     cin >> x1 >> y1 >> x2 >> y2;     xmin = x1;     xmax = x2;     ymin = y1;     ymax = y2;     int total = (x2 - x1) * (y2 - y1);     for (int a = 1; a < n; ++a) {       cin >> x1 >> y1 >> x2 >> y2;       xmin = min(x1, xmin);       xmax = max(x2, xmax);       ymin = min(y1, ymin);       ymax = max(y2, ymax);       total += (x2 - x1) * (y2 - y1);     }     if (ymax - ymin == xmax - xmin and (xmax - xmin) * (xmax - xmin) == total)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     cin >> n;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, x1, x2, s = 0, x, y1 = 0, y2 = 0, sm = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x;       for (int i = 0; i < x; i++) cout << 7 <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> a[100010];   int x;   int now;   void print() {     cout <<  YES  << endl;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) cout << a[i][j] <<    ;       cout << endl;     }   }   int main() {     cin >> n >> m;     now = 1;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         a[i].push_back(now);         now += 1;       }     if (n == 1 && m == 1) {       cout <<  YES  << endl;       cout << 1;       return 0;     }     if (n * m == 2) {       cout <<  NO ;       return 0;     }     if (n * m == 3) {       cout <<  NO ;       return 0;     }     if (n == 2 && m == 2) {       cout <<  NO ;       return 0;     }     if (n * m == 6 && min(n, m) == 2) {       cout <<  NO ;       return 0;     }     if (n == 3 && m == 3) {       cout <<  YES  << endl;       cout <<  6 1 8  << endl;       cout <<  7 5 3  << endl;       cout <<  2 9 4  << endl;       return 0;     }     if (n == 1 && m >= 4) {       now = 0;       for (int i = 2; i <= m; i += 2) {         a[0][now] = i;         now += 1;       }       for (int i = 1; i <= m; i += 2) {         a[0][now] = i;         now += 1;       }       print();       return 0;     }     if (m == 1 && n >= 4) {       now = 0;       for (int i = 2; i <= n; i += 2) {         a[now][0] = i;         now += 1;       }       for (int i = 1; i <= n; i += 2) {         a[now][0] = i;         now += 1;       }       print();       return 0;     }     if (m >= 4) {       for (int i = 0; i < n; i++)         if (i % 2 == 0) {           int tmp0 = a[i][m - 2];           int tmp1 = a[i][m - 1];           for (int j = m - 1; j >= 2; j--) a[i][j] = a[i][j - 2];           a[i][1] = tmp1;           a[i][0] = tmp0;         }       for (int i = 0; i < m; i++)         if (i % 2 == 0) {           int tmp0 = a[0][i];           for (int j = 0; j < n - 1; j++) a[j][i] = a[j + 1][i];           a[n - 1][i] = tmp0;         }       print();       return 0;     }     if (n >= 4) {       for (int i = 0; i < m; i++)         if (i % 2 == 0) {           int tmp0 = a[n - 2][i];           int tmp1 = a[n - 1][i];           for (int j = n - 1; j >= 2; j--) a[j][i] = a[j - 2][i];           a[1][i] = tmp1;           a[0][i] = tmp0;         }       for (int i = 0; i < n; i++)         if (i % 2 == 0) {           int tmp0 = a[i][0];           for (int j = 0; j < m - 1; j++) a[i][j] = a[i][j + 1];           a[i][m - 1] = tmp0;         }       print();       return 0;     }     return 0;   }