Buggy python submission (verdict: Runtime Error):
k = int(input())

count = 0
q = deque(range(1,10))

while count < k:
    l = q.popleft()
    resid = l % 10
    if resid != 0: q.append(l*10 + resid - 1)

    q.append(l*10 + resid)
    
    if resid != 9: q.append(l*10 + resid + 1)
    
    count += 1

print(q[k-1])

Fixed submission:
from collections import deque

k = int(input())
count = 0
q = deque(range(1,10))

while count < k:
    l = q.popleft()
    resid = l % 10
    if resid != 0: q.append(l*10 + resid - 1)

    q.append(l*10 + resid)
    
    if resid != 9: q.append(l*10 + resid + 1)
    
    count += 1

print(l)

Buggy python submission (verdict: Runtime Error):
K = int(input())

from itertools import product
d = {}
num_list = []
for i in range(10):
    nums = set([min((i-1)%10, i), i, max((i+1)%10, i)])
#     nums = set([i, min(10-(i-1)%10, i),max((i+1)%10, i)])
    nums = [str(el) for el in nums]
    d[i] = list(product([str(i)], list(nums)))
    d[i] = [int(''.join(el)) for el in d[i]]
    d[i] = ['{:02}'.format(el) for el in d[i]]
    
    num_list.extend(d[i])
num_list = sorted(num_list)
dd = [None, None, d, 
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(10)}]

def gen_2ll():
    count = 0
    ret = 0
    while int(ret)!=99:
        if int(ret)< 9 :
            ret += 1
            count += 1
            yield ret
        else:
            for i in range(1,10):
                for ret in d[i]:
                    count += 1
                    yield ret

ll2_list = list(gen_2ll())
                   
def get_digit_top_list(num_digit, top_num):
    ret = dd[num_digit][top_num]
    if ret:
        return ret

    second_nums = sorted(set([min((top_num-1)%10, top_num), top_num, max((top_num+1)%10, top_num)]))    
    for second_num in second_nums:
        rem_nums = get_digit_top_list(num_digit-1, int(second_num))
        for rem_num in rem_nums:
            ll = str(top_num) + rem_num
            ret.append(ll)
    dd[num_digit][top_num] = ret

    
    return ret

def get_ll(K):

def get_kth_ll(K):
    if K<=len(ll2_list):
        print(ll2_list[K-1])
    else:
        K -= len(ll2_list)
        for num_digit in range(3,100):
            for top_num in range(1,10):
                _ll_list = get_digit_top_list(num_digit, top_num)
                if K-len(_ll_list)<0:
                    print(sorted([int(el) for el in _ll_list])[K])
                else:
                    K -= len(_ll_list)
get_kth_ll(K)
                

Fixed submission:
from collections import deque

k = int(input())
count = 0
q = deque(range(1,10))

while count < k:
    l = q.popleft()
    resid = l % 10
    if resid != 0: q.append(l*10 + resid - 1)

    q.append(l*10 + resid)
    
    if resid != 9: q.append(l*10 + resid + 1)
    
    count += 1

print(l)