malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, x, y, u, v, to[600005], nxt[600005], p[300005], sz[300005];   void dfs(int x, int lst) {     sz[x] = 1;     for (int i = p[x]; i != -1; i = nxt[i])       if (to[i] != lst) {         dfs(to[i], x);         sz[x] += sz[to[i]];       }   }   int main() {     scanf( %d%d%d , &n, &x, &y);     memset(p, -1, sizeof p);     for (int i = 1; i < n; i++) {       scanf( %d%d , &u, &v);       to[i * 2 - 1] = v, nxt[i * 2 - 1] = p[u], p[u] = i * 2 - 1;       to[i * 2] = u, nxt[i * 2] = p[v], p[v] = i * 2;     }     dfs(x, -1);     long long ans = sz[y];     dfs(y, -1);     ans *= sz[x];     cout << 1LL * n * (n - 1) - ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   const int maxn = 100;   const int MAXN = 2750131;   long long T, n, m, i, j;   long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }   long long g[200005];   int main() {     ios::sync_with_stdio(false);     long long a[20];     long long k = 1, s = 1, sum = 9;     for (i = 0; s < 1e12; i++) {       a[i] = s * sum * k;       s *= 10;       k++;     }     cin >> n;     if (n < 10) {       cout << n << endl;       return 0;     }     sum = 0;     i = 0;     k = 1;     s = 1;     long long m = n;     while (m > a[i]) {       m -= a[i];       i++;       k++;       s = pow(10, i);       sum = s - 1;     }     long long ans = (m) / k + sum;     if (m % k) {       ans++;     }     long long sk = m % k;     if (sk == 0) {       sk = k;     }     while (ans > 0) {       if (sk == k) {         cout << ans % 10 << endl;         break;       } else {         ans /= 10;         k--;       }     }     return 0;   }
#include <bits/stdc++.h>   int x1, x2, x3, y11, y2, y3, length;   int main() {     scanf( %d %d %d %d %d %d , &x1, &y11, &x2, &y2, &x3, &y3);     length = (int)(sqrt(x1 * y11 + x2 * y2 + x3 * y3) + 0.01);     if (x1 * y11 + x2 * y2 + x3 * y3 != length * length) {       printf( -1 n );       return 0;     }     if (x1 < y11) {       int temp = x1;       x1 = y11;       y11 = temp;     }     if (x2 < y2) {       int temp = x2;       x2 = y2;       y2 = temp;     }     if (x3 < y3) {       int temp = x3;       x3 = y3;       y3 = temp;     }     if (x1 == length && x2 == length && x3 == length) {       printf( %d n , length);       for (int i = 0; i < y11; i++) {         for (int j = 0; j < x1; j++) printf( A );         printf(  n );       }       for (int i = 0; i < y2; i++) {         for (int j = 0; j < x2; j++) printf( B );         printf(  n );       }       for (int i = 0; i < y3; i++) {         for (int j = 0; j < x3; j++) printf( C );         printf(  n );       }     } else if (x1 == length) {       printf( %d n , length);       if (x2 != length - y11) {         int temp = x2;         x2 = y2;         y2 = temp;       }       if (x3 != length - y11) {         int temp = x3;         x3 = y3;         y3 = temp;       }       for (int i = 0; i < y11; i++) {         for (int j = 0; j < x1; j++) printf( A );         printf(  n );       }       for (int i = 0; i < length - y11; i++) {         for (int j = 0; j < y2; j++) printf( B );         for (int j = 0; j < y3; j++) printf( C );         printf(  n );       }     } else if (x2 == length) {       printf( %d n , length);       if (x1 != length - y2) {         int temp = x1;         x1 = y11;         y11 = temp;       }       if (x3 != length - y2) {         int temp = x3;         x3 = y3;         y3 = temp;       }       for (int i = 0; i < y2; i++) {         for (int j = 0; j < x2; j++) printf( B );         printf(  n );       }       for (int i = 0; i < length - y2; i++) {         for (int j = 0; j < y11; j++) printf( A );         for (int j = 0; j < y3; j++) printf( C );         printf(  n );       }     } else if (x3 == length) {       printf( %d n , length);       if (x1 != length - y3) {         int temp = x1;         x1 = y11;         y11 = temp;       }       if (x2 != length - y3) {         int temp = x2;         x2 = y2;         y2 = temp;       }       for (int i = 0; i < y3; i++) {         for (int j = 0; j < x3; j++) printf( C );         printf(  n );       }       for (int i = 0; i < length - y3; i++) {         for (int j = 0; j < y11; j++) printf( A );         for (int j = 0; j < y2; j++) printf( B );         printf(  n );       }     } else {       printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e3;   bool possible, check[N << 2], mark[N << 2];   vector<int> topol, from[N << 2], to[N << 2];   int n, m, c, d[N], com[N << 2], row[N], col[N], a[N][N], b[N][N];   void dfs_scc(int u, int c) {     com[u] = c;     mark[u] = true;     for (auto v : to[u])       if (!mark[v]) dfs_scc(v, c);   }   void strongly_connected_components() {     memset(mark, false, sizeof mark);     for (int i = 0; i < n << 2; i++)       if (check[i] && !mark[i]) dfs_scc(i, ++c);   }   void dfs_topolo(int u) {     mark[u] = true;     for (auto v : from[u])       if (!mark[v]) dfs_topolo(v);     topol.push_back(u);   }   void topological_sort() {     for (int i = 0; i < n << 2; i++)       if (check[i] && !mark[i]) dfs_topolo(i);     reverse(topol.begin(), topol.end());   }   void input(int w) {     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (int j = 0; j < n; j++) (w ? a[i][j] : b[i][j]) = s[j] -  0 ;     }   }   void add_edge(int u, int v) {     check[u] = check[v] = true;     from[u].push_back(v);     from[v].push_back(u);     to[u].push_back(v);     to[v].push_back(u);   }   void add_clause(int u, int v) {     add_edge(u ^ 1, v);     add_edge(u, v ^ 1);   }   void F2(int u, int v) {     int k = a[u][v] + b[u][v];     if (k == 1) (d[v] & 1 ? row[u] : col[v]) = 1;   }   void F1(int u, int v, int k) {     k += a[u][v] + b[u][v];     if (k == 3) {       add_clause(u << 1, (v + n) << 1);       return;     }     if (k == 1) {       cout << -1;       exit(0);     }     if (k == 4 || (!a[u][v] && k == 2)) {       add_clause(u << 1 ^ 1, (v + n) << 1);       return;     }   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     input(1), input(0);     string s;     cin >> s;     for (int i = 0; i < n; i++) d[i] = s[i] -  0 ;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) d[i] == d[j] ? F1(i, j, d[i] + d[j]) : F2(i, j);     topological_sort();     strongly_connected_components();     for (int i = 0; i < n << 1; i++)       if (check[i << 1] && com[i << 1] == com[i << 1 ^ 1]) {         cout << -1;         return 0;       } else if (check[i << 1] && com[i << 1] < com[i << 1 ^ 1])         i >= n ? col[i - n] = 1 : row[i] = true;     int cnt = 0;     for (int i = 0; i < n; i++) cnt += row[i] + col[i];     cout << cnt << endl;     for (int i = 0; i < n; i++)       if (row[i]) cout <<  row   << i << endl;     for (int i = 0; i < n; i++)       if (col[i]) cout <<  col   << i << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     int index1 = 0;     int index2 = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] == 1)         index1 = i + 1;       else if (a[i] == n)         index2 = i + 1;     }     int ans = max(max(max(index2 - 1, n - index2), index1 - 1), n - index1);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Node {     int idx, sum;     int left, right;   } tree[3000000];   int cnt;   long long sumVal;   char ch[10];   void addNode(int cur, int def, int h, int val) {     if (tree[cur].idx == def) {       tree[cur].sum += val;       return;     }     tree[cur].sum += val;     if ((1 << (h)) & def) {       if (tree[cur].right == 0) {         tree[cur].right = ++cnt;         tree[cnt].idx = tree[cur].idx * 2 + 1;         tree[cnt].sum = 0;         tree[cnt].left = tree[cnt].right = 0;       }       addNode(tree[cur].right, def, h - 1, val);     } else {       if (tree[cur].left == 0) {         tree[cur].left = ++cnt;         tree[cnt].idx = tree[cur].idx * 2;         tree[cnt].sum = 0;         tree[cnt].left = tree[cnt].right = 0;       }       addNode(tree[cur].left, def, h - 1, val);     }   }   void decayNode(int cur, int h, int maxVal) {     if (h == 0) {       sumVal += max(maxVal, tree[cur].sum);       return;     }     int u = tree[cur].left, v = tree[cur].right;     if (tree[u].sum > tree[v].sum) {       long long t = max(maxVal, tree[cur].sum - tree[v].sum);       sumVal += (long long)(1 << (h - 1)) * t;       maxVal = max(maxVal, tree[cur].sum - tree[u].sum);       decayNode(u, h - 1, maxVal);     } else {       long long t = max(maxVal, tree[cur].sum - tree[u].sum);       sumVal += (long long)(1 << (h - 1)) * t;       maxVal = max(maxVal, tree[cur].sum - tree[v].sum);       decayNode(v, h - 1, maxVal);     }   }   int main(int argc, char** argv) {     int n, m, k, e;     scanf( %d%d , &n, &m);     cnt = 1;     tree[1].idx = 1;     tree[1].sum = 0;     tree[0].sum = 0;     tree[1].left = tree[1].right = 0;     for (int i = 1; i <= m; i++) {       scanf( %s , ch);       if (ch[0] ==  d ) {         sumVal = 0;         decayNode(1, n, 0);         double ans = (double)sumVal / (double)(1 << (n));         printf( %.8lf n , ans);       } else {         scanf( %d%d , &k, &e);         int h = 0, p = k / 2;         while (p) {           p /= 2;           h += 1;         }         addNode(1, k, h - 1, e);       }     }     return (EXIT_SUCCESS);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   char a[65];   void pre() {     int j = 1;     for (j = 1; j <= 10; j++) a[j - 1] = (char)(j - 1 + 48);     for (int i = 0; i < 26; i++) a[j++] = (char)(i + 97);     for (int i = 0; i < 26; i++) a[j++] = (char)(i + 65);     a[10] =  Z ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     pre();     int T;     cin >> T;     while (T--) {       vector<int> val(65, 0);       int r, c, k;       cin >> r >> c >> k;       string s[r], ans[r];       int R = 0;       for (int i = 0; i < r; i++) {         cin >> s[i];         for (int j = 0; j < s[i].size(); j++) {           if (s[i][j] ==  R ) R++;           ans[i] +=  . ;         }       }       int x = R / k;       R = R % k;       for (int i = 0; i < k; i++) {         val[i] = x;         if (R) {           R--;           val[i]++;         }       }       int gg = 0;       for (int i = 0; i < r; i++) {         if (i % 2 == 0) {           for (int j = 0; j < c; j++) {             ans[i][j] = a[gg];             if (s[i][j] ==  R ) {               val[gg]--;               if (!val[gg]) {                 gg++;               }             }             if (gg >= k - 1) gg = k - 1;           }         } else {           for (int j = c - 1; j >= 0; j--) {             ans[i][j] = a[gg];             if (s[i][j] ==  R ) {               val[gg]--;               if (!val[gg]) {                 gg++;               }             }             if (gg >= k - 1) gg = k - 1;           }         }       }       for (int i = 0; i < r; i++) cout << ans[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 4;   const int M = 1e9 + 7;   vector<pair<int, int> > g[N];   const int inf = 1e9 + 10;   vector<int> dist(N, inf);   void dijkstra(int source) {     dist[source] = 0;     set<pair<int, int> > s;     s.insert({0, source});     while (!s.empty()) {       auto x = *(s.begin());       s.erase(x);       for (auto it : g[x.second])         if (dist[it.first] > max(dist[x.second], it.second)) {           s.erase({dist[it.first], it.first});           dist[it.first] = max(dist[x.second], it.second);           s.insert({dist[it.first], it.first});         }     }   }   void solve() {     int n, m, k;     cin >> n >> m >> k;     int x[k];     for (int i = 0; i < k; i++) cin >> x[i];     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       if (u != v) {         g[u].push_back({v, w});         g[v].push_back({u, w});       }     }     dijkstra(x[0]);     int ans = 0;     for (int i = 0; i < k; i++) ans = max(ans, dist[x[i]]);     for (int i = 0; i < k; i++) cout << ans <<    ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int to_reach(long long int number, long long int moves,                          long long int target) {     if (target == 0) {       return (number / moves);     } else {       long long int res = (target - number) / moves;       return res;     }   }   int main() {     long long int n, m, xc, yc, dxi, dyi, step;     cin >> n >> m;     cin >> xc >> yc;     long long int k, count = 0;     cin >> k;     for (int i = 0; i < k; i++) {       cin >> dxi >> dyi;       long long int toReachX, toReachY;       if (dxi == 0)         toReachX = 10000000000;       else if (dxi > 0)         toReachX = to_reach(xc, dxi, n);       else         toReachX = to_reach(1 - xc, dxi, 0);       if (dyi == 0)         toReachY = 10000000000;       else if (dyi > 0)         toReachY = to_reach(yc, dyi, m);       else         toReachY = to_reach(1 - yc, dyi, 0);       long long int tomove = min(toReachX, toReachY);       xc = xc + dxi * tomove, yc = yc + dyi * tomove;       count += tomove;     }     cout << count << endl;     return 0;   }
#include<iostream>   using namespace std;   int main()   {       int t;       cin>>t;       while(t--){           int a,b;           cin>>a>>b;           if(a==0&&b==0)               cout<< 0 n ;           else if(a==0&&b!=0)               cout<<2*b-1<<endl;           else if(a!=0&&b==0)               cout<<2*a-1<<endl;           else{               if(a>b){                   int x=(2*b)+(2*(a-b)-1);                   cout<<x<<endl;               }               else if(a<b){                   int x=(2*a)+(2*(b-a)-1);                   cout<<x<<endl;               }               else if(a==b)                   cout<<2*a<<endl;               }           }       }
#include <bits/stdc++.h>   using namespace std;   bool comp(const vector<int> &l, const vector<int> &r) {     if (l[0] % 2 && r[0] % 2) {       return l[1] < r[1];     }     if ((l[0] % 2) && (r[0] % 2 == 0)) return true;     if ((l[0] % 2 == 0) && (r[0] % 2))       return false;     else       return true;   }   int main() {     int tmp, ans, test, c, i, j, n, k, t, odd, ans1 = 0, ans2 = 0;     vector<int> ar[102], v;     scanf( %d , &test);     for (int i = 1; i <= test; i++) {       scanf( %d , &n);       ar[i].push_back(n);       if (n % 2 == 0) {         ans = 0;         for (k = 1; k <= n / 2; k++) {           scanf( %d , &t);           ans += t;         }         ar[i].push_back(ans);         ans = 0;         for (k = 1; k <= n / 2; k++) {           scanf( %d , &t);           ans += t;         }         ar[i].push_back(ans);         ar[i].push_back(-1);       } else {         ans = 0;         for (k = 1; k <= n / 2; k++) {           scanf( %d , &t);           ans += t;         }         ar[i].push_back(ans);         scanf( %d , &odd);         ans = 0;         for (k = 1; k <= n / 2; k++) {           scanf( %d , &t);           ans += t;         }         ar[i].push_back(ans);         ar[i].push_back(odd);         v.push_back(odd);       }     }     for (i = 1; i <= test; i++) {       if (1 || ar[i][0] % 2 == 0) {         ans1 += ar[i][1];         ans2 += ar[i][2];       }     }     sort(v.begin(), v.end());     reverse(v.begin(), v.end());     bool ok = true;     for (i = 0; i < v.size(); i++) {       if (ok)         ans1 += v[i];       else         ans2 += v[i];       ok = !ok;     }     cout << ans1 <<     << ans2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = (long long)1e9 + 7;   const int N = 105;   const int M = 5005;   long long dp[N][M];   int x[N];   int y[N];   long long c[M][N];   int sum[N];   int rSum[N];   int h[N];   int main() {     int n, i, j, k, l;     long long ans = 0;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &x[i]);     }     for (i = 1; i <= n; i++) {       scanf( %d , &y[i]);     }     for (i = 0; i < M; i++) {       c[i][0] = 1;       if (i <= 100) {         c[i][i] = 1;       }       for (j = 1; j < min(i, N); j++) {         c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;       }     }     for (i = 1; i <= n; i++) {       sum[i] = sum[i - 1] + x[i];     }     for (i = n; i >= 1; i--) {       rSum[i] = rSum[i + 1] + y[i] - x[i];     }     for (i = 1; i <= n; i++) {       h[i] = x[i] + min(sum[i - 1], rSum[i]);     }     for (j = x[n]; j <= y[n]; j++) {       dp[n][j] = 1;     }     for (i = n - 1; i >= 1; i--) {       for (j = x[i]; j <= h[i]; j++) {         for (k = 0; k <= min(y[i], j); k++) {           dp[i][j] = (dp[i][j] + c[j][k] * dp[i + 1][x[i + 1] + j - k]) % MOD;         }       }     }     ans = dp[1][x[1]];     int num = sum[n];     for (i = 1; i <= n; i++) {       ans = (ans * c[num][x[i]]) % MOD;       num -= x[i];     }     printf( %d n , (int)ans);   }
#include <bits/stdc++.h>   using namespace std;   long long dp[1005][1005], sum[1005][1005], c[2 * 1005][2 * 1005];   long long res[55][1005], p[55];   int main() {     dp[0][0] = 1;     for (int i = 0; i < 1005; i++) sum[0][i] = 1;     for (int i = 1; i <= 51; i++) {       for (int j = 1005 - 1; j >= 1; j--) {         for (int k = 1005 - 1; k >= 1; k--) {           if ((j >= k && i == 1) || j > k)             dp[j][k] = sum[j - k][k - 1];           else             dp[j][k] = 0;           sum[j][k] = dp[j][k];         }         for (int k = 1; k < 1005; k++)           sum[j][k] = (sum[j][k] + sum[j][k - 1]) % 1000000007;         res[i][j] = sum[j][1005 - 1];       }       sum[0][0] = dp[0][0] = 0;     }     c[0][0] = c[1][1] = 1;     for (int i = 2; i < 2 * 1005; i++)       for (int j = 1; j <= i; j++)         c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % 1000000007;     p[0] = 1;     for (int i = 1; i < 55; i++) p[i] = (p[i - 1] * i) % 1000000007;     for (int i = 0; i <= 51; i++)       for (int j = 1; j < 1005; j++)         res[i][j] =             (res[i][j - 1] + (res[i][j] * p[i]) % 1000000007) % 1000000007;     int t;     scanf( %d , &t);     while (t--) {       int n, k;       scanf( %d %d , &n, &k);       if (k > 51)         printf( 0 n );       else {         long long ans = 0;         for (int i = k; i <= n; i++)           ans = (ans + (res[k][i] * c[n - i + k][k]) % 1000000007) % 1000000007;         printf( %I64d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int *s;   int fenzhi(int left, int right, int d) {     int mins = 0x3f3f3f3f;     ;     for (int i = left; i <= right; i++) mins = min(mins, s[i] - d);     int ans = 0;     for (int i = left; i <= right; i++)       if (s[i] > mins + d) {         int j = i;         while (s[j + 1] > mins + d && j + 1 <= right) j++;         ans += fenzhi(i, j, mins + d);         i = j + 1;       }     return min(right - left + 1, mins + ans);   }   int main() {     int n;     cin >> n;     s = new int[n];     for (int i = 0; i < n; i++) cin >> s[i];     cout << fenzhi(0, n - 1, 0) << endl;     delete[] s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a;     cin >> a;     for (int i = 0; i < a.length(); i++) {       if (isupper(a[i])) a[i] = tolower(a[i]);     }     string s =    ;     for (int i = 0; i < a.length(); i++) {       if (a[i] ==  a  || a[i] ==  o  || a[i] ==  u  || a[i] ==  e  ||           a[i] ==  i  || a[i] ==  y )         continue;       s +=  . ;       s += a[i];     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[112], dp[312][312], mnix[312];   int **func(int **mat1, int **mat2, int mx) {     int **ans;     ans = new int *[mx + 2];     for (int i = 1; i <= mx; i++) {       ans[i] = new int[mx + 2];       for (int j = 1; j <= mx; j++) {         ans[i][j] = 0;         for (int k = i; k <= j; k++)           ans[i][j] = max(ans[i][j], mat1[i][k] + mat2[k][j]);       }     }     return ans;   }   int main() {     int n, k, mx = 0;     cin >> n >> k;     for (int i = 0; i < 312; i++) {       mnix[i] = 500;       for (int j = 0; j < 312; j++) {         dp[i][j] = 0;       }     }     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       mx = max(mx, a[i]);       mnix[a[i]] = min(mnix[a[i]], i);     }     int **mat;     mat = new int *[312];     for (int i = 0; i < 312; i++) {       mat[i] = new int[312];       for (int j = 0; j < 312; j++) mat[i][j] = 0;     }     for (int st = 1; st <= mx; st++) {       if (mnix[st] > 200) continue;       for (int j = 1; j <= mx; j++) {         if (j >= st)           dp[mnix[st]][j] = 1;         else           dp[mnix[st]][j] = 0;       }       for (int i = mnix[st] + 1; i < n; i++) {         for (int j = 1; j <= mx; j++) {           if (a[i] < st)             dp[i][j] = dp[i - 1][j];           else if (j < a[i])             dp[i][j] = dp[i - 1][j];           else if (j == a[i])             dp[i][j] = dp[i - 1][j] + 1;           else             dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);         }       }       for (int j = 1; j <= mx; j++) {         if (j < st) mat[st][j] = 0;         mat[st][j] = dp[n - 1][j];       }       for (int i = 0; i <= mx; i++) {         for (int j = 0; j <= mx; j++) {           dp[i][j] = 0;         }       }     }     int **ans;     ans = new int *[mx + 2];     for (int i = 0; i <= mx; i++) {       ans[i] = new int[mx + 2];       for (int j = 0; j <= mx; j++) ans[i][j] = 0;     }     while (k) {       if (k % 2 == 1) ans = func(ans, mat, mx);       mat = func(mat, mat, mx);       k = k / 2;     }     int fans = 0;     for (int j = 1; j <= mx; j++) fans = max(fans, ans[j][mx]);     cout << fans << endl;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     vector<long long> v(n + 1);     long long s = 0;     for (long long i = 1; i <= n; i++) {       cin >> v[i];       s += v[i] - i, v[i] = i;     }     for (long long i = 1; i <= n; i++) v[i] += s / n;     for (long long i = 1; i <= s % n; i++) v[i]++;     for (long long i = 1; i <= n; i++) cout << v[i] <<    n [i == n];   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     long long t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> q;   long long i, j, n, k, m = 1000000007, ww = 1, a[20005], b[20005], c[20005],                         w[20005];   bool flag;   bool otv(int n, bool sign) {     long long t = n;     for (long long j = 0; j < q.size(); j++) {       if (t % q[j] == 0) {         t /= q[j];         if (sign)           w[j]++;         else           w[j]--;         j--;       }       if (t == 1) break;     }     if (t > 1) ww = (ww * t) % m;     return 0;   }   long long ans() {     long long i, j, first = 1;     for (i = 0; i < q.size(); i++)       for (j = 0; j < w[i]; j++) first = (first * q[i]) % m;     first = (ww * first) % m;     return first;   }   int main() {     cin >> n >> k;     for (i = 1; i <= n; i++) cin >> a[i];     if (k == 0) {       for (i = 1; i <= n; i++) cout << a[i] <<    ;       return 0;     }     for (i = 2; i <= 30000; i++) {       flag = 0;       for (j = 0; j < q.size(); j++)         if (i % q[j] == 0) {           flag = 1;           break;         }       if (!flag) q.push_back(i);     }     b[1] = 1;     k--;     for (i = 2; i <= n; i++) {       otv(i + k - 1, 1);       otv(i - 1, 0);       b[i] = ans();     }     for (i = 1; i <= n; i++)       for (j = 0; j < i; j++) c[i] = ((a[i - j] * b[j + 1]) % m + c[i]) % m;     for (i = 1; i <= n; i++) cout << c[i] <<    ;     return 0;   }