#include #include #include using namespace std; typedef pair P; int main(){ int n; string s; while(cin >> s){ vector

t; n = s.size(); for(int i = 0; i < n; i++){ t.push_back(P(s[i], i)); } sort(t.rbegin(), t.rend()); for(int i = 0; i < n; i++){ int j; for(j = 0; j < n; j++) if(t[i].first > s[j]) break; if(j < t[i].second){ swap(s[j], s[t[i].second]); break; } } cout << s << endl; } }