Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

a = [9,8,7,6,5,4,3,2,1]
current_str = ''

for i in range(k):
  current_str = str(a.pop())
  candidates = []

  if current_str[-1] == "0":
    cp = current_str + "0"
    cp1 = current_str + "1"

    candidates.append(int(cp))
    candidates.append(int(cp1))
  elif current_str[-1] == "9":
    cp = current_str + "8"
    cp1 = current_str + "9"
    
    candidates.append(int(cp))
    candidates.append(int(cp1))
  else:
    cp = current_str + str(int(current_str[-1]) - 1)
    cp1 = current_str + current_str[-1]
    cp2 = current_str + str(int(current_str[-1]) + 1)

    candidates.append(int(cp))
    candidates.append(int(cp1))
    candidates.append(int(cp2))
    

  for c in candidates:
    a.insert(0, c)

print(current_str)

Fixed submission:
from collections import deque

k = int(input())

a = deque([9,8,7,6,5,4,3,2,1])
current_num = 0

for i in range(k):
  current_num = a.pop()
  current_str = str(current_num)
  current_last = int(current_str[-1])

  up = ""  
  mid = current_str + str(current_last)
  down = ""

  if current_last >= 0 and current_last <= 8:
    up = current_str + str(current_last + 1)

  if current_last >= 1 and current_last <= 9:
    down = current_str + str(current_last - 1)
  
  if len(down) != 0:
    a.appendleft(down)

  a.appendleft(mid)

  if len(up) != 0:
    a.appendleft(up)

print(current_num)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

a = [9,8,7,6,5,4,3,2,1]
current_str = ''

for i in range(k):
  current_str = str(a.pop())
  current = list(current_str)
  candidates = []

  if current[-1] == "0":
    cp = current.copy()
    cp1 = current.copy()
    
    cp.append("0")
    cp1.append("1")

    candidates.append(int(''.join(cp)))
    candidates.append(int(''.join(cp1)))
  elif current[-1] == "9":
    cp = current.copy()
    cp1 = current.copy()
    
    cp.append("8")
    cp1.append("9")

    candidates.append(int(''.join(cp)))
    candidates.append(int(''.join(cp1)))
  else:
    cp = current.copy()
    cp1 = current.copy()
    cp2 = current.copy()

    cp.append(str(int(current[-1]) - 1))
    cp1.append(str(int(current[-1])))
    cp2.append(str(int(current[-1]) + 1))

    candidates.append(''.join(cp))
    candidates.append(''.join(cp1))
    candidates.append(''.join(cp2))
    

  for c in candidates:
    a.insert(0, int(c))

print(current_str)

Fixed submission:
from collections import deque

k = int(input())

a = deque([9,8,7,6,5,4,3,2,1])
current_num = 0

for i in range(k):
  current_num = a.pop()
  current_str = str(current_num)
  current_last = int(current_str[-1])

  up = ""  
  mid = current_str + str(current_last)
  down = ""

  if current_last >= 0 and current_last <= 8:
    up = current_str + str(current_last + 1)

  if current_last >= 1 and current_last <= 9:
    down = current_str + str(current_last - 1)
  
  if len(down) != 0:
    a.appendleft(down)

  a.appendleft(mid)

  if len(up) != 0:
    a.appendleft(up)

print(current_num)

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

a = [9,8,7,6,5,4,3,2,1]
current_str = ''

for i in range(k):
  current_str = str(a.pop())
  current = list(current_str)
  candidates = []

  if current[-1] == "0":
    cp = current.copy()
    cp1 = current.copy()
    
    cp.append("0")
    cp1.append("1")

    candidates.append(int(''.join(cp)))
    candidates.append(int(''.join(cp1)))
  elif current[-1] == "9":
    cp = current.copy()
    cp1 = current.copy()
    
    cp.append("8")
    cp1.append("9")

    candidates.append(int(''.join(cp)))
    candidates.append(int(''.join(cp1)))
  else:
    cp = current.copy()
    cp1 = current.copy()
    cp2 = current.copy()

    cp.append(str(int(current[-1]) - 1))
    cp1.append(str(int(current[-1])))
    cp2.append(str(int(current[-1]) + 1))

    candidates.append(''.join(cp))
    candidates.append(''.join(cp1))
    candidates.append(''.join(cp2))
    

  for c in candidates:
    a.insert(0, int(c))

print(current_str)

Fixed submission:
from collections import deque

k = int(input())

a = deque([9,8,7,6,5,4,3,2,1])
current_num = 0

for i in range(k):
  current_num = a.pop()
  current_str = str(current_num)
  current_last = int(current_str[-1])

  up = ""  
  mid = current_str + str(current_last)
  down = ""

  if current_last >= 0 and current_last <= 8:
    up = current_str + str(current_last + 1)

  if current_last >= 1 and current_last <= 9:
    down = current_str + str(current_last - 1)
  
  if len(down) != 0:
    a.appendleft(down)

  a.appendleft(mid)

  if len(up) != 0:
    a.appendleft(up)

print(current_num)