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: Time Limit Exceeded

Solution code:
k=int(input())

def judge(s):
    flag = 1
    if len(s)<=1: return 1
    for i in range(len(s)-1):
        s1, s2 = int(s[i]),int(s[i+1])
        if abs(abs(s1)-abs(s2)) <= 1: continue
        else:
            flag = 0 
            break
    return flag


def bfs(k, cnt=1, now=1):
    while True:
        s=str(now)
        if judge(s) and k==cnt: return now
        elif judge(s):
            cnt+=1
            now+=1
        else: now+=1

print(bfs(k,1,1))

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if len(str(K)) == 1:
    print(K)
else:
    h = 10
    cnt = 9
    while h <= 10 ** 100:
        X = str(h)
        N = len(X)

        i = 0
        ans = 'Yes'
        while i < N-1:
            if (int(X[i]) - int(X[i+1]) == 1) or (int(X[i+1]) - int(X[i]) == 1) or (int(X[i]) == int(X[i+1])):
                i += 1
            else:
                ans = 'No'
                break
        if ans == 'Yes':
            cnt += 1
    
        if cnt == K:
            print(h)
            break
        else:
            h += 1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(input())
cnt = 0
flag = 1
i = 0
for i in range(1,sys.maxsize):
  if i < 10:
    cnt += 1
  else:
    s = str(i)
    sn = len(s)
    judge = 0
    sj = int(s[0])
    sj1 = int(s[1])
    if sj in (sj1,sj1 + 1,sj1 - 1):
      for j in range(1,sn):
        sj = int(s[j])
        sj1 = int(s[j-1])
        if sj in (sj1,sj1 + 1,sj1 - 1):
          judge += 0
        else:
          judge += 1
    else:
      judge += 1
    if judge == 0:
      cnt += 1

  if n == cnt:
    print(i)
    exit()

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

lunlun_number_memo = {}

def is_lunlun(str_n):
    if lunlun_number_memo.get(str_n):
        return True
    elif len(str_n) == 1:
        return True
    else:
        if abs(int(str_n[0]) - int(str_n[1])) <= 1:
            return is_lunlun(str_n[1:])
        else:
            return False


lunlun_number_count = 0
i = 0
while lunlun_number_count < K:
    i += 1
    if is_lunlun(str(i)):
        lunlun_number_memo[str(i)] = True
        lunlun_number_count += 1
        # print(i)
        # print(lunlun_number_count)
        # print("running")

print(i)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

cnt = 9
if k < 10:
    print(k)
else:
    for i in range(10,10**16+2):
        s = str(i)
        flag = True
        for j in range(len(s)-1):
            if abs(int(s[j])-int(s[j+1])) > 1:
                flag = False
                break
        if flag == True:
            cnt += 1
        if cnt == k:
            print(i)
            break

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
c = 0
x = 0
sx = 0
while c < k:
  x+=1
  sx = str(x)
  c+=1
  for i in range(len(sx)-1):
    if abs(int(sx[i]) - int(sx[i+1])) > 1:
     c-=1
     break
print(x)

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
a=9#すでに9個ある
k=9
while k<K:
    a+=1
    x=0
    for i in range(len(str(a))-1):
        if abs(int(str(a)[i])-int(str(a)[i+1]))<=1:
            x+=1
#        else:
#            a+=8
    if x+1==len(str(a)):
        k+=1
    
    if k==K:
        break
if K<=9:
    print(K)
else:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
num=9
count=9
if K<10:
    print(K)
else:
    for j in range(1000000000000000):
        num+=1
        order=len(str(num))
        count2=0
        for k in range(order-1):
            if abs(int(str(num)[k])-int(str(num)[k+1]))<2:    
                count2+=1
            else:
                break
        if count2==order-1:
            count+=1
        if count==K:
            break        
    print(num)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
a = ['1','2','3','4','5','6','7','8','9']
if K <= 9:
    print(K)

