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())
ans=9
dp=[[0]*10 for i in range(10)]
dp[0]=[1]*10
flag=0
index,r=0,0
for j in range(1,10):
    for i in range(10):
        tmp=0
        tmp+=dp[j-1][i]
        if i-1>=0:
            tmp+=dp[j-1][i-1]
        if i+1<=9:
            tmp+=dp[j-1][i+1]
        dp[j][i]=tmp
        if i!=0:
            ans+=dp[j][i]
        if ans>=K:
            index,r=j,i
            flag=1
            break
    if flag==1:
        break
print(dp)
print(index,r)
K-=ans
ans=r*10**(index)
K=abs(K)
print(K)
for i in range(index-1,-1,-1):
    for j in range(10):
        if K-dp[i][j]>0:
            K-=dp[i][j]
        elif K-dp[i][j]==0:
            ans+=j*10**(i+1)
            print(ans)
            print(exit())
        else:
            K+=dp[i][j]
            ans+=(j)*10**(i)
            break
print(ans)

from collections import deque
K=int(input())
q=deque([1,2,3,4,5,6,7,8,9])
for i in range(K):
    ans=q.popleft()
    tmp=ans
    if tmp%10 >0:
        q.append(tmp*10+tmp%10-1)
    q.append(tmp*10+tmp%10)
    if tmp%10 < 9:
        q.append(tmp*10+tmp%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):
# coding: utf-8
# Your code here!

k = int(input())

lunlun = []

end = False
while True:
    val = 0
    while True:
        val += 1
        val_list = [int(x) for x in list(str(val))]
        is_lun = True 
        for x in range(len(val_list) - 1):
            if abs(val_list[x] - val_list[x + 1]) <= 1:
                continue
            else:
                is_lun = False
        if is_run:
            lunlun.append(val)
        else:
            continue
        if len(lunlun) == k:
            end = True
            break
    if end:
        break

print(lunlun[k - 1])


k = int(input())

nums = []
def inc(num):
    if num > 3234566667:
        return None
    if num <= 3234566667:
      nums.append(num)

    end = str(num)[-1:]
    end_num = int(end)

    if end_num < 9:
        inc(num * 10 + end_num + 1)

    inc(num * 10 + end_num)

    if end_num > 0:
        inc(num * 10 + end_num - 1)

for i in range(1, 10):
    inc(i)

sort_nums = sorted(nums)
print(sorted(nums)[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())
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)

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)

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)

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)

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)

Verdicts: Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

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())
n=0
c=0
while 1:
  j=True
    if len(n_str) > 1 and abs(int(n_str[0]) - int(n_str[1])) > 1:
    n = (int(str(int(n_str[0])+1)+str(int(n_str[0]))))*(10**(len(n_str)-2))
  else:
    n+=1
  n_str=str(n)
  for i in range(len(n_str)-1):
    if abs(int(n_str[i]) - int(n_str[i+1])) > 1:
      j=False
  if j:
    c+=1
  if c==K:
    print(n)
    break


from collections import deque
K=int(input())
Q=deque(list(range(1,10)))
for _ 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: 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())

dq = deque(list(range(1,10)))

rep = 0

while rep < K:
    now = dq.popleft()
    rep += 1
    for i in (-1,0,1):
        if 0 <= now%10+1<10:
            dq.append(now*10+now*10+i)

print(now)

from collections import deque

K = int(input())

dq = deque(list(range(1,10)))

rep = 0

while rep < K:
    now = dq.popleft()
    rep += 1
    for i in (-1,0,1):
        if 0 <= now%10+1<10:
            dq.append(now*10+i)

print(now)

from collections import deque

K = int(input())

dq = deque(list(range(1,10)))

for i in range(K):
    now = dq.popleft()
    for i in (-1,0,1):
        add = (now%10)+i
        if 0 <= add<10:
            dq.append(now*10+add)

print(now)

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

k = int(input())
a = [i+1 for i in range(9)]


while 1:
    if k <= len(a):
        print(a[k-1])
        exit()
    k -= len(a)
    old = []
    a, old = old, a
    for x in old:
        for i in range(-1, 2):
            d = x % 10 + i
            if d < 0 or d > 9: continue
            nx = x*10 + d
            a.append(nx)
    print(a)


