TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
K = int(input())

dp = [[0 for i in range(10)] for j in range(100)]

for i in range(10):
  dp[1][i] = i
dp[1][0] = 1

p = 1
c = 0
a = 0

while c == 0:
  for n in range(10):
    if n != 0 and n != 9:
      dp[p+1][n] = dp[p][n]+dp[p][n-1]+dp[p][n+1]+dp[p][9]
    if n == 9:
      dp[p+1][n] = dp[p][n]+dp[p][n-1]+dp[p][9]
    if dp[p+1][n] >= K:
      c = dp[p+1][n]
      if a == 1:
        a = n
      break
    
    if n == 0:
      dp[p+1][n] = dp[p][1] + dp[p][0]

s = str(a)
for k in range(p,0,-1):

  if a != 0 and a != 9:
    for j in [1,0,-1]:
      c = c - dp[k][a+j]
      if c < K:
        s = s + str(a+j)
        break
  
  if a == 0:
    for j in [1,0]:
      c = c - dp[k][a+j]
      if c < K:
        s = s + str(a+j)
        break

  if a == 9:
    for j in [0,-1]:
      c = c - dp[k][a+j]
      if c < K:
        s = s + str(a+j)
        break       
print(int(s))

from collections import deque
d = deque([1,2,3,4,5,6,7,8,9])

k = int(input())

cnt = 0
while k > cnt:
  x = d.popleft()
  cnt += 1  
  if x%10 != 0:
  	d.append(x*10+x%10-1)
  d.append(x*10+x%10)
  if x%10 != 9:
    d.append(x*10+x%10+1)
print(x)  

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k=int(input())
x=0
ans=0
for i in range(10**5):
  ans+=1
  l = [int(x) for x in list(str(i))]
  if x==k:
      break
  for j in range(int(len(l))-1):
    if l[j]==l[j+1] or l[j]==l[j+1]+1 or l[j]==l[j+1]-1:
      x+=1
    
print(ans)

k=int(input())
a=list(range(1, 10))
b=[]
n=int(len(a))
x=k
while x>n:
  x-=n
  for i in range(n):
    for l in range(3):
      c=(a[i]%10)-1+l
      if 0<=c<=9:
        a.append((a[i]*10)+c)
  del a[0:n]
print(a[x-1])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

lis = [[0]*12 for _ in range(10)]
lis[9] = [0,3,3,3,3,3,3,3,3,3,2,0]
for i in range(8,-1,-1):
  for j in range(1,11):
    lis[i][j] = lis[i+1][j-1] + lis[i+1][j] + lis[i+1][j+1]

new_lis = [[0]*10 for _ in range(10)]
new_lis[9] = [9,3,3,3,3,3,3,3,3,2]
for i in range(8,-1,-1):
  for j in range(10):
    if j == 0:
      new_lis[i][j] = sum(new_lis[i+1])
    else:
      new_lis[i][j] = lis[i][j]
      
ans = 0
cnt = 0
for i in range(10):
  if ans == 0:
    s,e = 0,9
  else:
    s = max(0,j-1)
    e = min(9,j+1)
  for j in range(s,e+1):
    #print('cnt',cnt)
    if cnt + lis[i][j] >= K:
      
      break
    cnt += lis[i][j]
  #print(ans,j)
  ans += j*10**(10-i)
  #print(ans)

ans += K-cnt+j-2
  

#print(new_lis)
print(ans)
#print(*ans,sep=' ')

K = int(input())

from collections import deque
d = deque()
for i in range(1,10):
  d.append(str(i))

for _ in range(K):
  a = d.popleft()
  #print(a)
  if a[-1] != '0':
    d.append(a+str(int(a[-1])-1))
  d.append(a+a[-1])
  if a[-1] != '9':
    d.append(a+str(int(a[-1])+1))

ans = a
print(ans)
#print(*ans,sep=' ')


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
l = [_ for _ in range(1,10)]

cnt = 9
d = [-1, 0, 1]
for i in range(10**5):
    if cnt >= n: break
    for j in d:
        if 0 <= int(str(l[i])[-1]) + j <= 9:
            l.append(l[i]*10 + l[i][-1] + j)
            cnt += 1

print(l[n-1])


from collections import deque
 
n = int(input())

