Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections
import numpy as np

n = int(input())
li = list(map(int, input().split()))

di = collections.Counter(li)
#print(di)

arr = np.array(list(di.values()))
arrr = arr - 1
c = np.dot(arr, arrr) // 2
#print(c)

for v in li:
    x = int(di[v])
    if x == 1:
        print(c)
    else:
        print(c-(x-1))
    
#(n * n-1)-(n-1 * n-2) / 2

Fixed submission:
import collections
import numpy as np

n = int(input())
li = list(map(int, input().split()))

di = collections.Counter(li)
#print(di)

arr = np.array(list(di.values()))
arrr = arr - 1
c = np.dot(arr, arrr) // 2
#print(c)

#(n * n-1)-(n-1 * n-2) / 2 = n-1

for v in li:
    x = int(di[v])
    if x == 1:
        print(c)
    else:
        print(c-(x-1))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
s = list(input())
q = int(input())

first = []
end = []
f = 0
for _ in range(q):
    li = list(input().split())
    if len(li) == 1:
        f = ~f
    else:
        if li[1] == '1':
            if f == 0:
                first = [li[2]] + first
            else:
                end += [li[2]]
        else:
            if f == 0:
                end += [li[2]]
            else:
                first = [li[2]] + first
s = first + s + end
if f == -1:
    s = s[::-1]
    
print(''.join(s))

Fixed submission:
# coding: utf-8
s = list(input())
q = int(input())

first = []
end = []
f = 0
for _ in range(q):
    li = list(input().split())
    if len(li) == 1:
        f = ~f
    else:
        if li[1] == '1':
            if f == 0:
                first.append(li[2])
            else:
                end.append(li[2])
        else:
            if f == 0:
                end.append(li[2])
            else:
                first.append(li[2])
s = first[::-1] + s + end
if f == -1:
    s = s[::-1]
    
print(''.join(s))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
s = input()
q = int(input())
f = 0
for _ in range(q):
    li = list(input().split())
    if len(li) == 1:
        f = ~f
    else:
        if li[1] == '1':
            if f == 0:
                s = li[2] + s
            else:
                s = s + li[2]
        else:
            if f == 0:
                s = s + li[2]
            else:
                s = li[2] + s
if f == -1:
    s = s[::-1]
    
print(s)

Fixed submission:
# coding: utf-8
s = list(input())
q = int(input())

first = []
end = []
f = 0
for _ in range(q):
    li = list(input().split())
    if len(li) == 1:
        f = ~f
    else:
        if li[1] == '1':
            if f == 0:
                first.append(li[2])
            else:
                end.append(li[2])
        else:
            if f == 0:
                end.append(li[2])
            else:
                first.append(li[2])
s = first[::-1] + s + end
if f == -1:
    s = s[::-1]
    
print(''.join(s))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import numpy as np

card = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())

for _ in range(n):
    num = int(input())
    if num in card:
        pos = tuple(nd[0] for nd in np.where(card == num))
        card[pos[0], pos[1]] = 0

f = 0

for i in range(3):
    if sum(card[i,:]) == 0 or sum(card[:,i]) == 0:
        f = 1
    if card[0,0]+card[1,1]+card[2,2] == 0 or card[2,0]+card[1,1]+card[2,0] == 0:
        f = 1

if f:
    print('Yes')
else:
    print('No')

Fixed submission:
# coding: utf-8
import numpy as np

card = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())

for _ in range(n):
    num = int(input())
    if num in card:
        pos = tuple(nd[0] for nd in np.where(card == num))
        card[pos[0], pos[1]] = 0

f = 0

for i in range(3):
    if sum(card[i,:]) == 0 or sum(card[:,i]) == 0:
        f = 1
    if card[0,0]+card[1,1]+card[2,2] == 0 or card[2,0]+card[1,1]+card[2,0] == 0:
        f = 1

if f:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import numpy as np

f = 1
n, m = map(int, input().split())

li = [-1] * n

for _ in range(m):
    s, c = map(int, input().split())
    if li[s-1] != -1 and li[s-1] != c:
        f = 0
        break
    else:
        li[s-1] = c

if li[0] == -1 or li[0] == 0:
    f = 0
else:
    while -1 in li:
        li[li.index(-1)] = 0

if f:
    for i in range(n):
        print(li[i], end='')
    print('')
else:
    print('-1')

Fixed submission:
# coding: utf-8

f = 1
n, m = map(int, input().split())

li = [-1] * n

