Problem p02720 (C++) — buggy submission, verdict: Runtime Error

// Author: kaiyu
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define int long long
#define SZ(x) ((int)(x).size()) m
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define tt                                                                     \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
#define int3(x, y, z)                                                          \\
  ll x, y, z;                                                                  \\
  cin >> x >> y >> z;
#define int2(x, y)                                                             \\
  ll x, y;                                                                     \\
  cin >> x >> y;
#define int1(x)                                                                \\
  ll x;                                                                        \\
  cin >> x;
#define fio                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(NULL);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// bool cmp(pair<string,int>p1,pair<string,int>p2) {
////    return p1.ss > p2.ss;
////}
////if (s1.find(s2) != std::string::npos) {
////   std::cout << "found!" << '\\n';
////}
set<int> s;
void rec(int x) {
  if (x > 4e9)
    return;
  s.insert(x);
  int last = x % 10;
  if (last - 1 >= 0)
    rec(x * 10 + last - 1);
  rec(x * 10 + last);
  if (last + 1 <= 9)
    rec(x * 10 + last + 1);
}
int32_t main() {
  fio int1(k) for (int i = 1; i <= 9; ++i) { rec(i); }
  vector<int> v;
  for (auto &i : s) {
    v.push_back(i);
  }
  cout << v[k - 1];

  return 0;

  return 0;
}

Error: -11

Fixed submission:

// Author: kaiyu
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define int long long
#define SZ(x) ((int)(x).size()) m
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define tt                                                                     \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
#define int3(x, y, z)                                                          \\
  ll x, y, z;                                                                  \\
  cin >> x >> y >> z;
#define int2(x, y)                                                             \\
  ll x, y;                                                                     \\
  cin >> x >> y;
#define int1(x)                                                                \\
  ll x;                                                                        \\
  cin >> x;
#define fio                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(NULL);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// bool cmp(pair<string,int>p1,pair<string,int>p2) {
//     return p1.ss > p2.ss;
// }
// if (s1.find(s2) != std::string::npos) {
//    std::cout << "found!" << '\\n';
// }
set<int> s;
void rec(int x) {
  if (x > 4e9)
    return;
  s.insert(x);
  int last = x % 10;
  if (last - 1 >= 0)
    rec(x * 10 + last - 1);
  rec(x * 10 + last);
  if (last + 1 <= 9)
    rec(x * 10 + last + 1);
}
int32_t main() {
  fio int1(k) for (int i = 1; i <= 9; ++i) { rec(i); }
  vector<int> v;
  for (auto &i : v) {
    v.push_back(i);
  }
  cout << v[k - 1];
  return 0;

  return 0;
}