malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T abs(T x) {     return x > 0 ? x : -x;   }   template <typename T>   T sqr(T x) {     return x * x;   }   template <typename T>   ostream &operator<<(ostream &s, const vector<T> &x) {     s <<  [ ;     for (auto it : x) {       s <<  it          <<  ,  ;     }     s <<  ] ;     return s;   }   template <typename T>   ostream &operator<<(ostream &s, const set<T> &x) {     s <<  { ;     for (auto it : x) {       s <<  it          <<  ,  ;     }     s <<  } ;     return s;   }   vector<pair<long long, long long> > a[5];   int main() {     int n, k, b, c;     cin >> n >> k >> b >> c;     if (b > c * 5) b = c * 5;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       for (int i = 0; i < 5; i++)         a[((x + i) % 5 + 5) % 5].push_back(make_pair(x + i, i * c));     }     long long ans = 1e18;     for (int i = 0; i < 5; i++) {       sort(a[i].begin(), a[i].end());       auto v = a[i];       bool flag = false;       long long firstpos = -1;       multiset<long long> setic;       long long allsum = 0;       for (auto f : v) {         long long pos = f.first, w = f.second;         if (!flag) {           flag = true;           firstpos = pos;         }         w -= (pos - firstpos) / 5 * b;         allsum += w;         setic.insert(w);         if ((int)setic.size() > k) {           auto it = setic.end();           it--;           allsum -= *it;           setic.erase(it);         }         if ((int)setic.size() == k) {           ans = min(ans, allsum + (long long)k * (pos - firstpos) / 5 * b);         }       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxLog = 10;   const int maxN = 1 << maxLog;   const int INF = 0x3c3c3c3c;   int f[333];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     string s;     cin >> s;     vector<int> a(n);     f[ > ] = 1;     f[ < ] = -1;     for (auto &x : a) {       cin >> x;     }     int v = 0;     for (int i = 0; i < n * 2 + 2; i++) {       int j = f[s[v]] * a[v];       v += j;       if (!(0 <= v && v < n)) {         cout <<  FINITE  << endl;         return 0;       }     }     cout <<  INFINITE  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, ans;     scanf( %lld%lld , &b, &a);     ans = (b + 1) % 10;     if (a == b) ans = 1;     for (long long i = b + 2; i <= a; i++) {       if (i % 10 == 0) {         ans = 0;         break;       }       ans *= i % 10;     }     printf( %lld n , ans % 10);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, q;     cin >> n >> k >> q;     vector<int> A(n);     set<int> S;     for (int i = 0; i < n; ++i) cin >> A[i];     int ty, id;     for (int i = 0; i < q; ++i) {       cin >> ty >> id;       if (ty == 1) {         S.insert(A[id - 1]);         if (S.size() > k) {           S.erase(S.begin());         }       } else {         if (S.find(A[id - 1]) != S.end())           cout <<  YES  << endl;         else           cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using uint = unsigned int;   using pii = pair<int, int>;   using vi = vector<int>;   int main() {     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       if (a % b == 0)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, odd = 0, even = 0;     cin >> n;     while (n--) {       cin >> a;       if (a % 2 == 0) {         even += 1;       } else {         odd += 1;       }     }     cout << (odd % 2 == 1 ? odd : even) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double n, m, a[1001], b[1001], litri = 0, ok = 1;     cin >> n >> m;     double copie = m;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) cin >> b[i];     litri = m / (b[1] - 1);     for (int i = n; i >= 1; i--) {       m = m + litri;       litri = m / (a[i] - 1);       m = m + litri;       litri = m / (b[i] - 1);       if (a[i] == 1 || b[i] == 1) ok = 0;     }     double diferenta;     diferenta = m - copie;     if (ok == 0)       cout << -1;     else       cout << fixed << setprecision(10) << diferenta;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   ifstream fin( test.in );   double i, j, sens, k, o, ta, tb, pasi, p, d, pl, haur, n;   int a, b, t, f, c;   int main() {     cin >> a >> b >> t >> f >> c;     k = 1000;     ta = a / k;     tb = b / k;     p = a * t;     sens = 1;     while (p < c) {       n = 0;       while (p + a > d + b && p < c) {         p += a;         d += b;         n += a;       }       while (p > d && p < c) {         p += ta;         d += tb;         n += ta;       }       if (p < c && p != c) ++haur;       d = 0;       p += n + a * f;     }     cout << haur;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     char opr[40];     while ((~scanf( %s , opr)) && opr[0] ==  s ) {       int x = 0, y = 1;       while (1) {         printf( ? %d %d n , x, y);         fflush(stdout);         char ans[20];         scanf( %s , ans);         if (ans[0] ==  x ) break;         x = y, y = y * 2 + 1;       }       int mid;       int l = x, r = y;       while (l + 1 < r) {         mid = (l + r) >> 1;         printf( ? %d %d n , l, mid);         fflush(stdout);         char ans[20];         scanf( %s , ans);         if (ans[0] ==  y )           l = mid;         else           r = mid;       }       if (l == 0) {         printf( ! 1 n );         fflush(stdout);         continue;       }       printf( ? %d %d n , r, r + 1);       fflush(stdout);       char ans[20];       scanf( %s , ans);       if (ans[0] ==  x ) r--;       printf( ! %d n , r);       fflush(stdout);     }   }
#include <bits/stdc++.h>   char s[128];   bool ce(char r, char a, char b, char c) { return r == a || r == b || r == c; }   bool spcmp(char a, char b, char c) {     return ce( A , a, b, c) && ce( B , a, b, c) && ce( C , a, b, c);   }   int main() {     int n, i;     scanf( %s , s);     for (i = 1; s[i + 1] !=   0 ; i++) {       if (spcmp(s[i - 1], s[i], s[i + 1])) {         printf( Yes n );         return 0;       }     }     printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k, x, y, res = 0;       cin >> n >> k;       vector<vector<int>> gr(n + 1);       vector<int> deg(n + 1, 0), ch(n + 1, 0), nxt;       for (int i = 0; i < n - 1; i++) {         cin >> x >> y;         gr[x].push_back(y);         gr[y].push_back(x);         deg[x]++;         deg[y]++;       }       for (int i = 1; i <= n; i++) {         if (deg[i] == 1) {           int par = gr[i].front();           ch[par]++;           if (ch[par] >= k) {             nxt.push_back(par);           }         }       }       while (!nxt.empty()) {         int a = nxt.back();         nxt.pop_back();         if (ch[a] < k) {           continue;         }         vector<int> del;         for (int i = 0; i < gr[a].size(); i++) {           if (deg[gr[a][i]] == 1) {             del.push_back(i);           }         }         res += del.size() / k;         while (del.size() % k != 0) {           del.pop_back();         }         ch[a] -= del.size();         for (int i = del.size() - 1; i >= 0; i--) {           gr[a].erase(gr[a].begin() + del[i]);         }         deg[a] -= del.size();         if (deg[a] == 1) {           int par = gr[a].front();           ch[par]++;           if (ch[par] >= k) {             nxt.push_back(par);           }         }       }       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = (int)1e9;   const double PI = 2 * acos(0.0);   const double eps = 1e-9;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     int foo = max(3 * a / 10, a - a / 250 * c);     int bar = max(3 * b / 10, b - b / 250 * d);     if (foo == bar)       cout <<  Tie  << endl;     else if (foo > bar)       cout <<  Misha  << endl;     else       cout <<  Vasya  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n + 1];     for (int i = 1; i < n + 1; i++) {       cin >> a[i];     }     int s = 0;     int arr[n + 1], max;     max = INT_MIN;     memset(arr, 0, sizeof(arr));     for (int i = 1; i < n + 1; i++) {       if (a[i] == 1) {         arr[i] = arr[i - 1] + 1;       } else {         arr[i] = 0;       }       if (arr[i] > max) {         max = arr[i];       }     }     if (arr[n] != 0) {       int j = 1;       while (arr[j] != 0) {         arr[n]++;         j++;       }       if (arr[n] > max) {         max = arr[n];       }     }     cout << max;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long p[10], n, res;   int main() {     std::ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     p[1] = 2;     p[2] = 3;     p[3] = 5;     p[4] = 7;     res = 0;     for (int a = 1; a <= 4; a++) res += n / p[a];     for (int a = 1; a <= 4; a++)       for (int b = a + 1; b <= 4; b++) res -= n / (p[a] * p[b]);     for (int a = 1; a <= 4; a++)       for (int b = a + 1; b <= 4; b++)         for (int c = b + 1; c <= 4; c++) res += n / (p[a] * p[b] * p[c]);     for (int a = 1; a <= 4; a++)       for (int b = a + 1; b <= 4; b++)         for (int c = b + 1; c <= 4; c++)           for (int d = c + 1; d <= 4; d++) res -= n / (p[a] * p[b] * p[c] * p[d]);     res = n - res;     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isPal(string s, long long l, long long r) {     while (l < r) {       if (s[l] != s[r]) return false;       l++;       r--;     }     return true;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     string s;     cin >> s;     long long ans = 0;     for (long long i = 0; i < s.size(); i++) {       for (long long j = i; j < s.size(); j++) {         if (!isPal(s, i, j)) {           if (ans < j - i + 1) ans = j - i + 1;         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void test() { cerr <<   n ; }   template <typename T, typename... Args>   void test(T x, Args... args) {     cerr << x <<    ;     test(args...);   }   const int MAXN = (int)1e6 + 5;   const int MOD = (int)1e9 + 7;   void solve() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     long long sum = 0, ma = a[0], mi = 0;     for (int i = 0; i < n; i++) {       sum += a[i];       if (i == 0) {         mi = sum;       } else {         ma = max(ma, sum - mi);         mi = min(mi, sum);       }       if (i != n - 1) ma = max(ma, sum);     }     cout << (sum > ma ?  YES  :  NO ) <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int T;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MSIZE = 1e3 + 5;   const int MOD = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       string s;       cin >> s;       int cnt[26] = {0};       for (char c : s) cnt[c -  a ]++;       int os = 0;       for (int i = 0; i <= 25; i++) {         if (cnt[i] >= k - os) {           cnt[i] -= (k - os);           cout << (char)( a  + i);           break;         }         os += cnt[i];         cnt[i] = 0;       }       if (os) {         cout << endl;         continue;       }       bool pr = 0;       for (int i = 0; i <= 25; i++) {         if (cnt[i] and cnt[i] == n - k) {           int val = cnt[i] / k + (cnt[i] % k != 0);           while (val--) cout << (char)( a  + i);           break;         }         while (cnt[i]--) cout << (char)( a  + i);       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   const int INF = (int)1e9;   using namespace std;   template <class T>   T abs(T x) {     return x < 0 ? -x : x;   }   template <class T>   T sqr(T x) {     return x * x;   }   int n;   int x[1000], y[1000];   bool used[1000];   void dfs(int v) {     used[v] = true;     for (int i = 0; i < n; ++i) {       if ((!used[i]) && (x[v] == x[i] || y[v] == y[i])) {         dfs(i);       }     }   }   int main() {     cin >> n;     for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];     memset(used, false, sizeof(used));     int ans = -1;     for (int j = 0; j < n; ++j) {       if (!used[j]) {         ans++;         dfs(j);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int v, c;     node *opp, *next;   } Map[500];   node *List[110];   int d[110], vd[110];   int e, n;   int a[110], p1[110], p2[110], N, M;   bool b[100000 + 10];   int prime[100000 + 10], Nprime = 0;   void addedge(int i, int j, int c) {     Map[++e].v = j;     Map[e].c = c;     Map[e].opp = &Map[e + 1];     Map[e].next = List[i];     List[i] = &Map[e];     Map[++e].v = i;     Map[e].c = 0;     Map[e].opp = &Map[e - 1];     Map[e].next = List[j];     List[j] = &Map[e];   }   int dfs(int i, int flow) {     int j, temp, ff = 0;     node *u;     if (i == n) return (flow);     u = List[i];     while (u != NULL) {       j = u->v;       if (u->c > 0 && d[i] == d[j] + 1) {         temp = dfs(j, min(u->c, flow - ff));         u->c = u->c - temp;         u->opp->c = u->opp->c + temp;         ff += temp;         if (ff == flow) return (flow);       }       u = u->next;     }     if (d[1] >= n) return (ff);     vd[d[i]]--;     if (vd[d[i]] == 0) d[1] = n;     d[i]++;     vd[d[i]]++;     return (ff);   }   void getprime() {     for (int i = 2; i <= 100000; i++) {       if (!b[i]) {         prime[++Nprime] = i;         for (int j = i + i; j <= 100000; j += i) b[j] = true;       }     }   }   int solve(int k) {     e = 0;     for (int i = 0; i < 110; i++) List[i] = NULL;     for (int i = (1); i <= (M); ++i) {       int t1 = a[p1[i]], t2 = a[p2[i]];       int count = 0;       while (t1 % k == 0 && t2 % k == 0) {         t1 /= k;         t2 /= k;         count++;       }       if (p1[i] % 2 == 1)         addedge(p1[i] + 1, p2[i] + 1, count);       else         addedge(p2[i] + 1, p1[i] + 1, count);     }     for (int i = (1); i <= (N); ++i) {       int count = 0;       while (a[i] % k == 0) {         a[i] /= k;         count++;       }       if (i % 2 == 1)         addedge(1, i + 1, count);       else         addedge(i + 1, N + 2, count);     }     n = N + 2;     memset(d, 0, sizeof(d));     memset(vd, 0, sizeof(vd));     vd[0] = n;     int maxflow = 0;     while (d[1] <= n - 1) maxflow = maxflow + dfs(1, 100000000);     return maxflow;   }   int main() {     getprime();     scanf( %d%d , &N, &M);     for (int i = (1); i <= (N); ++i) scanf( %d , a + i);     for (int i = (1); i <= (M); ++i) scanf( %d%d , p1 + i, p2 + i);     int ans = 0;     for (int i = (1); i <= (Nprime); ++i) ans += solve(prime[i]);     for (int i = (1); i <= (N); ++i)       if (a[i] > 1) ans += solve(a[i]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long nC2(int n) {     if (n == 0) return 0;     return ((long long)n * (n - 1)) / 2;   }   void solve() {     int n, m;     scanf( %d %d , &n, &m);     long long Kmin, Kmax;     int r = n % m;     Kmin = nC2((n + m - 1) / m) * r + nC2(n / m) * (m - r);     Kmax = nC2(n - m + 1);     printf( %lld %lld n , Kmin, Kmax);   }   int main() {     int tt;     tt = 1;     for (int i = 0; i < tt; ++i) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[5001][5001];   int p[5001];   bool u[5001];   int i, j, n, k;   int main() {     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %s , &a[i]);       for (j = 0; j < n; j++) a[i][j] -=  0 ;     }     for (i = 0; i < n; i++)       for (j = 0; j < n; j++) p[i] += a[i][j];     for (i = 0; i < n; i++)       for (j = 0; j < n; j++)         if (p[j] == n - i - 1) {           u[j] = 1;           break;         }     for (i = 0; i < n; i++)       if (!u[i]) break;     if (i == n) {       printf( -1 n );       return 0;     }     for (j = 0; j < n; j++)       for (k = 0; k < n; k++)         if (a[i][j] && a[j][k] && a[k][i]) {           printf( %d %d %d n , i + 1, j + 1, k + 1);           return 0;         }     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 1e9;   const int mx = 1e3 + 10;   const int mxd = (1 << 13) + 10;   long long int a[mx], b[mx];   vector<long long int> divs;   pair<int, long long int> f[mx][mxd];   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     int n;     long long int k;     scanf( %d %lld , &n, &k);     long long int g = k;     for (int i = 1; i <= n; i++) {       scanf( %lld , a + i);       b[i] = gcd(k, a[i]);       g /= gcd(g, a[i]);     }     if (g != 1) {       puts( -1 );       return 0;     }     if (k == 1) {       puts( 1 );       int idx = min_element(a + 1, a + 1 + n) - a;       printf( %d n , idx);       return 0;     }     for (long long int d = 1; d * d <= k; d++) {       if (k % d == 0) {         divs.push_back(d);         if (d != k / d) divs.push_back(k / d);       }     }     sort(divs.begin(), divs.end());     divs.resize(unique(divs.begin(), divs.end()) - divs.begin());     int nd = divs.size();     unordered_map<long long int, int> mp;     for (int i = 0; i < int(divs.size()); i++) mp[divs[i]] = i;     for (int d = 1; d < nd; d++) f[0][d] = pair<int, long long int>(oo, 0ll);     for (int i = 1; i <= n; i++) {       for (int d = 1; d < nd; d++) {         f[i][d] = f[i - 1][d];         long long int x = divs[d] / gcd(divs[d], b[i]);         int idx = mp[x];         pair<int, long long int> bet(f[i - 1][idx].first + 1,                                      a[i] + f[i - 1][idx].second);         f[i][d] = min(f[i][d], bet);       }     }     int pos = n, x = nd - 1;     printf( %d n , f[n][nd - 1].first);     int c = 0;     while (c < f[n][nd - 1].first) {       if (f[pos][x] == f[pos - 1][x])         pos--;       else {         printf( %d  , pos);         long long int nx = divs[x] / gcd(divs[x], b[pos]);         x = mp[nx];         pos--;         c++;       }     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long q;     long long m;     cin >> q >> m;     long long j = 0;     vector<pair<long long, long long>> spells;     spells.push_back({0, 0});     for (int i = 0; i < q; i++) {       long long k, a, b;       cin >> k >> a >> b;       if (k == 1) {         long long x = 1 + (a + j) % 1000000;         long long y = 1 + (b + j) % 1000000;         long long l = -1;         long long r = spells.size();         while (l + 1 != r) {           long long mid = (r + l) / 2;           if (spells[mid].first < x)             l = mid;           else             r = mid;         }         if (r == spells.size() ||             (spells[r].second - spells[r - 1].second) *                     (x - spells[r - 1].first) >                 (y - spells[r - 1].second) *                     (spells[r].first - spells[r - 1].first)) {           spells.insert(spells.begin() + r, {x, y});           long long shift = 0;           while (r - shift > 1) {             if ((spells[r].second - spells[r - shift - 2].second) *                     (spells[r - shift - 1].first - spells[r - shift - 2].first) >                 (spells[r - shift - 1].second - spells[r - shift - 2].second) *                     (spells[r].first - spells[r - shift - 2].first))               break;             shift++;           }           if (shift > 0)             spells.erase(spells.begin() + r - shift, spells.begin() + r);         }       } else {         long long t = 1 + (a + j) % 1000000;         long long h = 1 + (b + j) % 1000000;         long long l = -1;         long long r = spells.size();         if (h > spells[r - 1].first * t) {           cout <<  NO n ;           continue;         }         while (l + 1 != r) {           long long mid = (r + l) / 2;           if (spells[mid].first * t < h)             l = mid;           else             r = mid;         }         if (spells[r - 1].second * (t * spells[r].first - h) +                 spells[r].second * (h - t * spells[r - 1].first) <=             m * (spells[r].first - spells[r - 1].first)) {           cout <<  YES n ;           j = i + 1;         } else           cout <<  NO n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 16;     int k;     int a[n];     cin >> k;     for (int i = 0; i < n; i++) {       a[0] = 15;       a[1] = 14;       a[2] = 12;       a[3] = 13;       a[4] = 8;       a[5] = 9;       a[6] = 10;       a[7] = 11;       a[8] = 0;       a[9] = 1;       a[10] = 2;       a[11] = 3;       a[12] = 4;       a[13] = 5;       a[14] = 6;       a[15] = 7;       cout << a[k];       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t = 1;     while (t--) {       long long int n = 0, m = 0, k = 0, i = 0, j = 0, p = 0, q = 0, x = 0, y = 0,                     z = 0, cnt = 0, l = 0, r = 0, mid = 0, lo = 0, hi = 0;       string s;       bool flag = false;       cin >> n;       long long int a[n];       for (i = 0; i <= n - 1; i++) cin >> a[i];       long long int dpl[n];       long long int dpr[n];       pair<long long int, long long int> pr;       stack<pair<long long int, long long int>> st;       st.push(make_pair(a[0], 0));       for (i = 1; i < n; i++) {         while (!st.empty() && (st.top()).first > a[i]) {           pr = st.top();           st.pop();           dpr[pr.second] = i;         }         st.push(make_pair(a[i], i));       }       while (!st.empty()) {         pr = st.top();         st.pop();         dpr[pr.second] = n;       }       st.push(make_pair(a[n - 1], n - 1));       for (i = n - 2; i >= 0; i--) {         while (!st.empty() && (st.top()).first > a[i]) {           pr = st.top();           st.pop();           dpl[pr.second] = i;         }         st.push(make_pair(a[i], i));       }       while (!st.empty()) {         pr = st.top();         st.pop();         dpl[pr.second] = -1;       }       long long int ans[n + 1];       vector<pair<long long int, long long int>> vec;       for (i = 0; i < n; i++) vec.push_back(make_pair(a[i], i));       sort(vec.rbegin(), vec.rend());       j = 1;       for (i = 0; i < n; i++) {         pr = vec[i];         z = 0;         z = pr.second - dpl[pr.second] - 1;         z += dpr[pr.second] - pr.second - 1;         z++;         while (j <= z) ans[j] = pr.first, j++;       }       for (i = 1; i <= n; i++) cout << ans[i] <<    ;       cout << endl;     }     return 0;   }