malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int kx[8] = {+2, +2, -2, -2, +1, +1, -1, -1};   int ky[8] = {+1, -1, +1, -1, +2, -2, +2, -2};   int d9x[9] = {+1, +1, +1, +0, +0, +0, -1, -1, -1};   int d9y[9] = {+1, +0, -1, +1, +0, -1, +1, +0, -1};   int dx4[4] = {+0, +0, +1, -1};   int dy4[4] = {+1, -1, +0, +0};   long long int gcd(unsigned long long int a, unsigned long long int b) {     return (a == 0) ? b : gcd(b % a, a);   }   long long int lcm(unsigned long long int a, unsigned long long int b) {     return a * (b / gcd(a, b));   }   const long long INF = 1e18;   using namespace std;   int main() {     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       int a[n];       int earliest[n + 1];       memset(earliest, -1, sizeof(earliest));       for (int i = 0; i < n; ++i) {         cin >> a[i];       }       for (int i = 0; i < n; ++i) {         if (earliest[a[i]] == -1) {           earliest[a[i]] = i;         } else if (earliest[a[i]] < i - 1) {           cout <<  YES n ;           goto end_of_loop;         }       }       cout <<  NO n ;     end_of_loop:;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> adj[200001];   long long a[200001];   vector<long long> start;   stack<long long> last;   long long ans;   bool f;   void dfs(long long);   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     set<long long> roots;     for (long long i = 1; i <= n; i++) roots.insert(i);     for (long long i = 1; i <= n; i++) cin >> a[i];     long long x;     for (long long i = 1; i <= n; i++) {       cin >> x;       if (x != -1) {         adj[x].push_back(i);         roots.erase(i);       }     }     start.clear();     while (!last.empty()) last.pop();     ans = 0;     for (auto x : roots) {       dfs(x);     }     cout << ans <<   n ;     for (auto x : start) {       cout << x <<    ;     }     while (!last.empty()) {       cout << last.top() <<    ;       last.pop();     }   }   void dfs(long long v) {     for (auto x : adj[v]) {       dfs(x);       if (a[x] > 0) a[v] += a[x];     }     ans += a[v];     if (a[v] > 0) {       start.push_back(v);     } else {       last.push(v);     }   }
#include <bits/stdc++.h>   using namespace std;   int output = 0;   int N, consCats;   vector<int> adj[999999];   int vCats[999999];   bool visited[999999];   bool leafs[999999];   bool aux;   void deep(int s, bool visited[], vector<int> adj[], int consCats, int var,             int vCats[]);   int main() {     cin >> N >> consCats;     for (int i = 1; i <= N; i++) {       visited[i] = false;       leafs[i] = false;     }     int cat;     for (int i = 1; i <= N; i++) {       cin >> cat;       vCats[i] = cat;     }     for (int i = 1; i < N; i++) {       int x, y;       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     deep(1, visited, adj, consCats, 0, vCats);     cout << output;     return 0;   }   void deep(int s, bool visited[], vector<int> adj[], int consCats, int var,             int vCats[]) {     if (visited[s]) return;     visited[s] = true;     aux = true;     for (int i = 0; i < adj[s].size(); i++) {       if (visited[adj[s][i]] == false) {         aux = false;         break;       }     }     (aux) ? leafs[s] = true : leafs[s] = false;     vCats[s] ? var += vCats[s] : var = 0;     if (leafs[s] && var <= consCats) {       output++;       return;     }     for (auto u : adj[s]) {       if (var > consCats)         continue;       else         deep(u, visited, adj, consCats, var, vCats);     }   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   long long i, n, x, m, k, ans;   int main() {     cin >> n;     x = n;     while (x) {       x /= 10;       m++;     }     ans = n * m + m - 1;     k = 1;     for (i = 0; i < m - 1; i++) {       k *= 10;       ans -= k;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ost(int k, int res) {     int ans = 0;     while (k < (double)res / 2) {       ans++;       k *= 2;     }     return ans;   }   int main() {     int n, k;     cin >> n >> k;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     sort(a.begin(), a.end());     int ans = 0;     for (int i = 0; i < n; i++) {       if (k < ((double)a[i]) / 2) ans += ost(k, a[i]);       k = max(k, a[i]);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string scan();   const int mod = 1000000007;   const int MAXN = 10010;   int sta[MAXN], stb[MAXN];   long long s, x;   long long memo[MAXN][2];   long long bt(int i, int rem) {     if (i > 52 && rem == 0) return 1;     if (i == 60) return 0;     long long &ret = memo[i][rem];     if (ret != -1) return ret;     ret = 0;     if (sta[i] == 1 && ((rem + 1) % 2) == stb[i])       return ret = 2 * bt(i + 1, (rem + 1) / 2);     if (sta[i] == 1) return rem = 0;     if ((rem + 2) % 2 == stb[i]) ret += bt(i + 1, (rem + 2) / 2);     if (rem % 2 == stb[i]) ret += bt(i + 1, 0);     return ret;   }   int main() {     memset(memo, -1, sizeof memo);     long long a, b;     cin >> a >> b;     s = a, x = b;     for (int i = 0; a; a /= 2, i++) stb[i] = a % 2;     for (int i = 0; b; b /= 2, i++) sta[i] = b % 2;     cout << bt(0, 0) - (s == x ? 2 : 0) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ;     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     int mi = *min_element(a, a + n);     int p = -1;     int f = 0;     int ans = INT_MAX;     for (int i = 0; i < n; i++) {       if (a[i] == mi and !f) {         f = 1;         p = i;       } else if (a[i] == mi and f) {         ans = min(ans, i - p);         p = i;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int a[20007];   int main() {     ios_base::sync_with_stdio(0);     int t = 1;     while (t--) {       int n;       cin >> n;       map<int, int> mp;       for (int i = 0; i < n; i++) {         int x, y;         cin >> x >> y;         mp[x] = y;         if (mp[x] == -1 * mp[x + y]) {           cout <<  YES ;           return 0;         }       }       cout <<  NO             <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v[100010];   long long dp[100010];   void dfs(long long i, long long first) {     dp[first]++;     for (auto x : v[i]) {       dfs(x, first + 1);     }   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n;     cin >> n;     for (long long i = 2; i <= n; i++) {       long long x;       cin >> x;       v[x].push_back(i);     }     long long ans = 0;     dfs(1, 1);     for (long long i = 1; i <= n; i++) {       ans += (dp[i] % 2);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int num;     string ss;   };   unordered_map<string, node> mm;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     while (cin >> n) {       mm.clear();       for (int i = 0; i < n; i++) {         string s;         cin >> s;         for (int j = 0; j < s.length(); j++) {           for (int k = 1; k <= (s.length() - j); k++) {             string sb = s.substr(j, k);             if (mm.find(sb) != mm.end() && mm[sb].ss != s) {               mm[sb].num++;               mm[sb].ss = s;             } else if (mm.find(sb) == mm.end()) {               node temp;               temp.num = 1;               temp.ss = s;               mm[sb] = temp;             }           }         }       }       int q;       cin >> q;       for (int i = 0; i < q; i++) {         string s;         cin >> s;         if (mm.find(s) != mm.end()) {           cout << mm[s].num <<     << mm[s].ss << endl;         } else {           cout << 0 <<   -  << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 100005;   long long p = 1e9 + 7;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n;     cin >> n;     long long sum = 0;     for (long long i = 1; i <= n; i++) {       long long a;       cin >> a;       sum += a;     }     for (long long i = 1; i <= n; i++) {       long long a;       cin >> a;       sum -= a;     }     if (sum < 0)       cout <<  No ;     else       cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long double pi = acos(-1);   const int MOD = 1e9 + 7;   int ocor[26];   int prefix[100010][26];   int blaublau[100010];   string s, t;   bool confere(int idx) {     int cu = blaublau[idx];     int aux[26];     for (int i = 0; i < 26; i++) aux[i] = prefix[idx][i];     idx -= t.size();     if (idx >= 0) {       cu -= blaublau[idx];       for (int i = 0; i < 26; i++) aux[i] -= prefix[idx][i];     }     for (int i = 0; i < 26; i++) {       if (aux[i] < ocor[i]) {         if (cu >= ocor[i] - aux[i]) {           cu -= (ocor[i] - aux[i]);         } else           return false;       }     }     return true;   }   int main() {     ios::sync_with_stdio(false);     ;     cin >> s >> t;     memset(prefix, 0, sizeof(prefix));     memset(blaublau, 0, sizeof(blaublau));     memset(ocor, 0, sizeof(ocor));     for (int i = 0; i < s.size(); i++) {       int aux = 0;       if (s[i] ==  ? )         blaublau[i]++;       else         prefix[i][s[i] -  a ] = 1;       if (i == 0) continue;       blaublau[i] += blaublau[i - 1];       for (int j = 0; j < 26; j++) {         prefix[i][j] += prefix[i - 1][j];       }     }     for (int i = 0; i < t.size(); i++) ocor[t[i] -  a ]++;     int r = 0;     for (int i = t.size() - 1; i < s.size(); i++) {       if (confere(i)) r++;     }     cout << r <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   vector<int> digits;   vector<vector<bool>> dp;   vector<int> bin_digits;   bool can;   void In() {     cin >> n >> k;     digits.resize(n);     string next;     for (int i = 0; i < n; i++) {       cin >> next;       digits[i] = stoi(next, 0, 2);     }   }   int GetDistance(int from, int result) {     int count = 0;     for (int bit = 0; bit <= 6; bit++) {       int num = 1 << bit;       int first = from & num;       int second = result & num;       if (first != second) {         if (first == 0)           count++;         else           return -1;       }     }     return count;   }   bool Solve() {     bin_digits.push_back(stoi( 1110111 , 0, 2));     bin_digits.push_back(stoi( 0010010 , 0, 2));     bin_digits.push_back(stoi( 1011101 , 0, 2));     bin_digits.push_back(stoi( 1011011 , 0, 2));     bin_digits.push_back(stoi( 0111010 , 0, 2));     bin_digits.push_back(stoi( 1101011 , 0, 2));     bin_digits.push_back(stoi( 1101111 , 0, 2));     bin_digits.push_back(stoi( 1010010 , 0, 2));     bin_digits.push_back(stoi( 1111111 , 0, 2));     bin_digits.push_back(stoi( 1111011 , 0, 2));     dp.resize(n + 1, vector<bool>(k + 1, false));     dp[n][0] = true;     for (int n_index = n - 1; n_index >= 0; n_index--)       for (int i = 0; i <= k; i++)         for (int j = 0; j <= 9; j++) {           int next_distance = GetDistance(digits[n_index], bin_digits[j]);           if (next_distance == -1) continue;           if (i - next_distance < 0) continue;           if (dp[n_index + 1][i - next_distance]) dp[n_index][i] = true;         }     if (!dp[0][k]) return false;     return true;   }   void Out() {     if (!can) {       cout << -1 << endl;       return;     }     for (int n_index = 0; n_index < n; n_index++) {       int distance;       int next_digit;       for (int j = 0; j <= 9; j++) {         int next_distance = GetDistance(digits[n_index], bin_digits[j]);         if (next_distance == -1) continue;         if (k - next_distance < 0) continue;         if (dp[n_index + 1][k - next_distance]) {           next_digit = j;           distance = next_distance;         }       }       k -= distance;       cout << next_digit;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     In();     can = Solve();     Out();   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5;   void solve() {     int n;     cin >> n;     vector<int> v(n);     map<int, int> mpp;     for (int i = 0; i < n; i++) {       cin >> v[i];       mpp[v[i]]++;     }     int ans1 = 0, ans2 = 0;     bool flag = false;     for (int i = 0; i <= 100; i++) {       if (mpp[i] >= 2) {         if (!flag) {           ans1++;         }         ans2++;       } else if (mpp[i] == 1) {         flag = true;         ans2++;       } else {         break;       }     }     cout << ans1 + ans2 <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     cin >> t;     while (t--) solve();     cerr <<  Time :   << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC          <<  ms n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     int a[1010];     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     sort(a, a + n);     if (a[0] == 1) {       printf( -1 n );     } else {       printf( 1 n );     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (1 << 30) + 7;   const int N = 1e5 + 7;   int main() {     ios::sync_with_stdio(false);     int q, l, r, d, ans;     cin >> q;     while (q--) {       cin >> l >> r >> d;       ans = (r / d + 1) * d;       if (d < l)         ans = d;       else         ans = (r / d + 1) * d;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void read(T& x) {     bool fu = 0;     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     if (c ==  - ) fu = 1, c = getchar();     for (x = 0; c > 32; c = getchar()) x = x * 10 + c -  0 ;     if (fu) x = -x;   };   template <class T>   inline void read(T& x, T& y) {     read(x);     read(y);   }   template <class T>   inline void read(T& x, T& y, T& z) {     read(x);     read(y);     read(z);   }   inline char getc() {     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     return c;   }   int n, p, i, j, k, l, g, x;   int a[50010];   int pos[40], c[40];   long long len[1111];   char f[33][32][50010], f2[33][32][50010];   int v[11111];   long long pow(long long a, long long b, long long c) {     long long ans = 1;     for (a %= c; b; b >>= 1, a = a * a % c)       if (b & 1) ans = ans * a % c;     return ans;   }   void xx(char& x, char y) { x = min(10, x + y); }   int main() {     read(n, p);     for (i = 1; i <= n; i++) {       read(x);       if (x < 32) {         g++;         pos[g] = i;         c[g] = x;         for (len[g] = 1; len[g] <= c[g]; len[g] *= 10)           ;       }     }     f[0][0][0] = 1;     for (i = 0; i <= g - 1; i++)       for (j = 0; j <= 31; j++)         for (k = 0; k <= p - 1; k++)           if (f[i][j][k] > 0) {             xx(f[i + 1][j ^ c[i + 1]][(1LL * k * len[i + 1] + c[i + 1]) % p],                f[i][j][k]);             f2[i + 1][j ^ c[i + 1]][(1LL * k * len[i + 1] + c[i + 1]) % p] = 1;             xx(f[i + 1][j][k], f[i][j][k]);           }     if (f[g][0][0] < 2) {       printf( No n );       return 0;     }     printf( Yes n );     i = g;     j = 0;     k = 0;     while (i) {       if (f2[i][j][k]) v[++v[0]] = pos[i];       if (f2[i][j][k]) {         bool h = 0;         for (int j2 = (0); j2 <= (31); j2++) {           for (int k2 = (0); k2 <= (p - 1); k2++)             if (f[i - 1][j2][k2])               if ((j2 ^ c[i]) == j)                 if ((1LL * k2 * len[i] + c[i]) % p == k) {                   j = j2;                   k = k2;                   h = 1;                   break;                 }           if (h) break;         }       }       i--;     }     printf( %d n , v[0]);     for (i = v[0]; i >= 1; i--) printf( %d  , v[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void read() {}   int main() {     read();     string s;     while (cin >> s) {       int l = s.size();       string ans;       bool f = 0;       for (int i = 0; i < l; i++) {         if (i != 0) {           if (s[i] ==  a  && i + 1 < l - 1 && s[i + 1] ==  t  && !f) {             ans.push_back( @ );             i += 1;             f = 1;             continue;           } else if (s[i] ==  d  && i + 2 < l - 1 && s[i + 1] ==  o  &&                      s[i + 2] ==  t ) {             ans.push_back( . );             i += 2;             continue;           }         }         ans.push_back(s[i]);       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     sort(arr, arr + n);     int c[1005] = {0};     int u[1005] = {0}, t = 0;     for (int i = 0; i < n; i++) {       if (c[arr[i]] == 0) {         u[t++] = arr[i];       }       c[arr[i]]++;     }     int fans = 0;     while (1) {       int ans = -1;       for (int i = 0; i < t; i++) {         if (c[u[i]] > 0) {           ans++;           c[u[i]]--;         }       }       if (ans <= 0) break;       fans += ans;     }     cout << fans;   }
#include <bits/stdc++.h>   using namespace std;   long long int a, b, c, d, n, ans = 0;   int main() {     cin >> a;     cin >> b;     cin >> c;     cin >> d;     if ((a + b > c && a + c > b && b + c > a) ||         (a + b > d && a + d > b && b + d > a) ||         (a + d > c && a + c > d && d + c > a) ||         (d + b > c && d + c > b && b + c > d)) {       cout <<  TRIANGLE ;     } else if ((a + b == c) || (a + b == d) || (a + c == b) || (a + c == d) ||                (a + d == c) || (a + d == b) || (b + c == a) || (b + c == d) ||                (b + d == a) || (b + d == c) || (c + d == a) || (c + d == b)) {       cout <<  SEGMENT ;     } else {       cout <<  IMPOSSIBLE ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int _inf = 0xc0c0c0c0;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const long long _INF = 0xc0c0c0c0c0c0c0c0;   const long long mod = (int)1e9 + 7;   const int N = 3e5 + 100;   vector<int> vc[N], e[N];   int col[N];   int vis[N];   int mx = 0;   void dfs(int o, int u) {     for (int v : vc[u]) {       vis[col[v]]++;     }     int b = 1;     for (int v : vc[u]) {       if (col[v]) continue;       while (vis[b]) ++b;       vis[b] = 1;       col[v] = b;     }     mx = max(mx, b);     for (int v : vc[u]) {       vis[col[v]] = 0;     }     for (int v : e[u]) {       if (v == o) continue;       dfs(u, v);     }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) {       int si, tv;       scanf( %d , &si);       for (int j = 1; j <= si; ++j) {         scanf( %d , &tv);         vc[i].push_back(tv);       }     }     int u, v;     for (int i = 1; i < n; ++i) {       scanf( %d%d , &u, &v);       e[u].push_back(v);       e[v].push_back(u);     }     dfs(0, 1);     printf( %d n , mx);     for (int i = 1; i <= m; ++i) {       if (!col[i]) col[i] = 1;       printf( %d%c , col[i],    n [i == m]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     for (int l = 0; l < n; l++) {       string b;       cin >> b;       string a;       a = b[0];       string c;       for (int i = 1; i <= b.length(); i += 2) {         c = b[i];         a += c;       }       cout << a <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int sz = 1500000;   const long long MAX = 10000000000000000;   template <typename T>   T abs(T a) {     return a < 0 ? -a : a;   }   int main() {     int n, m;     cin >> n >> m;     vector<vector<int> > graph(n);     for (long long i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       graph[u - 1].push_back(v - 1);       graph[v - 1].push_back(u - 1);     }     vector<int> val(n, 0);     set<int> q;     vector<int> flag(n, 0);     vector<int> a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];       if (!a[i]) {         q.insert(i);       }     }     vector<int> ans;     while (!q.empty()) {       int top = *q.begin();       q.erase(q.begin());       if (flag[top]) {         return 1;       }       val[top]++;       flag[top] = true;       ans.push_back(top);       for (vector<int>::iterator i = graph[top].begin(); i != graph[top].end();            i++) {         val[*i]++;         if (val[*i] == a[*i]) {           q.insert(*i);         }       }     }     cout << ans.size() << endl;     for (vector<int>::iterator i = ans.begin(); i != ans.end(); i++) {       cout << (*i) + 1 <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     char grid[n][n];     int hash_count = 0, cross = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> grid[i][j];         if (grid[i][j] ==  # ) hash_count++;       }     }     for (int i = 0; i < n - 2; i++) {       for (int j = 0; j < n - 2; j++) {         if (grid[i][j + 1] ==  #  && grid[i + 1][j] ==  #  &&             grid[i + 1][j + 1] ==  #  && grid[i + 1][j + 2] ==  #  &&             grid[i + 2][j + 1] ==  # ) {           cross += 5;           grid[i][j + 1] =  x ;           grid[i + 1][j] =  x ;           grid[i + 1][j + 1] =  x ;           grid[i + 1][j + 2] =  x ;           grid[i + 2][j + 1] =  x ;         }       }     }     if (hash_count == cross)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> m = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int y, m1, d1, y2, m2, d2, s[13];   bool is_leap(int x) {     if (x % 100 == 0) return !(x % 400);     return !(x % 4);   }   int main() {     scanf( %d:%d:%d , &y, &m1, &d1);     scanf( %d:%d:%d , &y2, &m2, &d2);     for (int i = 1; i <= 12; i++) s[i] = s[i - 1] + m[i - 1];     long long ans2 = 0ll + d2 + s[m2 - 1] + (m2 > 2) * is_leap(y2);     long long ans1 = 0ll + d1 + s[m1 - 1] + (m1 > 2) * is_leap(y);     for (int i = 1; i < y; i++) ans1 += (is_leap(i) ? 366 : 365);     for (int i = 1; i < y2; i++) ans2 += (is_leap(i) ? 366 : 365);     printf( %lld n , abs(ans1 - ans2));   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n, k;     cin >> n >> k;     vector<int> v(n);     long long sum = 0;     for (int i = 0; i < n; i++) {       cin >> v[i];       sum += v[i];     }     if (sum % k != 0)       cout <<  No n ;     else {       int num = sum / k;       for (int i = 1; i < n; i++) {         v[i] += v[i - 1];       }       int cnt = 0;       vector<int> res;       int q = 0;       for (int i = 0; i < n; i++) {         q++;         if (v[i] % num == 0) {           cnt++;           res.push_back(q);           q = 0;         }       }       if (cnt == k) {         cout <<  Yes n ;         for (int i = 0; i < k; i++) cout << res[i] <<    ;       } else         cout <<  No n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   long long a[200200];   int f(int x) { return ((x % n) + n) % n; }   int main() {     scanf( %d%d , &n, &m);     m--;     for (int i = (0); i < (n); i++) cin >> a[i];     int p = m;     for (int i = (1); i <= (n); i++)       if (a[p] >= a[f(m + i)]) p = f(m + i);     long long tmp = a[p] * n + f(m - p);     for (int i = (0); i < (n); i++)       if (i != p) a[i] -= a[p];     for (int i = (0); i < (n); i++) {       a[f(i + p)]--;       if (f(i + p) == m) break;     }     a[p] = tmp;     cout << a[0];     for (int i = (1); i < (n); i++) cout <<     << a[i];     puts(  );     return 0;   }