太暴力了

#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <numeric>
#include <ctime>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
const ll N = 1e5 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f;

int n;

bool check(string a) {
    map<char, bool>mp;

    for (auto i : a) {
        mp[i] = true;
    }

    return mp.size() == 5;
}

bool cmp(string a, string b) {
    return a > b;
}

void solve() {
    cin >> n;

    vector<string>ans;

    for (int i = 1234; i <= 98765; i++) {
        string a = to_string(i);
        if (a.size() == 4)a = "0" + a;
        if (check(a))ans.push_back(a);
    }
    sort(ans.begin(), ans.end(), cmp);

    cout << ans[n - 1] << '\n';
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    //cin>>t;

    while (t--) {

        solve();

    }

    return 0;
}