queue = deque([[1],[2],[3],[4],[5],[6],[7],[8],[9]]) 
ptns = [] 

while queue: 
    tmp = queue.popleft() 
    if len(ptns) < n: 
        ptns.append(tmp)
    else:
        break
 
    if tmp[-1] != 0:
        queue.append(tmp + [tmp[-1] -1])

    queue.append(tmp + [tmp[-1]])

    if tmp[-1] != 9:
        queue.append(tmp + [tmp[-1] +1])


print(''.join(map(str, ptns[-1])))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
ans=0
runrun = 0
i =0
while runrun = K:
    if i < 10:
        runrun +=1
    else:
        a = list(map(int,str(i)))
        for j in range(1,len(a)):
            tmp = 0
            if abs(a[j]-a[j-1])<=1:
                tmp +=1
        if tmp == len(a)-1:
            runrun +=1
            ans = i
    i +=1
print(ans)

                


k=int(input())
cand=[[1,2,3,4,5,6,7,8,9]]
for _ in range(9): 
 tmp=[]
 for val in cand[-1]:
   if val%10!=0: 
     tmp.append(val*10+(val%10-1))
   tmp.append(val*10+(val%10))
   if val%10!=9: 
     tmp.append(val*10+(val%10+1))
 cand.append(tmp)
ans=[]
for i in range(len(cand)):
 for val in cand[i]:
   ans.append(val)
ans=sorted(ans)
print(ans[k-1])

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
num = 0
for _ in range(k):
  num += 1
  digit = [int(digit) for digit in str(num)]
  len_digit = len(digit)
  for i in range(1, len_digit):
    if digit[-i] > min(digit[-i-1] + 1, 9):
      digit[-i-1] += 1
      digit[-i] = -1
    elif digit[-i] < digit[-i-1] - 1:
      digit[-i] = -1
  for i in range(1, len_digit):
    if digit[i] == -1:
      for j in range(i, len_digit):
        digit[j] = max(digit[j-1] - 1, 0)
      break
  num = d[0]
  for d in digit[1:]:
    num = num * 10 + d
print(num)

k = int(input())
num = 0
for _ in range(k):
  num += 1
  digit = list(map(int, str(num)))
  len_digit = len(digit)
  for i in range(1, len_digit):
    if digit[-i] > min(digit[-i-1] + 1, 9):
      digit[-i-1] += 1
      digit[-i] = -1
    elif digit[-i] < digit[-i-1] - 1:
      digit[-i] = -1
  for i in range(1, len_digit):
    if digit[i] == -1:
      for j in range(i, len_digit):
        digit[j] = max(digit[j-1] - 1, 0)
      break
  num = int(''.join(map(str, digit)))
print(num)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
from collections import deque
sys.setrecursionlimit(10**7)
k = int(input())
ans = []
def bfs(que):
    finished = set()
    while que and len(ans) <= 10**6:
        x = que.popleft()
        ans.append(int(x))
        if x not in finished:
            finished.add(x)
            p = int(x[-1])
            que.append(x + str(p))
            if 1 <= p <= 8:
                que.append(x + str(p+1))
                que.append(x + str(p-1))
            elif p == 0:
                que.append(x + str(p+1))
            else:
                que.append(x + str(p-1))
que = deque([])
for i in range(1,10):
    que.append(str(i))
bfs(que)
ans.sort()
print(ans[k-1])

import sys
from collections import deque
sys.setrecursionlimit(10**7)
k = int(input())
ans = []
def bfs(que):
    finished = set()
    while que and len(ans) <= 10**5:
        x = que.popleft()
        ans.append(int(x))
        if x not in finished:
            finished.add(x)
            p = int(x[-1])
            if 1 <= p <= 8:
                que.append(x + str(p-1))
                que.append(x + str(p))
                que.append(x + str(p+1))
            elif p == 0:
                que.append(x + str(p))
                que.append(x + str(p+1))
            else:
                que.append(x + str(p-1))
                que.append(x + str(p))
que = deque([])
for i in range(1,10):
    que.append(str(i))
bfs(que)
ans.sort()
print(ans[k-1])

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
K=int(input())
import queue
a=queue.Queue()
if K<=9:
  print(K)
