output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      K
attempt: import sys
  import resource
  
  sys.setrecursionlimit(10**9)
  resource.setrlimit(resource.RLIMIT_STACK, (-1, -1))
  
  k = int(input())
  
  ary = [1, 2, 3, 4, 5, 6, 7, 8, 9]
  
  
  def ans(j, nums):
      nums[j] += 1
      pre = nums[j]
      for i in range(j + 1, len(nums)):
          if pre > 0:
              nums[i] = pre - 1
              pre = nums[i]
          else:
              nums[i] = pre
      return int("".join(map(str, nums)))
  
  
  def lunlun(n):
      if n <= 9:
          return ary[n - 1]
      l = lunlun(n - 1)
      nums = list(map(int, list(str(l))))
      first = len(nums) - 1
      last = 0
      for i in range(len(nums)):
          j = len(nums) - i - 1
          c = nums[j] + 1
          # 桁数が変わらないとき
          if j == first:
              # 1桁目
              if nums[j] < 9 and abs(nums[j - 1] - c) <= 1:
                  nums[j] += 1
                  return int("".join(map(str, nums)))
          elif j == last:
              # 最終桁
              if nums[j] < 9 and abs(nums[j + 1] - c) <= 1:
                  return ans(j, nums)
          elif j != first and j != last:
              # 間の桁
              if nums[j] < 9 and abs(nums[j - 1] - c) <= 1 and abs(nums[j + 1] - c) <= 1:
                  return ans(j, nums)
  
      # 桁が繰り上がるとき
      return int("1" + "".join(["0"] * len(nums)))
  
  
  print(lunlun(k))
  
problem_description: Statement
  
  A positive integer X is said to be a lunlun number if and only if the
  following condition is satisfied:
  
    * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.
  
  For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or
  13579 is.
  
  You are given a positive integer K. Find the K-th smallest lunlun number.
samples: [{"input": "15", "output": "23\n    \n\nWe will list the 15 smallest lunlun numbers in ascending order:  \n1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 21, 22, 23.  \nThus, the answer is 23.\n\n* * *"}, {"input": "1", "output": "1\n    \n\n* * *"}, {"input": "13", "output": "21\n    \n\n* * *"}, {"input": "100000", "output": "3234566667\n    \n\nNote that the answer may not fit into the 32-bit signed integer type."}]