cnt = 9
while True:
    a_tmp = []
    for s in a:
        for t in range(max(0, int(str(s[-1])) - 1), min(9, int(str(s[-1])) + 1) + 1):
            a_tmp.append(s+str(t))
            cnt += 1
            if cnt == K:
                print(s+str(t))
                exit()
    a = a_tmp

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
ans = 0 #答え
i = 1 #数回す用
c = 0 #ルンルン数カウント

while c < k:
  j = str(i)
  if i < 13: #13未満なら
    c = c + 1 #ルンルン数
    #print(c, i)
  else: #それ以外なら
    x = 0
    for n in range(len(j)-1): #ルンルン数判定を行う
      if abs(int(j[n]) - int(j[n+1])) > 1:#桁の差が1より大きかったら
        x = 1
        break
    if x == 0:
      c = c + 1
      #print(c, i)
  i = i + 1 #iに1を足す

print(i-1)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def main():
     k = int(input())

     runrun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
     index = 0
     s = 9
     while(s < k):
          runrun, s = make(runrun[index], runrun, s)
          index += 1
          # print(runrun)

     print(runrun[k-1])

def make(n, r, s):
     num = n % 10
     p = n * 10 + num
     if num == 0:          
          return r + [p, p + 1], s + 2
     elif num == 9:
          return r + [p - 1, p], s + 2
     else:
          return r + [p - 1, p, p + 1], s + 3

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

def isRunRun(X):
    x = str(X)
    sa = 0
    for i in range(len(x)-1):
        if abs(int(x[i]) - int(x[i+1])) > 1:
            return False
    return True

num = 1
count = 0

while count < K:
    if isRunRun(num):
        count += 1
    num += 1

print(num-1)

Submission status: Time Limit Exceeded

Solution code:
import sys
input=sys.stdin.readline
K = int(input())
def bunkai(N):
    k = 0
    while 10 ** k <= N:
        k += 1
    oldk = k
    order = [0] * k
    k -= 1
    while N > 0:
        a = N // (10**k)
        N = N % (10**k)
        order[oldk-k-1] = a
        k -= 1
    return order
c = 0
for i in range(1,3234566668):
    d = 0
    arr = bunkai(i)
    n = len(arr)
    if n == 1:
        c += 1
    else:
        for j in range(n-1):
            if abs(arr[j] - arr[j+1]) >1:
                d = 1
                break
        if d == 0:
            c += 1 
    if c == K:
        print(i)
        break

Submission status: Time Limit Exceeded

Solution code:
import sys

K = int(input())
if K < 12:
  print(K)
  sys.exit() 
  
if K == 100000:
  print(3234566667)
  sys.exit() 
count = 12

def run(list):
  for i in range(len(list)-1):
    if not abs(int(list[i]) - int(list[i+1])) > 1:
      continue
    else:
      return False
          
  return True
      
for nums in range(21, 3234566667):
  tmp = list(str(nums))
  if run(tmp):
    count +=1  
  if K == count:
    print(nums)
    sys.exit()

Submission status: Time Limit Exceeded

Solution code:
K = int(input())


if K < 10 ** 4 + 4 * 10 ** 3:
    count = 0
    for _ in range(1, 3234566667):
        i = list(map(int, list(str(_))))
        for j in range(1, len(i)):
            if abs(i[j] - i[j - 1]) > 1:
                break
        else:
            count += 1
            if count == K:
                print(_)
                quit()
else:
    count = 100001
    for _ in range(1, 3234566668)[::-1]:
        i = list(map(int, list(str(_))))
        for j in range(1, len(i)):
            if abs(i[j] - i[j - 1]) > 1:
                break
        else:
            count -= 1
            if count == K:
                print(_)
                quit()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
i = 1
x = 0
while i <= k:
    x = int(x)
    x += 1
    x = str(x)
    if len(x)==1:
        i += 1
    elif len(x)>1 and max([abs(int(x[i])-int(x[i+1])) for i in range(len(x)-1)]) <= 1:
        i += 1

