Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# B - バイナリハックイージー

s = input()
listAns = []

set1 = ['0', '1']
set2 = ['B']

listS = list(s)

print(listS)

for i in listS:
    if i in set1:
        listAns.append(i)

    elif i in set2:
        if len(listAns) != 0:
            listAns.pop()

ans = reduce(lambda x, y: x + y, [str(x) for x in listAns])

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
# B - バイナリハックイージー

s = input()
listAns = []

set1 = ['0', '1']
set2 = ['B']

listS = list(s)

# print(listS)

for i in listS:
    if i in set1:
        listAns.append(i)

    elif i in set2:
        if len(listAns) != 0:
            listAns.pop()

ans = "".join(listAns)

print(ans)
Buggy python submission (verdict: Runtime Error):
    l = list(map(int, input().split()))

    counter5 = 0
    counter7 = 0

    for num in l:
        if num == 5:
            counter5+=1
        
        if num == 7:
            counter7+=1

    if counter5 == 2 and counter7 == 1:
        print("Yes")
    
    else:
        print("No")

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

counter5 = 0
counter7 = 0

for num in l:
    if num == 5:
        counter5+=1
    
    if num == 7:
        counter7+=1

if counter5 == 2 and counter7 == 1:
    print("YES")

else:
    print("NO")

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

    counter5 = 0
    counter7 = 0

    for num in input:
        if num == 5:
            counter5+=1
        
        if num == 7:
            counter7+=1

    if counter5 == 2 and counter7 == 1:
        print("Yes")
    
    else:
        print("No")

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

counter5 = 0
counter7 = 0

for num in l:
    if num == 5:
        counter5+=1
    
    if num == 7:
        counter7+=1

if counter5 == 2 and counter7 == 1:
    print("YES")

else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def main():
    # input = "5 7 7"
    input = list(map(int, input().split()))
    print(input)

    counter5 = 0
    counter7 = 0

    for num in input:
        if num == 5:
            counter5+=1
        
        if num == 7:
            counter7+=1

    if counter5 == 2 and counter7 == 1:
        print("Yes")
    
    else:
        print("No")



if __name__ == "__main__":
    main()

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

counter5 = 0
counter7 = 0

for num in l:
    if num == 5:
        counter5+=1
    
    if num == 7:
        counter7+=1

if counter5 == 2 and counter7 == 1:
    print("YES")

else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# C - こだわり者いろはちゃん

N, K = map(int, input().split())
D = list(map(int, input().split()))
numList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
listAns = []

num = []
listN = [int(x) for x in list(str(N))]

# print(listN)

for i in numList:
    if i not in D:
        num.append(i)

# print(num)

for i in listN:
    for j in num:
        if j >= i:
            listAns.append(j)
            break
            
# print(listAns)
ans = int(reduce(lambda x, y: x + y, [str(x) for x in listAns]))
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