else:
  for i in range(1,10):
    a.put(i)
  n=K
  while n>1:
    x=a.get()
    if x%10!=0:
      a.put(10*x-1)
    a.put(10*x)
    if x%10!=9:
      a.put(10*x+1)
    n-=1
  ans=a.get()
  print(ans)

K=int(input())
import queue
a=queue.Queue()
if K<=9:
  print(K)
else:
  for i in range(1,10):
    a.put(i)
  n=K
  while n>1:
    p=a.get()
    x=p%10
    if x%10!=0:
      a.put(10*p+x-1)
    a.put(10*p+x)
    if x%10!=9:
      a.put(10*p+x+1)
    n-=1
  ans=a.get()
  print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k=int(input())
list=[1,2,3,4,5,6,7,8,9]
for i in range(k-1):
  m=list[i]
  n=m*10+m%10
  if m%10!=0:
    list.append(m-1)
  list.append(m)
  if m%10!=9:
    list.append(m+1)
print(list[k-1])

k=int(input())
list=[1,2,3,4,5,6,7,8,9]
for i in range(k-1):
  m=list[i]
  n=m*10+m%10
  if m%10!=0:
    list.append(n-1)
  list.append(n)
  if m%10!=9:
    list.append(n+1)
print(list[k-1])
print(list)

k=int(input())
list=[1,2,3,4,5,6,7,8,9]
for i in range(k-1):
  m=list[i]
  n=m*10+m%10
  if m%10!=0:
    list.append(n-1)
  list.append(n)
  if m%10!=9:
    list.append(n+1)
print(list[k-1])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

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)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())

#a = list(map(int, input().split()))
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
    x = q.popleft()
    a = 10*x+(x % 10)
    if x % 10 != 0:
        q.append(a-1)
    q.append(a)
    if x % 10 != 9:
        q.append(a+1)

print(x)

from collections import deque
k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
    x = q.popleft()
    a = 10*x+(x % 10)
    if x % 10 != 0:
        q.append(a-1)
    q.append(a)
    if x % 10 != 9:
        q.append(a+1)

print(x)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
t=sum(a)
a=list(filter(lambda x: math.ceil(t/(4*m)) < x, a))
print('Yes' if m <= len(a) else 'No')


k=int(input())
l=list(map(str,range(1,10)))
for i in range(k):
    x=l[i][-1]
    if x=='0':
        l.append(l[i]+x)
        l.append(l[i]+'1')
    elif x=='9':
        l.append(l[i]+'8')
        l.append(l[i]+x)
    else:
        n=int(x)
        l.append(l[i]+str(n-1))
        l.append(l[i]+x)
        l.append(l[i]+str(n+1))
print(sorted(map(int,l))[k-1])

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
print("yippe")

import queue
k = int(input())
q = [1,2,3,4,5,6,7,8,9]
qq = queue.Queue()
for i in range(1,10):
	qq.put(i)

for i in range(k):
	x = qq.get()
	if x%10 != 0:
		qq.put(10*x + (x%10) -1)
	qq.put(10*x + (x%10))
	if x%10 != 9:
		qq.put(10*x + (x%10) +1)
		
print(x)
		

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k=int(input())
num=0

while k>0:
  num+=1
  snum=str(num)
  flg=0
  for i in range(0,len(snum)-1):
    if abs(int(snum[i])-int(snum[i+i]))>1:
      flg=1
      break
  if flg==0:
    k-=1
print(num)

k=int(input())
num=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
keta=0
for i in range(0,k):
  for j in range(0,len(num)-1):
    if num[j]==-1:
      num[j]=1
      keta=j
      break
    elif num[j]!=9 and (num[j+1]==-1 or (num[j]-num[j+1])<1):
      num[j]+=1
      break
  for x in range(j-1,-1,-1):
    num[x]=max(0,num[x+1]-1)

for i in range(keta,-1,-1):
  print(num[i],end='')
print()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

