#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}

string to_string_keta(const long long int l, const int keta) {
	ostringstream oss;

	oss << std::setw(keta) << std::setfill('0') << l;

	return oss.str();
}

int main() {
	string from; cin >> from;
	
	long long int  st(stoll(from));
	int keta = from.size();
	vector<int>perms(10);
	iota(perms.begin(), perms.end(), 0);
	pair<long long int, long long int>ans(0, 0);
	do {
		string after;
		long long int aft = 0;
		for (int i = 0; i < keta; ++i) {
			aft = aft * 10 + perms[i];
		}
		auto p = make_pair(min(abs(st - aft), powint(10, keta) - abs(st - aft)), -aft);
		ans = max(ans, p);
		
		
	} while (next_permutation(perms.begin(), perms.end()));
	string ast = to_string_keta(-ans.second, keta);
	cout << ast<< endl;
	return 0;
}
### Prompt

Develop a solution in cpp to the problem described below:

Example

Input

201


Output

701

### Response

```cpp
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}

string to_string_keta(const long long int l, const int keta) {
	ostringstream oss;

	oss << std::setw(keta) << std::setfill('0') << l;

	return oss.str();
}

int main() {
	string from; cin >> from;
	
	long long int  st(stoll(from));
	int keta = from.size();
	vector<int>perms(10);
	iota(perms.begin(), perms.end(), 0);
	pair<long long int, long long int>ans(0, 0);
	do {
		string after;
		long long int aft = 0;
		for (int i = 0; i < keta; ++i) {
			aft = aft * 10 + perms[i];
		}
		auto p = make_pair(min(abs(st - aft), powint(10, keta) - abs(st - aft)), -aft);
		ans = max(ans, p);
		
		
	} while (next_permutation(perms.begin(), perms.end()));
	string ast = to_string_keta(-ans.second, keta);
	cout << ast<< endl;
	return 0;
}
```