malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   int n, s;   long long a[maxn], b[maxn], c[maxn];   vector<int> p[2];   bool cmp1(int i, int j) { return b[i] - c[i] > b[j] - c[j]; }   bool cmp2(int i, int j) { return c[i] - b[i] > c[j] - b[j]; }   int main() {     scanf( %d%d , &n, &s);     long long tot = 0, A = 0, B = 0, v1 = 0, v2 = 0;     p[0].clear();     p[1].clear();     for (int i = 0; i < n; i++) {       scanf( %I64d%I64d%I64d , a + i, b + i, c + i);       tot += a[i];       if (b[i] > c[i]) {         p[0].push_back(i);         A += a[i] * b[i];         v1 += a[i];       } else {         p[1].push_back(i);         B += a[i] * c[i];         v2 += a[i];       }     }     sort(p[0].begin(), p[0].end(), cmp1);     sort(p[1].begin(), p[1].end(), cmp2);     long long ans = 0;     long long c1 = v1 / s + (v1 % s ? 1 : 0);     long long c2 = v2 / s + (v2 % s ? 1 : 0);     tot = tot / s + (tot % s ? 1 : 0);     if (c1 + c2 > tot) {       long long tmp = A + B;       long long now = v1 % s;       for (int i = p[0].size() - 1; i >= 0; i--) {         now -= a[p[0][i]];         long long cnt = a[p[0][i]];         if (now < 0) cnt = a[p[0][i]] + now;         tmp += (c[p[0][i]] - b[p[0][i]]) * cnt;         if (now <= 0) break;       }       ans = max(ans, tmp);       tmp = A + B;       now = v2 % s;       for (int i = p[1].size() - 1; i >= 0; i--) {         now -= a[p[1][i]];         long long cnt = a[p[1][i]];         if (now < 0) cnt = a[p[1][i]] + now;         tmp += (b[p[1][i]] - c[p[1][i]]) * cnt;         if (now <= 0) break;       }       ans = max(ans, tmp);     } else       ans = A + B;     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 2.0 * acos(0.0);   const int INF = 1000 * 1000 * 1000;   const int maxn = 1100;   int W, H, N, M, cnt, tot;   char g[maxn][maxn];   int upp[maxn][maxn], lf[maxn][maxn];   bool can;   void play(int x, int y) {     if (x == N || y == M) return;     bool r, d;     if (y + 1 < M && upp[x][y + 1] >= H)       r = true;     else       r = false;     if (x + 1 < N && lf[x + 1][y] >= W)       d = true;     else       d = false;     if (r && d)       can = false;     else if (r) {       cnt += H;       play(x, y + 1);     } else if (d) {       cnt += W;       play(x + 1, y);     }   }   int solve(int maxVal, int coefh, int coefw, int sx, int sy) {     for (int len = 1; len <= maxVal; len++) {       W += (coefw);       H += (coefh);       bool all = true;       for (int k = 0; k < H && all; k++)         for (int t = 0; t < W && all; t++) {           if (g[k + sx][t + sy] !=  X ) all = false;         }       if (!all) continue;       can = true;       cnt = H * W;       play(sx + H - 1, sy + W - 1);       if (can && cnt == tot) return H * W;     }     return -1;   }   int main() {     ios_base::sync_with_stdio(false);     int i, j, k;     cin >> N >> M;     int sx = -1, sy;     tot = 0;     W = H = 0;     for (int i = 0; i < N; i++)       for (int j = 0; j < M; j++) {         cin >> g[i][j];         if (g[i][j] ==  X ) tot++;         if (g[i][j] ==  X  && sx == -1) {           sx = i, sy = j;         }       }     memset(upp, 0, sizeof upp);     memset(lf, 0, sizeof lf);     for (int i = 0; i < M; i++) upp[0][i] = (g[0][i] ==  X  ? 1 : 0);     for (int i = 0; i < N; i++) lf[i][0] = (g[i][0] ==  X  ? 1 : 0);     for (int i = 0; i < N; i++)       for (int j = 0; j < M; j++) {         if (i != 0 && g[i][j] ==  X ) upp[i][j] = upp[i - 1][j] + 1;         if (j != 0 && g[i][j] ==  X ) lf[i][j] = lf[i][j - 1] + 1;       }     int w = 0, h = 0;     for (int i = sy; i < M && g[sx][i] ==  X ; i++) w++;     for (int i = sx; i < N && g[i][sy] ==  X ; i++) h++;     int coefh = 0, coefw = 0;     int ans;     W = w, H = 0;     ans = solve(h, 1, 0, sx, sy);     W = 0, H = h;     int ans2 = solve(w, 0, 1, sx, sy);     if (ans == -1 || (ans2 != -1 && ans2 < ans)) ans = ans2;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k;     int l;     cin >> k >> l;     int u[k];     int y[l];     for (int i = 0; i < k; i++) {       cin >> u[i];     }     for (int i = 0; i < l; i++) {       cin >> y[i];     }     long long int h = 0;     long long int v = 0;     int f = 0;     int g = 0;     int p = 0;     while (p != k || g != l) {       if (v == h && v == 0) {         v += y[g];         h += u[p];         g++;         p++;       } else if (v > h) {         h += u[p];         p++;       } else if (v < h) {         v += y[g];         g++;       } else {         f++;         h = 0;         v = 0;       }     }     cout << f + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k, x = 1;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     m = k * (5 + (n - 1) * 6);     cout << m << endl;     while (n--) {       cout << x * k <<     << (x + 1) * k <<     << (x + 2) * k <<                << (x + 4) * k << endl;       x += 6;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   const long double PI = 3.1415926535;   const long double eps = 1e-07;   const long long INF = 1e18;   const int inf = 1e9;   const long long M = 305;   const string IO[2]{ NO n ,  YES n };   const string io[2]{ No n ,  Yes n };   struct STree {     int start;     vector<int> t;     STree(int n) {       start = 1;       while (start < n) start *= 2;       t = vector<int>(2 * start, inf);     }     int min(int v, int l, int r, int ql, int qr) {       if (l > qr || r < ql) return inf;       if (l >= ql && r <= qr) return t[v];       int c = (l + r) / 2;       return std::min(min(2 * v, l, c, ql, qr), min(2 * v + 1, c + 1, r, ql, qr));     }     void upd(int v, int l, int r, int p, int x) {       if (l > p || r < p) return;       if (l == r) {         t[v] = x;         return;       }       int c = (l + r) / 2;       upd(2 * v, l, c, p, x);       upd(2 * v + 1, c + 1, r, p, x);       t[v] = std::min(t[2 * v], t[2 * v + 1]);     }   };   void solve() {     int m;     cin >> m;     vector<int> x(m);     for (int i = 0; i < m; ++i) cin >> x[i];     sort(x.begin(), x.end());     auto last = unique(x.begin(), x.end());     x.erase(last, x.end());     m = x.size();     int a, b;     cin >> b >> a;     int n = b - a + 1;     STree st = STree(n);     int start = st.start;     vector<int> maxx(n, 1);     for (auto& nx : x) {       int fa = ((a - 1) / nx) * nx + nx;       for (int i = fa; i <= b; i += nx) maxx[i - a] = max(maxx[i - a], nx - 1);     }     st.upd(1, 0, start - 1, n - 1, 0);     for (int i = b - 1; i >= a; --i) {       int x = i - a;       int cw = maxx[x];       int ans = 1 + st.min(1, 0, start - 1, x + 1, x + cw);       st.upd(1, 0, start - 1, x, ans);     }     cout << st.min(1, 0, start - 1, 0, 0) <<   n ;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<string> a(n);     for (int i = 0; i < n; ++i) cin >> a[i];     for (int j = 0; j < m; ++j) {       vector<int> indx;       for (int i = 0; i < n; ++i) {         if (a[i][j] ==  # ) indx.push_back(i);       }       for (int i = 1; i < indx.size(); ++i) {         if (a[indx[i]] != a[indx[0]]) {           cout <<  No ;           return 0;         }       }     }     cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2 * 1e5 + 100;   vector<int> Prime;   int main() {     Prime.clear();     int n, k;     scanf( %d%d , &n, &k);     int flag = 1;     for (int i = 2; flag && i <= n; i++) {       if (n % i == 0) {         while (n % i == 0) {           Prime.push_back(i);           n /= i;         }         if (n == 1) {           flag = 0;         }         if (n < i && n > 1) {           flag = 0;           Prime.push_back(n);         }       }     }     if (Prime.size() < k) {       cout << -1 << endl;     } else {       for (int i = 0; i < k - 1; i++) {         cout << Prime[i] <<    ;       }       int ans = 1;       for (int i = k - 1; i < Prime.size(); i++) {         ans *= Prime[i];       }       if (ans != 1) {         cout << ans << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[10];   int n;   int notzero[12], cnt[12], ten[10], ans;   int main() {     ten[0] = 1;     for (int i = 1; i < 8; ++i) ten[i] = 10 * ten[i - 1];     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %s , s);       int len = strlen(s);       notzero[s[0] -  a ] = 1;       for (int j = 0; j < len; ++j) cnt[s[j] -  a ] += ten[len - j - 1];     }     int zero = -1;     for (int i = 0; i < 10; ++i) {       if (notzero[i] == 0) {         if (zero == -1 || cnt[i] > cnt[zero]) zero = i;       }     }     vector<int> v;     for (int i = 0; i < 10; ++i) {       if (zero != i) v.push_back(cnt[i]);     }     sort(v.begin(), v.end());     for (int i = 0; i < 9; ++i) {       ans += (9 - i) * v[i];     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool a[4];   int main() {     int n;     string s;     int cz = 0;     int c1 = 0;     int c0 = 0;     cin >> s;     for (int i = 0; i < s.length(); ++i)       if (s[i] ==  0 )         ++c0;       else if (s[i] ==  1 )         ++c1;       else if (s[i] ==  ? )         ++cz;     n = s.length();     if (c0 + cz > c1) a[0] = true;     if (c1 + cz > c0 + 1) a[3] = true;     if (s.length() % 2 == 0) {       int p = s.length() / 2;       if (abs(c0 - p) + abs(c1 - p) <= cz) {         if (s[n - 1] ==  1  || s[n - 1] ==  ?  && c1 < p) a[1] = true;         if (s[n - 1] ==  0  || s[n - 1] ==  ?  && c0 < p) a[2] = true;       }     } else {       int p = s.length() / 2;       if (abs(c0 - p) + abs(c1 - (p + 1)) <= cz) {         if (s[n - 1] ==  1  || s[n - 1] ==  ?  && c1 < p + 1) a[1] = true;         if (s[n - 1] ==  0  || s[n - 1] ==  ?  && c0 < p) a[2] = true;       }     }     if (a[0]) cout <<  00  << endl;     if (a[1]) cout <<  01  << endl;     if (a[2]) cout <<  10  << endl;     if (a[3]) cout <<  11  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     long long v[n + 10];     for (long long i = 0; i < n; i++) {       cin >> v[i];     }     sort(v, v + n);     k--;     long long div = k / n;     long long cnt = 0;     long long val = v[div];     for (long long i = 0; i < n; i++) {       if (v[i] == val) cnt++;       if (v[i] < val) k = k - n;     }     long long amt = cnt;     long long now = k / amt;     cout << val <<     << v[now] << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct atom {     long long f, w, where;     void scan() { scanf( %I64d%I64d , &f, &w); }   } x[310000];   priority_queue<long long> A, B;   int compare(atom k1, atom k2) {     return k1.f > k2.f || (k1.f == k2.f && k1.where < k2.where);   }   int n, pre, ans, where;   long long rem;   void insert(long long k1) {     if (!B.empty()) {       long long k2 = B.top();       if (k2 > k1) {         A.push(-k2);         B.pop();         B.push(k1);         rem += k2 - k1;         return;       }     }     A.push(-k1);     pre++;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) x[i].scan(), x[i].where = i;     n++;     x[n] = (atom){0, 0, n};     sort(x + 1, x + n + 1, compare);     pre = 0, ans = 0, where = 0;     long long rem = 0;     for (int i = 1; i <= n; i++)       if (x[i].where == 1) where = i;     ans = where;     pre = where;     for (int i = 1; i < where; i++) A.push(-(x[i].w - x[i].f + 1));     for (int i = where + 1; i <= n; i++) {       rem += x[i - 1].f - x[i].f;       if (i - 1 != where) insert(x[i - 1].w - x[i - 1].f + 1);       while (!A.empty()) {         long long k1 = -A.top();         if (k1 <= rem) {           rem -= k1;           pre--;           A.pop();         } else           break;       }       ans = min(ans, pre);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, x, y, z;   string str[5][200];   int blcks[5], whites[5];   int ara[] = {0, 1, 2, 3};   int main() {     cin >> n;     for (int i = 0; i < 4; i++) {       for (int j = 0; j < n; j++) cin >> str[i][j];       int tmp = 0;       for (int j = 0; j < n; j++) {         for (int k = 0; k < n; k++) {           if ((j + k) % 2 == 0) {             if (str[i][j][k] ==  0 )               blcks[i]++;             else               whites[i]++;           } else {             if (str[i][j][k] ==  1 )               blcks[i]++;             else               whites[i]++;           }         }       }     }     int ans = 100000000;     do {       int tmp1 = whites[ara[0]] + blcks[ara[1]] + whites[ara[2]] + blcks[ara[3]];       int tmp2 = whites[ara[1]] + blcks[ara[0]] + whites[ara[3]] + blcks[ara[2]];       ans = min(ans, tmp1);       ans = min(ans, tmp2);     } while (next_permutation(ara, ara + 4));     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct SegTree {     int sz;     vector<int> dat;     SegTree(int _sz = 1) {       sz = 1;       while (sz < _sz) sz <<= 1;       dat.resize(sz << 1);     }     void upd(int pos, int val) {       pos += sz - 1;       dat[pos] = val;       while (pos > 1) {         pos >>= 1;         dat[pos] = max(dat[pos << 1], dat[pos << 1 | 1]);       }     }     int qry(int id, int l, int r, int ql, int qr) {       if (qr < l || r < ql) return 0;       if (ql <= l && r <= qr) return dat[id];       return max(qry(id << 1, l, l + r >> 1, ql, qr),                  qry(id << 1 | 1, (l + r >> 1) + 1, r, ql, qr));     }     int qry(int l, int r) { return qry(1, 1, sz, l, r); }   } segx, segy;   int n, m, V;   set<pair<int, int>> tph, thp;   void plant(int p, int h) {     vector<pair<int, int>> v;     for (auto it = thp.begin(); it != thp.end() && it->first < h; it++) {       v.emplace_back(it->second, it->first);     }     thp.emplace(h, p);     tph.emplace(p, h);     v.emplace_back(p, h);     reverse(v.begin(), v.end());     for (auto p : v) {       segx.upd(p.first, 0);     }     for (auto p : v) {       int lis = segx.qry(p.first + 1, n) + 1;       segx.upd(p.first, lis);       segy.upd(p.second, lis);     }   }   void cutdown(int id) {     vector<pair<int, int>> v;     for (auto it = tph.begin(); id--; it++) {       if (id)         v.emplace_back(it->first, it->second);       else {         thp.erase(make_pair(it->second, it->first));         segx.upd(it->first, 0);         segy.upd(it->second, 0);         tph.erase(it);       }     }     reverse(v.begin(), v.end());     for (auto p : v) {       segy.upd(p.second, 0);     }     for (auto p : v) {       int lis = segy.qry(p.second + 1, V) + 1;       segx.upd(p.first, lis);       segy.upd(p.second, lis);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     segx = SegTree(n);     segy = SegTree(V = m + 10);     while (m--) {       int typ, x, y;       cin >> typ >> x;       if (typ == 1) {         cin >> y;         plant(x, y + m);       } else {         cutdown(x);       }       cout << segx.qry(1, n) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int n, k;     cin >> n >> k;     string s;     cin >> s;     string res =   ;     for (int i = 0; i < n; i++) {       if ((s[i] -  a ) >= ( z  - s[i])) {         if ((s[i] -  a ) <= k) {           k -= (s[i] -  a );           res +=  a ;         } else {           res += (char)(s[i] - k);           k = 0;         }       } else {         if (( z  - s[i]) <= k) {           k -= ( z  - s[i]);           res +=  z ;         } else {           res += (char)(s[i] + k);           k = 0;         }       }     }     if (k != 0) {       cout << -1;     } else {       cout << res;     }   }
#include <bits/stdc++.h>   using namespace std;   int parent[300005], maxLen[300005];   int findRoot(int u) {     int root = u;     while (parent[root] != root) {       root = parent[root];     }     while (parent[u] != root) {       int y = parent[u];       parent[u] = root;       u = y;     }     return root;   }   void unionNum(int u, int v) {     int ru = findRoot(u), rv = findRoot(v);     if (ru == rv) return;     if (maxLen[ru] > maxLen[rv]) {       parent[rv] = ru;       maxLen[ru] = max(maxLen[ru], maxLen[ru] / 2 + maxLen[rv] / 2 +                                        maxLen[ru] % 2 + maxLen[rv] % 2 + 1);     } else {       swap(ru, rv);       parent[rv] = ru;       maxLen[ru] = max(maxLen[ru], maxLen[ru] / 2 + maxLen[rv] / 2 +                                        maxLen[ru] % 2 + maxLen[rv] % 2 + 1);     }   }   int visited[300005] = {0};   bool nVis(int &i, int n) {     while (i <= n && visited[i] == 1) i++;     if (i <= n) return true;     return false;   }   void dfs(int node, vector<int> child[]) {     map<int, int> v1, v2, d1, d2;     stack<int> myStack;     myStack.push(node);     v1[node] = 1;     d1[node] = 0;     visited[node] = 1;     while (!myStack.empty()) {       int y = myStack.top();       myStack.pop();       for (size_t i = 0; i < child[y].size(); i++) {         if (v1[child[y][i]] == 0) {           v1[child[y][i]] = 1;           d1[child[y][i]] = d1[y] + 1;           myStack.push(child[y][i]);           visited[child[y][i]] = 1;         }       }     }     for (map<int, int>::iterator it = d1.begin(); it != d1.end(); it++) {       if (d1[node] < it->second) {         node = it->first;       }     }     myStack.push(node);     d2[node] = 0;     v2[node] = 1;     while (!myStack.empty()) {       int y = myStack.top();       myStack.pop();       parent[y] = node;       for (size_t i = 0; i < child[y].size(); i++) {         if (v2[child[y][i]] == 0) {           v2[child[y][i]] = 1;           d2[child[y][i]] = d2[y] + 1;           maxLen[node] = max(maxLen[node], d2[child[y][i]]);           myStack.push(child[y][i]);         }       }     }   }   int main() {     int n, m, q, a, b;     scanf( %d%d%d , &n, &m, &q);     for (int i = 0; i <= n; i++) {       parent[i] = i;       maxLen[i] = 0;     }     vector<int> child[n + 1];     for (int i = 0; i < m; i++) {       scanf( %d%d , &a, &b);       child[a].push_back(b);       child[b].push_back(a);     }     int i = 1;     while (nVis(i, n)) {       dfs(i, child);     }     while (q--) {       int type;       scanf( %d , &type);       if (type == 1) {         scanf( %d , &a);         printf( %d n , maxLen[findRoot(a)]);       } else {         scanf( %d%d , &a, &b);         unionNum(a, b);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int sum[1000005];   int main() {     int n, x;     cin >> n;     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j) {         scanf( %d , &x);         if (i == j) sum[i] = x;       }     int all = 0;     for (int i = 0; i < n; ++i) all += sum[i];     int q, tipo;     cin >> q;     while (q--) {       scanf( %d , &tipo);       if (tipo == 3) {         printf( %d , all % 2);       } else {         scanf( %d , &x);         x--;         if (sum[x] == 0) {           sum[x] = 1;           ++all;         } else {           sum[x] = 0;           --all;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     cin >> t;     while (t--) {       long long int n, s = 0;       cin >> n;       long long int* arr = new long long int[n];       for (long long int i = 0; i < n; i++) {         cin >> arr[i];         s += arr[i];       }       if (s == 0)         cout <<  NO               <<   n ;       else if (s > 0) {         cout <<  YES               <<   n ;         sort(arr, arr + n, greater<long long int>());         for (long long int i = 0; i < n; i++) cout << arr[i] <<    ;         cout <<   n ;       } else {         cout <<  YES               <<   n ;         sort(arr, arr + n);         for (long long int i = 0; i < n; i++) cout << arr[i] <<    ;         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 20, S = (1 << 16) + 10, V = 2048;   bitset<V> dp[S];   int a[N], id[N];   priority_queue<pair<int, int> > q;   int main() {     int n, k, v = 0;     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]), v += a[i];     dp[0][0] = 1;     int u = (1 << n) - 1;     for (int s = 0; s <= u; ++s) {       for (int i = v / k; i >= 1; --i)         if (dp[s][i * k]) dp[s][i] = 1;       for (int i = 1; i <= n; ++i)         if (!(s >> i - 1 & 1)) dp[s | (1 << i - 1)] |= dp[s] << a[i];     }     puts(dp[u][1] ?  YES  :  NO );     if (!dp[u][1]) return 0;     int c = 1e9;     for (int s = u, j = 1; s;)       for (int t = j, ok = 0; !ok; t *= k, c -= !ok)         for (int i = 1; i <= n; ++i) {           if (t < a[i]) continue;           if ((s >> i - 1 & 1) && dp[s ^ (1 << i - 1)][t - a[i]]) {             id[i] = c, s ^= 1 << i - 1, j = t - a[i], ok = 1;             break;           }         }     for (int i = 1; i <= n; ++i) q.push(make_pair(-(id[i] - c), a[i]));     while (q.size() > 1) {       pair<int, int> x = q.top();       q.pop();       pair<int, int> y = q.top();       q.pop();       printf( %d %d n , x.second, y.second);       int v = x.second + y.second, u = 0;       while (v % k == 0) v /= k, ++u;       q.push(make_pair(-(-x.first + u), v));     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   long long n, k, s, h[200005];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> k >> s;     h[0] = 1;     if (k * (n - 1) < s || k > s) {       cout <<  NO ;       return 0;     }     long long t = s / k, z = s % k;     for (long long i = 1; i <= z; i++) {       if (h[i - 1] + t + 1 <= n) {         h[i] = h[i - 1] + t + 1;       } else         h[i] = h[i - 1] - t - 1;     }     for (long long i = z + 1; i <= k; i++) {       if (h[i - 1] + t <= n) {         h[i] = h[i - 1] + t;       } else         h[i] = h[i - 1] - t;     }     cout <<  YES n ;     for (long long i = 1; i <= k; i++) cout << h[i] <<    ;     return 0;   }