Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import itertools
x = int(input())
num = [i**5 for i in range(3000)]
ans= list(itertools.combinations_with_replacement(num, 2))
for i in ans:
    if abs(i[0]-i[1]) == x:
        if i[0] < i[1]:
            print(int(i[1]**0.2),int(i[0]**0.2)*)
        else:
            print(int(i[0]**0.2),int(i[1]**0.2))
        break
    elif i[0]+i[1] == x:
        print(int(i[0]**0.2),int(i[1]**0.2)*-1)
        break


Fixed submission:
import itertools
x = int(input())
num = [i**5 for i in range(3000)]
ans= list(itertools.combinations_with_replacement(num, 2))
for i in ans:
    if abs(i[0]-i[1]) == x:
        if i[0] < i[1]:
            print(int(i[1]**0.2),int(i[0]**0.2))
        else:
            print(int(i[0]**0.2),int(i[1]**0.2))
        break
    elif i[0]+i[1] == x:
        print(int(i[0]**0.2),int(i[1]**0.2)*-1)
        break
Buggy python submission (verdict: Runtime Error):
s,w = map(int,input())
if s <= w:
    print("unsafe")
else:
    print("safe")


Fixed submission:
s,w = map(int,input().split())
if s <= w:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = []
for i in range(n):
    s = input()
    if not s in ans:
        ans.append(s)
print(len(ans))


Fixed submission:
from collections import Counter

n = int(input())
ans = []
for i in range(n):
    s = input()
    ans.append(s)
answer = Counter(ans)
print(len(list(answer.keys())))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
m = list(map(int,input().split()))
for i in range(n):
    if i+1 in m:
        print(m.count(i+1))
    else:
        print(0)


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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
m = list(map(int,input().split()))
for i in range(n):
    if i+1 in m:
        print(m.count(i+1))
    else:
        print(0)


Fixed submission:
n = int(input())
m = list(map(int,input().split()))
a = [0 for i in range(n)]
for i in m:
    a[i-1] += 1
for i in a:
    print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input())
r = []
g = []
b = []
for i,j in enumerate(s):
    if j == "R":
        r.append(i)
    elif j == "G":
        g.append(i)
    else:
        b.append(i)
ans = 0
ss = [len(r),len(g),len(b)]
if max(ss) == len(b):
    for i in r:
        for j in g:
            sa = abs(i-j)
            if sa%2==0:
                p = (i+j)//2
                if p in b:
                    ans-=1
                    ans += len(b)
            if i<j:
                if (i-sa) in b:
                    ans -= 1
                if (j+sa) in b:
                    ans -= 1
            if i>j:
                if (j-sa) in b:
                    ans -= 1
                if (i+sa) in b:
                    ans -= 1
if max(ss) == len(g):
    for i in r:
        for j in b:
            sa = abs(i-j)
            if sa%2==0:
                p = (i+j)//2
                if p in g:
                    ans-=1
                    ans += len(g)
            if i<j:
                if (i-sa) in g:
                    ans -= 1
                if (j+sa) in g:
                    ans -= 1
            if i>j:
                if (j-sa) in g:
                    ans -= 1
                if (i+sa) in g:
                    ans -= 1
if max(ss) == len(r):
    for i in b:
        for j in g:
            sa = abs(i-j)
            if sa%2==0:
                p = (i+j)//2
                if p in r:
                    ans-=1
                    ans += len(r)
            if i<j:
                if (i-sa) in r:
                    ans -= 1
                if (j+sa) in r:
                    ans -= 1
            if i>j:
                if (j-sa) in r:
                    ans -= 1
                if (i+sa) in r:
                    ans -= 1

print(ans)


Fixed submission:
s = list(input())
if "7" in s:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input())
r = []
g = []
b = []
for i,j in enumerate(s):
    if j == "R":
        r.append(i)
    elif j == "G":
        g.append(i)
    else:
        b.append(i)
ans = 0
for i in r:
    for j in g:
        for k in b:
            a=[i,j,k]
            a.sort()
            if a[2]-a[1] != a[1]-a[0]:
                ans+=1
print(ans)


Fixed submission:
s = list(input())
if "7" in s:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
#各番号がいくつずつあるのかを整理
#keyに番号、valueにその番号が書かれてあるボールの数
for i in range(n):
    if not s[i] in ans.keys():
        ans[s[i]] = 1
    else:
        ans[s[i]] += 1
#iC2の総和
answer = 0
for i in ans.values():
    answer += i*(i-1)//2
#answer-nC2+(n-1)C2 = answer-n+1
#nはans[s[i]],よって以下の出力で求められる
for i in range(n):
    print(answer-ans[s[i]]+1)


