Problem:


Score : 400 points

Problem Statement

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.

Constraints

1 \leq K \leq 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

K

Output

Print the answer.

Sample Input 1

15

Sample Output 1

23

We will list the 15 smallest lunlun numbers in ascending order:

1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
21,
22,
23.

Thus, the answer is 23.

Sample Input 2

1

Sample Output 2

1

Sample Input 3

13

Sample Output 3

21

Sample Input 4

100000

Sample Output 4

3234566667

Note that the answer may not fit into the 32-bit signed integer type.



Sample input:
15


Sample output:
23

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
K = int(input())
l = [None]*26

def getRun(num):
    pre = num%10
    for i in range(1,6):
        k = 10**i
        val = num//k
        if val==0:
            return True
        if abs(pre-val)>1:
            return False
        pre = val
cnt = 0
for i in range(10,100):
    if getRun(i):
        l[cnt] = str(i)
        cnt += 1

if K<=9:
    print(K)
elif K<=26:
    print(l)
    print(l[K-10])
    exit()
L = ['00','01']
l = L+l

new_dp = [None]*10
for i in l:
    d = int(i)//10
    if new_dp[d]!=None:
        new_dp[d].append(i)
    else:
        new_dp[d] = [i]

cnt = 26

def CNT(cnt,I,L):
    leng = len(L)
    T = [None]*leng
    for i in range(leng):
        T[i] = I+L[i]
        if I!='0':
            cnt += 1
        # else:
        #     if T[i]=='0'*10:
        #         ans = 10*9
        #         for _ in range(9):
        #             if ans==K:
        #                 print(ans)
        #                 exit()
        #             ans+=1
        #             cnt+=1
        if cnt==K-9:
            print(T[i])
            exit()
    return cnt,T

for i in range(10):
    tmp = [None]*10
    #先頭につける数
    for j in range(10):
        m = j-1
        J = j
        M = j+1
        #Jを先頭につけて追加
        if not m<0:
            if tmp[j] is not None:
                cnt,T = CNT(cnt,str(j),new_dp[m])
                tmp[j] += T
            else:
                cnt,T = CNT(cnt,str(j),new_dp[m])
                tmp[j] = T
        if tmp[j] is not None:
            cnt,T = CNT(cnt,str(j),new_dp[J])
            tmp[j] += T
        else:
            cnt,T = CNT(cnt,str(j),new_dp[J])
            tmp[j] = T
        if not M>9:
            if tmp[j] is not None:
                cnt,T = CNT(cnt,str(j),new_dp[M])
                tmp[j] += T
            else:
                cnt,T = CNT(cnt,str(j),new_dp[M])
                tmp[j] = T

    new_dp = tmp

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
k = int(input())
dp = [[0] * 10 for _ in range(20)] 
dp[0] = [1] * 10
dp[0][0] = 0
ind = 0
s = 0
for i in range(0, 20):
	ind = i
	for j in range(1, 9):
		dp[i + 1][j - 1] += dp[i][j]
		dp[i + 1][j] += dp[i][j]
		dp[i + 1][j + 1] += dp[i][j]
	dp[i + 1][0] += dp[i][0]
	dp[i + 1][1] += dp[i][0]
	dp[i + 1][9] += dp[i][9]
	dp[i + 1][8] += dp[i][9]
	if s + sum(dp[i + 1]) >= k:
		break
	s += sum(dp[i + 1])
d = []
t = 0
for x in range(ind + 1):
	t += sum(dp[x])
k -= t
for i in range(ind + 1, -1, -1):
	cnt = 0
	sm = 0
	for j in range(10):
		if sm + dp[i][j] < k:
			sm += dp[i][j]
			cnt += 1
		else:
			break
	d.append(cnt)
	k -= sm