def main():


    N, K = map(int, input().split())
    D = list(map(int, input().split()))

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

    num = set()
        
    for i in numList:
        if i not in D:
            num.add(i)
    

    for i in range(N, N * 10 + 1):
        setI = set(int(x) for x in list(str(i)))
        if len(num | setI) <= len(num):
            ans = i
            break
                
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
l, r, d = input().split()
print(r//d -(l-1)//d)

Fixed submission:
l, r, d = map(int, input().split())
print(r//d - (l-1)//d)

Buggy python submission (verdict: Runtime Error):
l, r, d = input().split()
t1 = int(r/d)
t2 = int(l/d)
print(t1-t2)

Fixed submission:
l, r, d = map(int, input().split())
print(r//d - (l-1)//d)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

count = 0

for i in range(int(N/2)+1):
  cd = 2 * i
  jd = a[cd]
  if jd % 2 == 1:
    count += 1

print(count)

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

count = 0

for i in range(0,N,2):
  jd = a[i]
  if jd % 2 == 1:
    count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []
a = input().split()

count = 0

for i in range(int(N/2) + 1):
  cd = 2 * i - 2
  jd = int(a[cd])
  if jd % 2 == 1:
    count += 1
    

print(count)

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

count = 0

for i in range(0,N,2):
  jd = a[i]
  if jd % 2 == 1:
    count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
import numpy as np

a,b,x = input().split()
a = int(a)
b = int(b)
x = int(x)
ans = 0.000000000
if 2*x/(a**2) < b:
  l = 2*x/(a*b)
  ans = np.arctan(l/b)
else:
  l = 2 * (b - x/(a**2))
  ans = np.arctan(a/l)

ans = 90 - np.rad2deg(ans)
print('{:.10f}'.format(ans))

Fixed submission:
import numpy as np

a,b,x = input().split()
a = int(a)
b = int(b)
x = int(x)
ans = 0
if 2*x/(a**2) < b:
  l = 2*x/(a*b)
  ans = np.arctan(l/b)
else:
  l = 2 * (b - x/(a**2))
  if l == 0:
    ans = np.pi/2
  else:
    ans = np.arctan(a/l)

ans = 90 - np.rad2deg(ans)
print('{:.10f}'.format(ans))
Buggy python submission (verdict: Runtime Error):
L,R,d = (int(x) for x in input().split())

for i in range(R):
    if d*i>=R:
      max=i
      break

for i in range(L):
    if d*i>=L:
        min=i-1
        break

print(str(max-min))

Fixed submission:
L,R,d = (int(x) for x in input().split())
cnt=0
for i in range(L,R+1):
 if i%d==0:
        cnt+=1

print(cnt)

Buggy python submission (verdict: Runtime Error):
L,R,d = (int(x) for x in input().split())

for i in range(R):
    if d*i>=R:
      max=i
      break

for i in range(L):
    if d*i>L:
        min=i
        break

print(str(max-min))

Fixed submission:
L,R,d = (int(x) for x in input().split())
cnt=0
for i in range(L,R+1):
 if i%d==0:
        cnt+=1

print(cnt)

Buggy python submission (verdict: Runtime Error):
L=input("始まりの数")
L=int (L)
R=input("終わりの数")
R=int (R)
d=input("倍数の元となる数")
d=int(d)
for i in range(R):
    if d*i>=R:
      max=i
      break

for i in range(L):
    if d*i>=L:
        min=i
        break

print(str(max-min))

Fixed submission:
L,R,d = (int(x) for x in input().split())
cnt=0
for i in range(L,R+1):
 if i%d==0:
        cnt+=1

print(cnt)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
sum=0
while sum<=k and (A!=[] or B!=[]):
    if A!=[] and B!=[]:
        a=A[0]
        b=B[0]
        if a<b or B==[]:
            sum+=A.pop(0)
            ans+=1
        elif b<a and A==[]:
            sum+=B.pop(0)
            ans += 1
        else:
            x=min(len(A),len(B))
            for i in range(x):
                if A[i]<B[i]:
                    sum += A.pop(0)
                    ans += 1
                    break
                elif A[i]>B[i]:
                    sum += B.pop(0)
                    ans += 1
                    break
            if len(A)>len(B):
                if A[i+1]>B[i]:
                    sum += B.pop(0)
                    ans += 1
                else:
                    sum += A.pop(0)
                    ans += 1
    elif A!=[]:
        sum += A.pop(0)
        ans += 1
    elif B!=[]:
        sum += B.pop(0)
        ans += 1
if sum>k:
    print(ans-1)
else:
    print(ans)

Fixed submission:
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans=0
j=m
for i in range(n+1):
    if a[i]>k:
        break
    time=a[i]+b[j]
    while time>k:
        j-=1
        time=a[i]+b[j]
    ans=max(ans,i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ans=0
d=[0]*(N+1)
for n in range(1,N+1):
    ret=0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret+=1
            if i != n // i:
                ret+=1
    ans+=n*ret
    d[n]=ret
print(ans)

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1):
    m=n//i
    ans+=m*(m+1)//2*i
print(ans)
Buggy python submission (verdict: Runtime Error):
length=int(input())
list=list(map(int,input().split()))
list.sort()
max=list[-1]
dp=[True]*(max+1)
ret=0
for num in list:
    if dp[num]:
        if list.count(num)!=1:
            dp[num]=False
        else:
            ret=ret+1
            i=2
            num2=num*i
            while num2<max+1:
                if num2 in list:
                    dp[num2]=False
                i=i+1
                num2=num*i
print(ret)

Fixed submission:
input=input()
x = input.split()
for i in range(5):
    if(x[i]=='0'):
        print(i+1)
        break

Buggy python submission (verdict: Runtime Error):
input=[input().split() for i in range(2)]
length=int(input[0][0])
list=[]
for i in range(length):
    list.append(int(input[1][i]))
ret=0
list.sort()
for i in range(length):
    flg=True
    num=list[i]
    if list.count(num)==1:
        for j in range(i):
            if i!=j and num%list[j]==0:
                flg=False
                break
        if flg:
            ret=ret+1
print(ret)

Fixed submission:
input=input()
x = input.split()
for i in range(5):
    if(x[i]=='0'):
        print(i+1)
        break

Buggy python submission (verdict: Runtime Error):
input=[input().split() for i in range(2)]
length=int(input[0][0])
list=[]
for i in range(length):
    list.append(int(input[1][i]))
ret=0
list.sort()
for i in range(length):
    flg=True
    num=list[i]
    if list.count(num)==1:
        for j in range(i+1):
            if i!=j and num%list[j]==0:
                flg=False
                break
        if flg:
            ret=ret+1
print(ret)

Fixed submission:
input=input()
x = input.split()
for i in range(5):
    if(x[i]=='0'):
        print(i+1)
        break
Buggy python submission (verdict: Time Limit Exceeded):
length=int(input())
list=list(map(int,input().split()))
list.sort()
max=list[-1]
dp=[True]*(max+1)
ret=0
for num in list:
    if dp[num]:
        for i in range(max//num+1):
            dp[num*i]=False
        if list.count(num)==1:
            ret=ret+1
print(ret)

Fixed submission:
import numpy as np
from collections import Counter

length=int(input())
list=list(map(int,input().split()))
list.sort()

max=list[-1]
dp=[0]*(max+1)
dp=np.array(dp,int)

for num in list:
    dp[num]=1

for num in list:
    if dp[num]==1:
        dp[2*num::num]=0

count=Counter(list)

for num,cnt in count.items():
    if cnt>1:
        dp[num]=0

print(dp.sum())

Buggy python submission (verdict: Time Limit Exceeded):
length=int(input())
list=list(map(int,input().split()))
list.sort()
max=list[-1]
dp=[True]*(max+1)
ret=0
for num in list:
    if dp[num]:
        for i in range(max//num+1):
            dp[num*i]=False
        if list.count(num)==1:
            ret=ret+1
print(ret)


Fixed submission:
import numpy as np
from collections import Counter

length=int(input())
list=list(map(int,input().split()))
list.sort()

max=list[-1]
dp=[0]*(max+1)
dp=np.array(dp,int)

for num in list:
    dp[num]=1

for num in list:
    if dp[num]==1:
        dp[2*num::num]=0

count=Counter(list)

for num,cnt in count.items():
    if cnt>1:
        dp[num]=0

print(dp.sum())

Buggy python submission (verdict: Time Limit Exceeded):
input=[input().split() for i in range(2)]
length=int(input[0][0])
list=[]
for i in range(length):
    list.append(int(input[1][i]))
ret=0
list.sort()
for i in range(length):
    flg=True
    num=list[i]
    if list.count(num)==1:
        for j in range(i):
            if i!=j and num%list[j]==0:
                flg=False
                break
        if flg:
            ret=ret+1
print(ret)

Fixed submission:
import numpy as np
from collections import Counter

length=int(input())
list=list(map(int,input().split()))
list.sort()

max=list[-1]
dp=[0]*(max+1)
dp=np.array(dp,int)

for num in list:
    dp[num]=1

for num in list:
    if dp[num]==1:
        dp[2*num::num]=0

count=Counter(list)

for num,cnt in count.items():
    if cnt>1:
        dp[num]=0

print(dp.sum())

Buggy python submission (verdict: Time Limit Exceeded):
input=[input().split() for i in range(2)]
length=int(input[0][0])
list=[]
for i in range(length):
    list.append(int(input[1][i]))
ret=0
for i in range(length):
    flg=True
    num=list[i]
    for j in range(length):
        if i!=j and num%list[j]==0:
            flg=False
            break
    if flg:
        ret=ret+1
print(ret)

Fixed submission:
import numpy as np
from collections import Counter

length=int(input())
list=list(map(int,input().split()))
list.sort()

max=list[-1]
dp=[0]*(max+1)
dp=np.array(dp,int)

for num in list:
    dp[num]=1

for num in list:
    if dp[num]==1:
        dp[2*num::num]=0

count=Counter(list)

for num,cnt in count.items():
    if cnt>1:
        dp[num]=0

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

if 0 in list:
  print(0)
else:
  prod=1
  for a in list:
    flg=True
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)


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

flg=True
if 0 in list:
  print(0)
  flg=False
else:
  prod=1
  for a in list:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
n=input()
list=list(map(int,input().split()))
list=np.array(list,'int64')
ans=np.prod(list)
p=math.log10(ans)
if p>=18:
  print(-1)
else:
  print(np.prod(list))

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

flg=True
if 0 in list:
  print(0)
  flg=False
else:
  prod=1
  for a in list:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
n=input()
list=list(map(int,input().split()))
list=np.array(list,int)
ans=np.prod(list)
p=math.log10(ans)
if p>=18:
  print(-1)
else:
  print(np.prod(list))


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

flg=True
if 0 in list:
  print(0)
  flg=False
else:
  prod=1
  for a in list:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
n=input()
list=list(map(int,input().split()))
list=np.array(list,int)

p=math.log10(list)
p=p.sum()
if p>=18:
  print(-1)
else:
  print(np.prod(list))

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

flg=True
if 0 in list:
  print(0)
  flg=False
else:
  prod=1
  for a in list:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
ans=a*b
p=math.log10(ans)
if p>=18:
  print(-1)
else:
  print(ans)

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

flg=True
if 0 in list:
  print(0)
  flg=False
else:
  prod=1
  for a in list:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)
Buggy python submission (verdict: Time Limit Exceeded):
def func(ans, dic, keylst):
    if keylst == []:
        return ans
    else:
        array = []
        for i in range(2, N + 1):
            if not(i in ans.keys()):
                for j in keylst:
                    if j in dic[i]:
                        ans[i] = j
                        array.append(i)
                        break
        func(ans, dic, array)


N, M = map(int, input().split())
dic = {}
for i in range(N):
    dic[i + 1] = []

for i in range(M):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)

ans = {}
keylst = [1]
func(ans, dic, keylst)

flg=True
for i in range(2,N + 1):
    if not(i in ans.keys()):
        flg=False
        break

if flg:
    print('Yes')
    for i in range(2,N + 1):
        print(ans[i])
else:
    print('No')


Fixed submission:
from collections import deque

n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

ans=[-1]*(n+1)
ans[0]=0
ans[1]=0

d=deque()
d.append(1)

while d:
    v=d.popleft()
    for i in graph[v]:
        if ans[i]!=-1:
            continue
        ans[i]=v
        d.append(i)

ans=ans[2:]
print("Yes")
print(*ans,sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
def func(ans, dic, keylst):
    if keylst == []:
        return ans
    else:
        array = []
        for i in range(2, N + 1):
            if not(i in ans.keys()):
                for j in keylst:
                    if j in dic[i]:
                        ans[i] = j
                        array.append(i)
                        break
        func(ans, dic, array)


N, M = map(int, input().split())
dic = {}
for i in range(N):
    dic[i + 1] = []

for i in range(M):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)

ans = {}
keylst = [1]
func(ans, dic, keylst)

flg=True
for i in range(2,N + 1):
    if not(i in ans.keys()):
        flg=False
        break

if flg:
    print('Yes')
    for i in range(2,N + 1):
        print(ans[i])
else:
    print('No')


Fixed submission:
from collections import deque

n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

ans=[-1]*(n+1)
ans[0]=0
ans[1]=0

d=deque()
d.append(1)

while d:
    v=d.popleft()
    for i in graph[v]:
        if ans[i]!=-1:
            continue
        ans[i]=v
        d.append(i)

ans=ans[2:]
print("Yes")
print(*ans,sep="\n")
Buggy python submission (verdict: Runtime Error):
def main():
    n,m=map(int,input().split())
    sc=[list(map(int,input().split())) for _ in range(m)]
    a=[0]*(n+1)
    if n==3:
        a[1]=1
    elif n==2:
        a[2]=1
    d=[-1]*(n+1)
    for i in range(m):
        s=sc[i][0]
        c=sc[i][1]
        if d[s]==-1 or a[s]==c:
            a[s]=c
            d[s]=0
        else:
            print(-1)
            return
    ans=100*a[1]+10*a[2]+a[3]
    if ans>=10**(n-1):
        print(ans)
        return
    else:
        print(-1)
        return
main()

Fixed submission:
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
a=[0]*(n+1)
if n!=1:
    a[1]=1
d=[-1]*(n+1)
flg=True
for i in range(m):
    s=sc[i][0]
    c=sc[i][1]
    if d[s]==-1 or a[s]==c:
        a[s]=c
        d[s]=0
    else:
        flg=False
ans=int("".join(map(str,a)))
if ans>=10**(n-1) and flg:
    print(ans)
elif n==1 and ans==0:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
max=0
for i in range(n-k+1):
    sum=0
    for j in range(i,i+k):
         sum+=p[j]
    if sum>max:
        max=sum
ans=(max+k)*0.5
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
max=0
sum=0
for i in range(0, k):
    sum += p[i]
max=sum
for i in range(1,n-k+1):
    sum+=p[k-1+i]-p[i-1]
    if sum>max:
        max=sum
ans=(max+k)*0.5
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
max=0
for i in range(n-k+1):
    sum=0
    for j in range(i,i+k):
         sum+=p[j]
    if sum>max:
        max=sum
ans=(max+k)*0.5
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
max=0
sum=0
for i in range(0, k):
    sum += p[i]
max=sum
for i in range(1,n-k+1):
    sum+=p[k-1+i]-p[i-1]
    if sum>max:
        max=sum
ans=(max+k)*0.5
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ret=0
while "BW" in s:
    ret+=s.count("BW")
    s=s.replace("BW","WB")
print(ret)

Fixed submission:
s=input()
n=len(s)
ret=0
pos=0
for i in range(n):
    if s[i]=="W":
        ret+=i-pos
        pos+=1
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ret=0
while "BW" in s:
    ret+=s.count("BW")
    s=s.replace("BW","WB")
print(ret)

Fixed submission:
s=input()
n=len(s)
ret=0
pos=0
for i in range(n):
    if s[i]=="W":
        ret+=i-pos
        pos+=1
print(ret)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
tmp = min(n,k)
n = max(n, k)
k = tmp

def calc(n, k):
  if n < k:
    return abs(n-k)
  else:
    return calc(abs(n-k), k)
 
if k == 1:
  print(0)
else:
  print(calc(n,k))

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

tmp = n%k
print(min(tmp, abs(tmp-k)))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
queue = [i for i in range(1, 10)]

for i in range(k-1):
  tmp = queue.pop(0)
  r = tmp % 10
  if r != 0:
    queue.append(10*tmp + r -1)
  queue.append(10*tmp + r)
  if r != 9:
    queue.append(10*tmp + r + 1)
print(queue.pop(0))
  

Fixed submission:
from collections import deque
k = int(input())
q = deque([i for i in range(1, 10)])

for i in range(k-1):
  tmp = q.popleft()
  r = tmp % 10
  if r != 0:
    q.append(10*tmp + r -1)
  q.append(10*tmp + r)
  if r != 9:
    q.append(10*tmp + r + 1)
print(q.popleft())

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
queue = [i for i in range(1, 10)]

for i in range(k-1):
  tmp = queue.pop(0)
  r = tmp % 10
  if r != 0:
    queue.append(10*tmp + r -1)
  queue.append(10*tmp + r)
  if r != 9:
    queue.append(10*tmp + r + 1)
print(queue.pop(0))
  

Fixed submission:
from collections import deque
k = int(input())
q = deque([i for i in range(1, 10)])

for i in range(k-1):
  tmp = q.popleft()
  r = tmp % 10
  if r != 0:
    q.append(10*tmp + r -1)
  q.append(10*tmp + r)
  if r != 9:
    q.append(10*tmp + r + 1)
print(q.popleft())
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
dists = [0 for i in range(n)]

for i in range(1, n+1):
  for j in range(i+1, n+1):
    dist = min(abs(j-i), 1 + abs(x-i)+abs(y-j), 1 + abs(y-i)+abs(x-j))
    if dist > 0:
      dists[dist-1]+=1
    
for i in range(n-1):
  print(dists[i])

Fixed submission:
n, x, y = map(int, input().split())
dists = [0 for i in range(n+1)]

for i in range(1, n+1):
  for j in range(i+1, n+1):
    dist = min(abs(j-i), 1 + abs(x-i)+abs(y-j), 1 + abs(y-i)+abs(x-j))
    dists[dist]+=1
    
for i in range(1, n):
  print(dists[i])

Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())

for k in range(1, n):
  count = 0
  for i in range(1, n+1):
    for j in range(1, n+1):
      dist = min(abs(j-i), 1 + abs(x-i)+abs(y-j), 1 + abs(y-i)+abs(x-j))
      if dist == k:
        count+=1
  print(count//2)
    

Fixed submission:
n, x, y = map(int, input().split())
dists = [0 for i in range(n+1)]

for i in range(1, n+1):
  for j in range(i+1, n+1):
    dist = min(abs(j-i), 1 + abs(x-i)+abs(y-j), 1 + abs(y-i)+abs(x-j))
    dists[dist]+=1
    
for i in range(1, n):
  print(dists[i])