from collections import deque

k = int(input())

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

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

ans = que.popleft()
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 = 12
table = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in table:
  if len(table) > K:
    break
  x = i % 10
  for j in range(max(0, x - 1), min(x + 2, 10)):
    table.append(i * 10 + j)

print(table[K-1])

import numpy as np
K = int(input())
table = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
c = 9
result = []
for i in table:
  runrun = i
  if runrun[-1] == '0':
    table.extend([runrun + str(int(runrun[-1])), 
                   runrun + str(int(runrun[-1])+1)])
    c += 2
  elif runrun[-1] == '9':
    table.extend([runrun + str(int(runrun[-1])-1), 
                   runrun + str(int(runrun[-1]))])
    c += 2
  else:
    table.extend([runrun + str(int(runrun[-1])-1), 
                   runrun + str(int(runrun[-1])), 
                   runrun + str(int(runrun[-1])+1)])
    c += 3
  if c>=K:
    print(table[K-1])
    exit()


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())
d = deque([1,2,3,4,5,6,7,8,9])

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

print(a)




from collections import deque


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

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

print(a)




from collections import deque


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

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

print(a)




from collections import deque


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

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

print(a)




Verdicts: Wrong Answer

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):
k=int(input())
a=[i for i in range(10)]

while True:
    
    if k<=len(a):
        print(a[k-1])
        break
    
    k-=len(a)
    old=[]
    old, a=a, old
    for x in old:
        for i in range(-1,2):
            d=x%10+d
            if d<0 or d>9:
                continue
            new_x=x*10+d
            a.append(new_x)

k=int(input())
a=[i for i in range(1,10)]

while True:
    
    if k<=len(a):
        print(a[k-1])
        break
    
    k-=len(a)
    old=[]
    old, a=a, old
    for x in old:
        for i in range(-1,2):
            d=x%10+i
            if d<0 or d>9:
                continue
            new_x=x*10+d
            a.append(new_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 sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    k = ni()

    que = queue.Queue()

    if k < 11:
        print(k)
        exit(0)

    for i in range(1, 10):
        que.put(i)

    cnt = 19
    flg = True
    while flg:
        tmp = que.get()
        grade1 = tmp % 10

        for i in (-1, 0, 1):
            if -1 < grade1 + i < 10:
                que.put(tmp * 10 + grade1 + i)
                cnt += 1
                if cnt == k:
                    print(tmp * 10 + grade1 + i)

                    exit(0)


if __name__ == '__main__':
    main()


import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    k = ni()

    que = queue.Queue()

    if k < 11:
        print(k)
        exit(0)

    for i in range(1, 10):
        que.put(i)

    cnt = 9
    flg = True
    while flg:
        tmp = que.get()
        grade1 = tmp % 10

        for i in (-1, 0, 1):
            if -1 < grade1 + i < 10:
                que.put(tmp * 10 + grade1 + i)
                cnt += 1
                if cnt == k:
                    print(tmp * 10 + grade1 + i)
                    exit(0)


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):
def is_lunlun(n):
    m = str(n)
    for i in range(1,len(m)):
        if abs(int(m[i]) - int(m[i-1])) > 1:
            return False
    return True

def main():
    K = int(input())
    A = [i for i in range(100000) if is_lunlun(i)]
    B = [int(str(a1)+str(a2)) for a1 in A for a2 in A if is_lunlun(int(str(a1)+str(a2))) and int(str(a1)+str(a2)) < 3234566668]
    B2 = sorted(set(B))
    print(B2[K])

if __name__ == "__main__":
    main()

def main():
    K = int(input())
    from collections import deque
    A = deque([1,2,3,4,5,6,7,8,9])
    a = 0
    while True:
        x = A.popleft()
        xmod10 = x % 10
        if xmod10 != 0:
            A.append(10*x + xmod10 - 1)
        A.append(10*x + xmod10)
        if xmod10 != 9:
            A.append(10*x + xmod10 + 1)
        a += 1
        if a == K:
            print(x)
            break

