Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
ls = [0]*n
param_list = [0]*2**n
for i in range(2**n):
    l = [False]*n
    for id_r, row in enumerate(ls):
        if i & (2 ** id_r) >0:
            l[id_r] = True
    param_list[i] = l 
#1print(param_list)
"""
for i in range(2**(n-1)):
    l = [True]+[False]*(n-1)
    for id_r, row in enumerate(ls):
        if i & id_r >0:
            l[id_r] = True
    param_list[i+2**(n-1)] = l 
print()
print(len(param_list))
print(param_list)
a_list = get_unique_list(param_list)
print(len(a_list))
print(a_list)"""

for i in range(n):
    A = int(input())
    for k in range(A):
        a,b = map(int, input().split())
        b = (1==b)
        new_param =[]
        for d in a_list:
            if d[i]:
                if d[a-1] == b:
                    new_param.append(d)
                    pass
                else:
                    #print(2)
                    pass
            else:
                new_param.append(d)
                #if d[a-1] is b:
                    #print(3)
                    #pass
                #else:
                    #print(4)
                    #new_param.append(d)
                    #pass
            
        param_list = new_param
        #print(param_list)
            
ans = 0    
for d in param_list:
    ans = max(ans, d.count(True))
print(ans)

Fixed submission:
n = int(input())
ls = [0]*n
param_list = [0]*2**n
for i in range(2**n):
    l = [False]*n
    for id_r, row in enumerate(ls):
        if i & (2 ** id_r) >0:
            l[id_r] = True
    param_list[i] = l 


for i in range(n):
    A = int(input())
    for k in range(A):
        a,b = map(int, input().split())
        b = (1==b)
        new_param =[]
        for d in param_list:
            if d[i]:
                if d[a-1] == b:
                    new_param.append(d)
                    pass
                else:
                    #print(2)
                    pass
            else:
                new_param.append(d)
                #if d[a-1] is b:
                    #print(3)
                    #pass
                #else:
                    #print(4)
                    #new_param.append(d)
                    #pass
            
        param_list = new_param
        #print(param_list)
            
ans = 0    
for d in param_list:
    ans = max(ans, d.count(True))
