#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <queue>
#include <limits.h>
#include <string.h>
#include <vector>
#include <map>
#include <math.h>
#define LL long long
#define INF 2100000000
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define eps 5e-7
#define getr(x,y) x*y/(x+y+2.0*sqrt(x*y))
#define getd(x,y) 2.0*sqrt(x*y)
#define judgel(r,x) r+sqrt(2*x*r+r*r)<=x
#define fuck(x1,y1,x2,y2,z) (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)<=z*z

using namespace std;
const int maxn=(int)1e5+10;
const int maxm=(int)4e6+10;
const LL MOD=(LL)1e9+7;
LL a[maxm];
struct dfs{
    int now,vis;
    LL num;
    dfs(){}
    dfs(int now,LL num,int vis):now(now),num(num),vis(vis){}
};
dfs q[maxn];
int fuc(int L){
    int t=0;
    q[0]=dfs(0,0,0);
    int h=1;
    while(h){
        dfs tmp=q[h-1];
        h--;
        if(L==tmp.now){
            a[t++]=tmp.num;
            continue;
        }
        tmp.num*=10;
        for(int i=0;i<10;i++){
            if(!((tmp.vis>>i)&1)) q[h++]=dfs(tmp.now+1,tmp.num+i,tmp.vis|(1<<i));
        }
    }
    return t;
}
#define getdif(n,snum,power) min(abs(n-snum),power-abs(n-snum));
int main(){
#ifdef shuaishuai
    freopen("C:\\Users\\hasee\\Desktop\\a.txt","r",stdin);
    //freopen("C:\\Users\\hasee\\Desktop\\b.txt","w",stdout);
#endif
    string s;
    cin>>s;
    int l=s.size();
    int sz=fuc(l);
   // for(int i=0;i<a.size();i++ )printf("%lld\n",a[i]);
 //  printf("%d\n",a.size());
    LL fuck=0;
    LL tot=1;
    for(int i=0;i<l;i++){
        fuck*=10;
        tot*=10;
        fuck+=s[i]-'0';
    }
    LL dif=0;
    LL ans=0;

    for(int i=0;i<sz;i++){
        LL tmp=getdif(a[i],fuck,tot);
        if(tmp>dif){
            dif=tmp;
            ans=a[i];
        }
        else if(tmp==dif){
            if(a[i]<ans) ans=a[i];
        }
    }
    vector<int> q;
    while(ans){
        q.push_back(ans%10);
        ans/=10;
    }
    for(int i=q.size();i<l;i++) q.push_back(0);
    for(int i=q.size()-1;i>=0;i--)printf("%d",q[i]);printf("\n");
    return 0;
}
### Prompt

Generate a cpp solution to the following problem:

Example

Input

201


Output

701

### Response

```cpp
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <queue>
#include <limits.h>
#include <string.h>
#include <vector>
#include <map>
#include <math.h>
#define LL long long
#define INF 2100000000
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define eps 5e-7
#define getr(x,y) x*y/(x+y+2.0*sqrt(x*y))
#define getd(x,y) 2.0*sqrt(x*y)
#define judgel(r,x) r+sqrt(2*x*r+r*r)<=x
#define fuck(x1,y1,x2,y2,z) (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)<=z*z

using namespace std;
const int maxn=(int)1e5+10;
const int maxm=(int)4e6+10;
const LL MOD=(LL)1e9+7;
LL a[maxm];
struct dfs{
    int now,vis;
    LL num;
    dfs(){}
    dfs(int now,LL num,int vis):now(now),num(num),vis(vis){}
};
dfs q[maxn];
int fuc(int L){
    int t=0;
    q[0]=dfs(0,0,0);
    int h=1;
    while(h){
        dfs tmp=q[h-1];
        h--;
        if(L==tmp.now){
            a[t++]=tmp.num;
            continue;
        }
        tmp.num*=10;
        for(int i=0;i<10;i++){
            if(!((tmp.vis>>i)&1)) q[h++]=dfs(tmp.now+1,tmp.num+i,tmp.vis|(1<<i));
        }
    }
    return t;
}
#define getdif(n,snum,power) min(abs(n-snum),power-abs(n-snum));
int main(){
#ifdef shuaishuai
    freopen("C:\\Users\\hasee\\Desktop\\a.txt","r",stdin);
    //freopen("C:\\Users\\hasee\\Desktop\\b.txt","w",stdout);
#endif
    string s;
    cin>>s;
    int l=s.size();
    int sz=fuc(l);
   // for(int i=0;i<a.size();i++ )printf("%lld\n",a[i]);
 //  printf("%d\n",a.size());
    LL fuck=0;
    LL tot=1;
    for(int i=0;i<l;i++){
        fuck*=10;
        tot*=10;
        fuck+=s[i]-'0';
    }
    LL dif=0;
    LL ans=0;

    for(int i=0;i<sz;i++){
        LL tmp=getdif(a[i],fuck,tot);
        if(tmp>dif){
            dif=tmp;
            ans=a[i];
        }
        else if(tmp==dif){
            if(a[i]<ans) ans=a[i];
        }
    }
    vector<int> q;
    while(ans){
        q.push_back(ans%10);
        ans/=10;
    }
    for(int i=q.size();i<l;i++) q.push_back(0);
    for(int i=q.size()-1;i>=0;i--)printf("%d",q[i]);printf("\n");
    return 0;
}
```