if __name__ == "__main__":
    main()

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):
from collections import deque

K = int(input())
Q = list(range(1, 10))

for i in range(K):
    x = Q[i]
    y = x%10
    if y != 0:
        Q.append(10*x + y-1)
    Q.append(10*x + y)
    if y != 9:
        Q.append(10*x + y+1)

print(Q[K])

from collections import deque

K = int(input())
Q = list(range(1, 10))

for i in range(K):
    x = Q[i]
    y = x%10
    if y != 0:
        Q.append(10*x + y-1)
    Q.append(10*x + y)
    if y != 9:
        Q.append(10*x + y+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):
a = int(input())

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

For  x  in  range(a):
  tmp = N[x]
  if tmp%10 != 0:
    N.append(tmp*10+tmp%10-1)
  N.append(tmp*10+tmp%10)
  if tmp%10 != 9:
    N.append(tmp*10+tmp%10+1)
print(N[a-1])


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

for i in range(9):
    n = len(lunlun[i])
    lunlun[i+1] = []
    for x in lunlun[i]:
        r = x%10
        if r > 0:
            lunlun[i+1].append(10*x + r-1)
        lunlun[i+1].append(10*x + r)
        if r < 9:
            lunlun[i+1].append(10*x + r+1)
    i += 1

for i in range(1, 11):
    for j in range(len(lunlun[i])):
        k -= 1
        if k == 0:
            print(lunlun[i][j])
            exit()


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

for _ in range(9):
    n = len(lunlun[i])
    lunlun[i+1] = []
    for x in lunlun[i]:
        r = x%10
        if r > 0:
            lunlun[i+1].append(10*x + r-1)
        lunlun[i+1].append(10*x + r)
        if r < 9:
            lunlun[i+1].append(10*x + r+1)
    i += 1

for i in range(1, 11):
    for j in range(len(lunlun[i])):
        k -= 1
        if k == 0:
            print(lunlun[i][j])
            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):
from collections import deque

k = int(input())
a = deque(range(1, 10))
cnt = 0

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

print(x)

from collections import deque

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

for i in range(k):
    x = a.popleft()
    mod = x % 10
    if mod != 0:
        a.append(x*10 + mod -1)
    a.append(x * 10 + mod)
    if mod != 9:
        a.append(x*10 + mod + 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):
def main():
    k=int(input())
    l=[[] for _ in range(20)]
    l[1]=[0,1,2,3,4,5,6,7,8,9]
    cnt=9
    if cnt>=k:
        print(l[k])
        exit()
    for i in range(2,20):
        for keta in range(1,i):
            for j in l[keta]:
                f=j//10**(i-2)
                if j==0:
                    l[i].append(10**(i-1)+j)
                if f==0:
                    if j//10**(len(str(j))-1)==1:
                        l[i].append(10**(i-1)+j)
                elif f==1:
                    l[i].append(10**(i-1)+j)
                    l[i].append(2*10**(i-1)+j)
                elif f==9:
                    l[i].append(8*10**(i-1)+j)
                    l[i].append(9*10**(i-1)+j)
                elif f>0:
                    l[i].append((f-1)*10**(i-1)+j)
                    l[i].append(f*10**(i-1)+j)
                    l[i].append((f+1)*10**(i-1)+j)
            if cnt+len(l[i])>=k:
                l[i].sort()
                ans=l[i][k-cnt-1]
                if ans==0:
                    print(10**(i-1))
                else:
                    l[4].sort()
                    print(l[4])
                    print(ans)
                exit()
            else:
                cnt+=len(l[i])

if __name__ == '__main__':
    main()

