alexjercan/bugnet huggingface dataset:
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

// g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

vector<vector<ll>> num(30);
/*
ll runrun(ll x){
  ll res = num[x-1];
  bool flag = true;
  while(flag){
    res++;
    string s = to_string(res);
    int l = s.size();
    //bool hantei = true;
    //while(hantei){
      rep(i,l-1)if(abs((s.at(i)-'0')-(s.at(i+1)-'0')) > 1)flag = false;
      if(flag){
        flag = false;
        break;
      }else{
        flag = true;
      }

  }
  return res;
}
*/

int main() {
  ll N;
  cin >> N;
  for (int i = 1; i < 10; i++) {
    num.at(1).push_back(i);
  }
  for (int i = 2; i < 12; i++) {
    ll l = num.at(i - 1).size();
    rep(j, l) {
      ll iti = num.at(i - 1).at(j) % 10;
      if (iti - 1 >= 0 && iti - 1 <= 9) {
        ll tmp = num.at(i - 1).at(j) * 10 + iti - 1;
        num.at(i).push_back(tmp);
      }
      if (iti >= 0 && iti <= 9) {
        ll tmp = num.at(i - 1).at(j) * 10 + iti;
        num.at(i).push_back(tmp);
      }
      if (iti + 1 >= 0 && iti + 1 <= 9) {
        ll tmp = num.at(i - 1).at(j) * 10 + iti + 1;
        num.at(i).push_back(tmp);
      }
    }
  }

  ll cnt = 0;
  bool flag = false;
  int keta = 1;
  while (N > 0) {
    rep(i, num.at(keta).size()) {
      N--;
      // cnt++;
      if (N == 0) {
        cout << num.at(keta).at(i) << endl;
        // flag = true;
        break;
      }
    }
    keta++;
  }

  // cout << num[N] << endl;
}


Error: TLE

Fixed submission:

// g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

vector<ll> num(100010, 0);

ll runrun(ll x) {
  ll res = num[x - 1];
  bool flag = true;
  while (flag) {
    res++;
    string s = to_string(res);
    int l = s.size();
    // bool hantei = true;
    // while(hantei){
    rep(i, l - 1) if (abs((s.at(i) - '0') - (s.at(i + 1) - '0')) > 1) flag =
        false;
    if (flag) {
      flag = false;
      break;
    } else {
      flag = true;
    }
  }
  return res;
}