for _ in range(m):
    s, c = map(int, input().split())
    if li[s-1] != -1 and li[s-1] != c:
        f = 0
        break
    else:
        li[s-1] = c

if n > 1 and li[0] == 0:
    f = 0
else:
    if -1 in li and li.index(-1) == 0:
        if n > 1:
            li[0] = 1
        else:
            li[0] = 0
    while -1 in li:
        li[li.index(-1)] = 0

if f:
    for i in range(n):
        print(li[i], end='')
    print('')
else:
    print('-1')
Buggy python submission (verdict: Runtime Error):
n,r=map(int,input().split())
if n>=10:
  print(r)
else:
  print(r+100*(10-k))

Fixed submission:
n,r=map(int,input().split())
if n>=10:
  print(r)
else:
  print(r+100*(10-n))

Buggy python submission (verdict: Runtime Error):
n,r=map(int,input().split())
if n>=10:
  print(r)
else:
  print(r+100*(10-k))

Fixed submission:
n,r=map(int,input().split())
if n>=10:
  print(r)
else:
  print(r+100*(10-n))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
n = int(input())

from collections import defaultdict
d = defaultdict(int)
    
for _ in range(n):
    d[input()] += 1

li = [k for k, v in d.items() if v == max(d.values())]
li.sort()

for l in li:
    print(l)

Fixed submission:
# coding: utf-8
n = int(input())

from collections import defaultdict
d = defaultdict(int)
maxnum = 0
maxli = []

for _ in range(n):
    s = input()
    d[s] += 1
    if d[s] > maxnum:
        maxnum += 1
        maxli = [s]
    elif d[s] == maxnum:
        maxli.append(s)
    
maxli.sort()

for l in maxli:
    print(l)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
l = list(map(int, input().split()))

max_val = 0
for i in range(n-k+1):
    x = sum(l[i:i+k])
    if x > max_val:
        max_val = x

print((max_val+k)*1.0/2)

Fixed submission:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
l = list(map(int, input().split()))

x = sum(l[:k])
max_val = x
for i in range(n-k):
    x = x-l[i]+l[i+k]
    if x > max_val:
        max_val = x

print((max_val+k)*1.0/2)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
 
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    if P[i] <= min(P[:i+1]):
        ans += 1
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
 
N = int(input())
P = list(map(int, input().split()))