Fixed submission:
n = list(map(int,input().split()))
ans = 0
if n[0]>=2:
    ans += n[0]*(n[0]-1)//2
if n[1]>=2:
    ans += n[1]*(n[1]-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(round((n/3)**3,15)


Fixed submission:
n = int(input())
print(round((n/3)**3,15))
Buggy python submission (verdict: Runtime Error):
n = list(map(int,input().split()))
print((n[0]*n[1]+1)//2)

Fixed submission:
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(a[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = {}
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if not s[i]+s[j]+s[k] in ans:
                ans[s[i]+s[j]+s[k]] = 0
print(len(ans))

Fixed submission:
n = input()
s = input()
ans = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j),a+1)
        if b == -1:
            continue
        for k in range(10):
            c = s.find(str(k),b+1)
            if c == -1:
                continue
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())-3
s = list(input())
ans = list(combinations(s,3))
#print(ans)
answer = []
for i in ans:
    if i not in answer:
        answer.append(i)
print(len(answer))

Fixed submission:
n = input()
s = input()
ans = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j),a+1)
        if b == -1:
            continue
        for k in range(10):
            c = s.find(str(k),b+1)
            if c == -1:
                continue
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def make_divisors(n,m):
    divisors = []
    for i in range(1, int(n)):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
print(c[-1+k])

Fixed submission:
def make_divisors(n,m):
    divisors = []
    for i in range(1,n+1):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
c.reverse()
print(c[k-1])

Buggy python submission (verdict: Runtime Error):
def make_divisors(n,m):
    divisors = []
    for i in range(1, int(n)):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
print(c[-1+k])

Fixed submission:
def make_divisors(n,m):
    divisors = []
    for i in range(1,n+1):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
c.reverse()
print(c[k-1])

Buggy python submission (verdict: Runtime Error):
def make_divisors(n,m):
    divisors = []
    for i in range(1, int(n)):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
print(c[-1+k]

Fixed submission:
def make_divisors(n,m):
    divisors = []
    for i in range(1,n+1):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
c.reverse()
print(c[k-1])
Buggy python submission (verdict: Runtime Error):
n = input()
s = list(map(int,input().split()))
c = 0
for i in s:
    if s % 2 == 1:
        c+=1
if c % 2 == 1:
    print("NO")
else:
    print("YES")

Fixed submission:
n = input()
s = list(map(int,input().split()))
c = 0
for i in s:
    if i % 2 == 1:
        c+=1
if c % 2 == 1:
    print("NO")
else:
    print("YES")

Buggy python submission (verdict: Runtime Error):
n = input()
s = list(map(int,input().split()))
c = 0
for i in s:
  if s % 2 == 1:
    c+=1
if c % 2 == 1:
  print("NO")
else:
  print("YES")

Fixed submission:
n = input()
s = list(map(int,input().split()))
c = 0
for i in s:
    if i % 2 == 1:
        c+=1
if c % 2 == 1:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul

n, k = map(int, input().split())
a = list(map(int, input().split()))

num = reduce(mul, a[:k])
for i in range(k, n):
    num2 = num*a[i]//a[i-k]
    if num < num2:
        print('Yes')
    else:
        print('No')
    num = num2

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

for i in range(k, n):
    if a[i]/a[i-k] > 1:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul

n, k = map(int, input().split())
a = list(map(int, input().split()))

num = reduce(mul, a[:k])
for i in range(k, n):
    num2 = reduce(mul, a[i-k+1:i+1])
    if num < num2:
        print('Yes')
    else:
        print('No')
    num = num2

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

for i in range(k, n):
    if a[i]/a[i-k] > 1:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 1
 
    for i in a:
        ans *= i
    
    if ans > int(1e18): return -1
    return ans
    

print(solve())

Fixed submission:
from collections import Counter
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a: return 0
    l = Counter(a)
    ans = 1
    for i,j in l.items():
        ans *= i**j
        if ans > int(1e18):
            return -1

    return ans
    

print(solve())

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

    ans = 1
 
    for i in a:
        ans *= i
      	if ans > int(1e18): return -1
    
    
    return ans
    

print(solve())


Fixed submission:
from collections import Counter
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a: return 0
    l = Counter(a)
    ans = 1
    for i,j in l.items():
        ans *= i**j
        if ans > int(1e18):
            return -1

    return ans
    

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 1
 
    for i in a:
        ans *= i
    
    if ans > int(1e18): return -1
    return ans
    

print(solve())

Fixed submission:
from collections import Counter
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a: return 0
    l = Counter(a)
    ans = 1
    for i,j in l.items():
        ans *= i**j
        if ans > int(1e18):
            return -1

    return ans
    

print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
def good(h, cnt, i, a, b):
    if a == i+1:
        if h[i] <= h[b-1]:
            cnt[i] -= 1
    elif b == i+1:
        if h[i] <= h[a-1]:
            cnt[i] -= 1
    return cnt

def solve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in range(m)]

    cnt = [0]*n
    for i in range(n):
        for j in range(m):
            a, b = ab[j]
            good(h, cnt, i, a, b)

    return cnt.count(0)




