Buggy python submission (verdict: Runtime Error):
## 解説をみての答え
from collections import deque

q = deque(range(1,10))
K = int(input())

for i in range(K):
    x = q.popleft()
    r =  x % 10
    if r != 0:
        q.append((10 * x) + (r - 1))
    q.append((10 * x) + r)
    if r != 9:
        q.put((10 * x) + (r + 1))

print(x)

Fixed submission:
from collections import deque

q = deque(range(1,10))
K = int(input())

for i in range(K):
    x = q.popleft()
    r =  x % 10
    if r != 0:
        q.append((10 * x) + (r - 1))
    q.append((10 * x) + r)
    if r != 9:
        q.append((10 * x) + (r + 1))

print(x)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
cnt = 10
i = 10
lunlun_nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
if cnt > K:
    output = K
else :
    while cnt < K:
        i += 1
        if i//10 in lunlun_nums:
            num = list(map(int,[l for l in str(i)]))
            if abs(num[-2] - num[-1]) <= 1:
                lunlun_nums.add(i)
                cnt += 1
    output = i
print(output)


Fixed submission:
from collections import deque

q = deque(range(1,10))
K = int(input())

for i in range(K):
    x = q.popleft()
    r =  x % 10
    if r != 0:
        q.append((10 * x) + (r - 1))
    q.append((10 * x) + r)
    if r != 9:
        q.append((10 * x) + (r + 1))

print(x)

Buggy python submission (verdict: Time Limit Exceeded):
# def lunlunChecker(N):
#   num = list(map(int,[l for l in str(N)]))
#    flag = True
#   for n in range(len(num)-1):
#       if abs(num[n]-num[n+1]) > 1:
#           flag = False
#           break
#   return flag
    
K = int(input())
cnt = 10
i = 10
lunlun_nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
if cnt > K:
    output = lunlun_nums.index(K) + 1
else :
    while cnt < K:
        i += 1
        if i//10 in lunlun_nums:
            num = list(map(int,[l for l in str(i)]))
            if abs(num[-2] - num[-1]) <= 1:
                lunlun_nums.append(i)
                cnt += 1
    output = i
print(output)


Fixed submission:
from collections import deque

q = deque(range(1,10))
K = int(input())

for i in range(K):
    x = q.popleft()
    r =  x % 10
    if r != 0:
        q.append((10 * x) + (r - 1))
    q.append((10 * x) + r)
    if r != 9:
        q.append((10 * x) + (r + 1))

print(x)

Buggy python submission (verdict: Time Limit Exceeded):
def lunlunChecker(N):
    num = list(map(int,[l for l in str(N)]))
    flag = True
    for n in range(len(num)-1):
        if abs(num[n]-num[n+1]) > 1:
            flag = False
            break
    return flag
    
K = int(input())
cnt = 10
i = 10
lunlun_nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
if cnt > K:
    output = lunlun_nums.index(K) + 1
else :
    while cnt < K:
        i += 1
        if i//10 in lunlun_nums:
            if lunlunChecker(i):
                lunlun_nums.append(i)
                cnt += 1
    output = i
print(output)


Fixed submission:
from collections import deque

q = deque(range(1,10))
K = int(input())

for i in range(K):
    x = q.popleft()
    r =  x % 10
    if r != 0:
        q.append((10 * x) + (r - 1))
    q.append((10 * x) + r)
    if r != 9:
        q.append((10 * x) + (r + 1))

print(x)

Buggy python submission (verdict: Time Limit Exceeded):
def lunlunChecker(N):
    num = list(map(int,[l for l in str(N)]))
    flag = True
    for n in range(len(num)-1):
        if abs(num[n]-num[n+1]) > 1:
            flag = False
            break
    return flag
    
K = int(input())
cnt = 0
i = 0
lunlun_nums = []
while cnt < K:
    i += 1
    if lunlunChecker(i):
        lunlun_nums.append(i)
        cnt += 1

print(i)


Fixed submission:
from collections import deque

q = deque(range(1,10))
K = int(input())

for i in range(K):
    x = q.popleft()
    r =  x % 10
    if r != 0:
        q.append((10 * x) + (r - 1))
    q.append((10 * x) + r)
    if r != 9:
        q.append((10 * x) + (r + 1))

print(x)