#include #define rep(i,n) for (int i = 0; i < (n); ++i) #define repp(i,n,m) for (int i = m; i < (n); ++i) using namespace std; templateostream &operator<<(ostream &os,const vector &v){if(v.size()==0){os< 0){ int m = n % 2; ans += to_string(m); n /= 2; } reverse(ans.begin(),ans.end()); return ans; } int num(string s){ reverse(s.begin(),s.end()); int ans = 0; int ni = 1; for (char c : s){ if (c == '1') ans += ni; ni *= 2; } return ans; } set used; stack now; string code; int leng; int lim; void saiki(int ind){ if (ind == leng){ vector ans; while (!now.empty()){ ans.emplace_back(now.top()); now.pop(); } reverse(ans.begin(),ans.end()); cout << ans; exit(0); } string nows = ""; repp(i,leng,ind){ nows += code[i]; int nown = num(nows); if (nown > lim) break; if (i + 1 == leng || code[i+1] == '1'){ if (used.find(nown) == used.end()){ used.insert(nown); now.push(nown); saiki(i+1); used.erase(nown); now.pop(); } } } } int main(){ string s; cin >> s; int n = 0; int siz = s.size(); int tiz = 0; while (tiz < siz){ n++; string z = bin(n); tiz += z.size(); } code = s; leng = siz; lim = n; saiki(0); }