malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n;   long long x[1005], y[1005];   set<pair<pair<long long, long long>, pair<long long, long long> > > S;   map<pair<long long, long long>, long long> mp;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main(void) {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i >= j) continue;         int s = i, t = j;         pair<pair<long long, long long>, pair<long long, long long> > l;         if (x[s] == x[t]) {           l = make_pair(make_pair(1, 0), make_pair(x[s], 1));         } else {           if (x[s] > x[t]) swap(s, t);           long long dx = x[t] - x[s], dy = y[t] - y[s];           long long d = gcd(abs(dx), abs(dy));           dx /= d, dy /= d;           l.first = make_pair(dy, dx);           long long bunsi = (dx * y[s] - dy * x[s]), bunbo = dx;           d = gcd(abs(bunsi), abs(bunbo));           bunsi /= d, bunbo /= d;           l.second = make_pair(bunsi, bunbo);         }         S.insert(l);       }     }     long long lnum = S.size();     for (auto it = S.begin(); it != S.end(); it++) mp[it->first]++;     long long ans = 0;     for (auto it = mp.begin(); it != mp.end(); it++) {       ans += it->second * (it->second - 1) / 2;     }     cout << lnum * (lnum - 1) / 2 - ans << endl;     return 0;   }
#include <bits/stdc++.h>   const long double ACOSPI = (acosl(-1.0));   using namespace std;   int main() {     int n = 0;     int i = 0;     int x = 0;     long long ans = 0;     map<int, long long> m;     int a = 0;     cin >> n >> x;     for (i = 0; i < n; i++) {       cin >> a;       ans += m[a];       m[x ^ a]++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }   int toInt(char xx) { return xx -  0 ; }   char toChar(int xx) { return xx +  0 ; }   int isDigit(char xx) { return ( 0  <= xx && xx <=  9 ); }   bool isCharacter(char xx) {     return (( a  <= xx && xx <=  z ) || ( A  <= xx && xx <=  Z ));   }   void swapInt(int &x, int &y) {     x = x ^ y;     y = x ^ y;     x = x ^ y;   }   const int dx[4] = {-1, 1, 0, 0};   const int dy[4] = {0, 0, -1, 1};   const int Mod = 9901;   const int maxn = 1e5 + 10;   int exitInput = 0;   int n;   int a[maxn], b[maxn], p[maxn];   void read() {     cin >> n;     int i;     for (i = 1; i <= n; ++i) {       cin >> a[i];     }     for (i = 1; i <= n; ++i) {       cin >> b[i];     }     for (i = 1; i <= n; ++i) {       p[a[i]] = b[i];     }   }   void init() {}   void solve() {     cout << p[1];     int i;     for (i = 2; i <= n; ++i) {       cout <<     << p[i];     }     cout << endl;   }   int main() {     ios_base::sync_with_stdio(0);     int ntest = 1;     int itest = 1;     for (itest = 1; itest <= ntest; ++itest) {       read();       if (exitInput) {         break;       }       init();       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Dev {     int p;     int e;     long double t;   } d[100000];   int n, p;   bool fun(long double midTime) {     long double energy = 0, t;     for (int i = 0; i < n; i++) {       t = midTime - d[i].t;       if (t > 0) energy += t * d[i].p;     }     return midTime * p >= energy;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> p;     long long sumPow = 0;     for (int i = 0; i < n; i++) {       cin >> d[i].p >> d[i].e;       d[i].t = (double)d[i].e / d[i].p;       sumPow += d[i].p;     }     if (sumPow <= p) {       cout << -1 << endl;       return 0;     }     long double minTime = 0;     long double maxTime = 1e18;     long double midTime;     for (int i = 0; i < 80; i++) {       midTime = (minTime + maxTime) / 2;       if (fun(midTime))         minTime = midTime;       else         maxTime = midTime;     }     if (midTime > 1e18 - 100)       cout << -1 << endl;     else       cout << midTime << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> build_z(const vector<int>& a) {     int n = (int)(a).size();     vector<int> z(n);     int l = 0, r = 0;     for (int i = 1; i < n; i++) {       z[i] = max(0, min(z[i - l], r - i));       while (i + z[i] < n && a[z[i]] == a[z[i] + i]) z[i]++;       if (i + z[i] > r) l = i, r = i + z[i];     }     return z;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     int n, m;     cin >> n >> m;     vector<int> a(n), b(m);     for (int i = 0; i < (int)(n); i++) cin >> a[i];     for (int i = 0; i < (int)(m); i++) cin >> b[i];     auto get_diff = [&](vector<int> a) {       vector<int> ret;       for (int i = 1; i < (int)(a).size(); i++) ret.push_back(a[i] - a[i - 1]);       return ret;     };     auto da = get_diff(a), db = get_diff(b);     vector<int> com = db;     com.push_back(1e9 + 7);     for (int i : da) com.push_back(i);     auto z = build_z(com);     int cnt = 0;     for (int i = m - 1; i < (int)(z).size(); i++) cnt += (z[i] == m - 1);     cout << cnt <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int i, a[n];     for (i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     i = 1;     while (a[i] == a[0]) {       i++;     }     if (i < n)       cout << a[i];     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int INF = 1e9 + 10;   int n, D[2020][2020];   int add(int& x, int y) { return x = (x + y) % MOD; }   int main() {     scanf( %d , &n);     int ans = 0;     D[0][0] = 1;     for (int i = 1; i <= 2 * n; i++) {       for (int j = 0; j <= i; j++) {         if (j > 0) add(D[i][j], D[i - 1][j - 1]);         add(D[i][j], D[i - 1][j + 1]);         if (i % 2 && 2 * n - i >= j) add(ans, D[i][j]);       }     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int f[300000];   int a[40];   int add(int a, int b) { return (a + b >= m) ? a + b - m : a + b; }   void inc(int& a, int b) { a = (a + b >= m) ? a + b - m : a + b; }   int main(void) {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) scanf( %d , &a[i]), a[i] %= m;     for (int i = 0, len = n / 2; i < (1 << len); i++) {       int t = 0;       for (int j = 0; j < len; j++)         if (i & (1 << j)) inc(t, a[j]);       f[i] = t;     }     sort(f, f + (1 << n / 2));     int cnt = unique(f, f + (1 << n / 2)) - f;     int ans = f[cnt - 1];     for (int i = 0, len = n - n / 2; i < (1 << len); i++) {       int t = 0;       for (int j = 0; j < len; j++)         if (i & (1 << j)) inc(t, a[j + n / 2]);       ans = max(ans, t);       int pos = lower_bound(f, f + cnt, m - 1 - t) - f;       for (int j = max(0, pos - 1); j <= pos + 1; j++) {         ans = max(ans, add(t, f[j]));       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int q;     cin >> q;     for (int d = 0; d < q; d++) {       string s, t;       cin >> s >> t;       int n = s.size();       int m = t.size();       n = n % 2;       m = m % 2;       int y = abs(n - m);       int j = 0;       for (int i = y; i < s.size(); i++) {         if (s[i] == t[j]) {           j++;         } else {           i++;         }         if (j == t.size()) {           break;         }       }       if (j == t.size()) {         cout <<  YES  <<   n ;         ;       } else {         cout <<  NO  <<   n ;         ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 110;   int a[N], b[N];   int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i <= n; i++) scanf( %d , &a[i]);     for (int i = 0; i <= m; i++) scanf( %d , &b[i]);     if (n > m) {       if (a[0] * b[0] > 0)         puts( Infinity );       else         puts( -Infinity );     } else if (n < m) {       printf( 0/1 n );     } else {       if (a[0] > 0 && b[0] > 0 || a[0] < 0 && b[0] < 0) {         a[0] = abs(a[0]);         b[0] = abs(b[0]);         int t = gcd(a[0], b[0]);         a[0] /= t;         b[0] /= t;         printf( %d/%d n , a[0], b[0]);       } else {         a[0] = abs(a[0]);         b[0] = abs(b[0]);         int t = gcd(a[0], b[0]);         a[0] /= t;         b[0] /= t;         printf( -%d/%d n , a[0], b[0]);       }     }     return 0;   }
#include <bits/stdc++.h>   template <class T>   void read(T &a) {     a = 0;     char x = getchar();     bool f = 0;     for (; x <  0  || x >  9 ; x = getchar()) f |= x ==  - ;     for (; x >=  0  && x <=  9 ; x = getchar()) a = (a << 3) + (a << 1) + x -  0 ;     if (f) a = -a;   }   template <class T, class... Args>   void read(T &a, Args &...args) {     read(a);     read(args...);   }   using namespace std;   const int N = 2e5 + 5;   int n;   int f[N], lim;   pair<int, int> d[N];   bool cmp(pair<int, int> a, pair<int, int> b) {     if (a.first ^ b.first) {       return a.first < b.first;     }     return a.second > b.second;   }   int main() {     read(n);     for (int i = 1; i <= n; ++i) {       read(d[i].first);       d[i].second = i;     }     sort(d + 1, d + n + 1, cmp);     int lim = 0;     for (int i = 1; i <= n; ++i) {       int c = d[i].second - d[i].first;       if (c < 0) continue;       if (lim == 0) {         f[++lim] = c;         continue;       }       if (c >= f[lim]) {         f[++lim] = c;         continue;       }       int l = 1, r = lim + 1;       while (l < r - 1) {         int mid = l + r >> 1;         if (f[mid] <= c) {           l = mid;         } else {           r = mid;         }       }       if (f[l] > c) {         f[l] = c;       } else if (l != lim) {         f[l + 1] = c;       }     }     printf( %d n , lim);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mo = 998244353;   long long bin_fun(long long chto, long long vkak) {     if (vkak == 0) return 1;     if (vkak == 1) return chto;     if (vkak % 2 == 0)       return bin_fun(chto * chto % mo, vkak / 2);     else       return (bin_fun(chto * chto % mo, vkak / 2) * chto) % mo;   }   int main() {     long long a, s, d, i, j, k;     cin >> a;     vector<long long> v1;     for (i = 0; i < a * 2; i++) {       cin >> s;       v1.push_back(s);     }     sort(v1.begin(), v1.end());     long long sum = 0;     for (i = 0; i < a; i++) sum = (sum + abs(v1[a * 2 - i - 1] - v1[i])) % mo;     long long ch1 = 1, ch2 = 1;     for (i = a + 1; i <= a * 2; i++) {       ch1 = (ch1 * i) % mo;     }     for (i = 1; i <= a; i++) {       long long t = bin_fun(i, mo - 2);       ch2 = (ch2 * t) % mo;     }     long long otv = (ch1 * ch2) % mo;     cout << (otv * sum) % mo;   }
#include <bits/stdc++.h>   using namespace std;   int x, y, z, X, Y, Z, A, B, C, D, E, F;   int main() {     cin >> X >> Y >> Z >> x >> y >> z >> A >> B >> C >> D >> E >> F;     cout << A * (Y < 0) + B * (Y > y) + C * (Z < 0) + D * (Z > z) + E * (X < 0) +                 F * (X > x)          <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   inline char gc() { return getchar(); }   template <class T>   int read(T &ans) {     ans = 0;     char ch = gc();     T f = 1;     while (!isdigit(ch)) {       if (ch == EOF) return -1;       if (ch ==  - ) f = -1;       ch = gc();     }     while (isdigit(ch)) ans = ans * 10 + ch -  0 , ch = gc();     ans *= f;     return 1;   }   template <class T1, class T2>   int read(T1 &a, T2 &b) {     return read(a) != EOF && read(b) != EOF ? 2 : EOF;   }   template <class T1, class T2, class T3>   int read(T1 &a, T2 &b, T3 &c) {     return read(a, b) != EOF && read(c) != EOF ? 3 : EOF;   }   const int Maxn = 1100000;   const int inf = 0x3f3f3f3f;   int n, m, D, to[Maxn], nxt[Maxn], first[Maxn], tot = 1;   int vis[Maxn], d[Maxn], u, v, cnt;   queue<int> q;   vector<int> vi[Maxn];   inline void add(int u, int v) {     to[tot] = v;     nxt[tot] = first[u];     first[u] = tot++;     to[tot] = u;     nxt[tot] = first[v];     first[v] = tot++;   }   void dfs(int root) {     vis[root] = cnt;     for (int i = first[root]; i; i = nxt[i])       if (!vis[to[i]]) dfs(to[i]);   }   signed main() {     read(n, m, D);     for (int i = 1; i <= m; i++) {       read(u, v);       add(u, v);       d[u]++;       d[v]++;     }     if (d[1] >= D && D) {       vis[1] = ++cnt;       for (int i = first[1]; i; i = nxt[i])         if (vis[to[i]])           vi[vis[to[i]]].push_back(to[i]);         else           cnt++, dfs(to[i]), vi[cnt].push_back(to[i]);       if (cnt - 1 > D)         puts( NO );       else {         memset(vis, 0, sizeof(vis));         vis[1] = 1;         puts( YES );         for (int i = 2; i <= cnt; i++)           printf( 1 %d n , vi[i][0]), vis[vi[i][0]] = 1, q.push(vi[i][0]);         D -= cnt - 1;         for (int i = 2; i <= cnt; i++) {           for (int j = 1; j < vi[i].size(); j++) {             if (!D) break;             D--;             printf( 1 %d n , vi[i][j]);             vis[vi[i][j]] = 1;             q.push(vi[i][j]);           }         }         while (!q.empty()) {           int now = q.front();           q.pop();           for (int i = first[now]; i; i = nxt[i])             if (!vis[to[i]]) {               vis[to[i]] = 1;               printf( %d %d n , now, to[i]);               q.push(to[i]);             }         }       }     } else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct note {     int a, b, x;   } a[100005 * 2];   long long ansa, ansb;   int n;   int tot;   bool cmp(note i, note j) { return i.x > j.x; }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       long long a1, b, c, d;       scanf( %I64d%I64d%I64d%I64d , &a1, &b, &c, &d);       if (a1 <= d && b <= c) continue;       if (a1 + b > c + d) {         a[++tot].a = a1;         a[tot].b = b;         a[tot].x = a1 + b;         a[++tot].a = c;         a[tot].b = d;         a[tot].x = c + d;       } else {         if (a1 > d) {           ansa += a1;           ansb += d;         } else {           ansa += c;           ansb += b;         }       }     }     sort(a + 1, a + tot + 1, cmp);     for (int i = 1; i <= tot; i++) {       if (i % 2 == 1)         ansa += a[i].a;       else         ansb += a[i].b;     }     printf( %I64d , ansa - ansb);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n % 2 == 0) {       cout <<  NO ;     } else {       cout <<  YES n ;       int i = 1;       int a[2 * n];       for (int j = 0; j < n; j++) {         a[j] = i;         if (j % 2 == 0) {           a[j + n] = i + 1;           i += 3;         } else {           a[j + n] = i - 1;           i++;         }       }       for (int j = 0; j < 2 * n; j++) {         cout << a[j] <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j, ans = 0;     cin >> n;     pair<int, int> p[n];     int ab, be, le, ri;     for (i = 0; i < n; i++) {       int r, s;       cin >> r >> s;       p[i] = make_pair(r, s);     }     for (i = 0; i < n; i++) {       ab = 0, be = 0, le = 0, ri = 0;       for (j = 0; j < n; j++) {         if (i == j) {           continue;         }         if (p[i].first == p[j].first) {           if (p[i].second < p[j].second) {             ab++;           } else {             be++;           }         }         if (p[i].second == p[j].second) {           if (p[i].first < p[j].first) {             ri++;           } else {             le++;           }         }         if (ab > 0 && be > 0 && le > 0 && ri > 0) {           ans++;           break;         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>       using namespace std;       #define endl   n    #define ll long long   #define fr(i,s,e) for(ll i=s;i<=e;i++)   #define rfr(i,s,e) for(ll i=s;i>=e;i--)   #define f(x,m) for(auto x : m)   #define ff first   #define ss second   #define pb push_back   #define pp pop_back   #define pf push_front   #define ppf pop_front   #define m_p make_pair   #define mod 1000000007   #define TIME cerr<< Time Taken: <<(float)clock()/CLOCKS_PER_SEC*1000<< ms <<endl       const ll INF = (1LL << 60) - 1;       int main()   {       #ifndef ONLINE_JUDGE    freopen( ../input-output/input.txt ,  r , stdin);    freopen( ../input-output/output.txt ,  w , stdout);   #endif    ios_base::sync_with_stdio(false);       cin.tie(NULL);        int t;    cin>>t;    while(t--){     ll r,b,d;     cin>>r>>b>>d;     int noPackets=min(r,b);     r=max(r,b)-min(r,b);     // cout<<r<<   ;     if(noPackets==0){      cout<< NO n ;      continue;     }     ll maxdiff=r/noPackets;     if(r%noPackets) maxdiff++;     // cout<<maxdiff<<endl;     if(maxdiff<=d) cout<< YES n ;     else cout<< NO n ;    }        TIME;    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, i, j, r[55];   long long m, f[55];   void solve(int n, int p, long long m) {     if (n == 0) return;     for (int i = 1; i <= n && i <= 2; i++) {       if (m <= f[n - i]) {         solve(n - i, p + i, m);         for (int j = p + i; j <= N; j++) r[j] += i;         for (int j = p + i - 1, k = 1; j >= p; j--, k++) r[j] = k;         break;       } else         m -= f[n - i];     }   }   int main() {     cin >> N >> m;     for (f[0] = i = 1; i <= N; i++)       for (j = 1; j <= i && j <= 2; j++) f[i] = min(m + 1, f[i] + f[i - j]);     solve(N, 1, m);     for (i = 1; i <= N; i++) printf( %d%c , r[i], i == N ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll MOD = 1e9 + 7, N = 1e5 + 10;   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ll a[3];     cin >> a[0] >> a[1] >> a[2];     cout <<  First  << endl;     vector<ll> b(3);     iota(b.begin(), b.end(), 0);     sort(b.begin(), b.end(), [&](ll u, ll v) { return a[u] < a[v]; });     sort(a, a + 3);     cout << 2 * a[2] - a[1] - a[0] << endl;     ll x;     cin >> x;     --x;     if (x == -1) return 0;     if (x == b[0]) {       cout << a[2] - a[1] << endl;       cin >> x;       return 0;     } else if (x == b[1]) {       cout << a[2] - a[0] << endl;       cin >> x;       return 0;     }     cout << 6 * a[2] - 3 * a[1] - 3 * a[0] << endl;     cin >> x;     --x;     if (x == -1) return 0;     if (x == b[0]) {       cout << 3 * a[2] - a[0] - a[1] - a[1] << endl;       cin >> x;       return 0;     }     cout << 3 * a[2] - a[0] - a[1] - a[0] << endl;     cin >> x;     return 0;   }
#include <bits/stdc++.h>   const long long RXD = 1e9 + 7;   const long long N = 1e5 + 1000;   using namespace std;   long long C[N][110], a[N], s[N][110], n, m, l, r, K;   long long read() {     long long x = 0, f = 1, c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) x = x * 10 + c -  0 , c = getchar();     return x * f;   }   int main() {     C[0][0] = 1;     for (long long i = 1; i <= 100100; i++)       for (long long j = 0; j <= i && j <= 105; j++)         C[i][j] = (j == 0) ? 1 : (C[i - 1][j] + C[i - 1][j - 1]) % RXD;     n = read();     m = read();     for (long long i = 1; i <= n; i++) a[i] = read();     for (long long i = 1; i <= m; i++) {       l = read();       r = read();       K = read();       for (long long i = 0; i <= K; i++) s[l][i] = (s[l][i] + C[K][K - i]) % RXD;       for (long long i = 0; i <= K; i++)         s[r + 1][i] = (s[r + 1][i] - C[K + r + 1 - l][K - i] + RXD) % RXD;     }     for (long long i = 1; i <= n; i++)       for (long long j = 101; j; j--)         s[i + 1][j - 1] = ((s[i + 1][j - 1] + s[i][j]) % RXD + s[i][j - 1]) % RXD;     for (long long i = 1; i <= n; i++)       printf( %d  , ((a[i] + s[i][0]) % RXD + RXD) % RXD);   }
#include <bits/stdc++.h>   using namespace std;   void readi(int &x) {     int v = 0, f = 1;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - )       f = -1;     else       v = v * 10 + c -  0 ;     while (isdigit(c = getchar())) v = v * 10 + c -  0 ;     x = v * f;   }   void readll(long long &x) {     long long v = 0ll, f = 1ll;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - )       f = -1;     else       v = v * 10 + c -  0 ;     while (isdigit(c = getchar())) v = v * 10 + c -  0 ;     x = v * f;   }   void readc(char &x) {     char c;     while ((c = getchar()) ==    )       ;     x = c;   }   void writes(string s) { puts(s.c_str()); }   void writeln() { writes(  ); }   void writei(int x) {     if (!x) putchar( 0 );     char a[25];     int top = 0;     while (x) {       a[++top] = (x % 10) +  0 ;       x /= 10;     }     while (top) {       putchar(a[top]);       top--;     }   }   void writell(long long x) {     if (!x) putchar( 0 );     char a[25];     int top = 0;     while (x) {       a[++top] = (x % 10) +  0 ;       x /= 10;     }     while (top) {       putchar(a[top]);       top--;     }   }   int fa[100005], n, m, i, j, x;   set<int> s;   int find(int x) {     if (fa[x] == x) return x;     return fa[x] = find(fa[x]);   }   int main() {     cin >> n;     for (i = 1; i <= n; i++) fa[i] = i;     for (i = 1; i <= n; i++) {       cin >> x;       fa[find(x)] = find(i);     }     for (i = 1; i <= n; i++) s.insert(find(i));     cout << s.size();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int toInt(string s) {     int v;     istringstream sin(s);     sin >> v;     return v;   }   template <class T>   string toString(T x) {     ostringstream sout;     sout << x;     return sout.str();   }   vector<string> form(string a, char s) {     a += s;     vector<string> v;     string b;     for (int i = (0); i < (int)(a.size()); ++i) {       if (a[i] == s) {         v.push_back(b);         b =   ;       } else         b += a[i];     }     return v;   }   vector<int> formint(string a, char s) {     vector<int> v;     vector<string> w = form(a, s);     for (int i = (0); i < (int)(w.size()); ++i) v.push_back(toInt(w[i]));     return v;   }   const int mod = 1000000007;   int aa[2048];   int bb[2048];   int pows(int a, int b) {     if (b == 0) return 1;     int k = pows(a, b / 2);     k = ((long long)k * k) % mod;     if (b % 2 == 1) k = ((long long)k * a) % mod;     return k;   }   int divs(int a, int b) { return (((long long)a) * pows(b, mod - 2)) % mod; }   int combi(int a, int b) {     int res = 1;     if (a / 2 < b) b = a - b;     for (int i = a, j = 0; j < b; i--, j++) res = (((long long)res) * i) % mod;     for (int i = 2; i <= b; i++) res = divs(res, i);     return res;   }   int main(void) {     int n, k;     cin >> n >> k;     for (int i = (0); i < (int)(n); ++i) cin >> aa[i];     if (k == 0) {       for (int i = (0); i < (int)(n); ++i) {         if (i > 0) cout <<    ;         cout << aa[i];       }       cout << endl;       return 0;     }     for (int i = (0); i < (int)(n); ++i) bb[i] = combi(k + i - 1, i);     for (int i = (0); i < (int)(n); ++i) {       if (i != 0) cout <<    ;       int res = 0;       for (int j = (0); j < (int)(i + 1); ++j) {         res = (res + ((long long)aa[j] * bb[i - j]) % mod) % mod;       }       cout << res;     }     cout << endl;     return 0;   }