def cal():
    count = 9
    d = [[1,2,3,4,5,6,7,8,9]]
    for i in range(10**9):
        d_ = []
        for j in range(len(d[i])):
            a = str(d[i][j])
            if a[-1]=="0":
                for k in [0,1]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            elif a[-1]=="9":
                for k in [8,9]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return 
            else:
                for k in [-1, 0, 1]:
                    d_.append(int(a)*10+int(a[-1])+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            d.append(d_)
if k <= 9:
    print(K)
else:
    cal()

K = int(input())

def cal():
    count = 9
    d = [[1,2,3,4,5,6,7,8,9]]
    for i in range(10**9):
        d_ = []
        for j in range(len(d[i])):
            a = str(d[i][j])
            if a[-1]=="0":
                for k in [0,1]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            elif a[-1]=="9":
                for k in [8,9]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return 
            else:
                for k in [-1, 0, 1]:
                    d_.append(int(a)*10+int(a[-1])+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            d.append(d_)
if k <= 9:
    print(k)
else:
    cal()

from collections import deque
k = int(input())
if k <= 9: print(k)
que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
count = 9
while count <= k:
    X = que.popleft()
    if X%10==0: check=[0, 1]
    elif X%10==9: check=[8, 9]
    else: check = [X%10-1, X%10, X%10+1]
    for i in check:
        que.append(X*10+i)
        count += 1
        if count == k:
            print(que[-1])
            exit()

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import heapq
k = int(input())
run_list = [i for i in range(1,10)]
heapq.heapify(run_list)
result = 0
for i in range(k):
  result = heapq.pop(run_list)
  if result % 10 ==0:
    new_1 = result * 10
    new_2 = result * 10 + 1
    heapq.heappush(run_list, new_1)
    heapq.heappush(run_list, new_2)
  elif result % 10 ==9:
    new_1 = result * 10 + 8
    new_2 = result * 10 + 9
    heapq.heappush(run_list, new_1)
    heapq.heappush(run_list, new_2)
  else:
    new_1 = result * 10 + (resut % 10)
    new_2 = result * 10 + (resut % 10) + 1
    new_3 = result * 10 + (resut % 10) - 1
    heapq.heappush(run_list, new_1)
    heapq.heappush(run_list, new_2)
print(result)
    heapq.heappush(run_list, new_3)

import heapq
k = int(input())
run_list = [i for i in range(1,10)]
heapq.heapify(run_list)
result = 0
for i in range(k):
  result = heapq.heappop(run_list)
  if result % 10 ==0:
    new_1 = result * 10
    new_2 = result * 10 + 1
    heapq.heappush(run_list, new_1)
    heapq.heappush(run_list, new_2)
  elif result % 10 ==9:
    new_1 = result * 10 + 8
    new_2 = result * 10 + 9
    heapq.heappush(run_list, new_1)
    heapq.heappush(run_list, new_2)
  else:
    new_1 = result * 10 + (result % 10)
    new_2 = result * 10 + (result % 10) + 1
    new_3 = result * 10 + (result % 10) - 1
    heapq.heappush(run_list, new_1)
    heapq.heappush(run_list, new_2)
    heapq.heappush(run_list, new_3)
print(result)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())
a = []
def dfs(x):
    if x > 3234566667:
        return
    a.append(x)
    for i in range(10):
        if abs(x%10-i) <= 1:
            dfs(x*10+i)

for i in range(1,11):
    dfs(i)
a = sorted(a)
print(a[K-1])

K = int(input())
a = []
def dfs(x):
    if x > 3234566667:
        return
    a.append(x)
    for i in range(10):
        if abs(x%10-i) <= 1:
            dfs(x*10+i)

for i in range(1,10):
    dfs(i)
a = sorted(a)
print(a[K-1])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K = int(read())

pre_lis = []
for i in range(1,10):
    pre_lis.append(str(i))
print(pre_lis)
ct = 9
if K <= 9:
    print(pre_lis[K-1])
else:
    new_lis = []
    flag = False
    while ct < K:
        for num in pre_lis:
            pre_num = int(num[-1])
            for i in range(10):
                if abs(pre_num-i) <= 1:
                    new_lis.append(num + str(i))
                    ct+=1
                    #print((new_lis[-1]))
                    if ct == K:
                        print(new_lis[-1])
                        flag = True
                        break
            pre_lis = new_lis
            if flag:
                break
        if flag:
            break

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K = int(read())

pre_lis = []
for i in range(1,10):
    pre_lis.append(str(i))
    
ct = 9
if K <= 9:
    print(pre_lis[K-1])
else:
    new_lis = []
    flag = False
    while ct < K:
        for num in pre_lis:
            pre_num = int(num[-1])
            for i in range(10):
                if abs(pre_num-i) <= 1:
                    new_lis.append(num + str(i))
                    ct+=1
                    if ct == K:
                        print(new_lis[-1])
                        flag = True
                        break
            pre_lis = new_lis
            if flag:
                break
        if flag:
            break

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# coding: utf-8
DATA = """
100000
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()



def Calc():
	K = [int(i) for i in get_line().strip().split(" ")][0]
	ret = [str(_) for _ in range(1,10)]
	size = len(ret)
	start = 0
	print (ret)
	count = len(ret)
	while(size < K):
		for i in range(start, size):
			v = int(ret[i][-1])
			ll = ret[i]
			if not v == 0:
				count += 1
				ret.append(ll + str(v - 1))
			ret.append(ll + str(v))
			count += 1
			if not v == 9:
				count += 1
				ret.append(ll + str(v+1))

			if count >= K:
				break
		if count >= K:
			break
		start = size
		size = len(ret)
	print (ret[K-1])
Calc()

# coding: utf-8
DATA = """
100000
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

def Calc():
	K = [int(i) for i in get_line().strip().split(" ")][0]
	ret = [str(_) for _ in range(1,10)]
	size = len(ret)
	start = 0
	count = len(ret)
	while(size < K):
		for i in range(start, size):
			v = int(ret[i][-1])
			ll = ret[i]
			if not v == 0:
				count += 1
				ret.append(ll + str(v - 1))
			ret.append(ll + str(v))
			count += 1
			if not v == 9:
				count += 1
				ret.append(ll + str(v+1))

			if count >= K:
				break
		if count >= K:
			break
		start = size
		size = len(ret)
	print (ret[K-1])
Calc()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k=input()
n=len(k)
cnt=9
def lunlun(x):
    flag=True
    x=str(x)
    for num in range(len(x)-1):
        a=x[num]
        b=x[num+1]
        if abs(int(a)-int(b))>1:
            flag=False
            break
    return flag
i=9
if n==1:
    print(k)
else:
    while cnt!=k:
        i+=1
        if lunlun(i):
            cnt+=1
    print(i)


#abc161 d 
k=int(input())

lunlun=[1,2,3,4,5,6,7,8,9]

def lunlun_generate(p):
    last=p%10
    if last-1>=0:
        yield p*10+last-1
    yield p*10+last
    if last+1<=9:
        yield p*10+last+1


p=0
while len(lunlun)<k:
    for new_lunlun in lunlun_generate(lunlun[p]):
        lunlun.append(new_lunlun)
    p+=1
    
print(lunlun[k-1])

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())
queue = []
for i in range(1, 10):
  queue.append(i)