print(solve())


Fixed submission:
def solve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in range(m)]

    cnt = [0]*n
    for j in range(m):
        a, b = ab[j]
        if h[a-1] < h[b-1]:
            cnt[a-1] -= 1
        elif h[b-1] < h[a-1]:
            cnt[b-1] -= 1
        elif h[a-1] == h[b-1]:
            cnt[a-1] -= 1
            cnt[b-1] -= 1

    
    return cnt.count(0)




print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in range(m)]

    cnt = [0]*n
    for i in range(n):
        for j in range(m):
            a, b = ab[j]
            if a == i+1:
                if h[i] <= h[b-1]:
                    cnt[i] -= 1
            elif b == i+1:
                if h[i] <= h[a-1]:
                    cnt[i] -= 1
        


    return cnt.count(0)




print(solve())


Fixed submission:
def solve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in range(m)]

    cnt = [0]*n
    for j in range(m):
        a, b = ab[j]
        if h[a-1] < h[b-1]:
            cnt[a-1] -= 1
        elif h[b-1] < h[a-1]:
            cnt[b-1] -= 1
        elif h[a-1] == h[b-1]:
            cnt[a-1] -= 1
            cnt[b-1] -= 1

    
    return cnt.count(0)




print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in range(m)]

    cnt = [0]*n
    for i in range(n):
        num = 0
        for j in range(m):
            a, b = ab[j]
            if a == i+1:
                if h[i] <= h[b-1]:
                    cnt[i] -= 1
                num += 1
            elif b == i+1:
                if h[i] <= h[a-1]:
                    cnt[i] -= 1
                num += 1
        if num == 0:
            cnt[i] = 0


    return cnt.count(0)




print(solve())


Fixed submission:
def solve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in range(m)]

    cnt = [0]*n
    for j in range(m):
        a, b = ab[j]
        if h[a-1] < h[b-1]:
            cnt[a-1] -= 1
        elif h[b-1] < h[a-1]:
            cnt[b-1] -= 1
        elif h[a-1] == h[b-1]:
            cnt[a-1] -= 1
            cnt[b-1] -= 1

    
    return cnt.count(0)




print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    l = []
    r = []
    
    for i in range(n):
        l.append((i + 1) + a[i])
        r.append((i + 1) - a[i])
        
    cnt = 0
    for i in l:
        for j in r:
            if i == j:
                cnt += 1



    
    return cnt




print(solve())


Fixed submission:
from collections import*
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    l = []
    r = []
    for i, j in enumerate(a):
        l += [i + j]
        r += [i - j]

    cnt = 0
    l = Counter(l)
    for r in r:
        cnt += l.get(r, 0)

    
    return cnt




print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    cnt = 0
    for i in range(n):
        l = (i + 1) + a[i]
        for j in range(n):
            r = (j + 1) - a[j]
            if l == r:
                cnt += 1
        



    
    return cnt




print(solve())


Fixed submission:
from collections import*
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    l = []
    r = []
    for i, j in enumerate(a):
        l += [i + j]
        r += [i - j]

    cnt = 0
    l = Counter(l)
    for r in r:
        cnt += l.get(r, 0)

    
    return cnt




print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    m = len(a)
    cnt = 0
    for i in combinations(range(m), 2):
        x = i[0]
        y = i[1]
        if abs(x-y) == a[x]+ a[y]:
            cnt += 1



    
    return cnt




print(solve())


Fixed submission:
from collections import*
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    l = []
    r = []
    for i, j in enumerate(a):
        l += [i + j]
        r += [i - j]

    cnt = 0
    l = Counter(l)
    for r in r:
        cnt += l.get(r, 0)

    
    return cnt




print(solve())
Buggy python submission (verdict: Runtime Error):
import math
def solve():
    n, m, q = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(q)]

    ans = 0
    for i in range(2**(n-2)):
        cur = []
        for j in range(n-2):
            if (i>>j)&1:
                cur.append(i+1)
        A = [1] + cur + [n, m]
        print(A)
        tot = 0
        for k in range(q):
            a, b, c, d = l[k]
            if b+1 <= n and A[b] - A[a] == c:
                print(A[0], A[a])
                tot += d
        ans = max(ans, tot)
    
    return ans


