Buggy python submission (verdict: Time Limit Exceeded):
import sys

def JudgeLunLun(num):
  val = num
  next = 0
  if num <= 12:
    val = num
  else:
    # 真面目なルンルン数判定。配列に1文字ずつ格納して全桁ループ処理して判定
    # 加算処理に備えて文字として扱う
    A = list(str(num))
    for i in range(len(A)-1):
      if abs(int(A[i])-int(A[i+1])) > 1:
        val = 0
        head = ''.join(A[:i+1])
        body = str(int(A[i+1]) +1)
        tail = '0' * (len(A) - (i+2))
        if body == '10':
          head = str(int(head)+1)
          body = '0'
        # 編集後の値を結合して数値変換して返す
        next = int(head+body+tail)
  
  return val, next

def main():
  K = int(input())
  cnt = 0
  i = 1
  while cnt < K:
    val, next = JudgeLunLun(i)
    # ルンルン数判定
    if val > 0:
      i += 1
      cnt += 1
      if cnt == K:
        break
    else:
      i = next
    
  print(val)

if __name__ == '__main__':
  main()


Fixed submission:
import sys

def JudgeLunLun(num):
  val = num
  next = 0
  if num <= 12:
    val = num
  else:
    # 真面目なルンルン数判定。文字列に変換して1桁毎の処理を行う。
    # 加算処理に備えて文字として扱う
    A = str(num)
    for i in range(len(A)-1):
      if abs(int(A[i])-int(A[i+1])) > 1:
        val = 0
        # A[i+1]が大きい時は、A[i]をカウントアップするしかない。
        if int(A[i]) < int(A[i+1]):
          head = str(int(A[:i+1])+1)
          body = '0'
          tail = '0' * (len(A) - (i+2))
        else:
          if int(A[i]) - int(A[i+1]) > 2:
            head = A[:i+1]
            body = str(int(A[i]) -1)
            tail = '0' * (len(A) - (i+2))            
          else:
            head = A[:i+1]
            body = str(int(A[i+1]) +1)
            tail = '0' * (len(A) - (i+2))
            if body == '10':
              head = str(int(head)+1)
              body = '0'
        
        # 編集後の値を結合して数値変換して返す
        next = int(head+body+tail)
  
  return val, next

def main():
  K = int(input())
  cnt = 0
  i = 1
  while cnt < K:
    val, next = JudgeLunLun(i)
    # ルンルン数判定
    if val > 0:
      i += 1
      cnt += 1
      if cnt == K:
        break
    else:
      i = next
    
  print(val)

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def JudgeLunLun(num):
  val = num
  if num <= 12:
    val = num
  else:
    # 真面目なルンルン数判定。配列に1文字ずつ格納して全桁ループ処理して判定
    A = [int(x) for x in list(str(num))]
    for i in range(len(A)-1):
      if abs(A[i]-A[i+1]) > 1:
        val = 0
        break
  return val

def main():
  K = int(input())
  cnt = 0
  for i in range(1, sys.maxsize):
    num = JudgeLunLun(i)
    # ルンルン数判定
    if num > 0:
      cnt += 1
    if cnt == K:
      break
  print(num)

if __name__ == '__main__':
  main()

Fixed submission:
import sys

def JudgeLunLun(num):
  val = num
  next = 0
  if num <= 12:
    val = num
  else:
    # 真面目なルンルン数判定。文字列に変換して1桁毎の処理を行う。
    # 加算処理に備えて文字として扱う
    A = str(num)
    for i in range(len(A)-1):
      if abs(int(A[i])-int(A[i+1])) > 1:
        val = 0
        # A[i+1]が大きい時は、A[i]をカウントアップするしかない。
        if int(A[i]) < int(A[i+1]):
          head = str(int(A[:i+1])+1)
          body = '0'
          tail = '0' * (len(A) - (i+2))
        else:
          if int(A[i]) - int(A[i+1]) > 2:
            head = A[:i+1]
            body = str(int(A[i]) -1)
            tail = '0' * (len(A) - (i+2))            
          else:
            head = A[:i+1]
            body = str(int(A[i+1]) +1)
            tail = '0' * (len(A) - (i+2))
            if body == '10':
              head = str(int(head)+1)
              body = '0'
        
        # 編集後の値を結合して数値変換して返す
        next = int(head+body+tail)
  
  return val, next

def main():
  K = int(input())
  cnt = 0
  i = 1
  while cnt < K:
    val, next = JudgeLunLun(i)
    # ルンルン数判定
    if val > 0:
      i += 1
      cnt += 1
      if cnt == K:
        break
    else:
      i = next
    
  print(val)

if __name__ == '__main__':
  main()