while K != 0:
  num = queue.pop(0)

  if K <= len(queue):
    print(queue[K-1])
    exit(0)
  K -= 1

  if K == 0:
    print(num)
    exit(0)

  o = int(str(num)[-1])
  for n in [o-1, o, o+1]:
    if n == -1 or n == 10: continue
    queue.append( int(str(num)+str(n)) )

from collections import deque

K = int(input())
queue = deque([i for i in range(1,10)])

while K != 0:
  if K <= len(queue):
    print(queue[K-1])
    exit(0)

  K -= 1
  num = queue.popleft()

  o = int(str(num)[-1])
  for n in [o-1, o, o+1]:
    if n == -1 or n == 10: continue
    queue.append( int(str(num)+str(n)) )

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k=int(input())
keta=2
unta=[[]]*10
unta[0]=["1","2","3","4","5","6","7","8","9"]
for _ in range(9):
	for i in range(len(unta[keta-2])):
		if unta[keta-2][i][len(unta[keta-2][i])-1]=="0":
			unta[keta-1].append(("").join(unta[keta-2][i])+"0")
			unta[keta-1].append(("").join(unta[keta-2][i])+"1")
		if unta[keta-2][i][len(unta[keta-2][i])-1]=="9":
			unta[keta-1].append(("").join(unta[keta-2][i])+"8")
			unta[keta-1].append(("").join(unta[keta-2][i])+"9")
		else:
			unta[keta-1].append(("").join(unta[keta-2][i])+str(int(unta[keta-2][i][len(unta[keta-2][i])-1])-1))
			unta[keta-1].append(("").join(unta[keta-2][i])+str(int(unta[keta-2][i][len(unta[keta-2][i])-1])))
			unta[keta-1].append(("").join(unta[keta-2][i])+str(int(unta[keta-2][i][len(unta[keta-2][i])-1])+1))
	keta += 1