def main():
    k=int(input())
    l=[[] for _ in range(20)]
    l[1]=[0,1,2,3,4,5,6,7,8,9]
    cnt=9
    if cnt>=k:
        print(l[1][k])
        exit()
    for i in range(2,20):
        for keta in range(1,i):
            for j in l[keta]:
                f=j//10**(i-2)
                if j==0:
                    l[i].append(10**(i-1)+j)
                if f==0:
                    if j//10**(len(str(j))-1)==1:
                        l[i].append(10**(i-1)+j)
                elif f==1:
                    l[i].append(10**(i-1)+j)
                    l[i].append(2*10**(i-1)+j)
                elif f==9:
                    l[i].append(8*10**(i-1)+j)
                    l[i].append(9*10**(i-1)+j)
                elif f>0:
                    l[i].append((f-1)*10**(i-1)+j)
                    l[i].append(f*10**(i-1)+j)
                    l[i].append((f+1)*10**(i-1)+j)
        if cnt+len(l[i])>=k:
            l[i].sort()
            ans=l[i][k-cnt-1]
            if ans==0:
                print(10**(i-1))
            else:
                print(ans)
            exit()
        else:
            cnt+=len(l[i])

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):
cands = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def add_v(v):
  global cands
  global K
  v0 = v % 10
  v0 = int(v[-1])
  if v0 == 0:
    cands += [v*10, v*10+1]
    K -=2
  elif v0 == 9:
    cands += [v*10+8, v*10+9]
    K -= 2
  else:
    cands += [v*10+v0-1, v*10+v0, v*10+v0+1]
    K -= 3

K = int(input())
idk = K
K -= 9
idx = 0
while K >= 0:
  add_v(cands[idx])
  idx += 1

print(cands[idk-1])

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

def add_v(v):
  global cands
  global K
  v0 = v % 10
  if v0 == 0:
    cands += [v*10, v*10+1]
    K -=2
  elif v0 == 9:
    cands += [v*10+8, v*10+9]
    K -= 2
  else:
    cands += [v*10+v0-1, v*10+v0, v*10+v0+1]
    K -= 3

K = int(input())
idk = K
K -= 9
idx = 0
while K >= 0:
  add_v(cands[idx])
  idx += 1

print(cands[idk-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):
import collections
k=int(input())
if k<=9:
    print(k)
else:
    k-=9
    l =list(range(9,0,-1))
    print(l)
    q = collections.deque(l)
    counter=0
    while counter<k:
        x=q.pop()
        xrem=x%10
        if xrem!=0:
            q.appendleft(10*x+xrem-1)
            counter+=1
            if counter>=k:
                break
        q.appendleft(10*x+xrem)
        counter+=1
        if counter>=k:
                break
        if xrem!=9:
            q.appendleft(10*x+xrem+1)
            counter+=1
    print(q[0])


import collections
k=int(input())
if k<=9:
    print(k)
else:
    k-=9
    l =list(range(9,0,-1))
    #print(l)
    q = collections.deque(l)
    counter=0
    while counter<k:
        x=q.pop()
        xrem=x%10
        if xrem!=0:
            q.appendleft(10*x+xrem-1)
            counter+=1
            if counter>=k:
                break
        q.appendleft(10*x+xrem)
        counter+=1
        if counter>=k:
                break
        if xrem!=9:
            q.appendleft(10*x+xrem+1)
            counter+=1
    print(q[0])


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())
lun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
cnt = 0

while(len(lun) < K):
  target = lun[cnt]
  num = target % 10
  print(lun,target,num)
  if num != 0:
      lun.append(target * 10 + num - 1)
  lun.append(target * 10 + num)
  if num != 9:
      lun.append(target * 10 + num + 1)
  cnt += 1

print(lun[K-1])


K = int(input())
lun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
cnt = 0

while(len(lun) < K):
  target = lun[cnt]
  num = target % 10
  if num != 0:
      lun.append(target * 10 + num - 1)
  lun.append(target * 10 + num)
  if num != 9:
      lun.append(target * 10 + num + 1)
  cnt += 1

