
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	string s;
	cin >> s;
	LL val = stoll(s);
	int n = s.size();
	vector<int>ten;
	for (int i = 0; i < 10; ++i)ten.push_back(i);
	LL tenten = 1;
	for (int i = 0; i < n; ++i)tenten *= 10;
	LL score = -1;
	LL value = INT_MAX;
	do
	{
		LL nw = 0;
		for (int i = 0; i < n; ++i)
		{
			nw *= 10;
			nw += ten[i];
		}
		LL sc = abs(nw - val);
		sc = min(sc, tenten - sc);
		if (sc > score || (sc == score && nw < value))
		{
			score = sc;
			value = nw;
		}
	} while (next_permutation(ten.begin(), ten.end()));
	char tmp[123];
	sprintf(tmp, "%lld", value);
	string ans = tmp;
	while (ans.size() < n)ans.insert(ans.begin(), '0');
	cout << ans << endl;
	return 0;
}
### Prompt

Develop a solution in Cpp to the problem described below:

Example

Input

201


Output

701

### Response

```cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	string s;
	cin >> s;
	LL val = stoll(s);
	int n = s.size();
	vector<int>ten;
	for (int i = 0; i < 10; ++i)ten.push_back(i);
	LL tenten = 1;
	for (int i = 0; i < n; ++i)tenten *= 10;
	LL score = -1;
	LL value = INT_MAX;
	do
	{
		LL nw = 0;
		for (int i = 0; i < n; ++i)
		{
			nw *= 10;
			nw += ten[i];
		}
		LL sc = abs(nw - val);
		sc = min(sc, tenten - sc);
		if (sc > score || (sc == score && nw < value))
		{
			score = sc;
			value = nw;
		}
	} while (next_permutation(ten.begin(), ten.end()));
	char tmp[123];
	sprintf(tmp, "%lld", value);
	string ans = tmp;
	while (ans.size() < n)ans.insert(ans.begin(), '0');
	cout << ans << endl;
	return 0;
}
```