Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
ANS=[]
for i in range(1,10**5):
  LEN=len(str(i))
  STR=str(i)
  if LEN==1:
    ANS+=[i]
  for k in range(LEN-1):
    if abs(int(STR[k])-int(STR[k+1]))>1:
      break
    if k==LEN-2:
      ANS+=[i]
i=10**5
while i<10**7:
  LEN=len(str(i))
  STR=str(i)
  if LEN==1:
    ANS+=[i]
  for k in range(LEN-1):
    if abs(int(STR[k])-int(STR[k+1]))>1:
      i+=10*(LEN-(k+2))
      break
    if k==LEN-2:
      ANS+=[i]
ans=ANS[K-1] 
print(ans)

Fixed submission:
K=int(input())
ANS=[i for i in range(1,10)]
i=0
while len(ANS)<=10**5:
  last=str(ANS[i])[-1]
  if last=="0":
    ANS+=[ANS[i]*10,ANS[i]*10+1]
  elif last=="9":
    ANS+=[ANS[i]*10+8,ANS[i]*10+9]
  else:
    ANS+=[ANS[i]*10+int(last)-1,ANS[i]*10+int(last),ANS[i]*10+int(last)+1]
  i+=1  
ans=ANS[K-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
K=int(input())
ANS=[]
for i in range(1,10**6*2):
  LEN=len(str(i))
  STR=str(i)
  if LEN==1:
    ANS+=[i]
  for k in range(LEN-1):
    if abs(int(STR[k])-int(STR[k+1]))>1:
      break
    if k==LEN-2:
      ANS+=[i]
ans=ANS[K-1] 
print(ans)

Fixed submission:
K=int(input())
ANS=[i for i in range(1,10)]
i=0
while len(ANS)<=10**5:
  last=str(ANS[i])[-1]
  if last=="0":
    ANS+=[ANS[i]*10,ANS[i]*10+1]
  elif last=="9":
    ANS+=[ANS[i]*10+8,ANS[i]*10+9]
  else:
    ANS+=[ANS[i]*10+int(last)-1,ANS[i]*10+int(last),ANS[i]*10+int(last)+1]
  i+=1  
ans=ANS[K-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
ANS=[]
for i in range(1,10**6*2):
  LEN=len(str(i))
  STR=str(i)
  if LEN==1:
    ANS+=[i]
  for k in range(LEN-1):
    if abs(int(STR[k])-int(STR[k+1]))>1:
      break
    if k==LEN-2:
      ANS+=[i]
ans=ANS[K-1] 
print(ans)

Fixed submission:
K=int(input())
ANS=[i for i in range(1,10)]
i=0
while len(ANS)<=10**5:
  last=str(ANS[i])[-1]
  if last=="0":
    ANS+=[ANS[i]*10,ANS[i]*10+1]
  elif last=="9":
    ANS+=[ANS[i]*10+8,ANS[i]*10+9]
  else:
    ANS+=[ANS[i]*10+int(last)-1,ANS[i]*10+int(last),ANS[i]*10+int(last)+1]
  i+=1  
ans=ANS[K-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
ANS=[]
for i in range(1,10**6*3):
  LEN=len(str(i))
  STR=str(i)
  if LEN==1:
    ANS+=[i]
  for k in range(LEN-1):
    if abs(int(STR[k])-int(STR[k+1]))>1:
      break
    if k==LEN-2:
      ANS+=[i]
ans=ANS[K-1] 
print(ans)

Fixed submission:
K=int(input())
ANS=[i for i in range(1,10)]
i=0
while len(ANS)<=10**5:
  last=str(ANS[i])[-1]
  if last=="0":
    ANS+=[ANS[i]*10,ANS[i]*10+1]
  elif last=="9":
    ANS+=[ANS[i]*10+8,ANS[i]*10+9]
  else:
    ANS+=[ANS[i]*10+int(last)-1,ANS[i]*10+int(last),ANS[i]*10+int(last)+1]
  i+=1  
ans=ANS[K-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
ANS=[]
for i in range(1,10**6*5):
  LEN=len(str(i))
  STR=str(i)
  if LEN==1:
    ANS+=[i]
  for k in range(LEN-1):
    if abs(int(STR[k])-int(STR[k+1]))>1:
      break
    if k==LEN-2:
      ANS+=[i]
ans=ANS[K-1] 
print(ans)

Fixed submission:
K=int(input())
ANS=[i for i in range(1,10)]
i=0
while len(ANS)<=10**5:
  last=str(ANS[i])[-1]
  if last=="0":
    ANS+=[ANS[i]*10,ANS[i]*10+1]
  elif last=="9":
    ANS+=[ANS[i]*10+8,ANS[i]*10+9]
  else:
    ANS+=[ANS[i]*10+int(last)-1,ANS[i]*10+int(last),ANS[i]*10+int(last)+1]
  i+=1  
ans=ANS[K-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
K=int(input())
ANS=[]
for i in range(1,10**6):
  LEN=len(str(i))
  STR=str(i)
  if LEN==1:
    ANS+=[i]
  for k in range(LEN-1):
    if abs(int(STR[k])-int(STR[k+1]))>1:
      break
    if k==LEN-2:
      ANS+=[i]
ans=ANS[K-1] 
print(ans)

Fixed submission:
K=int(input())
ANS=[i for i in range(1,10)]
i=0
while len(ANS)<=10**5:
  last=str(ANS[i])[-1]
  if last=="0":
    ANS+=[ANS[i]*10,ANS[i]*10+1]
  elif last=="9":
    ANS+=[ANS[i]*10+8,ANS[i]*10+9]
  else:
    ANS+=[ANS[i]*10+int(last)-1,ANS[i]*10+int(last),ANS[i]*10+int(last)+1]
  i+=1  
ans=ANS[K-1]
print(ans)