print(lun[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()) 
a = deque()

for i in range(1,10):
    a.append(i)
    
for i in range(K):
    j = a.popleft()
    print(j)
    if j%10 != 0:
        a.append((10*j) + ((j%10) -1))
        
    a.append((10*j)+j%10)
    
    if j%10 != 9:
        a.append((10*j) +((j%10)+1))


from collections import deque

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


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

K = input()
from collections import deque

a = deque()

for i in range(1,10):
    a.append(i)
    
for i in range(K):
    j = a.popleft()
    if j%10 != 0:
        a.append((10*j) + ((j%10) -1))
        
    a.append((10*j)+j%10)
    
    if j%10 != 9:
        a.append((10*j) +((j%10)+1))
        
a.popleft()

from collections import deque

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

for i in range(K-1):
    j = a.popleft()
    if j%10 != 0:
        a.append((10*j) + ((j%10) -1))
        
    a.append((10*j)+j%10)
    
    if j%10 != 9:
        a.append((10*j) +((j%10)+1))
    
print(a.popleft())

Verdicts: Wrong Answer

Wrong Answer

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

def main():
  	K = int(input())
    que = deque(['1', '2', '3', '4', '5', '6', '7', '8', '9'])

    while K:
        if K == 1:
            ans = que.popleft()
            break
        K -= 1
        v = que.popleft()
        if v[-1] == '0':
            que.append(v + '0')
            que.append(v + '1')
        elif v[-1] == '9':
            que.append(v + '8')
            que.append(v + '9')
        else:
            que.append(v + str(int(v[-1]) - 1))
            que.append(v + str(int(v[-1])))
            que.append(v + str(int(v[-1]) + 1))

    print(ans)

if __name__ == '__main__':
    main()

from collections import deque

def main():
    K = int(input())
    que = deque([i for i in range(1, 10)])

    while K:
        if K == 1:
            ans = que.popleft()
            break
        K -= 1
        v = que.popleft()
        for i in range(-1, 2, 1):
            a = v % 10 + i
            if a < 0 or a > 9:
                continue
            que.append(v * 10 + a)
            
    print(ans)

if __name__ == '__main__':
    main()

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 L(x):
    X = int(x)
    if X < 10:
        return True
    elif X <100:
        if abs(int(x[-2]) -int(x[-1])) <= 1:
            return True
        else:
            return False
    elif X <(10 ** 3):
        if abs(int(x[-3]) - int(x[-2])) <= 1 and abs(int(x[-2]) -int(x[-1])) <= 1:
            return True
        else:
            return False
    elif X <(10 ** 4):
        if abs(int(x[-4]) - int(x[-3])) <= 1 and abs(int(x[-2]) -int(x[-3])) <= 1 and abs(int(x[-2]) -int(x[-1]))<= 1:
            return True
        else:
            return False
    elif X <=(10 ** 5):
        if abs(int(x[-5]) - int(x[-4])) <= 1 and abs(int(x[-4]) - int(x[-3])) == 1 and abs(int(x[-2]) -int(x[-3])) <= 1 and abs(int(x[-2]) -int(x[-1]))<= 1:
            return True
        else:
            return False
I = 1
i = 1
while I != (K+1):
    print([i,I])
    if L(str(i)):
         I += 1
         i += 1
    else:
        i += 1
print(i-1)

import heapq
K = int(input())
def NewLun(strX):
    if strX[-1] != '0' and strX[-1] != '9':
        intX0 = int(strX[-1])
        heapq.heappush(Lun,int(strX + str(intX0+1)))
        heapq.heappush(Lun,int(strX + str(intX0)))
        heapq.heappush(Lun,int(strX + str(intX0-1)))
    elif strX[-1] == '0':
        heapq.heappush(Lun,int(strX + '0'))
        heapq.heappush(Lun,int(strX+'1'))
    else:
        heapq.heappush(Lun,int(strX +'9'))
        heapq.heappush(Lun,int(strX+'8'))
Lun = [i for i in range(1,10)]
heapq.heapify(Lun)
for _ in range(K):
    Ans = heapq.heappop(Lun)
    NewLun(str(Ans))
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())
L=[]
def f(d,now,L):
  L.append(now)
  
  if d==10:
    return
  
  for j in range(-1,2):
    v=now%10+j
    if 0<=v<=9:
      f(d+1,now*10+v,L)

f(0,0,L)
print(L[k-1])
      

from collections import deque

k=int(input())

lunlun=deque(i for i in range(1,10))
for _ in range(k-1):
  p=lunlun.popleft()
  if p%10!=0:
    lunlun.append(10*p+p%10-1)
  lunlun.append(10*p+p%10)
  if p%10!=9:
    lunlun.append(10*p+p%10+1)