ans = 0
min_val = P[0]
for i in range(N):
    if P[i] <= min(min_val, P[i]):
        ans += 1
        min_val = min(min_val, P[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int(input())
input_list = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i):
        if input_list[i] > input_list[j]:
            break
    else:
        ans += 1
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
 
N = int(input())
P = list(map(int, input().split()))

ans = 0
min_val = P[0]
for i in range(N):
    if P[i] <= min(min_val, P[i]):
        ans += 1
        min_val = min(min_val, P[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N=int(input())
L=list(map(int,input().split()))
L.sort()
#print(L)

#b-a < c < a+b
#a<=b<=c
ans=0
L_a=L[:N-2]
for i,a in enumerate(L_a):
    L_b=L[i+1:N-1]
    for j,b in enumerate(L_b,start=i+1):
        x=bisect.bisect(L[j+1:],a+b)
        ans+=x
        if L[j+x]==a+b:
            ans-=1
        #print(i,a,j,b,x,N-j-1,L[j+1:])
print(ans)

Fixed submission:
import bisect
import collections
N=int(input())
L=list(map(int,input().split()))
L.sort()
c = collections.Counter(L)
#print(L)
 
#b-a < c < a+b

#a<=b<=c
ans=0
L_a=L[:N-2]
for i,a in enumerate(L_a):
    L_b=L[i+1:N-1]
    for j,b in enumerate(L_b,start=i+1):
        x=bisect.bisect(L[j+1:],a+b)
        ans+=x
        if a+b==L[j+x]:
            #print(a,b,L[j+x])
            ans-=c[a+b]
        #print(i,a,j,b,x,N-j-1,L[j+1:])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
L=np.array(list(map(int,input().split())))
L.sort()
#print(L)

#b-a < c < a+b
#a<=b<=c
ans=0
L_a=L[:N-2]
for i,a in enumerate(L_a):
    L_b=L[i+1:N-1]
    for j,b in enumerate(L_b,start=i+1):
        ans+=sum((b-a < L[j+1:]) & (L[j+1:] < a+b))
        
print(ans)

Fixed submission:
import bisect
import collections
N=int(input())
L=list(map(int,input().split()))
L.sort()
c = collections.Counter(L)
#print(L)
 
#b-a < c < a+b

#a<=b<=c
ans=0
L_a=L[:N-2]
for i,a in enumerate(L_a):
    L_b=L[i+1:N-1]
    for j,b in enumerate(L_b,start=i+1):
        x=bisect.bisect(L[j+1:],a+b)
        ans+=x
        if a+b==L[j+x]:
            #print(a,b,L[j+x])
            ans-=c[a+b]
        #print(i,a,j,b,x,N-j-1,L[j+1:])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
L=list(map(int,input().split()))
L.sort()
L=np.array(L)
#print(L)

#b-a < c < a+b
#a<=b<=c
ans=0
for a in range(N-2):
    for b in range(a+1,N-1):
        ans+=sum((L[b]-L[a] < L[b+1:]) & (L[b+1:] < L[a]+L[b]))
        
print(ans)

Fixed submission:
import bisect
import collections
N=int(input())
L=list(map(int,input().split()))
L.sort()
c = collections.Counter(L)
#print(L)
 
#b-a < c < a+b

#a<=b<=c
ans=0
L_a=L[:N-2]
for i,a in enumerate(L_a):
    L_b=L[i+1:N-1]
    for j,b in enumerate(L_b,start=i+1):
        x=bisect.bisect(L[j+1:],a+b)
        ans+=x
        if a+b==L[j+x]:
            #print(a,b,L[j+x])
            ans-=c[a+b]
        #print(i,a,j,b,x,N-j-1,L[j+1:])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
li_p=[1]*n
li_pp=li_p

for i in range(n):
    li_tmp=[0]*n
    for j in range(n):
        if s[j]=='R':
            li_tmp[j+1]+=li_p[j]
        else:
            li_tmp[j-1]+=li_p[j]
    
    #print(li_tmp)
    
    if li_tmp==li_p:
        print(' '.join(map(str, li_tmp)))
        break
    
    elif li_tmp==li_pp:
        #print(i)
        if i%2:
            print(' '.join(map(str, li_tmp)))
        else:
            print(' '.join(map(str, li_p)))
        break
            
    li_pp=li_p
    li_p=li_tmp
    

Fixed submission:
S=input()+'R'
ans=[0]*(len(S)-1)

Rf=1
Rc,Lc=0,0
for i,s in enumerate(S):
    if s=='R':
        if Rf:
            Rc+=1
        else:
            #print(x,Rc,Lc)
            
            if Rc%2:
                if Lc%2:
                    ans[x]+=(Rc+Lc)//2
                    ans[x+1]+=(Rc+Lc)//2
                else:
                    ans[x]+=(Rc+Lc)//2 + 1
                    ans[x+1]+=(Rc+Lc)//2
            else:
                if Lc%2:
                    ans[x]+=(Rc+Lc)//2
                    ans[x+1]+=(Rc+Lc)//2 + 1         
                else:
                    ans[x]+=(Rc+Lc)//2
                    ans[x+1]+=(Rc+Lc)//2
            
            Rc,Lc=0,0
            Rc+=1
            Rf=1
    else:
        Lc+=1
        if Rf:
            Rf=0
            x=i-1
        else:
            pass

print(' '.join(list(map(str,ans))))
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
dp=[0]*(W+1)
# dp[w] := 上限の容量wのときの価値の最大値

for i in range(1,N+1):
    w,v=map(int,input().split())
    for j in reversed(range(w,W+1)):
        dp[j]=max(dp[j-w]+v, dp[j])
    
print(dp[-1])

Fixed submission:
N, W = map(int, input().split())
dp_pv = [0]*(W+1)

for i in range(N):
    w, v = map(int, input().split())
    
    dp = [dp_pv[j] if w > j else max(dp_pv[j], dp_pv[j-w]+v) for j in range(W+1)]
    dp_pv = dp
    #print(dp)
    
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
dp=[[0]*(W+1) for _ in range(N+1)]
# dp[n][w] := n個の品物のうち上限の容量wのときの価値の最大値

for i in range(1,N+1):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j>=w:
            dp[i][j]=max(dp[i-1][j-w]+v, dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
    
print(dp[-1][-1])

Fixed submission:
N, W = map(int, input().split())
dp_pv = [0]*(W+1)

for i in range(N):
    w, v = map(int, input().split())
    
    dp = [dp_pv[j] if w > j else max(dp_pv[j], dp_pv[j-w]+v) for j in range(W+1)]
    dp_pv = dp
    #print(dp)
    
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
dp_pv = [0]*(W+1)

for i in range(N):
    w, v = map(int, input().split())
    
    dp = [dp_pv[j] if w > j else max(dp_pv[j], dp_pv[j-w]+v) for j in range(W+1)]
    dp_pv = dp
    #print(dp)
    
print(dp[-1])
    

Fixed submission:
N, W = map(int, input().split())
dp_pv = [0]*(W+1)

for i in range(N):
    w, v = map(int, input().split())
    
    dp = [dp_pv[j] if w > j else max(dp_pv[j], dp_pv[j-w]+v) for j in range(W+1)]
    dp_pv = dp
    #print(dp)
    
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
# スペース区切りの整数の入力
a = input()
b = 0
for i in range(3):
	if a[i] =='1':
    	b += 1
print(b)

Fixed submission:
# -*- coding: utf-8 -*-
 
a = input()
b = 0
for i in range(3): 
    if a[i] =='1':
        b += 1
print(str(b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = 0
mod = 10**9+7

for i in range(n-1):
    for j in range(i+1,n):
        ans += a[i]*a[j]
        ans %= mod

print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans = 0
mod = 10**9+7

S = sum(a)

for i in range(n-1):
    S -= a[i]
    ans += a[i]*S
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n,d = list(map(int, input().split()))

count = 0
for i in range(n):
    x,y = list(map(int, input.split()))
    if (x**2 + y**2)**0.5 <= d:
        count += 1

print(count)


Fixed submission:
n,d = list(map(int, input().split()))

count = 0
for i in range(n):
    x,y = list(map(int, input().split()))
    if (x**2 + y**2)**0.5 <= d:
        count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
n,d = list(map(int, input.split()))

count = 0
for i in range(n):
    x,y = list(map(int, input.split()))
    if (x**2 + y**2)**0.5 <=d:
        count += 1

print(count)




Fixed submission:
n,d = list(map(int, input().split()))

count = 0
for i in range(n):
    x,y = list(map(int, input().split()))
    if (x**2 + y**2)**0.5 <= d:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
import math
a,b = list(map(float, input().split()))
B = int(str(b).replace(".",""))
A = int(A)
print(A*B//100)


Fixed submission:
import math
a,b = input().split()
B = int(str(b).replace(".",""))
A = int(a)
print(A*B//100)

Buggy python submission (verdict: Runtime Error):
import math
a,b = list(map(float, input().split()))
B = int(str(b.replace(".","")))
print(int(a*B//100))


Fixed submission:
import math
a,b = input().split()
B = int(str(b).replace(".",""))
A = int(a)
print(A*B//100)

Buggy python submission (verdict: Runtime Error):
a,b = list(map(int, input().split()))
print(int(a*b))


Fixed submission:
import math
a,b = input().split()
B = int(str(b).replace(".",""))
A = int(a)
print(A*B//100)
Buggy python submission (verdict: Runtime Error):
n,k = list(map(int, input().split()))
lst = list(map(int, input().split()))

checker = [None for i in range(n)]
checker[0] = 0
num = 0
count = 0

flag = 0
while flag==0 and count!=k:
    if checker[lst[num]-1]==None:
        checker[lst[num]-1]=count+1
        count+=1
        num = lst[num]-1
    else:
        flag = 1
        count+=1

remaining = (k-checker[lst[num]-1])%(count-checker[lst[num]-1])
num = lst[num]-1
# print("~~~")
# print("rem",remaining)
# print("checker",checker)
# print("num",num)
# print("count",count)

for i in range(remaining):
    num = lst[num]-1

print(num+1)


Fixed submission:
n,k = list(map(int, input().split()))
lst = list(map(int, input().split()))

checker = [None for i in range(n)]
checker[0] = 0
num = 0
count = 0

flag = 0
while flag==0 and count!=k:
    if checker[lst[num]-1]==None:
        checker[lst[num]-1]=count+1
        count+=1
        num = lst[num]-1
    else:
        flag = 1
        count+=1

if flag==1:
    remaining = (k-checker[lst[num]-1])%(count-checker[lst[num]-1])
    num = lst[num]-1
    # print("~~~")
    # print("rem",remaining)
    # print("checker",checker)
    # print("num",num)
    # print("count",count)
    for i in range(remaining):
        num = lst[num]-1

print(num+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = []

for i in range(n):
    s = input()
    if s not in lst:
        lst.append(s)

print(len(lst))


Fixed submission:
n = int(input())
lst = set()

for i in range(n):
    lst.add(input())
    # s = input()
    # if s not in lst:
    #     lst.add(s)

print(len(lst))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        num = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(num,c)

print(ans)


Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
num = k+2
lst = [([None]*num) for i in range(num)]
# print(lst)
for i in range(num):
    for j in range(num):
        lst[i][j] = gcd(i+1,j+1)
# print(lst)

ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        NUM = lst[a-1][b-1]
        for c in range(1,k+1):
            ans += lst[NUM-1][c-1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        k = j + (j-i)
        if k<n and set([s[i],s[j],s[k]])==set(["R","G","B"]):
            ans -= 1
print(ans)


Fixed submission:
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        k = j + (j-i)
        if k<n and set([s[i],s[j],s[k]])==set(["R","G","B"]):
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r = []
g = []
b = []
for i in range(len(s)):
    if s[i]=="R":
        r.append(i)
    elif s[i]=="G":
        g.append(i)
    else:
        b.append(i)

# print(r)
# print(g)
# print(b)

ans = len(r)*len(g)*len(b)

for i in range(n):
    for j in range(i+1,n):
        k = j + (j-i)
        if k<n and set([s[i],s[j],s[k]])==set(["R","G","B"]):
            ans -= 1
print(ans)


Fixed submission:
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        k = j + (j-i)
        if k<n and set([s[i],s[j],s[k]])==set(["R","G","B"]):
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r = []
g = []
b = []
for i in range(len(s)):
    if s[i]=="R":
        r.append(i)
    elif s[i]=="G":
        g.append(i)
    else:
        b.append(i)

# print(r)
# print(g)
# print(b)

ans = 0
for R in r:
    for G in g:
        for B in b:
            lst = [R,G,B]
            lst.sort()
            if lst[1]-lst[0]!=lst[2]-lst[1]:
                ans += 1
print(ans)


Fixed submission:
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        k = j + (j-i)
        if k<n and set([s[i],s[j],s[k]])==set(["R","G","B"]):
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r = []
g = []
b = []
for i in range(len(s)):
    if s[i]=="R":
        r.append(i)
    elif s[i]=="G":
        g.append(i)
    else:
        b.append(i)

# print(r)
# print(g)
# print(b)

ans = 0
for R in r:
    for G in g:
        for B in b:
            lst = [R,G,B]
            lst.sort()
            if lst[1]-lst[0]!=lst[2]-lst[1]:
                ans += 1
print(ans)


Fixed submission:
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        k = j + (j-i)
        if k<n and set([s[i],s[j],s[k]])==set(["R","G","B"]):
            ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
count = 0
num = 1

while count!=k:
    N = str(num)
    check = 0
    for i in range(len(N)-1):
        if abs(int(N[i])-int(N[i+1]))>1:
            check = 1
    if check==0:
        count += 1
    num += 1

print(num-1)


Fixed submission:
import queue
k = int(input())

q = queue.Queue()
num = 0
for i in range(1,10):
    q.put(i)

while num<k:
    i = q.get()
    l = i%10
    if l!=0:
        q.put(i*10+l-1)
    q.put(i*10+l)
    if l!=9:
        q.put(i*10+l+1)
    num += 1

print(i)
Buggy python submission (verdict: Runtime Error):
import copy

n,k,c = map(int, input().split())
s = input()
S = []
lst = [[] for i in range(n)]
# print(lst)
for i in range(len(s)):
    if s[i]=="o":
        S.append(i)
# print("S:",S)
for i in range(len(S)-1):
    koho = S[i+1:]
    for j in koho:
        if j>S[i]+c:
            lst[S[i]].append(j)
    # lst[S[i]].append(S[i+1:])
# print("lst:",lst)



ans = []
for i in S:
    testlst = copy.deepcopy(lst)
    testlst[i] = []
    for j in range(n):
        if testlst[j]!=[]:
            if  testlst[j][0]==i:
                testlst[j].remove(i)
    # print("i,testlst:",i,testlst)

    count = 1
    if i==S[0]:
        num = S[1]
    else:
        num = S[0]
    while testlst[num]!=[]:
        num = testlst[num][0]
        count += 1
    if count < k:
        ans.append(i+1)

for i in ans:
    print(i)


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

asc = []
des = []

count = 0
while count<n:
    if s[count]=="o":
        asc.append(count)
        count += c+1
    else:
        count += 1
asc = asc[0:k]

count = n-1
while count>=0:
    if s[count]=="o":
        des.append(count)
        count -= c+1
    else:
        count -= 1
des = des[0:k]
des.reverse()

# print(asc)
# print(des)

for i in range(len(asc)):
    if asc[i]==des[i]:
        print(asc[i]+1)