print(solve())


Fixed submission:
from itertools import combinations_with_replacement
def solve():
    n, m, q = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(q)]

    com = [int(x) for x in range(1, m+1)]
    ans = 0
    for i in combinations_with_replacement(com, n-1):
        cur = list(i)
        A = [1] + cur
        tot = 0
        for k in range(q):
            a, b, c, d = l[k]
            if A[b-1] - A[a-1] == c:
                tot += d
        ans = max(ans, tot)
    
    return ans


print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
import math
def solve():
    a, b, n = map(int, input().split())

    ans = 0
    for x in range(1, n+1):
        ans = max(ans, math.floor(a*x/b) - a*math.floor(x/b))


    return ans


print(solve())


Fixed submission:
import math
def solve():
    a, b, n = map(int, input().split())

    if n < b:
        return math.floor(a*n/b) - a*math.floor(n/b)
    elif n >= b:
        return math.floor(a*(b-1)/b) - a*math.floor((b-1)/b)



print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
import math
def solve():
    a, b, n = map(int, input().split())

    ans = 0
    for x in range(1, n+1):
        ans = max(ans, math.floor(a*x/b) - a*math.floor(x/b))


    return ans


print(solve())


Fixed submission:
import math
def solve():
    a, b, n = map(int, input().split())

    if n < b:
        return math.floor(a*n/b) - a*math.floor(n/b)
    elif n >= b:
        return math.floor(a*(b-1)/b) - a*math.floor((b-1)/b)



print(solve())
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
l = [int(i) for i in range(n+1)]
s = l[::-1]

ans = 0
for i in range(k, n+2):
  ans += sum(s[:i]) - sum(l[:i]) +1
  
print(ans%(int(1e9)+7))


Fixed submission:
import math

n = int(input())

print(2*n*math.pi)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = tuple(input())

cnt = 0
w = {'R', 'G', 'B'}

for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
        if {s[i], s[j], s[k]} == w and j-i != k-j:
          cnt += 1
      
print(cnt)


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

ans = 'No'
for i in range(len(n)):
  if n[i] == 7:
    ans = 'Yes'
    
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input())

cnt = 0
for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
        if j-i != k-j:
          cnt += 1
print(cnt)


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

ans = 'No'
for i in range(len(n)):
  if n[i] == 7:
    ans = 'Yes'
    
print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())

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

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

ans = 0
for a in range(1, k+1):
  for b in range(1, k+1):
      m = math.gcd(a, b)
      for c in range(1, k+1):
          ans += math.gcd(m, c)

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

ans = n
all = [n]
m = abs(n - k)

if n == 0 or n == 1 or k == 1 or n == 2*k or k == 2*n:
  ans = 0
else:
  all = []
  for _ in range(m):
    n = abs(n - k)
    all.append(n)

  
print(min(ans, min(all)))

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

rot = n//k
x = n

if k == 1 or n == k or n%k == 0:
  x = 0
elif rot >= 1:
  x = n - k*rot
  
t = x%k

print(min(t, abs(t-k)))

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

ans = n
all = [n]
if n == 1 or k == 1 or n == 2*k or k == 2*n:
  ans = 0
elif abs(n - k) < n or abs(n - k) < k:
  ans = abs(n - k)
else:
  all = []
  for i in range(2*n):
    n = abs(n - k)
    all.append(n)

  
print(min(ans, min(all)))

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

rot = n//k
x = n

if k == 1 or n == k or n%k == 0:
  x = 0
elif rot >= 1:
  x = n - k*rot
  
t = x%k

print(min(t, abs(t-k)))

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

ans = k
all = [k]
if n == 1 or k == 1 or n == 2*k or k == 2*n:
  ans = 0
else:
  all = []
  for i in range(2*n):
    n = abs(n - k)
    all.append(n)

  
print(min(ans, min(all)))

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

rot = n//k
x = n

if k == 1 or n == k or n%k == 0:
  x = 0
elif rot >= 1:
  x = n - k*rot
  
t = x%k

print(min(t, abs(t-k)))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
k = int(input())

cnt = 0
for i in range(1, 100000):
  if i < 9:
    cnt += 1
  else:
    num = copy.copy(i)
    nei = []
    while num < 10:
      nei.append(num%10)
      num /= 10
    for j in range(len(nei)):
      if abs(nei[j] - nei[j+1]) > 1:
        break
      elif abs(nei[j] - nei[j+1]) <= 1 and nei[j] == nei[len(nei)-1]:
        cnt += 1
        
  if cnt == k:
    print(i)
    break

Fixed submission:
from queue import Queue
q = Queue()

k = int(input())

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