#include <bits/stdc++.h>   using namespace std;   bool dp[5001][5001];   vector<int> bits[10001];   vector<pair<int, int> > cur;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s, ans;     cin >> s;     int n = s.size();     dp[0][0] = 1;     cur.push_back(make_pair(0, 0));     int cnt = 0;     while ((1 << cnt) < n) cnt++;     cnt--;     ans =   ;     for (int i = 0; i < (1 << cnt); i++)       for (int j = 0; j < cnt; j++)         if ((i & (1 << j)) == 0) bits[i].push_back(j);     int l = 1;     int m = n;     while (m > l) {       m -= l;       l *= 2;     }     while (ans.size() < m) {       char min_chr =  z ;       for (int i = 0; i < cur.size(); i++) {         auto x = cur[i];         for (auto j : bits[x.second]) {           if (dp[x.first + (1 << j)][x.second | (1 << j)] == 0) {             cur.push_back(make_pair(x.first + (1 << j), x.second | (1 << j)));             dp[x.first + (1 << j)][x.second | (1 << j)] = 1;           }         }         min_chr = min(min_chr, s[x.first]);       }       ans.push_back(min_chr);       vector<pair<int, int> > tmp;       for (auto x : cur) {         if (s[x.first] == min_chr) {           dp[x.first + 1][x.second] = 1;           tmp.push_back(make_pair(x.first + 1, x.second));         }       }       cur = tmp;     }     cout << ans <<   n ;     return 0;   }   