unchi=[]
for i in range(10):
	unchi+=unta[i]
print(unchi[k-1])

k=int(input())
unta=[[],[],[],[],[],[],[],[],[],[],[],[]]
unta[1]=["1","2","3","4","5","6","7","8","9"]
for keta in range(2,12):
	for i in range(len(unta[keta-1])):
		if unta[keta-1][i][keta-2]=="0":
			unta[keta].append(unta[keta-1][i]+"0")
			unta[keta].append(unta[keta-1][i]+"1")
		elif unta[keta-1][i][keta-2]=="9":
			unta[keta].append(unta[keta-1][i]+"8")
			unta[keta].append(unta[keta-1][i]+"9")
		else:
			unta[keta].append(unta[keta-1][i]+str(int(unta[keta-1][i][keta-2])-1))
			unta[keta].append(unta[keta-1][i]+unta[keta-1][i][keta-2])
			unta[keta].append(unta[keta-1][i]+str(int(unta[keta-1][i][keta-2])+1))
unchi=[]
for i in range(11):
	unchi+=unta[i]
print(unchi[k-1])

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())
count = 0
lunlun = 0

while count < K:
  #  count =+ 1
  #print(lunlun)
  ketasu = len(str(lunlun))
  lunlun = lunlun + 1
  flag = 0
  if ketasu == 1:
    count = count + 1
  else:
    for i in range(1, ketasu):
      # print((lunlun%(10**(i+1))//(10**i)), (lunlun%(10**i)))
      if abs((lunlun%(10**(i+1))//(10**i))-(lunlun%(10**i))) > 1:
        batsuketa = i
        break
      flag = flag + 1
    if flag == ketasu-1:
      print(lunlun)
      count = count + 1
    elif ((lunlun%(10**(i+1))//(10**i))-(lunlun%(10**i))) > 1:

      lunlun = (lunlun+10**batsuketa) // (10**batsuketa) * (10**batsuketa)

print(lunlun)

K = int(input())
count = 9
lunlun = [1,2,3,4,5,6,7,8,9]
i = 0

while count < K:
  if (lunlun[i]%10) != 0:
    lunlun.append(lunlun[i]*10+lunlun[i]%10-1)
    count = count + 1
  lunlun.append(lunlun[i]*10+lunlun[i]%10)
  count = count + 1
  if (lunlun[i]%10) != 9:
    lunlun.append(lunlun[i]*10+lunlun[i]%10+1)
    count = count+1
  i= i+1
print(lunlun[K-1])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
q = []
for i in range(1, 10):
    q.append(i)
for i in range(k):
    x = q.pop(0)
    if x % 10 != 0:
        q.append(10 * x + x % 10 - 1)
    q.append(10 * x + x % 10)
    if x % 10 != 9:
        q.append(10 * x + x % 10 + 1)
    # print(q)


from collections import deque


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

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

print(x)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import queue
num=int(input())
q=queue.Queue()
for i in range(1,10):
  q.put(i)
for j in range(num):
  ans=q.get()
  if ans%10!=0:
    q.put(10*ans+(ans%10)-1)
  q.put(10*ans+(ans%10)-1)
  if ans%10!=0:
    q.put(10*ans+(ans%10)-1)
print(ans)

import queue
num=int(input())
q=queue.Queue()
for i in range(1,10):
  q.put(i)
for j in range(num):
  ans=q.get()
  if ans%10!=0:
    q.put(10*ans+(ans%10)-1)
  q.put(10*ans+(ans%10))
  if ans%10!=9:
    q.put(10*ans+(ans%10)+1)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
muri

from collections import deque
k = int(input())
ans = 0
num = ["0","1","2","3","4","5","6","7","8","9"]
dq = deque(["1","2","3","4","5","6","7","8","9"])
# print(num[k:k+2])
if k<=12:
    print(k)
else:
    while 1:
        ans += 1
        a = dq.popleft()
        if ans == k:
            print(int(a))
            exit()
        for i in num[max(0,int(a[-1])-1):min(10,int(a[-1])+2)]:
            dq.append(a+i)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import deque

q=deque()

N=int(input())

for i in range(1,10):
  q.append(i)

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

print(q.poplefr())

from collections import deque

q=deque()

N=int(input())

for i in range(1,10):
  q.append(i)

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

print(q.popleft())


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input()) 
 
 lunlun = [i for i in range(1, 10)]
 
 p = 0 

 def generate_lunlun(p):
     last = p % 10
     if last - 1 >= 0:
         yield p * 10 + last - 1
    yield p * 10 + last
    if last + 1 <= 9:
        yield p * 10 + last + 1 

while len(lunlun) < k:
    for new_lunlun in generate_lunlun(lunlun[p]):
        lunlun.append(new_lunlun)
    p += 1

print(lunlun[k-1])

k = int(input()) 
 
lunlun = [i for i in range(1, 10)]
 
p = 0 

def generate_lunlun(p):
    last = p % 10
    if last - 1 >= 0:
        yield p * 10 + last - 1
    yield p * 10 + last
    if last + 1 <= 9:
        yield p * 10 + last + 1 

while len(lunlun) < k:
    for new_lunlun in generate_lunlun(lunlun[p]):
        lunlun.append(new_lunlun)
    p += 1

print(lunlun[k-1])

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import deque

k = int(input())
limit = 10

start = [i for i in range(1, 10)]
ans = []
q=deque(start)
while q:
	num=q.popleft()
	if len(str(num))>11:
		continue
	ans.append(num)
	last=str(num)[-1]
	if last == "0":
		add = ['0', '1']
	elif last == '9':
		add = ['8',"9"] 
	else:
		add = [str(int(last) - 1), str(int(last)), str(int(last) + 1)]
	for i in add:
		q.append(int(str(num)+i))

ans = sorted(ans)
print(ans[k - 1])

from collections import deque

k = int(input())
limit = 10

start = [i for i in range(1, 10)]
ans = []
def DFS(num):
	if len(str(num))>11:
		return 1
	ans.append(num)
	last=str(num)[-1]
	if last == "0":
		add = ['0', '1']
	elif last == '9':
		add = ['8',"9"] 
	else:
		add = [str(int(last) - 1), str(int(last)), str(int(last) + 1)]
	for i in add:
		DFS(int(str(num)+i))

for j in start:
	DFS(j)

ans = sorted(ans)
print(ans[k - 1])

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
a=[]

def dfs(x):
  if x>3234566667:
    return
  a.append(x)
  for i in range(10):
    if abs(x%10-i) <= 1:
      dfs(x%10+i)
      
for i in range(1,10):
  dfs(i)
a =sorted(a)
k=int(input())
print(a[k-1])

a = []

def dfs(x):
    if x > 3234566667:
        return
    a.append(x)
    for i in range(10):
        if abs(x%10-i) <= 1:
            dfs(x*10+i)

for i in range(1, 10):
    dfs(i)
a = sorted(a)
k = int(input())
print(a[k-1])


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import deque
K = int(input()) - 1
todo = deque(range(1, 10))
ans = []
counter = 0
while counter <= K:
    seed = todo.pop(0)
    ans.append(seed)
    counter += 1
    last_dig = int(str(seed)[-1])
    for i in range(max(0, last_dig-1), min(10, last_dig+2)):
        todo.append(int(str(seed) + str(i)))
print(ans[-1])

from collections import deque
K = int(input()) - 1
todo = deque(range(1, 10))
ans = []
counter = 0
while counter <= K:
    seed = todo.pop()
    ans.append(seed)
    counter += 1
    last_dig = int(str(seed)[-1])
    for i in range(max(0, last_dig-1), min(10, last_dig+2)):
        todo.append(int(str(seed) + str(i)))
print(ans[-1])

from collections import deque
K = int(input()) - 1
todo = deque(range(1, 10))
ans = []
counter = 0
while counter <= K:
    seed = todo.popleft()
    ans.append(seed)
    counter += 1
    last_dig = int(str(seed)[-1])
    for i in range(max(0, last_dig-1), min(10, last_dig+2)):
        todo.append(int(str(seed) + str(i)))
print(ans[-1])

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

q = [1,2,3,4,5,6,7,8,9]
i = 0
n = 0
while n < K:
    x = q[i]
    if x % 10 > 0:
        q.append(x * 10 + x - 1)
        n += 1
    q.append(x * 10 + x)
    n += 1
    if x % 10 < 9:
        q.append(x * 10 + x + 1)
        n += 1
    i += 1
print(q[K])

K = int(input())

q = [1,2,3,4,5,6,7,8,9]
i = 0
n = 9
while n < K:
    x = q[i]
    m = x % 10
    if m > 0:
        q.append(x * 10 + m - 1)
        n += 1
    q.append(x * 10 + m)
    n += 1
    if m < 9:
        q.append(x * 10 + m + 1)
        n += 1
    i += 1
print(q[K-1])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())
i = 10
l= 0
lunlunlist = []

while all:
    l += 1 
    lunlunlist.append(l)
    if(l == 9):
        break
    
while all:
    if(len(lunlunlist)>=K):
        break
    i_str = str(i)
    array = list(map(int,i_str))
    j=0
    f=0
    for j in range(len(array)-1):
        if(abs(array[j]-array[j+1])>1):
            f = 1
            break
    if(f==0):
        lunlunlist.append(i)
    i+=1
if(K<=9):
    print(lunlunlist[K-1])
print(lunlunlist,lunlunlist[-1])


import copy
keta_lunlun = [1,2,3,4,5,6,7,8,9]
nexketa_lunlun = []
K = 0
keta = 1
def lunlun_gen(lunlun):
    global K
    global keta_lunlun
    global nexketa_lunlun
    global keta
    if(keta>=10):
        return lunlun
    nexketa_lunlun.clear()
    for i in range(len(keta_lunlun)):
        if(0<keta_lunlun[i]%10<9):
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)-1)
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)  )
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)+1)
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10-1))
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10  ))
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10+1))
          
        elif(keta_lunlun[i]%10 == 9):
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)-1)
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)  )
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10-1))
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10))
        else:
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10))
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)+1)
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10))
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10+1))
    keta_lunlun.clear()
    keta_lunlun.extend(nexketa_lunlun)
    keta +=1
    return lunlun_gen(lunlun)

