Language: C++

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int> , null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
// #define endl '\n'
#define int int64_t
#define double long double
#define fdt fuck donald trump
mt19937 rnd(time(0));
const int MAXN = 100001;

int k;
int cnt = 0;
void back(int pos, int lim, int cur, int last){
	// cout << pos << " " << lim << " " << cur << " " << last << endl;
	if(pos == lim + 1){
		cnt ++;
		if(cnt == k){
			cout << cur;
			exit(0);
		}
		return;
	}
	for(int i = max(0LL, last - 1); i <= min(9LL, last + 1); i ++)
		back(pos + 1, lim, cur*10 + i, i);
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
	// freopen("FDT.txt","r",stdins);
	cin >> k;
	for(int i = 1; ; i ++)
		for(int j = 1; j <= 9; j ++)
			back(2, i, j, j);
}


Compiler output:
a.cc: In function 'void back(int64_t, int64_t, int64_t, int64_t)':
a.cc:31:24: error: no matching function for call to 'max(long long int, int64_t)'
   31 |         for(int i = max(0LL, last - 1); i <= min(9LL, last + 1); i ++)
      |                     ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:31:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   31 |         for(int i = max(0LL, last - 1); i <= min(9LL, last + 1); i ++)
      |                     ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:31:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |         for(int i = max(0LL, last - 1); i <= min(9LL, last + 1); i ++)
      |                     ~~~^~~~~~~~~~~~~~~
a.cc:31:49: error: no matching function for call to 'min(long long int, int64_t)'
   31 |         for(int i = max(0LL, last - 1); i <= min(9LL, last + 1); i ++)
      |                                              ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:31:49: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   31 |         for(int i = max(0LL, last - 1); i <= min(9LL, last + 1); i ++)
      |                                              ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:31:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |         for(int i = max(0LL, last - 1); i <= min(9LL, last + 1); i ++)
      |                                              ~~~^~~~~~~~~~~~~~~