print(lunlun.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):
for i in range(K-1):
  x = q.get()
  print(x)
  if x%10 != 0:
    q.put(10*x + (x%10 -1) )
  q.put(10*x+x%10)
  if x%10 != 9:
    q.put(10*x + (x %10 + 1) )
print(q.get())

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

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

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):
# -*- coding: utf-8 -*-

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

def input_multiple_number_as_list():
    return list(map(int, input().split()))


K = int(input())

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

for i in range(100000):
	for j in range(3):
		if ans[i]%10 == 0 and j ==0:
			continue
		elif ans[i]%10 == 9 and j ==2:
			continue
		ans.append(ans[i]*10+j-1+ans[i]%10)

print(ans[K+1])



# -*- coding: utf-8 -*-

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

def input_multiple_number_as_list():
    return list(map(int, input().split()))


K = int(input())

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

for i in range(100000):
	for j in range(3):
		if ans[i]%10 == 0 and j ==0:
			continue
		elif ans[i]%10 == 9 and j ==2:
			continue
		ans.append(ans[i]*10+j-1+ans[i]%10)

print(ans[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):
from collections import deque

k = int(input())
lunlun = []
q = deque([1,2,3,4,5,6,7,8,9])
for i in range(k-1):
    first = q.popleft()
    if first%10-1 >= 0:
        q.append(first*10 + (first%10-1))
    q.append(first*10 + first%10)
    if first%10+1 <= 9:
        q.append(10*first + (first%10+1))
    print(q)
print(q[0])

from collections import deque

k = int(input())
lunlun = []
q = deque([1,2,3,4,5,6,7,8,9])
while len(lunlun) <= k:
    first = q.popleft()
    lunlun.append(first)
    if first%10-1 >= 0:
        q.append(first*10 + (first%10-1))
    q.append(first*10 + first%10)
    if first%10+1 <= 9:
        q.append(10*first + (first%10+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):
k=int(input())
ans=[[i for i in range(1,10)]]
d=9
while d<k:
    ans.append([])
    for i in ans[-2]:
        x=str(i)
        z=int(x[-1])
        ans[-1].append(x+str(z))
        if z<=8:
            ans[-1].append(x+str(z+1))
        if z>=1:
            ans[-1].append(x+str(z-1))
    d+=len(ans[-1])
print(ans[-1][k-d-1])

k=int(input())
ans=[[i for i in range(1,10)]]
d=9
while d<k:
    ans.append([])
    for i in ans[-2]:
        x=str(i)
        if z==0:
            ans[-1].append(x+str(z))
            ans[-1].append(x+str(z+1))
        elif 1<=z<=8:
            ans[-1].append(x+str(z-1))
            ans[-1].append(x+str(z))
            ans[-1].append(x+str(z+1))
        else:
            ans[-1].append(x+str(z-1))
            ans[-1].append(x+str(z))
    d+=len(ans[-1])
l=len(ans[-1])
v=sorted([int(i) for i in ans[-1]])

print(v[k-(d-l)-1])

k=int(input())

q=["1","2","3","4","5","6","7","8","9"]
x=9
for i in q:
    if x>100000:
        break
    x+=1
    a=i[-1]
    for j in ([-1,0,1]):
        bb=int(a)+j
        if bb<10 and bb>=0:
            q.append(i+str(bb))


print(q[k-1])

Verdicts: Wrong Answer

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())
que = []
for i in range(1,10):
  que.append(i)
ct = 0
while(len(que) < k):
  ct += 1
  value = que[0]
  que.remove(value)
  for i in [-1,0,1]:
    if 0 <= (value%10) + i and (value%10) + i <= 9:
      tmp = 10*value + (value%10) + i
      q.append(tmp)  
print(que[k-1-ct])

k = int(input())
que = []
for i in range(10):
  que.append(i)
while(len(que) < k-1):
  x = que[0]
  que.remove(x)
  if (x%10 != 0):
    que.append((10*x) + (x%10) - 1)
    que.append((10*x) + (x%10))
  if (x%10 != 9):
    que.append((10*x) + (x%10) + 1)
print(que[k-1])

k = int(input())
que = []
for i in range(1,10):
  que.append(i)
ct = 0
while(len(que) < k):
  ct += 1
  value = que[0]
  que.remove(value)
  for i in [-1,0,1]:
    if 0 <= (value%10) + i and (value%10) + i <= 9:
      tmp = 10*value + (value%10) + i
      que.append(tmp)  
print(que[k-1-ct])

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):
def generate(n):
    if n == 1:
        for i in range(1, 10):
            yield [i]
    else:
        for A in generate(n - 1):
            for i in range(10):
                if abs(A[-1] - i) <= 1:
                    yield A + [i]


