malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   const long long p1 = 737;   const long long p2 = 3079;   const long long m1 = 1000000123;   const long long m2 = 1000000321;   vector<long long> p_pow1(N), p_pow2(N);   pair<vector<long long>, vector<long long> > H[3];   void init() {     p_pow1[0] = 1;     p_pow2[0] = 1;     for (int i = 1; i < N; i++) {       p_pow1[i] = (p_pow1[i - 1] * p1) % m1;       p_pow2[i] = (p_pow2[i - 1] * p2) % m2;     }   }   pair<vector<long long>, vector<long long> > Hash(string const& s) {     int n = s.size();     vector<long long> h1(n + 1), h2(n + 1);     for (int i = 0; i < n; i++) {       h1[i + 1] = ((h1[i] * p1) % m1 + (s[i] -  a  + 1)) % m1;       h2[i + 1] = ((h2[i] * p2) % m2 + (s[i] -  a  + 1)) % m2;     }     return {h1, h2};   }   pair<long long, long long> get_Hash(int idx, int l, int r) {     long long x =         (H[idx].first[r] - (H[idx].first[l - 1] * p_pow1[r - l + 1]) % m1 + m1) %         m1;     long long y = (H[idx].second[r] -                    (H[idx].second[l - 1] * p_pow2[r - l + 1]) % m2 + m2) %                   m2;     return {x, y};   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     ;     init();     string s, t1, t2;     char ch[2005];     scanf( %s , ch);     s = ch;     scanf( %s , ch);     t1 = ch;     scanf( %s , ch);     t2 = ch;     int n = s.size();     int a = t1.size();     int b = t2.size();     H[0] = Hash(s);     H[1] = Hash(t1);     H[2] = Hash(t2);     vector<pair<long long, long long> > v;     for (int i = 1; i <= (n - a + 1); i++) {       for (int j = i; j <= (n - b + 1); j++) {         int len1 = i + a - 1;         int len2 = j + b - 1;         if (get_Hash(0, i, len1) == get_Hash(1, 1, a) &&             get_Hash(0, j, len2) == get_Hash(2, 1, b)) {           if (len1 <= len2) v.push_back(get_Hash(0, i, len2));         }       }     }     sort(v.begin(), v.end());     int res = 0;     if (v.size()) res = 1;     for (int i = 1; i < v.size(); i++) {       if (v[i - 1] != v[i]) res++;     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, l, c, d, p, nl, np;     {       cin >> n >> k >> l >> c >> d >> p >> nl >> np;       int D = k * l;       D /= nl;       cout << min(D, min((c * d), (p / np))) / n << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {-1, 0, 1, 0};   int dy[] = {0, 1, 0, -1};   int dx2[] = {1, -1, -1, 1, 0, 0, -1, 1};   int dy2[] = {1, -1, 1, -1, 1, -1, 0, 0};   int kmx[] = {-1, -1, 1, 1, 2, -2, 2, -2};   int kmy[] = {2, -2, 2, -2, -1, -1, 1, 1};   int bishopX[] = {-1, 1, -1, 1};   int bishopY[] = {-1, -1, 1, 1};   class Timer {    public:     clock_t T;     Timer() { T = clock(); }     ~Timer() {       fprintf(stderr,   n%.3f n , double(clock() - T) / CLOCKS_PER_SEC);     }   };   int read() {     int x;     scanf( %d , &x);     return x;   }   long long readL() {     long long x;     scanf( %lld , &x);     return x;   }   const int N = 1e5 + 5;   int visX[N][4], visY[N][4];   vector<int> v1[4 * N], v2[4 * N];   int n, m, k;   long long ans[N];   pair<int, int> a[N];   int main() {     n = read();     m = read();     k = read();     for (int i = 0; i < k; i++) {       int x = read();       int y = read();       ans[i] = -1;       v1[x - y + N].push_back(i);       v2[x + y].push_back(i);       a[i] = make_pair(x, y);     }     int x = 0;     int y = 0;     int d = 0;     long long gt = 0;     int mn;     while (1) {       switch (d) {         case 0:           mn = min(n - x, m - y);           x = x + mn;           y = y + mn;           gt += mn;           break;         case 1:           mn = min(x, y);           x = x - mn;           y = y - mn;           gt += mn;           break;         case 2:           mn = min(x, m - y);           x = x - mn;           y = y + mn;           gt += mn;           break;         case 3:           mn = min(n - x, y);           x = x + mn;           y = y - mn;           gt += mn;           break;       }       int dif = x - y + N;       int sum = x + y;       if (d == 0 || d == 1)         for (int i = 0; i < v1[dif].size(); i++) {           int j = v1[dif][i];           if (ans[j] == -1) {             int dddd = abs(x - a[j].first);             ans[j] = gt - dddd;           }         }       else         for (int i = 0; i < v2[sum].size(); i++) {           int j = v2[sum][i];           if (ans[j] == -1) {             int dddd = abs(x - a[j].first);             ans[j] = gt - dddd;           }         }       if (x == 0 && y == 0 || x == 0 && y == m || x == n && y == 0 ||           x == n && y == m) {         break;       }       if (x == n) {         if (d == 0)           d = 2;         else if (d == 3)           d = 1;         continue;       }       if (y == m) {         if (d == 2)           d = 1;         else if (d == 0)           d = 3;         continue;       }       if (x == 0) {         if (d == 2)           d = 0;         else if (d == 1)           d = 3;         continue;       }       if (y == 0) {         if (d == 1)           d = 2;         else if (d == 3)           d = 0;         continue;       }     }     for (int i = 0; i < k; i++) {       printf( %lld n , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     int n, i, j, k, c, v, l = 1, r = 1, maxm = 0, minm;     cin >> n;     int A[n];     string s;     cin >> s;     for (i = 0; i < n; i++) A[i] = 0;     for (i = 0; i < n; i++) {       for (j = i; j < n; j++) {         swap(s[i], s[j]);         v = 0;         c = 0;         for (k = 0; k < n; k++) {           if (s[k] ==  ( )             v++;           else             v--;           A[k] = v;         }         if (v == 0) {           minm = 0;           for (k = 0; k < n; k++) {             if (A[k] < minm) {               minm = A[k];               c = 1;             } else if (A[k] == minm)               c++;           }           if (c > maxm) {             maxm = c;             l = i + 1;             r = j + 1;           }         }         swap(s[i], s[j]);       }     }     cout << maxm << endl;     cout << l <<     << r << endl;   }
#include <bits/stdc++.h>   using namespace std;   int div1(int a, int b) {     if (a % b == 0)       return a / b;     else       return a / b + 1;   }   int main() {     int k, n, s, p;     while (scanf( %d%d%d%d , &k, &n, &s, &p) != EOF) {       int ever_need = div1(n, s);       int ans = div1(ever_need * k, p);       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   const int oo = 1e9;   int g[N][N], n, m;   int col[N];   vector<pair<int, int> > ans;   pair<int, int> get(int val) {     for (int i = 1; i <= m; ++i) {       if (g[1][i] < val) return {oo, val};     }     memset(col, 0, sizeof(col));     ans.clear();     int ret = val;     for (int i = 1; i <= m; ++i) col[i] = g[1][i] - val;     ans.push_back({1, val});     for (int i = 2; i <= n; ++i) {       int mn = oo, mx = -oo;       for (int j = 1; j <= m; ++j) {         if (g[i][j] < col[j]) return {oo, val};         mn = min(mn, g[i][j] - col[j]);         mx = max(mx, g[i][j] - col[j]);       }       if (mn != mx) return {oo, val};       ans.push_back({i, mn});       ret += mn;     }     for (int i = 1; i <= m; ++i) {       ans.push_back({-i, col[i]});       ret += col[i];     }     return {ret, val};   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         scanf( %d , &g[i][j]);       }     }     pair<int, int> ret = {oo, -1};     for (int i = 0; i <= 500; ++i) ret = min(ret, get(i));     if (ret.first == oo) {       printf( -1 n );       return 0;     }     get(ret.second);     printf( %d n , ret.first);     for (auto u : ans) {       if (u.first < 0) {         for (int i = 1; i <= u.second; ++i) printf( col %d n , -u.first);       } else {         for (int i = 1; i <= u.second; ++i) printf( row %d n , u.first);       }     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long    #define pb push_back   #define inf 1e18   #define nn    n    #define vll vector<long long int>   #define vl vector<long int>   #define ff first   #define ss second                     int main()   {       #ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);       freopen( output.txt ,  w , stdout);       #endif          int t;       cin>>t;          while(t--)       {        ll int hero_attack,hero_health,n;        cin>>hero_attack>>hero_health>>n;           vector<pair<ll int,ll int>> v;        ll int attack[n];        for(int i=0;i<n;i++)        {         cin>>attack[i];              }           ll int health[n];                for(int i=0;i<n;i++)        {         cin>>health[i];              }           for(int i=0;i<n;i++)        {         v.pb({attack[i],health[i]});        }           sort(v.begin(),v.end());               int flag=1;           for(auto &it:v)           {                ll int x,y;            if(hero_health<=0)            {             flag=0;             cout<< NO <<nn;             break;            }               if(it.second%hero_attack!=0)            {            x=(it.second/hero_attack)+1;            }            if(it.second%hero_attack==0)            {            x=it.second/hero_attack;            }            if(hero_health%it.first!=0)            {            y=(hero_health/it.first)+1;            }            if(hero_health%it.first==0)            {            y=hero_health/it.first;            }                  if(x<=y)            {             hero_health=hero_health-x*it.first;               }            else            {             cout<< NO <<nn;             flag=0;             break;               }                    }              if(flag==1)            cout<< YES <<nn;                              }          return 0;      }
#include <bits/stdc++.h>   using namespace std;   static const int INF = 0x3f3f3f3f;   static const long long INFL = 0x3f3f3f3f3f3f3f3f;   static const double EPS = 1e-10;   static const double PI = acos(-1.0);   inline int read() {     int X = 0;     bool flag = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) flag = 0;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       X = (X << 1) + (X << 3) + ch -  0 ;       ch = getchar();     }     if (flag) return X;     return ~(X - 1);   }   inline void write(int X) {     if (X < 0) {       X = ~(X - 1);       putchar( - );     }     if (X > 9) write(X / 10);     putchar(X % 10 +  0 );   }   static const int MAXN = 500 + 10;   vector<int> g[MAXN];   int d[1 << 19], pre[1 << 19];   int n, m, u, v;   int main() {     scanf( %d%d , &n, &m);     while (m--) {       scanf( %d%d , &u, &v);       u--, v--;       g[u].push_back(v);       g[v].push_back(u);     }     memset(d, -1, sizeof(d));     d[n - 1] = 0;     queue<int> Q;     Q.push(n - 1);     while (!Q.empty()) {       int t = Q.front();       Q.pop();       bool flag = false;       if (t & (1 << 18)) {         flag = true;         t ^= (1 << 18);       }       int u = t >> 9, v = t & 511;       if (flag) t ^= (1 << 18);       if (flag) {         for (int i = 0; i < g[v].size(); i++)           if (g[v][i] != u && d[(u << 9) | g[v][i]] == -1) {             d[(u << 9) | g[v][i]] = d[t] + 1;             pre[(u << 9) | g[v][i]] = t;             Q.push((u << 9) | g[v][i]);           }       } else {         for (int i = 0; i < g[u].size(); i++)           if (d[(1 << 18) | (g[u][i] << 9) | v] == -1) {             d[(1 << 18) | (g[u][i] << 9) | v] = d[t];             pre[(1 << 18) | (g[u][i] << 9) | v] = t;             Q.push((1 << 18) | (g[u][i] << 9) | v);           }       }     }     int pos = (n - 1) << 9;     if (d[pos] == -1)       puts( -1 );     else {       printf( %d n , d[pos]);       vector<int> ans1, ans2;       ans1.push_back(n - 1);       ans2.push_back(0);       while (pos != n - 1) {         pos = pre[pre[pos]];         ans1.push_back(pos >> 9);         ans2.push_back(pos & 511);       }       reverse(ans1.begin(), ans1.end());       reverse(ans2.begin(), ans2.end());       for (auto it : ans1) printf( %d  , it + 1);       puts(  );       for (auto it : ans2) printf( %d  , it + 1);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   pair<int, int> joker[2] = {{-1, -1}, {-1, -1}};   pair<int, int> s1 = {-1, -1}, s2 = {-1, -1};   string ranks =  23456789TJQKA , suits =  CDHS , a[64][64];   set<string> deck;   vector<string> left_cards;   void gen_deck() {     for (char r : ranks)       for (char s : suits) {         string res =   ;         res = res + r;         res = res + s;         deck.insert(res);       }   }   bool can(int ii, int jj) {     set<char> cur_ranks;     set<char> cur_suits;     for (int i = 0; i < 3; i++)       for (int j = 0; j < 3; j++) {         cur_ranks.insert(a[ii + i][jj + j][0]);         cur_suits.insert(a[ii + i][jj + j][1]);       }     return ((((int)(cur_ranks).size()) == 9) || (((int)(cur_suits).size()) == 1));   }   bool check() {     for (int lr = 0; lr < n - 2; lr++)       for (int lc = 0; lc < m - 2; lc++)         for (int rr = 0; rr < n - 2; rr++)           for (int rc = 0; rc < m - 2; rc++) {             if (rr < lr + 3 && rc < lc + 3) continue;             if (can(lr, lc) && can(rr, rc)) {               s1 = {lr, lc};               s2 = {rr, rc};               return 1;             }           }     return 0;   }   int main() {     ios::sync_with_stdio(false);     gen_deck();     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         cin >> a[i][j];         if (a[i][j][0] ==  J ) joker[a[i][j][1] -  1 ] = {i, j};         deck.erase(a[i][j]);       }     for (auto it : deck) left_cards.push_back(it);     for (int i = 0; i < ((int)(left_cards).size()); i++)       for (int j = 0; j < ((int)(left_cards).size()); j++) {         if (i == j) continue;         if (joker[0].first != -1)           a[joker[0].first][joker[0].second] = left_cards[i];         if (joker[1].first != -1)           a[joker[1].first][joker[1].second] = left_cards[j];         if (check()) {           cout <<  Solution exists.  << endl;           if (joker[0].first < 0 && joker[1].first < 0) {             cout <<  There are no jokers.  << endl;           } else if (!((joker[0].first < 0) || (joker[1].first < 0))) {             cout <<  Replace J1 with   << left_cards[i] <<   and J2 with                    << left_cards[j] <<  .  << endl;           } else {             if (joker[0].first < 0) {               cout <<  Replace J2 with   << left_cards[j] <<  .  << endl;             } else {               cout <<  Replace J1 with   << left_cards[i] <<  .  << endl;             }           }           cout <<  Put the first square to (  << s1.first + 1 <<  ,                  << s1.second + 1 <<  ).  << endl;           cout <<  Put the second square to (  << s2.first + 1 <<  ,                  << s2.second + 1 <<  ).  << endl;           return 0;         }       }     cout <<  No solution.  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 25;   string str[maxn];   int a[maxn][maxn];   long long dp[1 << 20];   int mask[26], tot[26], big[26], cnt[26], candi[26];   int Min[maxn];   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> str[i];     }     memset(Min, 0x3f, sizeof(Min));     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> a[i][j];         Min[i] = min(Min[i], a[i][j]);       }     }     for (int i = 0; i < (1 << n); i++) {       int tmp = 0;       for (int j = 0; j < n; j++) {         if (i >> j & 1) tmp += Min[j + 1];       }       dp[i] = tmp;     }     for (int i = 1; i <= m; i++) {       memset(mask, 0, sizeof(mask));       memset(tot, 0, sizeof(tot));       memset(big, 0, sizeof(big));       memset(cnt, 0, sizeof(cnt));       for (int j = 1; j <= n; j++) {         int c = str[j][i - 1] -  a ;         cnt[c]++;         mask[c] |= (1 << (j - 1));         tot[c] += a[j][i];         big[c] = max(big[c], a[j][i]);       }       int idx = 0;       for (int j = 0; j < 26; j++) {         if (cnt[j]) candi[idx++] = j;       }       for (int j = 0; j < (1 << n); j++) {         for (int k = 0; k < idx; k++) {           int u = candi[k];           dp[j | mask[u]] = min(dp[j | mask[u]], dp[j] + (tot[u] - big[u]));         }       }     }     cout << dp[(1 << n) - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000006;   int t, n, m, x, y;   stack<int> s;   int rg[N], rs[N], ls[N], lg[N], a[N];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     a[0] = a[n + 1] = 0;     for (int i = 1; i <= n + 1; i++) {       while (!s.empty() && a[s.top()] > a[i]) {         t = s.top();         s.pop();         rs[t] = i - 1;       }       s.push(i);     }     s.pop();     for (int i = n; i >= 0; i--) {       while (!s.empty() && a[s.top()] >= a[i]) {         t = s.top();         s.pop();         ls[t] = i + 1;       }       s.push(i);     }     s.pop();     a[0] = a[n + 1] = INT_MAX;     for (int i = 1; i <= n + 1; i++) {       while (!s.empty() && a[s.top()] < a[i]) {         t = s.top();         s.pop();         rg[t] = i - 1;       }       s.push(i);     }     s.pop();     for (int i = n; i >= 0; i--) {       while (!s.empty() && a[s.top()] <= a[i]) {         t = s.top();         s.pop();         lg[t] = i + 1;       }       s.push(i);     }     s.pop();     long long ans = 0;     for (int i = 1; i <= n; i++) {       ans += 1LL * ((rg[i] - lg[i]) + 1LL * (rg[i] - i) * (i - lg[i])) * a[i];       ans -= 1LL * ((rs[i] - ls[i]) + 1LL * (rs[i] - i) * (i - ls[i])) * a[i];     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3FFFFFFF;   char arr[1001][1001];   int main() {     int n, m, x, y, z, p;     scanf( %d%d%d%d%d%d , &n, &m, &x, &y, &z, &p);     x %= 4;     y %= 2;     z %= 4;     vector<int> a(p), b(p);     for (int i = 0; i < p; i++) {       scanf( %d%d , &a[i], &b[i]);     }     if (x == 1) {       for (int i = 0; i < p; i++) {         int at = b[i];         int bt = n - a[i] + 1;         a[i] = at;         b[i] = bt;       }       swap(n, m);     } else if (x == 2) {       for (int i = 0; i < p; i++) {         int at = n - a[i] + 1;         int bt = m - b[i] + 1;         a[i] = at;         b[i] = bt;       }     } else if (x == 3) {       for (int i = 0; i < p; i++) {         int at = m - b[i] + 1;         int bt = a[i];         a[i] = at;         b[i] = bt;       }       swap(n, m);     }     if (y == 1) {       for (int i = 0; i < p; i++) {         int at = a[i];         int bt = m - b[i] + 1;         a[i] = at;         b[i] = bt;       }     }     if (z == 3) {       for (int i = 0; i < p; i++) {         int at = b[i];         int bt = n - a[i] + 1;         a[i] = at;         b[i] = bt;       }       swap(n, m);     } else if (z == 2) {       for (int i = 0; i < p; i++) {         int at = n - a[i] + 1;         int bt = m - b[i] + 1;         a[i] = at;         b[i] = bt;       }     } else if (z == 1) {       for (int i = 0; i < p; i++) {         int at = m - b[i] + 1;         int bt = a[i];         a[i] = at;         b[i] = bt;       }       swap(n, m);     }     for (int i = 0; i < p; i++) {       printf( %d %d n , a[i], b[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     if (a < b) return gcd(b, a);     while (a > b) {       a %= b;     }     return gcd(b, a);   }   long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }   const double EPS = 10e-9;   const double PI = acos(-1.0);   const double INF = (1LL << 29);   using namespace std;   template <typename T>   string toString(T t) {     stringstream ss;     ss << t;     return ss.str();   }   const long long prime = 1000000007;   long long power(long long n, long long a, long long prime) {     long long res = 1LL;     while (a > 0) {       if (a & 1LL) {         res *= n;         res %= prime;       }       n *= n;       n %= prime;       a >>= 1;     }     return res;   }   int main() {     string x;     cin >> x;     long long total = 0;     for (int i = 0; i < (x.size()); ++i) {       if (x[i] ==  1 ) {         int len = i, left = x.size() - len - 1;         long long part = power(2, len, prime) * power(4, left, prime);         total += part % prime;         total %= prime;       }     }     cout << total << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, cnt[21][21], pos[21][400001], dp[1 << 20];   vector<long long> v[21];   signed main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     cin >> n;     for (long long i = 1; i <= n; i++) {       long long a;       cin >> a;       a--;       v[a].push_back(i);       pos[a][i]++;     }     for (long long i = 0; i < 20; i++) {       for (long long j = 1; j <= n; j++) {         pos[i][j] += pos[i][j - 1];       }     }     for (long long i = 0; i < 20; i++) {       for (long long j = 0; j < 20; j++) {         if (i == j) continue;         for (auto x : v[i]) {           cnt[i][j] += pos[j][x];         }       }     }     dp[0] = 0;     for (long long i = 1; i < (1 << 20); i++) {       dp[i] = 1000000000000000000;       for (long long j = 0; j < 20; j++) {         if (i >> j & 1) {           long long ans1 = 0;           for (long long k = 0; k < 20; k++) {             if (k == j) continue;             if (i >> k & 1) ans1 += cnt[j][k];           }           dp[i] = min(dp[i], dp[i ^ (1 << j)] + ans1);         }       }     }     cout << dp[(1 << 20) - 1];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, ans = 0;     cin >> n;     vector<int> v;     int dat[101] = {};     for (int i = 0; i < n; ++i) {       cin >> a;       if (a == 1) break;       v.push_back(a);     }     if (a != 1) {       sort(v.begin(), v.end());       for (int i = 0; i < v.size(); ++i) {         if (dat[v[i]] == 0) {           for (int j = v[i]; j < 101; j += v[i]) {             dat[j] = 1;           }           ++ans;         }       }     } else       ans = 1;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long p = 998244353;   long long po(long long a, long long b) {     if (b == 0) return 1;     if (b == 1) return a;     if (b % 2 == 0) {       long long u = po(a, b / 2);       return (u * u) % p;     } else {       long long u = po(a, b - 1);       return (a * u) % p;     }   }   long long inv(long long x) { return po(x, p - 2); }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long a[n];     for (long long i = 0; i < n; ++i) cin >> a[i];     sort(a, a + n);     reverse(a, a + n);     long long pr[n + 1];     pr[0] = 0;     for (long long i = 0; i < n; ++i) pr[i + 1] = pr[i] + a[i];     for (long long k = 1; k <= n; ++k) {       long long ans = 0;       for (long long l = k; l <= n; l += k) {         ans += (pr[l] - pr[((l - 1) / k) * k]) * ((l - 1) / k);         ans %= p;         if (l > (n - k) && l < n) l = (n - k);       }       ans *= inv(n);       ans %= p;       ans += p;       ans %= p;       cout << ans <<    ;     }     return 0;   }