print(x)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

n = 0

X = 0

array = []

while n < K:
    X += 1
    if X <= 9:
        n += 1
    else:
        a = str(X)
        if a[1:] in array:
            array.append(a)
        else:
            t = 1
            v = len(a)
            for i in range(-v, -1):
                if abs(int(a[i])-int(a[i+1])) <= 1:
                    t += 1
            if t == v:
                n += 1
            else:
                array.append(X)
        
print(X)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
i = 1
count = 0
while True:
  s = str(i)
  ans = True
  for j in range(len(s)-1):
    if abs(int(s[j]) - int(s[j+1])) > 1:
      ans = False
      break
  if ans == False:
    i += 1
    continue
  else:
    count += 1
  if count == k:
    print(i)
    break
  else:
    i += 1
    continue

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

i = 0
n = 0
while True:
  i += 1
  s = str(i)
  for j in range(len(s)-1):
    if (int(s[j]) - int(s[j+1])) not in [-1, 0, 1]:
      break
  else:
    n += 1
    if n == k:
      print(i)
      break

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
a = ['1','2','3','4','5','6','7','8','9']
if K <= 9:
    print(K)

cnt = 9
while True:
    a_tmp = []
    for s in a:
        for t in range(max(0, int(str(s[-1])) - 1), min(9, int(str(s[-1])) + 1) + 1):
            a_tmp.append(s+str(t))
            cnt += 1
            if cnt == K:
                print(s+str(t))
                exit()
    a = a_tmp

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
S=1
i=1
ans=0
while S<=K: 
	a=str(i)
	flag=0
	for j in range(len(a)-1):
		sa=int(a[j])-int(a[j+1])
		b=abs(sa)
		if b>=2:
			flag=1
			break
	if flag==0:
		ans=i
		S=S+1
	i=i+1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
count = 0

for i in range(1,10**9):
    flag = 0
    ls = str(i)
    for j in range(len(ls)-1):
        if abs(int(ls[j+1])-int(ls[j])) > 1:
            flag = 1
            break
    if flag == 1:
        continue
    count += 1
    if count == k:
        print(i)
        break

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import sqrt
from collections import Counter, defaultdict

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    k = I()

    c = 0
    for i in range(1, 99999999999):
        string = str(i)
        s0 = int(string[0])
        flag = True
        for s in string:
            ints = int(s)
            if abs(ints - s0) > 1:
                flag = False
                break
            s0 = ints
        if flag:
            c += 1
        if c == k:
            print(i)
            break

    pass


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    w = 0 #見つかったるんるん数の数
    value = 1 #探し始め
    while w < n: #見つかったるんるん数が求めるるんるん数の番号より低ければ続ける
        value_check = list(map(int,str(value))) #valueをlistに直す
        TF = True
        for i in range(len(value_check)-1):
            if abs(value_check[i] - value_check[i+1]) >= 2:
                TF = False
                break
        if TF == True:
            w += 1
        value += 1
    print(value-1)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
i = 1
count = 0

def check(n):
    if n<10:
        return True
    else:
        place1 = n % 10
        place10 = n // 10
        if abs(place1 - place10) <= 1:
            return True
        else:
            return False

while True:
    if check(i):
        count += 1
        if count == k:
            ans = i
            break
        i += 1
    else:
        i += 8


print(ans)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
 
def isRunRun(X):
    x = str(X)
    sa = 0
    for i in range(len(x)-1):
        if abs(int(x[i]) - int(x[i+1])) > 1:
            return False
    return True
 
runrun_nums = [c for c in range(1, 23000000) if isRunRun(c)]
 