L = []
for n in range(1, 11):
    for A in generate(n):
        L.append(int(''.join([str(a) for a in A])))
print(len(L))
k = int(input())
print(L[k - 1])


def generate(n):
    if n == 1:
        for i in range(1, 10):
            yield [i]
    else:
        for A in generate(n - 1):
            for i in range(10):
                if abs(A[-1] - i) <= 1:
                    yield A + [i]


L = []
for n in range(1, 11):
    for A in generate(n):
        L.append(int(''.join([str(a) for a in A])))
k = int(input())
print(L[k - 1])


Verdicts: Wrong Answer

Accepted
Problem: Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.  You are given an integer C and a string S. Takahashi will choose his workdays as follows:    * After working for a day, he will refrain from working on the subsequent C days.   * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.  Find all days on which Takahashi is bound to work.

Submission attempts (in order):
kinmu = 0
niti = 0
p = 0
for i in range(N):
  if S[i] == "o" and tyousa[i] == p:
    kinmu = 0
    niti = 0
    route.clear()
    while kinmu < K and niti < N:
      if S[niti] == "o" and niti != i:
        route.append(niti)
        kinmu += 1
        niti += C
      niti += 1
    if niti >= N and kinmu < K:
      print(i + 1)
    if kinmu >= K:
      for i2 in route:
        tyousa[i2] += 1
      p += 1

N,K,C =map(int,input().rstrip().split(" "))
S = input()
kinmu = 0
niti = 0
f = []
b = []
kinmu = 0
niti = 0
while kinmu < K and niti < N:
  if S[niti] == "o":
    f.append(niti)
    kinmu += 1
    niti += C
  niti += 1
kinmu = 0
niti = N -1
while kinmu < K and niti >= 0:
  if S[niti] == "o":
    b.append(niti)
    kinmu += 1
    niti -= C
  niti -= 1
b.reverse()
for i in range(K):
  if f[i] == b[i]:
    print(f[i] + 1)

Verdicts: Runtime Error

Accepted
Problem: Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.  You are given an integer C and a string S. Takahashi will choose his workdays as follows:    * After working for a day, he will refrain from working on the subsequent C days.   * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.  Find all days on which Takahashi is bound to work.

Submission attempts (in order):
k = int(input())
lunluns = list(map(str, range(1,10)))
new = list(map(str, range(1,10)))
new_fueta = 9
end = False
while len(lunluns) < k:
  new_new_fueta = 0
  for x in lunluns[-new_fueta:]:
    str_x = str(x)
    if str_x[-1] == '0':
      lunluns += [int(str_x+'0'),int(str_x+'1')]
      new_new_fueta += 2
    elif str_x[-1] == '9':
      lunluns += [int(str_x+'8'),int(str_x+'9')]
      new_new_fueta += 2
    else:
      l = int(str_x[-1])
      lunluns += [int(str_x+str(l-1)), int(str_x+str(l)), int(str_x+str(l+1))]
      new_new_fueta += 3
  if end:
    break
  new_fueta = new_new_fueta
print(lunluns[k-1])

n, k, c = map(int, input().split())
s = input()

def solve_dp(s):
  dp = [0]*(n+2)
  for i in range(n):
    if i <= c and s[i] == 'o':
      dp[i+1] = 1
    else:
      if s[i] == 'o':
        dp[i+1] = max(dp[i], dp[i-c]+1)
      else:
        dp[i+1] = dp[i]
  return dp

mae = solve_dp(s)
ushiro = solve_dp(s[::-1])[::-1]