int main() {
  for (int i = 1; i < 10; i++)
    num[i] = i;
  ll N;
  cin >> N;
  for (int i = 10; i <= N; i++)
    num[i] = runrun(i);
  cout << num[N] << endl;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int K;
  cin >> K;
  queue<ll> q;
  for (ll i = 1; i < 10; i++) {
    q.push(i);
  }
  ll x;
  for (int k = 0; k < K; k++) {
    x = q.front();
    q.pop();
    if (x % 10 > 0) {
      q.push(10 * x + x % 10 - 1);
    }
    q.push(10 * x + x % 10);
    if (x % 10 < 9) {
      q.push(10 * x + x % 10 + 1);
    }
  }
  cout << x << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define MAX 100001
using namespace std;
long long lunlun[MAX] = {0};
long long K;
bool isLunlun(long long num) {
  while (num) {
    if ((0 < num && num < 10) || (num % 10 + 1 == (num / 10) % 10) ||
        (num % 10 - 1 == (num / 10) % 10) || (num % 10 == (num / 10 % 10))) {
      num /= 10;
    } else {
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> K;
  long long num = 1;
  for (int i = 1; i <= K; i++) {
    while (!isLunlun(num))
      num++;
    lunlun[i] = num;
    num++;
  }
  cout << lunlun[K] << "\\n";
  return 0;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

int main() {
  int x;
  scanf("%d", &x);
  queue<ll> number_maker;
  rep1(i, 9) { number_maker.push(i); }
  ll result;
  rep(i, x) {
    result = number_maker.front();
    if (result % 10 != 0) {
      number_maker.push(result * 10 + result % 10 - 1);
    }
    number_maker.push(result * 10 + result % 10);
    if (result % 10 != 9) {
      number_maker.push(result * 10 + result % 10 + 1);
    }
    number_maker.pop();
  }
  printf("%lld", result);
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

int main() {
  int x;
  scanf("%d", &x);
  ll count = 0;
  ll x_count = 0;
  while (x_count < x) {
    bool flag = true;
    count++;
    rep(i, log10(count)) {
      if (to_string(count)[i] == to_string(count)[i + 1] ||
          to_string(count)[i] == to_string(count)[i + 1] + 1 ||
          to_string(count)[i] == to_string(count)[i + 1] - 1) {
        continue;
      } else {
        flag = false;
        break;
        // printf("%lld\\n",count);
      }
    }
    if (flag) {
      x_count++;
    }
  }
  printf("%lld", count);
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

// ABC161D - Lunlun Number

#include <bits/stdc++.h>
using namespace std;

int main() {
  int K;
  cin >> K;

  if (K <= 9) {
    cout << K << endl;
    return 0;
  }

  queue<long long int> lunlun;
  for (long long int i = 1; i <= 9; i++) {
    lunlun.push(i);
  }

  int nol = 9; // Number Of Lunlun
  while (1) {
    long long int temp;
    int base;
    temp = lunlun.front();
    lunlun.pop();
    base = (int)(temp % 10);
    if (base != 0) {
      lunlun.push(temp * 10 + (base - 1));
      nol++;
      if (nol == K) {
        cout << temp * 10 + (base - 1) << endl;
        return 0;
      }
    }
    lunlun.push(temp * 10 + (base));
    nol++;
    if (nol == K) {
      cout << temp * 10 + (base) << endl;
      return 0;
    }
    if (base != 9) {
      lunlun.push(temp * 10 + (base + 1));
      nol++;
      if (nol == K) {
        cout << temp * 10 + (base + 1) << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

// ABC161D - Lunlun Number

#include <bits/stdc++.h>
using namespace std;

bool lunlun(long long int n) {
  if (n < 10) {
    return true;
  }

  bool ans = true;
  long long int t = n % 10;
  n /= 10;
  while (n > 0) {
    if (abs(n % 10 - t) >= 2) {
      ans = false;
      break;
    }
    t = n % 10;
    n /= 10;
  }

  return ans;
}

int main() {
  //	cout << lunlun(1234) << endl;
  //	cout << lunlun(1) << endl;
  //	cout << lunlun(334) << endl;
  //	cout << lunlun(31415) << endl;
  //	cout << lunlun(119) << endl;
  //	cout << lunlun(13579) << endl;

  int K;
  cin >> K;

  int t = 0;
  long long int n = 1;
  while (1) {
    if (lunlun(n)) {
      t++;
      if (t == K) {
        cout << n << endl;
        return 0;
      }
    }
    n++;
  }

  return 0;
}
Problem p02720 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; ++i)
    a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k - 1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; ++i) {
        int d = x % 10 + i;
        if (d < 0 || d > 9)
          continue;
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = acos(-1.0);
const ll mod = pow(10, 9) + 7;
const ll INF = pow(2, 31) - 1;
typedef pair<int, int> P;
typedef vector<int> vi;

ll gcd(ll a, ll b) {
  ll v0 = a, v1 = b, v2 = a % b;
  while (v2 != 0) {
    v0 = v1;
    v1 = v2;
    v2 = v0 % v1;
  }
  return v1;
}

ll lcm(ll a, ll b) { return (a * b / gcd(a, b)); }

int keta(ll n) {
  int res = 0;
  while (n) {
    n /= 10;
    res++;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i++; i <= 9)
    a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k - 1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; i++) {
        int d = x % 10 + i;
        if (d < 0 || d > 9)
          continue;
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <queue>
#include <string>

using namespace std;

long long k;
queue<long long> q;

int s2i(string c) {
  if (c == "1") {
    return 1;
  } else if (c == "2") {
    return 2;
  } else if (c == "3") {
    return 3;
  } else if (c == "4") {
    return 4;
  } else if (c == "5") {
    return 5;
  } else if (c == "6") {
    return 6;
  } else if (c == "7") {
    return 7;
  } else if (c == "8") {
    return 8;
  } else if (c == "9") {
    return 9;
  } else {
    return 0;
  }
}

long long lunlun() {
  long long x;
  int y;
  string s;
  x = q.front();
  q.pop();
  s = to_string(x);
  s = *(s.end() - 1);
  y = s2i(s);
  if (y != 0)
    q.push(x * 10 + y - 1);
  q.push(x * 10 + y);
  if (y != 9)
    q.push(x * 10 + y + 1);
  return x;
}

int main() {
  long long val;
  for (long long i = 1; i < 10; i++)
    q.push(i);
  cin >> k;
  for (int i = 1; i < k + 1; i++) {
    val = lunlun();
    if (i == k)
      cout << val << endl;
  }
}


Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <string>

using namespace std;

int s2i(char c) {
  if (c == '1') {
    return 1;
  } else if (c == '2') {
    return 2;
  } else if (c == '3') {
    return 3;
  } else if (c == '4') {
    return 4;
  } else if (c == '5') {
    return 5;
  } else if (c == '6') {
    return 6;
  } else if (c == '7') {
    return 7;
  } else if (c == '8') {
    return 8;
  } else if (c == '9') {
    return 9;
  } else {
    return 0;
  }
}

bool runrun(int i) {
  string s;
  int p, q;
  s = to_string(i);
  for (auto it = s.begin(); it != s.end(); it++) {
    if (it == s.end() - 1)
      break;
    auto that = it;
    that++;
    p = s2i(*it);
    q = s2i(*that);
    if (abs(p - q) >= 2)
      return false;
  }
  return true;
}

int main() {
  long long i = 0, j = 0, k;
  cin >> k;
  while (k != j) {
    i++;
    if (runrun(i) || i <= 10) {
      j++;
    }
  }

  cout << i << endl;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  rep(i, 9) a.push_back(i + 1);
  while (1) {
    if (k <= a.size()) {
      cout << a[k - 1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; ++i) {
        int d = x % 10 + i;
        if (d < 0 || d > 9)
          continue;
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;

bool lun(ll x) {
  string s = to_string(x);
  int n = s.size();
  rep(i, n - 1) if (abs(s[i] - s[i + 1]) >= 2) return false;
  return true;
}

int main() {
  int k;
  cin >> k;
  int cnt = 0;
  ll ans = 1;
  while (1) {
    if (lun(ans))
      ++cnt;
    if (cnt == k)
      break;
    ans++;
  }
  cout << ans << endl;
}
Problem p02720 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)(n); ++i)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

ll n;
ll ans;
ll c = 1;

bool f(ll num, ll digit) {
  if (digit == (ll)log10(num) + 1) {
    if (n == c) {
      ans = num;
      return true;
    } else {
      c++;
      return false;
    }
  }

  int rnum = num % 10;
  for (int i = max(rnum - 1, 0); i <= min(rnum + 1, 9); i++) {
    if (f(num * 10 + i, digit))
      return true;
  }
  return false;
}

int main() {
  cin >> n;

  ll digit = 1;
  while (true) {
    bool res = false;
    for (int i = 1; i <= 9; i++) {
      res = f(i, digit);
      if (res)
        break;
    }
    if (res)
      break;
    digit++;
  }

  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)(n); ++i)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

ll n;
ll ans;
ll c = 1;

bool f(ll num, ll digit) {
  if (digit == (ll)log10(num) + 1) {
    if (n == c) {
      ans = num;
      return true;
    } else {
      c++;
      return false;
    }
  }

  int rnum = num % 10;
  for (int i = max(rnum - 1, 0); i <= min(rnum + 1, 9); i++) {
    if (f(num * 10 + i, digit))
      return true;
  }
}

int main() {
  cin >> n;

  ll digit = 1;
  while (true) {
    bool res = false;
    for (int i = 1; i <= 9; i++) {
      res = f(i, digit);
      if (res)
        break;
    }
    if (res)
      break;
    digit++;
  }

  cout << ans << endl;

  return 0;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

// ABC 161 D LUNLUN number.

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()

{
  ll i, x, k, temp, count = 0;
  cin >> k;
  queue<ll> v;
  for (i = 1; i <= 9; i++)
    v.push(i);

  while (count != k) {
    count++;
    x = v.front();
    v.pop();
    temp = x * 10 + x % 10;
    if (x % 10 != 0)
      v.push(temp - 1);
    v.push(temp);
    if (x % 10 != 9)
      v.push(temp + 1);
  }
  cout << x << "\\n";

  return 0;
}


Error: TLE

Fixed submission:

// ABC 161 D LUNLUN number.

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()

{
  ll i, x, k, temp, count = 0;
  cin >> k;
  vector<ll> v;
  for (i = 1; i <= 9; i++)
    v.push_back(i);

  while (count != k) {
    count++;
    x = v[0];
    v.erase(v.begin());
    temp = x * 10 + x % 10;
    if (x % 10 != 0)
      v.push_back(temp - 1);
    v.push_back(temp);
    if (x % 10 != 9)
      v.push_back(temp + 1);
  }
  cout << x << "\\n";

  return 0;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;

int main() {
  int K;
  cin >> K;

  if (K <= 9) {
    cout << K << endl;
    return 0;
  } else {
    Int cnt = 9;

    vector<vector<Int>> L(20);
    L[0] = {1, 2, 3, 4, 5, 6, 7, 8, 9};

    for (int i = 1; i < 20; i++) {
      for (int j = 0; j < L[i - 1].size(); j++) {
        Int now = L[i - 1][j];
        Int r = now % 10;

        if (r >= 1)
          L[i].push_back(now * 10 + r - 1);
        L[i].push_back(now * 10 + r);
        if (r <= 8)
          L[i].push_back(now * 10 + r + 1);
      }

      if (K <= cnt + L[i].size()) {
        cout << L[i][K - cnt - 1] << endl;
        break;
      } else {
        cnt += L[i].size();
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;

int main() {
  int K;
  cin >> K;

  if (K <= 9) {
    cout << K << endl;
    return 0;
  } else {
    Int cnt = 9;

    vector<vector<Int>> L(20);
    L[0] = {1, 2, 3, 4, 5, 6, 7, 8, 9};

    for (int i = 1; i < 20; i++) {
      for (int j = 0; j < L[i - 1].size(); j++) {
        Int now = L[i - 1][j];
        Int r = now % 10;

        if (r >= 1)
          L[i].push_back(now * 10 + r - 1);
        L[i].push_back(now + 10 + r);
        if (r <= 8)
          L[i].push_back(now * 10 + r + 1);
      }

      if (K <= cnt + L[i + 1].size()) {
        cout << L[i + 1][K - cnt - 1] << endl;
        break;
      } else {
        cnt += L[i + 1].size();
      }
    }
  }
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define oo 1000000010
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  int k;
  cin >> k;
  queue<ll> q;
  for (int i = 1; i <= 9; i++)
    q.push(i);
  ll ans;
  for (int i = 0; i < k; i++) {
    ans = q.front();
    q.pop();
    if (ans % 10 != 0)
      q.push(ans * 10 + ans % 10 - 1);
    q.push(ans * 10 + ans % 10);
    if (ans % 10 != 9)
      q.push(ans * 10 + ans % 10 + 1);
  }

  cout << ans;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define oo 1000000010
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  int k;
  cin >> k;
  queue<ll> q, q2;
  for (int i = 1; i <= 9; i++)
    q.push(i);
  ll ans;
  for (int i = 0; i < k; i++) {
    ans = q.front();
    q.pop();
    if (ans % 10 != 0)
      q.push(ans * 10 + ans % 10 - 1);
    q.push(ans * 10 + ans % 10);
    if (ans % 10 != 9)
      q.push(ans * 10 + ans % 10 + 1);
    q2 = q;
    while (!q2.empty()) {
      // cout << q2.front() << ' ';
      q2.pop();
    }
    // cout << endl;
  }

  cout << ans;

  return 0;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; ++i)
    a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k - 1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; ++i) {
        int d = x % 10 + i;
        if (d < 0 || d > 9)
          continue;
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; i++)
    a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k - 1] << endl;
      return 0;
    }
    vector<ll> old;
    for (ll x : old) {
      for (int i = -1; i <= 1; i++) {
        int d = x % 10 + 1;
        if (d < 0 || d > 9)
          continue;
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define reps(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) reps(i, 0, n)
#define Rreps(i, n, e) for (int i = n - 1; i >= e; --i)
#define Rrep(i, n) Rreps(i, n, 0)
#define ALL(a) a.begin(), a.end()
#define endl "\\n"
typedef long long ll;
#define traceV(v)                                                              \\
  for (auto x : v)                                                             \\
    cout << x << " ";                                                          \\
  cout << endl
#define traceM(mp)                                                             \\
  for (auto x : mp)                                                            \\
  cout << x.first << " " << x.second << endl
#define MOD 1000000007

int cnt = 0;
vector<ll> res;

void func(ll cur) {
  if (cur > 3234566667)
    return;
  res.push_back(cur);

  ll lowest_place = cur % 10;
  if (lowest_place == 0)
    func(cur * 10 + 1);
  else if (lowest_place == 9)
    func(cur * 10 + 8);
  else {
    func(cur * 10 + lowest_place - 1);
    func(cur * 10 + lowest_place + 1);
  }
  func(cur * 10 + lowest_place);
}

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

  // 再帰による全列挙
  // https://drken1215.hatenablog.com/entry/2020/04/05/150900
  int K;
  cin >> K;
  reps(i, 1, 10) func(i);
  sort(ALL(res));
  cout << res[K - 1] << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define reps(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) reps(i, 0, n)
#define Rreps(i, n, e) for (int i = n - 1; i >= e; --i)
#define Rrep(i, n) Rreps(i, n, 0)
#define ALL(a) a.begin(), a.end()
#define endl "\\n"
typedef long long ll;
#define traceV(v)                                                              \\
  for (auto x : v)                                                             \\
    cout << x << " ";                                                          \\
  cout << endl
#define traceM(mp)                                                             \\
  for (auto x : mp)                                                            \\
  cout << x.first << " " << x.second << endl
#define MOD 1000000007

int K;
int cnt = 0;
vector<ll> res;

void func(ll cur) {
  if (cur > 3234566667)
    return;
  res.push_back(cur);
  sort(ALL(res));

  ll lowest_place = cur % 10;
  if (lowest_place == 0)
    func(cur * 10 + 1);
  else if (lowest_place == 9)
    func(cur * 10 + 8);
  else {
    func(cur * 10 + lowest_place - 1);
    func(cur * 10 + lowest_place + 1);
  }
  func(cur * 10 + lowest_place);
}

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

  cin >> K;
  reps(i, 1, 10) func(i);

  cout << res[K - 1] << endl;

  return 0;
}