print(ans)
Buggy python submission (verdict: Runtime Error):
#nの約数を列挙する関数
def n_div(n):
    div_list = []
    import math
    for i in range(1, math.ceil(math.sqrt(n))+1):
        if n % i ==0:
            div_list.append(i)
            if i*i ==n:
                continue
            div_list.append(n//i)
    div_list.sort()
    return div_list

n = int(input())
lr = n_div(n)
#print(lr)
if len(lr) % 2==0:
    a = len(lr)/2
    a = int(a)
    ans = lr[a]+lr[a-1]-2
else:
    a = math.floor(len(lr)/2)
    #print(a)
    ans = lr[a]*2  -2
    
print(ans)

Fixed submission:
#nの約数を列挙する関数
import math
def n_div(n):
    div_list = []
    import math
    for i in range(1, math.ceil(math.sqrt(n))+1):
        if n % i ==0:
            div_list.append(i)
            if i*i ==n:
                continue
            div_list.append(n//i)
    div_list.sort()
    return div_list

n = int(input())
lr = n_div(n)
#print(lr)
if len(lr) % 2==0:
    a = len(lr)/2
    a = int(a)
    ans = lr[a]+lr[a-1]-2
else:
    a = math.floor(len(lr)/2)
    #print(a)
    ans = lr[a]*2  -2
    
print(ans)

Buggy python submission (verdict: Runtime Error):
#nの約数を列挙する関数
def n_div(n):
    div_list = []
    import math
    for i in range(1, math.ceil(math.sqrt(n))+1):
        if n % i ==0:
            div_list.append(i)
            if i*i ==n:
                continue
            div_list.append(n//i)
    div_list.sort()
    return div_list

n = int(input())
lr = n_div(n)
#print(lr)
if len(lr) % 2==0:
    a = len(lr)/2
    a = int(a)
    ans = lr[a]+lr[a-1]-2
else:
    a = math.floor(len(lr))
    ans = lr[a]**2
    
print(ans)

Fixed submission:
#nの約数を列挙する関数
import math
def n_div(n):
    div_list = []
    import math
    for i in range(1, math.ceil(math.sqrt(n))+1):
        if n % i ==0:
            div_list.append(i)
            if i*i ==n:
                continue
            div_list.append(n//i)
    div_list.sort()
    return div_list

n = int(input())
lr = n_div(n)
#print(lr)
if len(lr) % 2==0:
    a = len(lr)/2
    a = int(a)
    ans = lr[a]+lr[a-1]-2
else:
    a = math.floor(len(lr)/2)
    #print(a)
    ans = lr[a]*2  -2
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
ans_list =[]
for i in range(n):
    ans_list.append(a_list.index(i+1)+1)
print(*ans_list)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
ans_list =[0]*n
for i in range(n):
    ans_list[a_list[i]-1] = i+1
print(*ans_list)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
tr_list = [i+1 for i in range(n)]
ans_list =[]
for i in range(n):
    ans_list.append(a_list.index(tr_list[i])+1)
print(*ans_list)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
ans_list =[0]*n
for i in range(n):
    ans_list[a_list[i]-1] = i+1
print(*ans_list)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
tr_list = [i+1 for i in range(n)]
ans_list =[]
for i in range(n):
    ans_list.append(a_list.index(tr_list[i])+1)
print(*ans_list)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
ans_list =[0]*n
for i in range(n):
    ans_list[a_list[i]-1] = i+1
print(*ans_list)
Buggy python submission (verdict: Runtime Error):
import math
p,q= input().split()
a,b =(int(p), int(q))
count = 1

for i in range(math.floor(b/a  + 4)):
    if count < b:
        count += a -1
    else:
        ans = i
        break

print(ans)

Fixed submission:
import math
p,q= input().split()
a,b =(int(p), int(q))
count = 1

for i in range(math.floor((b/a)**2 + 4)):
    if count < b:
        count += a -1
    else:
        print(i)
        ans = i
        break
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
count =0
store_list=[]
ans_list=[1]*n
for _ in range(n):
    s = input()
    dict_s =Counter(s)
    #print(dict_s)
    if dict_s in store_list:
        a = store_list.index(dict_s)
        ans_list[a] += 1
    else:
        store_list.append(dict_s)
#print(sum(ans_list))
#print(ans_list)
sum = 0
for i in range(n):
    b = ans_list[i]
    sum += b*(b-1)/2
       
print(int(sum))

Fixed submission:
n = int(input())
count =0
store_list=[]
dictA={}
ans_list=[1]*n
for _ in range(n):
    s = input()
    s_list = list(s)
    s_list.sort()
    a =tuple(s_list)
    dictA.setdefault(a,0)
    dictA[a] +=1 
    #print(dictA)
#print(sum(ans_list))
total = 0
for value in dictA.values() :
    total += value*(value-1)/2
       
print(int(total))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(input()) for _ in range(n)]
for i in range(n):
    cp_list = a_list.copy()
    cp_list[i] = 0
    print(max(cp_list))
    

Fixed submission:
n = int(input())
a_list = [int(input()) for _ in range(n)]
cp_list = a_list.copy()
cp_list.sort()
second_ans = cp_list[-2]
ans = cp_list[-1]
for i in range(n):
    if a_list[i] == ans:
        print(second_ans)
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
from math
a,b,c,d=list(map(int,input().split()))
a-=1
def calculation(x,c,d):
	x=x-(x//c)-(x//d)+(x//((c*d)//math.gcd(c,d)))
	return x
	
print(calculation(b,c,d)-calculation(a,c,d))

Fixed submission:
import math
a,b,c,d=list(map(int,input().split()))
a-=1
def calculation(x,c,d):
	x=x-(x//c)-(x//d)+(x//((c*d)//math.gcd(c,d)))
	return x
	
print(calculation(b,c,d)-calculation(a,c,d))
Buggy python submission (verdict: Time Limit Exceeded):
n,m =map(int, input().split())
    #idxへの行き方の通りをリスト化
num_list = [0]*(n+1)
num_list[0] = 1
a_list =[int(input()) for _ in range(m)]
if 1 not in a_list:
    num_list[1] = 1
for i in range(2,n+1):
    if i not in a_list:
        num_list[i] = num_list[i-1] + num_list[i-2]
print(num_list[n]%(10**9+7))

Fixed submission:
n,m =map(int, input().split())
    #idxへの行き方の通りをリスト化
num_list = [0]*(n+1)
num_list[0] = 1
a_list =set([int(input()) for _ in range(m)])
if 1 not in a_list:
    num_list[1] = 1
for i in range(2,n+1):
    if i not in a_list:
        num_list[i] = num_list[i-1] + num_list[i-2]
print(num_list[n]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,m =map(int, input().split())
    #idxへの行き方の通りをリスト化
    num_list = [0]*(n+1)
    num_list[0] = 1
    a_list =[int(input()) for _ in range(m)]
    if 1 not in a_list:
        num_list[1] = 1
    
    for i in range(2,n+1):
        if i not in a_list:
            num_list[i] = num_list[i-1] + num_list[i-2]
    #print(num_list)
    return num_list[n]

if __name__=='__main__':
    print(main()%(10**9+7))

Fixed submission:
n,m =map(int, input().split())
    #idxへの行き方の通りをリスト化
num_list = [0]*(n+1)
num_list[0] = 1
a_list =set([int(input()) for _ in range(m)])
if 1 not in a_list:
    num_list[1] = 1
for i in range(2,n+1):
    if i not in a_list:
        num_list[i] = num_list[i-1] + num_list[i-2]
print(num_list[n]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,m =map(int, input().split())
    #idxへの行き方の通りをリスト化
    num_list = [0]*(n+1)
    num_list[0] = 1
    a_list =[int(input()) for _ in range(m)]
    div =1000000007
    if 1 not in a_list:
        num_list[1] = 1
    
    for i in range(2,n+1):
        if i not in a_list:
            num_list[i] = num_list[i-1] + num_list[i-2]
    #print(num_list)
    return num_list[-1]%div

if __name__=='__main__':
    print(main())

Fixed submission:
n,m =map(int, input().split())
    #idxへの行き方の通りをリスト化
num_list = [0]*(n+1)
num_list[0] = 1
a_list =set([int(input()) for _ in range(m)])
if 1 not in a_list:
    num_list[1] = 1
for i in range(2,n+1):
    if i not in a_list:
        num_list[i] = num_list[i-1] + num_list[i-2]
print(num_list[n]%(10**9+7))
Buggy python submission (verdict: Runtime Error):
mport math 

a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
p = math.floor(z / x)
print(int(p * y))


Fixed submission:
import math 

a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
p = math.floor(z / x)
print(int(p * y))
Buggy python submission (verdict: Runtime Error):
a = input()
check = 'ACGT'
ans_list = []
for p in range(len(a)):
    for q in range(len(a)-1):
        
        count = 0
        for r in range(len(a[p:len(a)-q])):
            
            if a[p:len(a)-q][r] in check:
                count += 1
                if count == len(a[p:len(a)-q]):
                    ans_list.append(a[p:len(a)-q])
                    
                    break
ls =[]
for i in range(len(ans_list)):
    ls.append(len(ans_list[i]))

print(max(ls))

Fixed submission:
a = input()
check = 'ACGT'
ans_list = []
for p in range(len(a)):
    for q in range(len(a)-1):
        
        count = 0
        for r in range(len(a[p:len(a)-q])):
            
            if a[p:len(a)-q][r] in check:
                count += 1
                if count == len(a[p:len(a)-q]):
                    ans_list.append(a[p:len(a)-q])
                    break
ls =[]
for i in range(len(ans_list)):
    ls.append(len(ans_list[i]))
if len(ls) == 0:
    if a[0] in check:
        print(1)
    else:
        print(0)
else:
    print(max(ls))
Buggy python submission (verdict: Time Limit Exceeded):
import math
s = list(input())
s = list(map(int, s))
s_ori = s.copy()
s_len = len(s)

s_new=[]
for _ in range(200000):
    count=0
    s_len = len(s)
    if s_len ==1:
        #print('a')
        break
    for i in range(1,s_len):
        if count %2==1:
            count +=1
            if i +1==s_len:
                s_new.append(s[-1])
            continue
        if s[i] is not s[i-1]:
            count +=1
        else:
            s_new.append(s[i-1])
            if i +1==s_len:
                s_new.append(s[-1])
    #print(s_new)
    if s==s_new:
        s = s_new
        break
    s = s_new
    s_new=[]
    
#print(s_ori)    
#print(s)
print(math.floor((len(s_ori)-len(s))/2)*2)
            

Fixed submission:
import math
from collections import Counter
s = list(input())
s = list(map(int, s))
dict_s = Counter(s)
#print(dict_s)
print((min(dict_s[0], dict_s[1]))*2)

Buggy python submission (verdict: Time Limit Exceeded):
import math
s = list(input())
s = list(map(int, s))
s_ori = s.copy()
s_len = len(s)

s_new=[]
for _ in range(200000000):
    count=0
    for i in range(1,len(s)):
        if count %2==1:
            count +=1
            if i +1==len(s):
                s_new.append(s[-1])
            continue
        if s[i] is not s[i-1]:
            count +=1
        else:
            s_new.append(s[i-1])
            if i +1==len(s):
                s_new.append(s[-1])     
    if s==s_new:
        s = s_new
        break
    s = s_new
    s_new=[]

#print(s_ori)    
#print(s)
print(math.floor((len(s_ori)-len(s))/2)*2)

Fixed submission:
import math
from collections import Counter
s = list(input())
s = list(map(int, s))
dict_s = Counter(s)
#print(dict_s)
print((min(dict_s[0], dict_s[1]))*2)
Buggy python submission (verdict: Runtime Error):
n= int(input())
a_list = list(map(int, input().split()))
gcd = a_list[0]
for i in range(1,n):
    gcd = math.gcd(gcd,a_list[i])
    
    
print(gcd)

Fixed submission:
import math
n= int(input())
a_list = list(map(int, input().split()))
gcd = a_list[0]
for i in range(1,n):
    gcd = math.gcd(gcd,a_list[i])
    
    
print(gcd)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
import math
def dfs(lis, i):
    if i == 0:
        return lis[0]
    if i >0:
        ans = math.gcd(dfs(lis,i-1),lis[i])
        return ans
print(dfs(a_list,n-1))

Fixed submission:
import math
n= int(input())
a_list = list(map(int, input().split()))
gcd = a_list[0]
for i in range(1,n):
    gcd = math.gcd(gcd,a_list[i])
    
    
print(gcd)
Buggy python submission (verdict: Runtime Error):
p,q= input().split()
a,b =(int(p), int(q))
a_list = []
count_row = 0
for i in range(a):
    c = input()
    
    if c == '.'*b:
        count_row+=1
    else:
        a_list.append(c)
for i in range(b):
    count_clm = 0
    
    for j in range(a-count):
        if a_list[j][i] == '.':
            count_clm+=1
        else:
            break
    if count_clm == (b-count_clm):
        for j in range(a-count_row):
            a_list[j].pop(i)
            
            
for i in range(a-count_row):
    print(a_list[i])

Fixed submission:
p,q= input().split()
a,b =(int(p), int(q))
a_list = []
count_row = 0
b_h ='.'*b

for i in range(a):
    c = input()
    
    if c == b_h:
        count_row+=1
    else:
        a_list.append(c)

ans_list=[]
for i in range(b):
    count_clm = 0
    
    for j in range(a-count_row):
        if a_list[j][i] == '.':
            count_clm+=1
    
    
        if count_clm == (a-count_row):        
            ans_list.append(i)



for j in range(a-count_row):
    total=''
    for i in range(b):
        if i in ans_list:
            ds = 0
        else:
            total +=a_list[j][i]
            
    print(total)
Buggy python submission (verdict: Runtime Error):
n,k= list(map(int,input().split()))
pos= list(map(int,input().split()))
pos_abs =list(map(abs, pos))
pos_abs.sort()
#print(pos_abs)
ls = pos_abs[:k]
high = 0
low = 0
count =0
for a in ls[::-1]:
    if a in pos and high == 0:
        high = a
        count += 1
    elif a not in pos and low ==0:
        low = a
        count += 1
        
    if count == 2:
        break 
if low ==0 and ls.count(ls[-2])==2:
    low = ls[-2]
#print(high,low)
if high >=low:
    print(high+ low*2)
else:
    print(high*2+low)

Fixed submission:
n,k= list(map(int,input().split()))
pos= list(map(int,input().split()))
ans = 10**13
for i in range(n-k+1):
    a1 = abs(pos[i]) + abs(pos[i] - pos[i+k-1])
    a2 = abs(pos[i+k-1]) + abs(pos[i] - pos[i+k-1])
    ans = min(ans, a1,a2)
print(ans)
Buggy python submission (verdict: Runtime Error):
#最小公倍数でループ
import math
n = int(input())
ans = list(map(int,input().split()))
lcm = ans[0]
for k in ans:
    gcd = math.gcd(lcm, k)
    lcm = round(lcm*k/gcd)
    print(lcm)


an =0
for k in ans:
    an += (lcm-1)%k
        
print(an)

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

print(sum(ans)-n)

Buggy python submission (verdict: Runtime Error):
#最小公倍数でループ
import math
n = int(input())
ans = list(map(int,input().split()))
lcm = ans[0]
for k in ans:
    gcd = math.gcd(lcm, k)
    lcm = int(lcm*k/gcd)
#print(lcm)

an =0
for k in ans:
    an += (lcm-1)%k
        
print(an)

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

print(sum(ans)-n)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ls = list(map(int,input().split()))
bs = [ls[i]-i-1 for i in range(n)]
bs.sort()

if n %2 ==0:
    a = int(n/2)
    can = [bs[a],bs[a-1],bs[a+1]]
else:
    a = math.floor(n/2)
    can = [bs[a], bs[a+1],bs[a-1]]

#print(can)
result = 10**10
for k in can:
    ans =0
    for kn in bs:
        ans += abs(kn-k)
    
    result = min(result, ans)
print(result)    

Fixed submission:
import math
n = int(input())
ls = list(map(int,input().split()))
bs = [ls[i]-i-1 for i in range(n)]
bs.sort()
#print(bs)
if n %2 ==0:
    a = round(n/2)
    #print(a)
    can = [bs[a],bs[a-1],math.floor((bs[a] +bs[a-1])/2),math.ceil((bs[a] +bs[a-1])/2)]
elif n ==1:
    can = [bs[0],bs[0]]
else:
    a = math.floor(n/2)
    #print(a)
    can = [bs[a+1],bs[a-1],bs[a]]

#print(can)
result = 10**27
for k in can:
    ans =0
    for kn in bs:
        ans += abs(kn-k)
    #print(ans)
    result = min(result, ans)
    
print(result)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N=int(input())
A=list(map(int,input().split())

C=Counter(A)

A=set(A)

MAX_A=10**6

X=[0]*(MAX_A+1)

for a in A:
    for i in range(a,MAX_A+1,a):
        X[i]+=1

ans=len([a for a in A if (X[1]==1) and (C[a]==1)])

print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

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

edges=[[] for _ in range(n)]#[[１番目の部屋からいける部屋],[２番目の部屋からいける部屋]...]

for _ in range(m):
    a,b=map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

todo=deque([0,0])
seen=[-1]*n
seen[0]=0

while todo:
    node,parent=todo.popleft()#現在探索している部屋、その親
    
    for to in edges[node]:
        if seen[to]!=-1:
            continue

        todo.append([to,node])
        seen[to]=node

print('Yes')

for parent in seen[1:]:
    print(parent+1)

Fixed submission:
from collections import deque

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

edges=[[] for _ in range(n)]#[[１番目の部屋からいける部屋],[２番目の部屋からいける部屋]...]

for _ in range(m):
    a,b=map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

todo=deque([[0,0]])
seen=[-1]*n
seen[0]=0

while todo:
    node,parent=todo.popleft()#現在探索している部屋、その親
    
    for to in edges[node]:
        if seen[to]!=-1:
            continue

        todo.append([to,node])
        seen[to]=node

print('Yes')

for parent in seen[1:]:
    print(parent+1)
Buggy python submission (verdict: Runtime Error):
S=intput()

if S=="ABC":
  print("ARC")
else:
  print("ABC")


Fixed submission:
S=input()

if S=="ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):

N=int(input())
S=input()

Rn=S.count('R')
Gn=S.count('G')
Bn=S.count('B')

ans=0

for k in range(N//2-2+1 if N&1==0 else N//2-1+1):#k個飛ばし
    i=0
    while i+2*(k+1)<=N-1:
        ls=[S[i],S[i+k+1],S[i+2*(k+1)]]
        if "R" in ls and "G" in ls and "B" in ls:
            ans+=1
        i+=1

print(Rn*Gn*Bn-ans)

Fixed submission:
N=int(input())
S=input()

R_num=S.count('R')
G_num=S.count('G')
B_num=S.count('B')

ans=0
for k in range(N//2-2+1 if N&1==0 else N//2-1+1):
    flag=0
    for i in range(N-k-2):

        if i+2*(k+1)<=N-1:
            ls=[S[i],S[i+k+1],S[i+2*(k+1)]]
    
            if "R" in ls and "G" in ls and "B" in ls:
                ans+=1


print(R_num*G_num*B_num-ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

R_num=S.count('R')
G_num=S.count('G')
B_num=S.count('B')

ans=0
for k in range(N//2-2+1 if N&1==0 else N//2-1+1):
    flag=0
    for i in range(N-k-2):

        if i+2*(k+1)<=N-1:
            ls=[S[i],S[i+k+1],S[i+2*(k+1)]]
    
            if "R" in ls and "G" in ls and "B" in ls:
                ans+=1


print(R_num*G_num*B_num-ans)

Fixed submission:
N=int(input())
S=input()

R_num=S.count('R')
G_num=S.count('G')
B_num=S.count('B')

ans=0
for k in range(N//2-2+1 if N&1==0 else N//2-1+1):
    flag=0
    for i in range(N-k-2):

        if i+2*(k+1)<=N-1:
            ls=[S[i],S[i+k+1],S[i+2*(k+1)]]
    
            if "R" in ls and "G" in ls and "B" in ls:
                ans+=1


print(R_num*G_num*B_num-ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

K=int(input())

todo=deque(list(map(str,range(1,10))))

count=0

while todo:
    num=todo.popleft()
    count+=1

    if count==k:
        print(num)
        exit()
    
    base=int(num[-1])
    n1=base-1
    if n1!=-1:
        todo.append(num+str(n1))
    
    n2=base
    todo.append(num+str(n2))

    n3=base+1

    if n3!=10:
        todo.append(num+str(n3))

Fixed submission:
from collections import deque

K=int(input())

todo=deque(list(map(str,range(1,10))))

count=0

while todo:
    num=todo.popleft()
    count+=1

    if count==K:
        print(num)
        exit()
    
    base=int(num[-1])
    n1=base-1
    if n1!=-1:
        todo.append(num+str(n1))
    
    n2=base
    todo.append(num+str(n2))

    n3=base+1

    if n3!=10:
        todo.append(num+str(n3))

Buggy python submission (verdict: Runtime Error):
from collections import deque

K=int(input())
q=deque()
A=[]
q.append('0')
q.append('1')
q.append('2')
q.append('3')
q.append('4')
q.append('5')
q.append('6')
q.append('7')
q.append('8')
q.append('9')
q.append('10')
q.append('11')
q.append('12')

while len(A)<=K+10:
    snum=q.popleft()
    inum=int(snum)
    if snum[0]!='0':
        A.append(snum)
    
    if inum!=10 or inum!=11 or inum!=12: 
        if 1<=int(snum[0])<=8:
            q.append(str(int(snum[0])-1)+snum)
            q.append(str(int(snum[0])+1)+snum)

        elif int(snum[0])==0:
            q.append(str(int(snum[0])+1)+snum)
        
        elif int(snum[0])==9:
            q.append(str(int(snum[0])+1)+snum)
print(list(set(A))[K])


Fixed submission:
from collections import deque

K=int(input())

todo=deque(list(map(str,range(1,10))))

count=0

while todo:
    num=todo.popleft()
    count+=1

    if count==K:
        print(num)
        exit()
    
    base=int(num[-1])
    n1=base-1
    if n1!=-1:
        todo.append(num+str(n1))
    
    n2=base
    todo.append(num+str(n2))

    n3=base+1

    if n3!=10:
        todo.append(num+str(n3))