print(runrun_nums[K-1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

def rec(x, di, X):
    if di == 10:
        return 0
    if int(x) > X:
        return 0
    last = int(x[-1])
    res = 0
    res += rec(x+str(last), di+1, X)
    if last != 0:
        res += rec(x+str(last-1), di+1, X)
    if last != 9:
        res += rec(x+str(last+1), di+1, X)
    return res + 1

def check(X):
    res = 0
    for i in range(1, 10):
        res += rec(str(i), 0, X)
    return res >= K

K = INT()

res = bisearch_min(0, 3234566668, check)
print(res)

Submission status: Time Limit Exceeded

Solution code:
k=int(input(''))
r=[]
def detr(n):
    sn=str(n)
    j=0
    for a in sn:
        j=j+1
    
    if j==1:
        return True

    ok=1
    for a in range(j-1):
        if int(sn[a])-int(sn[a+1])==0 or int(sn[a])-int(sn[a+1])==1 or int(sn[a])-int(sn[a+1])==-1:
            ok=ok*1
        else:
            ok=ok*0
            break
    
    if ok==1:
        return True
    else:
        return False

lis=[]
x=1
while len(lis)<k:
    if detr(x)==True:
        lis.append(x)
    x=x+1

print(lis[-1])

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
def runrun(x):
    run = x + 1
    while(judg(run) == True):
        run += 1
    return run
def judg(x):
    list_x = list(str(x))
    flag = 0
    for i in range(len(list_x) - 1):
        if abs(int(list_x[i]) - int(list_x[i + 1])) <= 1:
            flag = 0
        else:
            flag = 1
            break
    if flag == 1:
        return True
    else:
        return False
ans = 1
if k == 1:
    print("1")
else:
    for i in range(k - 1):
        x = runrun(ans)
        ans = x
    print(x)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

i = 0
n = 0
while n <= 10000:
  i += 1
  s = str(i)
  for j in range(len(s)-1):
    if (int(s[j]) - int(s[j+1])) not in [-1, 0, 1]:
      break
  else:
    n += 1
    if n == k:
      print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import sqrt
from collections import Counter, defaultdict

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    k = I()

    c = 0
    for i in range(99999999999):
        string = str(i)
        s0 = int(string[0])
        flag = True
        for s in string:
            ints = int(s)
            if abs(ints - s0) > 1:
                flag = False
                break
            s0 = ints
        if flag:
            c += 1
        if c == k:
            print(i)

    pass


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

lunlun = []

def main():
    n = int(input())
    for i in range(3234566667):
        flag = True
        if len(str(i)) == 1:
            lunlun.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.append(i)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
x = 0
count = 0
if K <= 12:
  print(K)
  exit()
while count < K:
  x = int(x)
  x += 1
  x = str(x)
  for i in range(1,len(x)):
    if abs(int(x[i])-int(x[i-1])) > 1:
      count -= 1
      break
  count += 1
print(x)

Submission status: Time Limit Exceeded

Solution code:
import sys
a = int(input())


def isLun(n):
    n = [int(i) for i in list(str(n))]
    a = n[0]
    if len(n) > 1:
        for i in n:
            b = abs(a - i)

            if b > 1:
                return False
            a = i
    return True


res = 0
count = 0
i = 0
while count < a:
    i += 1
    if isLun(i):
        count += 1
        res = i
        # res.append(str(i + 1))
print(res)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
ans = []
queue = [str(i) for i in range(1,10)]

while queue:
    if len(ans)==k:
        print(ans[k-1])
        break
    now = queue.pop(0)
    ans.append(now)
    t = int(now[-1])
    if t -1 >= 0:
        queue.append(str(now) +str(t-1))

    queue.append(str(now) +str(now)[-1])

    if t +1 <= 9:
        queue.append(str(now) +str(t+1))

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

count = 0
if K < 10 ** 5 + 1:
    for _ in range(1, 3234566667):
        i = list(map(int, list(str(_))))
        for j in range(1, len(i)):
            if abs(i[j] - i[j - 1]) > 1:
                break
        else:
            count += 1
            if count == K:
                print(_)
                quit()

Submission status: Time Limit Exceeded

Solution code:
#d
k = int(input())
l_num = []
n = 0
cnt = 1
while n < k:
    if len(str(cnt)) == 1:
        l_num.append(cnt)
        cnt += 1
        n += 1
    else:
        cnt = str(cnt)
        flag = True
        for i in range(len(cnt)-1):
            if abs(int(cnt[i])-int(cnt[i+1])) > 1:
                flag = False
        cnt = int(cnt)
        if flag:
            l_num.append(cnt)
            cnt += 1
            n += 1
        else:
            cnt += 1
print(l_num[k-1])

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

i = 0
lun_ls = []
n = 0
while n <= 10000:
  i += 1
  s = str(i)
  for j in range(len(s)-1):
    if (int(s[j]) - int(s[j+1])) not in [-1, 0, 1]:
      break
  else:
    lun_ls.append(i)
    n += 1

print(lun_ls[k-1])

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

def isRunRun(X):
    x = str(X)
    sa = 0
    for i in range(len(x)-1):
        if abs(int(x[i]) - int(x[i+1])) > 1:
            return False
    return True

runrun_nums = [c for c in range(1, 30000000) if isRunRun(c)]

print(runrun_nums[K-1])

Submission status: Time Limit Exceeded

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

k = ni()

def is_lunlun(n):
  nn = [int(_) for _ in str(n)]

  last = 0
  for i in range(len(nn)):
    if i > 0:
      if abs(nn[i] - last) > 1:
        return False
    last = nn[i]
  return True

cnt = 0

for i in range(1,10**10):
  if(is_lunlun(i)):
    if cnt == k-1:
      print(i)
      exit()
    cnt+=1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
i = 1
count = 0

def check(n):
    if n<10:
        return True
    else:
        place1 = n % 10
        place10 = n // 10
        if abs(place1 - place10) <= 1:
            return True
        else:
            return False

while True:
    if check(i):
        count += 1
        if count == k:
            ans = i
            break
    i += 1
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

n = 0

X = 0

while n < K:
    X += 1
    if X <= 9:
        n += 1
    else:
        t = 1
        a = str(X)
        v = len(a)
        for i in range(-v, -1):
            if abs(int(a[i])-int(a[i+1])) <= 1:
                t += 1
        if t == v:
            n += 1
        
print(X)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
if(K < 10):
    num = K
else:
    count = 9
    num = 10
    flag = 1
    while(count != K):
        lsnum = str(num)
        for i in range(1, len(lsnum)):
            if(abs(int(lsnum[i-1]) - int(lsnum[i])) > 1):
                flag = 0
                break
        if(flag == 1):
            count += 1
        flag = 1
        num += 1
    num -= 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
S = int(input())
if S<10:
    print(S)
else:
    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

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
def lun(n):
    sx = str(n)
    s=[int(sx[i]) for i in range(len(sx))]
    for i in range(len(s)-1):
        if abs(s[i]-s[i+1])>1:
            return False
    return True

i,c=0,0
while c<K:
  i+=1
  if (lun(i)):
    c+=1
print(i)

Submission status: Time Limit Exceeded

Solution code:
def runrun(n):
    s = str(n)
    if len(s) == 1:
        return True 
    for i in range(len(s)-1):
        if abs(int(s[i]) - int(s[i+1])) > 1:
            return False
    return True

k = int(input())

i = 1
cnt = 0
while True:
    if runrun(i):
        cnt += 1
    if cnt == k:
        print(i)
        break
    i += 1

Submission status: Time Limit Exceeded

Solution code:
K= int(input())
if K <= 12:
  print(K)
  exit()

c = 13
checknumber = 21
tekito = False
while True:
  tekito = False
  sc = str(checknumber)
  for i in range(len(sc) - 1):
    if abs(int(sc[i]) - int(sc[i + 1])) > 1:
      tekito = True
      break
      
  if tekito == False:
    if c== K:
      print(checknumber)
      exit()
    else:
      c +=1
  checknumber+=1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
if k < 10:
    print(k)
    exit()


i = 10
ans = 10
while True:
    s = list(str(i))
    for j in range(len(s)-1):
        flag = True
        if abs(int(s[j])-int(s[j+1])) > 1:
            flag = False
            break
    if flag:
        ans += 1
    
    if ans==k+1:
        print(i)
        exit()
    
    i += 1

Submission status: Time Limit Exceeded

Solution code:
c=0
a = int(input())
for i in range(1,3234566668):
    f=0
    if i>12:
        l = [int(x) for x in list(str(i))]
        for j in range(1,len(str(i))):
            if abs(l[j-1]-l[j])>1:
                f=1
    if f==0:
        c+=1
    if c==a:
        print(i)
        break

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
def LunLun(num):
    lu=str(num)
    for i in range(len(lu)-1):
        if abs(int(lu[i]) - int(lu[i+1]))>1:
            return False
    return True

count=0
i=1
while True:
    if LunLun(i)==True:
        count+=1
    if count==k:
        print(i)
        break
    else:
        i+=1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

def isRunRun(X):
    x = str(X)
    sa = 0
    for i in range(len(x)-1):
        if abs(int(x[i]) - int(x[i+1])) > 1:
            return False
    return True

runrun_nums = [c for c in range(1, 10 ** 8) if isRunRun(c)]

print(runrun_nums[K-1])

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
A=[]
i = 0
while len(A) <= K:
    i += 1
    n = str(i)
    l = len(n)
    if l ==1:
        A.append(i)
    elif l ==2:
        count = 0
        if abs(int(n[0])-int(n[1])) <= 1:
            A.append(i)
    else:
        count = 0
        for j in range(l-1):
            if abs(int(n[j])-int(n[j+1])) > 1:
                count += 1
        if count == 0:
            A.append(i)

print(A[K-1])

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
count=0
num=1
while count<K:
  flg=0
  if(num<13):
    count+=1
    ans=num
    num+=1
    continue
  str_num=str(num)
  for i in range(len(str_num)-1):
    if(int(str_num[i])-int(str_num[i+1])!=0 and int(str_num[i])-int(str_num[i+1])!=1 and int(str_num[i])-int(str_num[i+1])!=-1):
      flg=1
      break
  if(flg==0):
    count+=1
    ans=num
  num+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
cur=1
ans=[]
while len(ans)<k:
    num=str(cur)
    n=len(num)
    flag=True
    pos=-1
  #  print(num,end=' num\n')
    for i in range(n-1):
        if abs(int(num[i])-int(num[i+1]))>1:
            pos=i+1
            flag=False
            break
 #   print(flag)
    if flag==True:
        ans.append(cur)
        cur+=1
    else:
        if int(num[pos])!=9:
            ch=str(int(num[pos])+1)
#            print(ch)
            cur=int(num[:pos]+ch+num[pos+1:])
        else:
            ch=str(int(num[pos-1])+1)
            cur=int(num[:pos-1]+ch+'0'*len(num[pos:]))
print(ans[-1])

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
count = 0
for i in range(10**10):
    num = i + 1
    k_list = []
    for k_i in str(num):
        k_list.append(int(k_i))
    for j, ele in enumerate(k_list):
        if j == 0:
            continue
        if abs(k_list[j - 1] - k_list[j]) > 1:
            break
    else:
        count += 1
    if count == k:
        print(num)
        break

Submission status: Time Limit Exceeded

Solution code:
#D
import sys
k = int(input())
count = 0
i=1
while count != k:
    a = str(i)
    b=True
    for j in range(len(a)-1):
        if int(a[j + 1]) == int(a[j]) + 1 or int(a[j]) == int(a[j + 1]) + 1 or int(a[j]) == int(a[j + 1]):
            pass
        else:
            b=False
    if b:
        count += 1
    i+=1
print(i-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
if(k<13):
  print(k)
else:
  cnt = 12
  for i in range(21, 3234566667):
    flg = 0
    str_num = str(i)
    for j in range(0,len(str_num)-1):
      dif = abs(int(str_num[j]) - int(str_num[j+1]))
      if(dif>1):
        flg = 1
        break
    if(flg == 0):
      cnt += 1
    if(cnt == k):
      print(i)
      break

Submission status: Time Limit Exceeded

Solution code:
def isRunLun(x):
    if(x < 10):
        return False
    xstr = str(x)
    #print(xstr)
    for i in range(1,len(xstr)):
        if(abs(int(xstr[i-1]) - int(xstr[i])) > 1):
            return False
    return True

N = int(input())

count = N
ans = 10

if(N < 10):
    print(N)
else:
    count -= 9
    while(True):
        ans += 1
        if(isRunLun(ans)):
            count -= 1
            if(count == 1):
                print(ans)
                break

Submission status: Time Limit Exceeded

Solution code:
#coding : utf-8

import os, sys

def is_lunlun(v):
	s = str(v)
	for i in range(len(s) - 1):
		if abs(int(s[i]) - int(s[i+1])) > 1:
			return False
	return True



K, = map(lambda x: int(x), input().split(" "))

#print("K=%d" % K)

value = 1
count = 0
while True:
	if is_lunlun(value):
#		print("lunlun = %d" % value)
		
		count += 1
		if count == K:
			print(value)
			sys.exit(0)

	value += 1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
if K <= 12:
    print(K)
else:
    i = flag = 12
    while(K != flag):
        i += 1
        bunkai = list(str(i))
        length = len(bunkai)
        flag2 = 0
        for j in range(length - 1):
            if bunkai[j] == bunkai[j + 1] or (abs(int(bunkai[j]) - int(bunkai[j + 1])) == 1):
                flag2 += 1
                continue
            else:
                break
        if flag2 == (length - 1):
            flag += 1
    print(i)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
runrun_counter = 0
no_runrun = False
ans = 0
for i in range(1,10**8):
    if i < 10:
        ans = i
        runrun_counter += 1
    else:
        num = [int(s) for s in list(str(i))]
        for n in range(len(num)-1):
            if abs(num[n]-num[n+1]) > 1:
                no_runrun = True
                break
        if not no_runrun:
            runrun_counter += 1
            ans = int(''.join(map(str, num)))
        no_runrun = False
    if runrun_counter == k:
        print(ans)
        exit()

Submission status: Time Limit Exceeded

Solution code:
n=int(input()) 
c = 0
tmp = 0

for i in range(3234566668):
    if i != 0:
        s = str(i)
        if len(s) != 1:
            for j in range(len(s)-1):
                if int(s[j]) > int(s[j+1]):
                    a = int(s[j]) - int(s[j+1])
                else:
                    a = int(s[j+1]) - int(s[j])
                if a > 1:
                    tmp = 0
                    break
                tmp = 1
        else:
            tmp = 1

        if tmp == 1:
            c = c + 1
        if c == n:
            print(i)
            exit()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
count = 0

for i in range(1,10**9):
    flag = 0
    ls = list(str(i))
    for j in range(len(ls)-1):
        if abs(int(ls[j+1])-int(ls[j])) > 1:
            flag = 1
            break
    if flag == 0:
        count += 1
    if count == k:
        print(i)
        break

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
ans=[]
i=0
while len(ans) < K:
  i += 1
  if len(str(i)) ==1:
    ans.append(i)
    continue
  x =0  
  for j in range(len(str(i))-1):
    if abs(int(str(i)[-(1+j)])-int(str(i)[-(2+j)])) >1:
      break
    elif abs(int(str(i)[-(1+j)])-int(str(i)[-(2+j)])) <=1:x +=1
    
  if x==(len(str(i))-1):
    ans.append(i)
  
print(ans[-1])