def main():
    global K
    K = int(input())
    lunlun = [1,2,3,4,5,6,7,8,9]
    ans = lunlun_gen(lunlun)
    print(ans[K-1])

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import deque

k = int(input())
q = deque([1,2,3,4,5,6,7,8,9])

for i in range(1,k):
    l = q.popleft()
    m = l % 10
    if (m != 0):
        q.append(l * 10 + m - 1)
    q.append(l * 10 + m)
    if (m != 9):
        q.append(l * 10 + m + 1)

print(q.pop())

from collections import deque

k = int(input())
q = deque([1,2,3,4,5,6,7,8,9])

for i in range(1,k):
    l = q.popleft()
    if (len(q) < k):
        m = l % 10
        if (m != 0):
            q.append(l * 10 + m - 1)
        q.append(l * 10 + m)
        if (m != 9):
            q.append(l * 10 + m + 1)

print(q.popleft())

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys

passed = set()

def check(x, y):
    if x == y:
        return True
    z = abs(x - y)
    return True if z <= 1 else False

def lunlun(x):
    sx = str(x)
    ix = x
    for i in range(len(sx) - 1):
        if ix in passed:
            return True
        if check(int(sx[0]), int(sx[1])):
            ix = ix - (int(sx[0] * (10 ** (len(sx) - 1))))
            sx = str(ix)
        else:
            return False
        return True

K = int(sys.stdin.readline().rstrip())

i = 0
x = 0
while i < K:
    x += 1
    if lunlun(x):
        i += 1
        passed.add(x)

print(x)


import sys
from collections import deque

K = int(sys.stdin.readline().rstrip())

deq = deque(range(9, 0, -1))
enqueue = deq.appendleft
dequeue = deq.pop

for _ in range(K):
	x = dequeue()
	y = x % 10
	if y != 0:
		enqueue(x * 10 + y - 1)
	enqueue(x * 10 + y)
	if y != 9:
		enqueue(x * 10 + y + 1)
print(x)


Verdicts: Wrong Answer

Accepted