print(*d, sep='')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def solve(K):
    d = defaultdict(list)
    '''
    d[0] = ["00", "10"]
    d[1] = ["01", "11", "21"]
    d[2] = ["12", "22", "32"]
    d[3] = ["23", "33", "43"]
    d[4] = ["34", "44", "54"]
    d[5] = ["45", "55", "65"]
    d[6] = ["56", "66", "76"]
    d[7] = ["67", "77", "87"]
    d[8] = ["78", "88", "98"]
    d[9] = ["89", "99"]        
    '''
    d[0] = ["00", "01", "10", "11", "12"]
    d[1] = ["00", "01", "10", "11", "12", "21", "22", "23"]
    d[2] = ["10", "11", "12", "21", "22", "23", "32", "33", "34"]
    d[3] = ["21", "22", "23", "32", "33", "34", "43", "44", "45"]
    d[4] = ["32", "33", "34", "43", "44", "45", "54", "55", "56"]
    d[5] = ["43", "44", "45", "54", "55", "56", "65", "66", "67"]
    d[6] = ["54", "55", "56", "65", "66", "67", "76", "77", "78"]
    d[7] = ["65", "66", "67", "76", "77", "78", "87", "88", "89"]
    d[8] = ["76", "77", "78", "87", "88", "89", "98", "99"]
    d[9] = ["87", "88", "89", "98", "99"]

    initial = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 21, 22, 23, 32, 33,
               34, 43, 44, 45, 54, 55, 56, 65, 66, 67, 76, 77, 78, 87, 88, 89, 98, 99]
    if K < len(initial):
        print(initial[K])
        return

    counter = len(initial)
    while True:
        new_adj = defaultdict(list)
        for i in range(0, 10):
            for j in d[i]:  # 最初の文字がiのとき
                n = (str(i)+j)
                if(n[0]!="0"):
                    counter += 1
                print(n)
                if counter == K:
                    print(n)
                    return

                new_adj[i].append(n)
                if i != 0:
                    new_adj[i-1].append(n)
                if i != 9:
                    new_adj[i+1].append(n)

        d = new_adj
K = int(input())
solve(K)
#solve(100000)
#print(3234566667)

Submission status: Wrong Answer

Solution code:
K=int(input())
x=[[0] for _ in range(11)]
y=[ 0 for _ in range(11)]

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

for i in range(2,11):
  x[i].pop()
  for num in x[i-1]:
    last = num%10
    if last==0:
      x[i].append(10*num)
      x[i].append(10*num+1)
      y[i] +=2
    elif last==9:
      x[i].append(10*num+8)
      x[i].append(10*num+9)
      y[i] +=2
    else:
      x[i].append(10*num+(last-1))
      x[i].append(10*num+last)
      x[i].append(10*num+(last+1))
      y[i] +=3
      
#print(y)
#print(sum(y))

z=[0,y[1]]
for i in range(2,11):
 z.append(z[-1]+y[i])
#print(z)

maxi=0
for r in range(11):
  if z[r]<=K:
    maxi=max(maxi,r)
    
keta=maxi+1
#print(K-y[maxi])
print(x[keta][K-y[maxi]-1])

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    K = II()
    if K <= 10:
            print(K)
            return
    x = [0]
    x = [0,1]
    for _ in range(K-10):
        # print(x)
        c = 1
        for j in range(len(x)):
            if c == 0:
                break
            x[j] += 1
            c = x[j] // 10
            x[j] %= 10
        if c == 1:
            x.append(1)


        for i in range(1,len(x)):
            d = x[i] - x[i-1]
            if d < -1:
                c = 1
                for j in range(i,len(x)):
                    if c == 0:
                        break
                    x[j] += 1
                    c = x[j] // 10
                    x[j] %= 10
                if c == 1:
                    x.append(1)
                for j in range(i,0,-1):
                    x[j-1] = min(x[j] - 1,0)
            elif d > 1:
                x[i-1] = x[i] - 1

    
    ans = 0
    # print(x)
    for i in x[::-1]:
        ans *= 10
        ans += i
    print(ans)
    

    
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# from sys import stdin
import sys
global cnt1


