#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  string n;
  cin>>n;
  int l = n.size();
  long nn = stoll(n);

  long tens = 1;
  rep(i,l) tens *= 10L;

  vector<int> v;
  rep(i,10) v.pb(i);
  long best = -1, bestd = 0;
  do {
    long nd = 0;
    rep(i,l) nd = nd*10 + v[i];

    long diff = min(abs(nn-nd), tens-abs(nn-nd));
    if(diff > bestd){
      bestd = diff;
      best = nd;
    }

    reverse(v.begin() + l, v.end());
  } while(next_permutation(all(v)));

  vector<int> ans(l,0);
  rep(i,l){
    ans[l-i-1] = best%10;
    best/=10;
  }
  rep(i,l) cout << ans[i];
  cout <<endl;

  return 0;
}
### Prompt

Please provide a CPP coded solution to the problem described below:

Example

Input

201


Output

701

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  string n;
  cin>>n;
  int l = n.size();
  long nn = stoll(n);

  long tens = 1;
  rep(i,l) tens *= 10L;

  vector<int> v;
  rep(i,10) v.pb(i);
  long best = -1, bestd = 0;
  do {
    long nd = 0;
    rep(i,l) nd = nd*10 + v[i];

    long diff = min(abs(nn-nd), tens-abs(nn-nd));
    if(diff > bestd){
      bestd = diff;
      best = nd;
    }

    reverse(v.begin() + l, v.end());
  } while(next_permutation(all(v)));

  vector<int> ans(l,0);
  rep(i,l){
    ans[l-i-1] = best%10;
    best/=10;
  }
  rep(i,l) cout << ans[i];
  cout <<endl;

  return 0;
}
```