for i in range(1,n+1):
  if mae[i-1] + ushiro[i+1] < k:
    print(i)

Verdicts: Runtime Error

Accepted
Problem: Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.  You are given an integer C and a string S. Takahashi will choose his workdays as follows:    * After working for a day, he will refrain from working on the subsequent C days.   * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.  Find all days on which Takahashi is bound to work.

Submission attempts (in order):
import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


def GetBase(s=0):
    ret = []
    last = -C * 2 - 1
    for i, s in enumerate(S[s:]):
        if s == 'x':
            continue
        elif last + C >= i + s:
            continue

        ret.append(i + s)
        last = i + s
    return ret


def GetDepend(base_ans):
    ruiseki = []
    a = 0
    for s in S:
        if s == 'o':
            a += 1
            ruiseki.append(a)
        else:
            ruiseki.append(a)

    ret = {a: False for a in base_ans}
    for a in ret:
        if ruiseki[a] == ruiseki[min(N - 1, a + C)]:
            ret[a] = True
    return ret


def solve():
    base_ans = GetBase()
    if len(base_ans) > K:
        return []

    depend_dict = GetDepend(base_ans)
    for i, b in enumerate(base_ans):
        if depend_dict[b] is True:
            continue
        S[b] = 'x'
        tmp = GetBase(s=i)
        if len(tmp) + i < K:
            depend_dict[b] = True
        else:
            for s in set(base_ans) & set(tmp):
                depend_dict[s] = True

        S[b] = 'o'

    return [a + 1 for a in base_ans if depend_dict[a] is True]


N, K, C = inpl()
S = list(input().strip())

ans = solve()

for a in ans:
    print(a)


import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


def GetBase(t=0):
    ret = []
    last = -C * 2 - 1
    for i, s in enumerate(S[t:]):
        if s == 'x':
            continue
        elif last + C >= i + t:
            continue

        ret.append(i + t)
        last = i + t
    return ret


def GetReverse():
    ret = []
    last = -C * 2 - 1
    for i, s in enumerate(S[::-1]):
        if s == 'x':
            continue
        elif last + C >= i:
            continue

        ret.append(len(S) - 1 - i)
        last = i
    return reversed(ret)


def GetDepend(base_ans):
    ruiseki = []
    a = 0
    for s in S:
        if s == 'o':
            a += 1
            ruiseki.append(a)
        else:
            ruiseki.append(a)

    ret = {a: False for a in base_ans}
    for a in ret:
        if ruiseki[a] == ruiseki[min(N - 1, a + C)]:
            ret[a] = True
    return ret


def solve():
    base_ans = GetBase()
    if len(base_ans) > K:
        return []

    reverse_ans = GetReverse()

    return sorted(list(set(base_ans) & set(reverse_ans)))


N, K, C = inpl()
S = list(input().strip())

ans = solve()

for a in ans:
    print(a + 1)


Verdicts: Runtime Error

Accepted
Problem: Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.  You are given an integer C and a string S. Takahashi will choose his workdays as follows:    * After working for a day, he will refrain from working on the subsequent C days.   * If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.  Find all days on which Takahashi is bound to work.

Submission attempts (in order):

N, K, C=map(int, input().split())
S='x'+input() 


A=[] 
i=1 
while len(A)<K:
  if S[i]=='o':
    
    A.append(i+1)
    i+=(C+1)
  else:
    
    i+=1
    

B=[]
i=N 
while len(B)<K:
  if S[i]=='o':
    
    B.append(i)
    i-=(C+1)
  else:
    
    i-=1
    
B=B[::-1] 
for i in range(K):
  
  if A[i]==B[i]:
    print(A[i])




N, K, C=map(int, input().split())
S='x'+input() 


A=[] 
i=1 
while len(A)<K:
  if S[i]=='o':
    
    A.append(i)
    i+=(C+1)
  else:
    
    i+=1
    

B=[]
i=N 
while len(B)<K:
  if S[i]=='o':
    
    B.append(i)
    i-=(C+1)
  else:
    
    i-=1
    
B=B[::-1] 
for i in range(K):
  
  if A[i]==B[i]:
    print(A[i])



Verdicts: Wrong Answer

Accepted