def bts(A, cnt, max):
    # print(A)
    if cnt == max:
        global cnt1
        cnt1 = cnt1+1
        if cnt1 == K:
            print(A)
            sys.exit()
        return
    cnt = cnt+1
    if A % 10 == 0:
        bts(A*10+(A % 10), cnt, max)
        bts(A*10+(A % 10)+1, cnt, max)
    elif A % 10 == 9:
        bts(A*10+(A % 10)-1, cnt, max)
        bts(A*10+(A % 10), cnt, max)
    else:
        bts(A*10+(A % 10)-1, cnt, max)
        bts(A*10+(A % 10), cnt, max)
        bts(A*10+(A % 10)+1, cnt, max)


K = int(input())
# print(K)
N = 9
A = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# global cnt1
cnt1 = 9
for i in range(len(A)):
    bts(A[i], 1, 100)
# print(cnt1)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

x = 10
while True:
#for i in range(10, 10**5):
    temp = list(map(int,list(str(x))))
    for j in range(len(temp)-1):
        if abs(temp[j] - temp[j+1]) <= 1:
            l.append(x)
    if len(l) == 100000:
        break
    else:
        x += 1

#print(l)

print(l[k-1])

Submission status: Wrong Answer

Solution code:
K = int(input())
A = [1,2,3,4,5,6,7,8,9,10]
for i in range(len(A)):
    if A[i] % 10 == 0:
        A.append(100)
        A.append(101)
    elif A[i] != 9:
        for j in range(-1,2):
            a = int(str(A[i]) + str(A[i]+j))
            A.append(a)
    else:
        A.append(98)
        A.append(99)
L1 = len(A.copy())
for i in range(10,L1):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L2 = len(A.copy())
for i in range(L1,L2):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B%10) + j))
            A.append(a)
L3 = len(A.copy())
for i in range(L2,L3):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L4 = len(A.copy())
for i in range(L3,L4):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L5 = len(A.copy())
for i in range(L4,L5):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L6 = len(A.copy())
for i in range(L5,L6):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L7 = len(A.copy())
for i in range(L6,L7):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L8 = len(A.copy())
for i in range(L7,L8):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
A = sorted(A)
# print(A)
print(A[K-1])

Submission status: Wrong Answer

Solution code:
import math

def runrun(x):
    number_list = []
    while True:
        if x<10:
            low_number = x - (x//10)*10
            number_list.append(low_number)
            x = x//10
            break
        low_number = x - (x//10)*10
        number_list.append(low_number)
        x = x//10

    for i in range(len(number_list)-1):
        if abs(number_list[i]-number_list[i+1])>1:
            return False

    return True

first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

K = first_input[0]
count = 0
number = 1

while True:
    if number%1000==1:
        if runrun(number//1000)==False:
            number = number+1000
            continue
    if runrun(number):
        count = count+1
    if count==K:
        print(number)
        break
    number = number+1

Submission status: Wrong Answer

Solution code:
K = int(input())
n=10
if K < 10:
  print(K)
else:
  K-=10
  if ((10+9*((K-1)//3)+K-1-((K-1)//3))) // 10 == n:
    num = (10+9*((K-1)//3)+K-1-((K-1)//3) )+1
    n = n*10
  else:
    num = 10+9*(K//3)+K-(K//3)
  print(num)

Submission status: Wrong Answer

Solution code:
lst=list(range(10))
for i in range(10):
    if i==0:
        lst.append(10)
        lst.remove(0)
    elif i==1:
        lst.append(11)
        lst.append(21)
    elif i==9:
        lst.append(89)
        lst.append(99)
    else:
        lst.append((i-1)*10+i)
        lst.append(i*10+i)
        lst.append((i+1)*10+i)

for k in range(2,10):
    lst2=lst+[]
    for i in lst2:
        j=i//(10**(k-1))
        if j==0:
            jj=str(i)[0]
            if jj=='1':
                lst.append(10**k+i)
        elif j==1:
            lst.append(10**k+i)
            lst.append(2*10**k+i)
        elif j==9:
            lst.append(8*10**k+i)
            lst.append(9*10**k+i)
        else:
            lst.append((j-1)*10**k+i)
            lst.append(j*10**k+i)
            lst.append((j+1)*10**k+i)

lst.sort()

K=int(input())
print(lst[K-1])

Submission status: Wrong Answer

Solution code:
# coding: utf-8

K = int(input())

def Is_runrun(n):
    n = str(n)
    return not(any([abs(int(i1)-int(i2)) <= 1 for i1, i2 in zip(n[:-1], n[1:])]))

if K <= 9:
    print(K)
else:
    K -= 9
    n = 10
    runruns = []
    while len(runruns) != K:
        if Is_runrun(n):
            runruns.append(n)
        n += 1
            
    print(runruns[-1])

Submission status: Wrong Answer

Solution code:
K = int(input())
count = 0
num = 1
while count < K:
    for i in range(len(str(num))):
        if len(str(num)) == 1:
            count += 1
        elif abs(int(str(num)[i-1]) - int(str(num)[i])) <= 1 and i>= 1:
            count += 1
    num += 1
print(num-1)

Submission status: Wrong Answer

Solution code:
S = int(input())
b=0
if S<10:
    print(S)
elif S<36:
    number=9
    for i in range(10,2**32,1):
        if number==S:
            print(i-1)
            break
        s=str(i)
        a=1
        for j in range(len(s)-1):
            if abs(int(s[j])-int(s[j+1]))>1:
                a=0
                break
        if a==1:
            number+=1
elif S<110:
    number=36
    for i in range(100,2**32,1):
        if number==S:
            print(i-1)
            break
        s=str(i-1)
        a=1
        for j in range(len(s)-1):
            if abs(int(s[j])-int(s[j+1]))>1:
                a=0
                break
        if a==1:
            number+=1
elif S<327:
    number=110
    for i in range(1000,2**32,1):
        if number==S:
            print(i-1)
            break
        s=str(i)
        a=1
        for j in range(len(s)-1):
            if abs(int(s[j])-int(s[j+1]))>1:
                a=0
                break
        if a==1:
            number+=1
elif S<544:
    number=327
    for i in range(10000,2**32,1):
        if number==S:
            print(i-1)
            break
        s=str(i)
        a=1
        for j in range(len(s)-1):
            if abs(int(s[j])-int(s[j+1]))>1:
                a=0
                break
        if a==1:
            number+=1
elif S<2370:
    number=544
    for i in range(100000,2**32,1):
        if number==S:
            print(i-1)
            break
        s=str(i)
        a=1
        for j in range(len(s)-1):
            if abs(int(s[j])-int(s[j+1]))>1:
                a=0
                break
        if a==1:
            number+=1
else :
    number=2370
    for i in range(1000000,2**32,1):
        if number==S:
            print(i-1)
            break
        s=str(i)
        a=1
        for j in range(len(s)-1):
            if abs(int(s[j])-int(s[j+1]))>1:
                a=0
                break
        if a==1:
            number+=1

Submission status: Wrong Answer

Solution code:
def d():
    k = int(input())

    val = 0
    hits = 0
    hit_tails = {}
    while hits < k:
        val += 1
        if len(str(val)) == 1:
            hits += 1
            hit_tails[val] = int(str(val)[-1])
            # print('====', hits, val)
            pass
        else:
            lst = list(map(int, str(val)))
            for i in range(len(lst) - 1):
                if lst[i] > lst[i+1] + 1:
                    lst[i+1] = lst[i] - 2
                    if(i < len(lst) - 2):
                        lst[i+2:] = [9] * (len(lst) - 2)
                    val = int(''.join(map(str, lst)))
                    break
                elif lst[i] < lst[i+1] - 1:
                    lst[i+1:] = [9] * (len(lst) - 1)
                    val = int(''.join(map(str, lst)))
                    break
                elif i == len(lst) - 2:
                    hits += 1
                    hit_tails[val] = int(str(val)[-1])
                    # print('====', hits, val)
                    pass

    print(val)


##########
if __name__ == "__main__":
    d()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import itertools

lunlun = [[] for i in range(11)]

def main():
    n = int(input())
    for i in range(100):
        flag = True
        l = len(str(i))
        if l == 1:
            lunlun[l - 1].append(i)
        else:
            for a in range(1, len(str(i))):
                if len(lunlun) > n:
                    print(lunlun[n])
                    exit()
                elif abs(int(str(i)[a - 1]) - int(str(i)[a])) >= 2:
                    flag = False
                    break
            if flag:
                lunlun[l - 1].append(i)
            else:
                continue
    for j in range(1, 9):
        for a in lunlun[j]:
            for b in range(10):
                if abs(int(str(a)[-1]) - b) < 2:
                    lunlun[j+1].append(int(str(a)+str(b)))
    lunlun2 = list(itertools.chain.from_iterable(lunlun))
    print(lunlun2[n])

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
k = int(input())

count_1 = 9
max_i = 10
ans = 0

while True:
  base = [1]*10
  base_1 = [0]*10
  j = 1
  sign = 0
  count = count_1
  while count < k:
    j = j+1
    for i in range(0,10):
      if i == 0:
        base_1[i] = base[1] + base[0]
    
      elif i == 1:
        base_1[i] = base[1] + base[2] + base[0]
    
      elif (2<=i) and (i<=8):
        base_1[i] = base[i-1] + base[i] + base[i+1]
  
      elif i == 9:
        base_1[i] = base[9] + base[8]
    
      base_1 = base
   
      if i != 0:
        count = count + base_1[i]
  
      if count >= k:
        ans = j * 10**(max_i - 1) + ans
        max_i = i
        sign = 1
        break 
      
    if sign == 1:  
      count_1 = count - base_1[max_i]
      
  if max_i == 1:
    break
        
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
m=[[]for j in range(12)]
for j in range(1,10):
    m[0].append(j)
def plus(x):
    for i in range(len(m[x])):
        a=m[x][i]
        b=str(a)
        c=len(b)
        k=int(b[-1])
        if b[-1]=='0':
            d=10*a+1
            e=10*a
            m[x+1].append(d)
            m[x+1].append(e)
        if b[0]=='9':
            d=10*a+9
            e=10*a+8
            m[x+1].append(d)
            m[x+1].append(e)
        else:
            d=10*a+k-1
            e=10*a+k
            f=10*a+k+1
            m[x+1].append(d)
            m[x+1].append(e)
            m[x+1].append(f)
if n<=9:
    exit()
n-=9
i=0
while True:
    plus(i)
    if n>=len(m[i+1]):
        n-=len(m[i+1])
        i+=1
    else:
        i+=1
        break
nn=sorted(m[i])
print(m[i][n-1])

Submission status: Wrong Answer

Solution code:
k = int(input())
listA = [1,2,3,4,5,6,7,8,9,10,11,12]
# k = int("1")
n = 1
z = 12

q = k // z
mod = k % z
if q == 0:
    print(str(listA[mod - 1]))
else:
    print(str(q + 1)+ str(listA[mod - 1]))

# for i in range(k):

# print([1,2,3,4,5,6,7,8,9,10,11,12,21,22,23,24,25,26,27,28,29,210,211,212][int(input()) - 1])

Submission status: Wrong Answer

Solution code:
K = int(input())  #数字

if K <= 12:
    print(K)
    exit()

num = 13
cou = 12
cal = 1
while cou < K:
    L = list(map(int, str(num)))  #iの各行を数字としてリストに格納し合計
    #print("num", num)
    #print(cal)
    for i in range(len(L) - 1):
        if abs(L[i] - L[i + 1]) > 1:
            num += 1
            break
        else:
            if cal == len(L) - 1:
                cou += 1
                num += 1
                cal = 1              
            else:
                cal += 1
    #print(cou)
print(num-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
def isRunrun(seinum):
    keta = len(str(seinum))
    if keta == 1:
        return 1
    seinumList = list(str(seinum))
    for i in range(len(seinumList) - 1):
        if abs(int(seinumList[i]) - int(seinumList[i+1])) >= 2:
            return 0
    return 1


run = []
i = 1
while True:
    if len(run) == k:
        print(run[k-1])
        exit()
    li = list(str(i))
    keta_li = len(li)
    tmp = str(i)
    if len(tmp) == 1 or i == 10:
        run.append(i)
        if i == k:
            print(i)
            exit()
    elif len(tmp) >= 2 and int(tmp[1:]) in run:
        if isRunrun(i):
            run.append(i)
            if i == k:
                print(i)
                exit()
    i += 1

Submission status: Wrong Answer

Solution code:
n = int(input())

if n <= 9:
  print(n)
  
n -= 9
t = n % 3
cnt = 0

while True:
  n //= 3
  cnt += 1
  
  if n < 3:
    break
   
if t == 0:
  print(n*10 + n+1)
else:
  print((n+1)*10 + (n+1)-(2-t))

Submission status: Wrong Answer

Solution code:
def jud(n1,n2):
	if abs(n1-int(str(n2)[0]))<=1:
		return 1
	else:
		return 0

rnrn = [[1,2,3,4,5,6,7,8,9],[10,11,12,21,22,23,32,33,34,43,44,45,54,55,56,65,66,67,76,77,78,87,88,89,98,99],
[100,101,110, 111, 112, 121, 122, 123, 210, 211, 212, 221, 222, 223, 232, 233, 234, 321, 322, 323, 332, 333, 334, 343, 344, 345, 432, 433, 434, 443, 444, 445, 454, 455, 456, 543, 544, 545, 554, 555, 556, 565, 566, 567, 654, 655, 656, 665, 666, 667, 676, 677, 678, 765, 766, 767, 776, 777, 778, 787, 788, 789, 876, 877, 878, 887, 888, 889, 898, 899, 987, 988, 989, 998, 999],
[1000,1001,1010,1011,1100, 1101, 1110, 1111, 1112, 1121, 1122, 1123, 1210, 1211, 1212, 1221, 1222, 1223, 1232, 1233, 1234, 2100, 2101, 2110, 2111, 2112, 2121, 2122, 2123, 2210, 2211, 2212, 2221, 2222, 2223, 2232, 2233, 2234, 2321, 2322, 2323, 2332, 2333, 2334, 2343, 2344, 2345, 3210, 3211, 3212, 3221, 3222, 3223, 3232, 3233, 3234, 3321, 3322, 3323, 3332, 3333, 3334, 3343, 3344, 3345, 3432, 3433, 3434, 3443, 3444, 3445, 3454, 3455, 3456, 4321, 4322, 4323, 4332, 4333, 4334, 4343, 4344, 4345, 4432, 4433, 4434, 4443, 4444, 4445, 4454, 4455, 4456, 4543, 4544, 4545, 4554, 4555, 4556, 4565, 4566, 4567, 5432, 5433, 5434, 5443, 5444, 5445, 5454, 5455, 5456, 5543, 5544, 5545, 5554, 5555, 5556, 5565, 5566, 5567, 5654, 5655, 5656, 5665, 5666, 5667, 5676, 5677, 5678, 6543, 6544, 6545, 6554, 6555, 6556, 6565, 6566, 6567, 6654, 6655, 6656, 6665, 6666, 6667, 6676, 6677, 6678, 6765, 6766, 6767, 6776, 6777, 6778, 6787, 6788, 6789, 7654, 7655, 7656, 7665, 7666, 7667, 7676, 7677, 7678, 7765, 7766, 7767, 7776, 7777, 7778, 7787, 7788, 7789, 7876, 7877, 7878, 7887, 7888, 7889, 7898, 7899, 8765, 8766, 8767, 8776, 8777, 8778, 8787, 8788, 8789, 8876, 8877, 8878, 8887, 8888, 8889, 8898, 8899, 8987, 8988, 8989, 8998, 8999, 9876, 9877, 9878, 9887, 9888, 9889, 9898, 9899, 9987, 9988, 9989, 9998, 9999],
[10001,10010,10011,10100,10101,10110,10111,11000, 11001, 11010, 11011, 11100, 11101, 11110, 11111, 11112, 11121, 11122, 11123, 11210, 11211, 11212, 11221, 11222, 11223, 11232, 11233, 11234, 12100, 12101, 12110, 12111, 12112, 12121, 12122, 12123, 12210, 12211, 12212, 12221, 12222, 12223, 12232, 12233, 12234, 12321, 12322, 12323, 12332, 12333, 12334, 12343, 12344, 12345, 21000, 21001, 21010, 21011, 21100, 21101, 21110, 21111, 21112, 21121, 21122, 21123, 21210, 21211, 21212, 21221, 21222, 21223, 21232, 21233, 21234, 22100, 22101, 22110, 22111, 22112, 22121, 22122, 22123, 22210, 22211, 22212, 22221, 22222, 22223, 22232, 22233, 22234, 22321, 22322, 22323, 22332, 22333, 22334, 22343, 22344, 22345, 23210, 23211, 23212, 23221, 23222, 23223, 23232, 23233, 23234, 23321, 23322, 23323, 23332, 23333, 23334, 23343, 23344, 23345, 23432, 23433, 23434, 23443, 23444, 23445, 23454, 23455, 23456, 32100, 32101, 32110, 32111, 32112, 32121, 32122, 32123, 32210, 32211, 32212, 32221, 32222, 32223, 32232, 32233, 32234, 32321, 32322, 32323, 32332, 32333, 32334, 32343, 32344, 32345, 33210, 33211, 33212, 33221, 33222, 33223, 33232, 33233, 33234, 33321, 33322, 33323, 33332, 33333, 33334, 33343, 33344, 33345, 33432, 33433, 33434, 33443, 33444, 33445, 33454, 33455, 33456, 34321, 34322, 34323, 34332, 34333, 34334, 34343, 34344, 34345, 34432, 34433, 34434, 34443, 34444, 34445, 34454, 34455, 34456, 34543, 34544, 34545, 34554, 34555, 34556, 34565, 34566, 34567, 43210, 43211, 43212, 43221, 43222, 43223, 43232, 43233, 43234, 43321, 43322, 43323, 43332, 43333, 43334, 43343, 43344, 43345, 43432, 43433, 43434, 43443, 43444, 43445, 43454, 43455, 43456, 44321, 44322, 44323, 44332, 44333, 44334, 44343, 44344, 44345, 44432, 44433, 44434, 44443, 44444, 44445, 44454, 44455, 44456, 44543, 44544, 44545, 44554, 44555, 44556, 44565, 44566, 44567, 45432, 45433, 45434, 45443, 45444, 45445, 45454, 45455, 45456, 45543, 45544, 45545, 45554, 45555, 45556, 45565, 45566, 45567, 45654, 45655, 45656, 45665, 45666, 45667, 45676, 45677, 45678, 54321, 54322, 54323, 54332, 54333, 54334, 54343, 54344, 54345, 54432, 54433, 54434, 54443, 54444, 54445, 54454, 54455, 54456, 54543, 54544, 54545, 54554, 54555, 54556, 54565, 54566, 54567, 55432, 55433, 55434, 55443, 55444, 55445, 55454, 55455, 55456, 55543, 55544, 55545, 55554, 55555, 55556, 55565, 55566, 55567, 55654, 55655, 55656, 55665, 55666, 55667, 55676, 55677, 55678, 56543, 56544, 56545, 56554, 56555, 56556, 56565, 56566, 56567, 56654, 56655, 56656, 56665, 56666, 56667, 56676, 56677, 56678, 56765, 56766, 56767, 56776, 56777, 56778, 56787, 56788, 56789, 65432, 65433, 65434, 65443, 65444, 65445, 65454, 65455, 65456, 65543, 65544, 65545, 65554, 65555, 65556, 65565, 65566, 65567, 65654, 65655, 65656, 65665, 65666, 65667, 65676, 65677, 65678, 66543, 66544, 66545, 66554, 66555, 66556, 66565, 66566, 66567, 66654, 66655, 66656, 66665, 66666, 66667, 66676, 66677, 66678, 66765, 66766, 66767, 66776, 66777, 66778, 66787, 66788, 66789, 67654, 67655, 67656, 67665, 67666, 67667, 67676, 67677, 67678, 67765, 67766, 67767, 67776, 67777, 67778, 67787, 67788, 67789, 67876, 67877, 67878, 67887, 67888, 67889, 67898, 67899, 76543, 76544, 76545, 76554, 76555, 76556, 76565, 76566, 76567, 76654, 76655, 76656, 76665, 76666, 76667, 76676, 76677, 76678, 76765, 76766, 76767, 76776, 76777, 76778, 76787, 76788, 76789, 77654, 77655, 77656, 77665, 77666, 77667, 77676, 77677, 77678, 77765, 77766, 77767, 77776, 77777, 77778, 77787, 77788, 77789, 77876, 77877, 77878, 77887, 77888, 77889, 77898, 77899, 78765, 78766, 78767, 78776, 78777, 78778, 78787, 78788, 78789, 78876, 78877, 78878, 78887, 78888, 78889, 78898, 78899, 78987, 78988, 78989, 78998, 78999, 87654, 87655, 87656, 87665, 87666, 87667, 87676, 87677, 87678, 87765, 87766, 87767, 87776, 87777, 87778, 87787, 87788, 87789, 87876, 87877, 87878, 87887, 87888, 87889, 87898, 87899, 88765, 88766, 88767, 88776, 88777, 88778, 88787, 88788, 88789, 88876, 88877, 88878, 88887, 88888, 88889, 88898, 88899, 88987, 88988, 88989, 88998, 88999, 89876, 89877, 89878, 89887, 89888, 89889, 89898, 89899, 89987, 89988, 89989, 89998, 89999, 98765, 98766, 98767, 98776, 98777, 98778, 98787, 98788, 98789, 98876, 98877, 98878, 98887, 98888, 98889, 98898, 98899, 98987, 98988, 98989, 98998, 98999, 99876, 99877, 99878, 99887, 99888, 99889, 99898, 99899, 99987, 99988, 99989, 99998, 99999]]

di = 4

for i in range(1,10):
	for j in range(len(rnrn[3])):
		if(jud(i,rnrn[3][j])):
			rnrn[4].append(int(str(i)+str(rnrn[3][j])))

print(rnrn)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

K = int(input())

def Is_runrun(n):
    n = str(n)
    return not(any([abs(int(i1)-int(i2)) <= 1 for i1, i2 in zip(n[:-1], n[1:])]))

if K <= 12:
    print(K)
else:
    K -= 12
    n = 13
    i = 0
    while i != K:
        if Is_runrun(n):
            runrun = n
            i += 1
        n += 1
            
    print(runrun)

Submission status: Wrong Answer

Solution code:
k = int(input())
count = 9
x = 10
while count < k:
  l = list(str(x))
  flag = True
  for i in range(len(l)-1):
    if abs(int(l[i])-int(l[i+1])) > 1:
      flag = False
  if flag:
    count += 1
  x += 1
print(x-1)