Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int, input().split())

print((a * b) // math.gcd(a, b))

Fixed submission:
a,b=map(int, input().split())
x = a * b

if a < b:
    tmp = a
    a = b
    b =tmp
r = a%b
while(r != 0):
    a = b
    b = r
    r = a % b

print(int(x/b))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())

seq = (100,101,102,103,104,105)
exists = False
for l in list(itertools.combinations_with_replacement(seq,n//100)):
    if sum(l) == n:
        print('1')
        exists =True
        break
if not exists:
    print('0')


Fixed submission:
n = int(input())
#n = 417
x=n//100
y=n%100
#print(x)
#print(y)
seq = (1,2,3,4,5)
exists = False

for i in seq:
    sum = 0
    z = y%i
    #print( 'z = ' + str(z))
    if z == 0:
        sum = y//i
        #print(sum)
        #print('a')
    else:
        sum = (y//i) + 1
        #print(sum)
    if sum <= x:
        print('1')
        exists =True
        break

if not exists:
    print('0')
Buggy python submission (verdict: Runtime Error):
n = int(input())
array = list(map(int,input().split(' ')))

def getSum(s, e):
    sum = 0
    for i in range(s, e):
        sum = sum + array[i]
    return sum

prev = 0
for i in range(0,n-1):
    diff = abs(getSum(0, i+1) - getSum(i+1, n))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)



Fixed submission:
n = input().split(' ')
third = 100000
second = 200000
first = 300000
sum = 0
for i in n:
    if int(i) == 3:
        sum = sum + third
    elif  int(i) == 2:
        sum = sum + second
    elif  int(i) == 1:
        sum = sum + first

if int(n[0]) == 1 and int(n[1]) == 1:
    sum = sum + 400000

print(sum)

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

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))  
    return list.index(min(diffList))

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )

Fixed submission:
n = input().split(' ')
third = 100000
second = 200000
first = 300000
sum = 0
for i in n:
    if int(i) == 3:
        sum = sum + third
    elif  int(i) == 2:
        sum = sum + second
    elif  int(i) == 1:
        sum = sum + first

if int(n[0]) == 1 and int(n[1]) == 1:
    sum = sum + 400000

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def hcfnaive(a, b):
    if (b == 0):
        return a
    else:
        return hcfnaive(b, a % b)

def gcd(a, b, c):
    return hcfnaive(a, hcfnaive(b, c))

##def gcd(a, b, c, cnt):
  ##  i = 0
    ####  i = i + 1
        ##if len(list(filter(is_prime, [a, b, c]))) == 0:
          ##  if (a % i == 0) and(b % i == 0) and (c % i == 0):
            ##    return gcd(a / i, b / i, c / i, cnt * i)
        ##else:
          ##  return cnt

def is_prime(n):
    if n % 2 == 0 and n > 2:
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))

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

print(ans)

Fixed submission:
import math

def hcfnaive(a, b):
    if (b == 0):
        return a
    else:
        return hcfnaive(b, a % b)

def gcd(a, b, c):
    return hcfnaive(a, hcfnaive(b, c))

##def gcd(a, b, c, cnt):
  ##  i = 0
    ####  i = i + 1
        ##if len(list(filter(is_prime, [a, b, c]))) == 0:
          ##  if (a % i == 0) and(b % i == 0) and (c % i == 0):
            ##    return gcd(a / i, b / i, c / i, cnt * i)
        ##else:
          ##  return cnt

def is_prime(n):
    if n % 2 == 0 and n > 2:
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))

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

print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())
z = int(input())

a = z
b = x
c = y

print(str(a)+" "+str(b)+" "+str(c))

Fixed submission:
x,y,z = input().split()

a = z
b = x
c = y

print(str(a)+" "+str(b)+" "+str(c))

Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())
z = int(input())

a = z
b = y
c = x

print("%i %i %i" %(a,b,c))

Fixed submission:
x,y,z = input().split()

a = z
b = x
c = y

print(str(a)+" "+str(b)+" "+str(c))

Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())
z = int(input())

a = z
b = y
c = x

print("%i %i %i" %(a,b,c))



Fixed submission:
x,y,z = input().split()

a = z
b = x
c = y

print(str(a)+" "+str(b)+" "+str(c))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

W,H,x,y =  list(map(float,input().split()))


if(W%x==0 and H%y==0):
    print (W*H/2,1)

else:
    print (W*H/2,0)


Fixed submission:
# coding: utf-8
# Your code here!

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

if X<A:
    print(0)
    
else:
    print(10)
Buggy python submission (verdict: Runtime Error):

N = input()
N = int(N)

s_all = sum(N)
fizz = sum(list(range(3,N,3)))
buzz = sum(list(range(5,N,5)))

fb = sum(list(range(15,N,15)))

print(s_all-fizz-buzz+fb)


Fixed submission:

N = input()
N = int(N)

s_all = sum(range(N+1))
fizz = sum(list(range(3,N+1,3)))
buzz = sum(list(range(5,N+1,5)))

fb = sum(list(range(15,N+1,15)))

print(s_all-fizz-buzz+fb)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import fractions

N = input()
N = int(N)

l = list(itertools.combinations_with_replacement(list(range(1,N+1)), 3))
s_all = 0
for nums in l:
    count = 0
    ans = nums[0]
    for i in range(1, 3):
        ans = fractions.gcd(ans, nums[i])
    a,b,c = nums[0], nums[1], nums[2]
    if a==b:
        count+=1
    if a==c:
        count+=1
    if b==c:
        count+=1

    if count==0:
        num = 6
    elif count==1:
        num=3
    elif count==3:
        num=1
    s_all += ans*num
print(s_all)


Fixed submission:
import itertools
import fractions
import functools

N = input()
N = int(N)

l = list(itertools.combinations_with_replacement(list(range(1,N+1)), 3))
s_all = 0

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def gcd(nums):
    return functools.reduce(euclid, nums)

for nums in l:
    count = 0
    # ans = nums[0]
    # for i in range(1, 3):
    #     ans = fractions.gcd(ans, nums[i])
    # ans = list(map(int, input().split()))
    ans = gcd(nums)
    a,b,c = nums[0], nums[1], nums[2]
    if a==b:
        count+=1
    if a==c:
        count+=1
    if b==c:
        count+=1

    if count==0:
        num = 6
    elif count==1:
        num=3
    elif count==3:
        num=1
    s_all += ans*num
print(s_all)
Buggy python submission (verdict: Runtime Error):
S = input()

if S[2:-2].count('C') != 1:
  print('WA')

if S[0] != 'A':
  print('WA')

S[0] == 'a'
S[S[2:-2].index('C')] == 'c'

if S.islower():
  print('AC')
else:
  print('WA')

Fixed submission:
S = input()

if S[2:-1].count('C') != 1:
  print('WA')
else:
    if S[0] != 'A':
      print('WA')
    else:
        S = list(map(lambda x: x, S))
        S[0] = 'a'
        S[S[2:-1].index('C')+2] = 'c'
        if ''.join(S).islower():
          print('AC')
        else:
          print('WA')
Buggy python submission (verdict: Runtime Error):
N = input()
l = list(map(int, input().split()))

count=0
for i in range(len(l)-1):
    if i == len(l)-1:
        break
    if l[i] == l[i+1]:
        if l[i+1]+l[i+2]< 10000:
            l[i+1] = l[i]+l[i+2]
        else:
            l[i+1] = l[i]-l[i+2]
        count=count+1
print(count)


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

count=0
for i in range(len(l)-1):
    if i == len(l)-2:
        if l[i] == l[i+1]:
            l[i] = l[i]+1
            count=count+1
            break
    if l[i] == l[i+1]:
        if l[i+1]+l[i+2]< 10000:
            l[i+1] = l[i]+l[i+2]
        elif l[i+1] - l[i+2] > 0:
            l[i+1] = l[i]-l[i+2]
        else:
            l[i+1] = l[i]+1
        count=count+1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
a = input()
ans = ""

for i in range(1,n+1):
    if i == 1:
        ans = str(a.count(str(i)))
    else:
        ans = ans + "\n" + str(a.count(str(i)))

print(ans)


Fixed submission:
from collections import deque

n = int(input())
a = list(map(int,input().split()))
ans = [0] * n

for i in a:
    ans[i-1] += 1

for j in ans:
    print(j)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
a = input()
ans = deque()

for i in range(1,n+1):
    ans.append(a.count(str(i)))

for j in ans:
    print(j)


Fixed submission:
from collections import deque

n = int(input())
a = list(map(int,input().split()))
ans = [0] * n

for i in a:
    ans[i-1] += 1

for j in ans:
    print(j)

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

for i in range(1,n+1):
    number = 0
    ans.append(a.count(i))

for j in ans:
    print(j)


Fixed submission:
from collections import deque

n = int(input())
a = list(map(int,input().split()))
ans = [0] * n

for i in a:
    ans[i-1] += 1

for j in ans:
    print(j)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
f = 0

for i in range(n):
    a = input()
    if a == "1":
        f += 1
    else:
        b,c,d = a.split()
        if f%2 == 0:
            if c == "1":
                s = d + s
            else:
                s = s + d
        else:
            if c == "1":
                s = s + d
            else:
                s = d + s

if f%2 == 1:
    print(s[::-1])
else:
    print(s)



Fixed submission:
from collections import deque

s = deque(list(input()))
n = int(input())
f = True

for i in range(n):
    a = input()
    if a == "1":
        f = not f
    else:
        b,c,d = a.split()
        if f:
            if c == "1":
                s.appendleft(d)
            else:
                s.append(d)
        else:
            if c == "1":
                s.append(d)
            else:
                s.appendleft(d)

if not f:
    s.reverse()

ans = "".join(s)
print(ans)

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

for i in range(n):
    a = input()
    if a == "1":
        s = s[::-1]
    else:
        b,c,d = a.split()
        if c == "1":
            s = d + s
        else:
            s = s + d

print(s)



Fixed submission:
from collections import deque

s = deque(list(input()))
n = int(input())
f = True

for i in range(n):
    a = input()
    if a == "1":
        f = not f
    else:
        b,c,d = a.split()
        if f:
            if c == "1":
                s.appendleft(d)
            else:
                s.append(d)
        else:
            if c == "1":
                s.append(d)
            else:
                s.appendleft(d)

if not f:
    s.reverse()

ans = "".join(s)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
if int(a) =< 9:
  ans = int(b) + 100 * (10 - int(a))
  print(ans)
else:
  print(b)
 

Fixed submission:
a, b = input().split()
if int(a) <= 9:
  ans = int(b) + 100 * (10 - int(a))
  print(ans)
else:
  print(b)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

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

K = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += gcd(i+1, j+1, k+1)

print(ans)


Fixed submission:
import math
from functools import reduce

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

K = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += gcd(i+1, j+1, k+1)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
list_H = sorted(H, reverse=True)
if len(H) < K:
    print(0)
else:
    for k in range(K):
        if len(list_H) > 0:
            list_H.pop(0)
    print(sum(list_H))


Fixed submission:
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
H.sort(reverse=True)
print(sum(H[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
list_H = sorted(H, reverse=True)
for k in range(K):
    if len(list_H) > 0:
        list_H.pop(0)
print(sum(list_H))


Fixed submission:
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
H.sort(reverse=True)
print(sum(H[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
list_H = sorted(H, reverse=True)
for k in range(K):
    if len(list_H) > 0:
        list_H.pop(0)
attack = 0
for i in list_H:
    attack += i
print(attack)


Fixed submission:
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
H.sort(reverse=True)
print(sum(H[K:]))

Buggy python submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
list_H = sorted(H, reverse=True)
for k in range(K):
    list_H.pop(k)
attack = 0
for i in H:
    attack += i
print(attack)


Fixed submission:
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
H.sort(reverse=True)
print(sum(H[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]

for k in range(K):
    max_H = 0
    for i in H:
        if max_H < i:
            max_H = i
    if len(H) > 0:
        H.remove(max_H)

attack = 0
for i in H:
    attack += i

print(attack)


Fixed submission:
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
H.sort(reverse=True)
print(sum(H[K:]))
Buggy python submission (verdict: Runtime Error):
L, R = map(int,input().split())
l = str(L)
r = str(R)
last_l = ""
last_r = ""
for i in range(L):
    last_r += r 
for i in range(R):
    last_l += l     
if L > R:
    print(last_r)
else:
    print(last_l

Fixed submission:
L, R = map(int,input().split())
l = str(L)
r = str(R)
last_l = ""
last_r = ""
for i in range(L):
    last_r += r 
for i in range(R):
    last_l += l     
if L > R:
    print(last_r)
else:
    print(last_l)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split())) 
correct_answer_count = 0
for i in range(N):
    bat_answer_count = 0
    for j in range(i):
        if len(A) < j:
            continue
        if not (A[i] <= A[j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)    


Fixed submission:
n = int(input())
p = list(map(int, input().split()))
 
cnt = 0
p_min = p[0]
for i in range(n):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())) 
correct_answer_count = 0
for i in range(1, N + 1):
    bat_answer_count = 0
    for j in range(1, i+1):
        if len(A) < j:
            continue
        if not (A[i] <= A[j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)    

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
 
cnt = 0
p_min = p[0]
for i in range(n):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())) 
correct_answer_count = 0
for i in range(1, N + 1):
    bat_answer_count = 0
    for j in range(1, i+1):
        if not (A[i] <= A[j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)    


Fixed submission:
n = int(input())
p = list(map(int, input().split()))
 
cnt = 0
p_min = p[0]
for i in range(n):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)

Buggy python submission (verdict: Runtime Error):
fast_list = list(map(int, input().split())) 
correct_answer_count = 0
bat_answer_count = 0
for i in range(1, fast_list[0] + 1):
    for j in range(1, i+1):
        if not (fast_list[1][i] <= fast_list[1][j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)    
            
            

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
 
cnt = 0
p_min = p[0]
for i in range(n):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)

Buggy python submission (verdict: Runtime Error):
fast_list = list(map(int, input().split())) 
correct_answer_count = 0
for i in range(1, fast_list[0] + 1):
    bat_answer_count = 0
    for j in range(1, i+1):
        if not (fast_list[1][i] <= fast_list[1][j]):
            bat_answer_count += 1

if bat_answer_count == 0:
    correct_answer_count += 1

print(correct_answer_count)    


Fixed submission:
n = int(input())
p = list(map(int, input().split()))
 
cnt = 0
p_min = p[0]
for i in range(n):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)
Buggy python submission (verdict: Runtime Error):
    def twoSum(self, k, x) -> str:        
        if k * 500 >= x:
          return "Yes"
        else:
          return "No"


Fixed submission:
a, b= map(int, input().split())
if a*500>=b:
    print("Yes")
else :
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = [int(_) for _ in input().split()]
for i in range(K):
    if A >= 1:
        A -= 1
    elif B >= 1:
        B -= 1
    else:
        break
print(A, B)


Fixed submission:
A,B,K = [int(_) for _ in input().split()]
if K <= A:
    A -= K
elif K <= A+B:
    B -= K-A
    A = 0
elif A+B < K:
    A = 0
    B = 0
print(A, B)
Buggy python submission (verdict: Runtime Error):
print(sum([int(i) for i in input()]))

Fixed submission:
a, b= map(int, input().split())
if a*b%2 == 0:
    print("Even")
else:
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a, b= map(int, input().split())
if a*b/2 % 0:
    print("Even")
else:
    print("Odd")
    



Fixed submission:
a, b= map(int, input().split())
if a*b%2 == 0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
s1, s2, s3 = map(str, input().split())
list = [s1, s2, s3]
bidama_num = 0
for item in list:
  if item == "1":
    bidama_num += 1
 
print(str(bidama_num))
  
  

Fixed submission:
print(sum([int(i) for i in input()]))

Buggy python submission (verdict: Runtime Error):
s1, s2, s3 = map(int, input().split())
list = [s1, s2, s3]
bidama_num = 0
for item in list:
  if item == 1:
    bidama_num += 1
  
  

Fixed submission:
print(sum([int(i) for i in input()]))
Buggy python submission (verdict: Time Limit Exceeded):

d={}

n,k=map(int,input().split(" "))
flag=True
while(flag):

    if(abs(n-k) not in d.keys()):
        d[abs(n-k)]=True
        n=abs(n-k)
    else:
        flag=False
#print(d.keys())
print(min(d.keys()))



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

if(n==k or n%k==0):
    print(0)
elif(n<k):
    print(min(n,abs(n-k)))
else:
    q=n//k
    ma=n%k

    aa = n-q*k
    print(min(aa,abs(aa-k)))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a_list = [int(i) for i in input().split()]
a_list = np.array(a_list, int)

for i in range(n):
    print(np.sum(a_list==i+1))

Fixed submission:
n = int(input())
a_list = [int(i) for i in input().split()]
a_dict = {}

for a in a_list:
    if a in a_dict.keys():
        a_dict[a] += 1
    else:
        a_dict[a] = 1

for i in range(n):
    if i+1 in a_dict.keys():
        print(a_dict[i+1])
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
s = input()

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

answer = r_count*g_count*b_count


n_temp = min(n, math.ceil(n/3)+6)
for k in range(1, n_temp):
    for i in range(k):
        extracted = s[i::k]
        if len(extracted) >= 3:
            for l in range(len(extracted)-2):
                temp = extracted[l:l+3]
                if temp.count('R') == 1 and temp.count('G')==1 and temp.count('B'):
                    answer -= 1

print(answer)

Fixed submission:
n = str(input())
if n.find('7') != -1:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
s = input()

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

answer = r_count*g_count*b_count


for k in range(1, min(n, math.ceil(n/3)+6)):
    for i in range(k):
        extracted = s[i::k]
        if len(extracted) >= 3:
            for l in range(len(extracted)-2):
                temp = extracted[l:l+3]
                if temp.count('R') == 1 and temp.count('G')==1 and temp.count('B'):
                    answer -= 1

print(answer)

Fixed submission:
n = str(input())
if n.find('7') != -1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

answer = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            ans = gcd(i, j)
            ans = gcd(ans, l)
            answer += ans
            
print(answer)

Fixed submission:
import itertools

k = int(input())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

answer = 0
nums = list(range(1, k+1))
for balls in itertools.combinations_with_replacement(nums, 3):
    i, j, l = balls[0], balls[1], balls[2]
    ans = gcd(i, j)
    ans = gcd(ans, l)
    if len(set(balls)) == 1:
        answer += ans
    elif len(set(balls)) == 2:
        answer += ans*3
    elif len(set(balls)) == 3:
        answer += ans*6
            
print(answer)
Buggy python submission (verdict: Runtime Error):
from collections import deque

k = int(input())

q = deque()

if k > 9:
    for i in range(1, 10):
        q.append(i)

for _ in range(k):
    temp = q.popleft()
    if temp % 10 != 0:
        q.append(temp*10+int(str(temp)[-1])-1)
    
    q.append(temp*10+int(str(temp)[-1]))

    if temp % 10 != 9:
        q.append(temp*10+int(str(temp)[-1])+1)

print(temp)
    

Fixed submission:
from collections import deque

k = int(input())

q = deque()

for i in range(1, 10):
    q.append(i)

for _ in range(k):
    temp = q.popleft()
    if temp % 10 != 0:
        q.append(temp*10+int(str(temp)[-1])-1)
    
    q.append(temp*10+int(str(temp)[-1]))

    if temp % 10 != 9:
        q.append(temp*10+int(str(temp)[-1])+1)

print(temp)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num_list = [int(i) for i in input().split()]

k = 0
for i in range(len(num_list)):
    if i != len(num_list)-1:
        if min(num_list[:i+1]) == num_list[i]:
            k += 1
    else:
        if min(num_list) == num_list[i]:
            k += 1
    
print(k)

Fixed submission:
n = int(input())
num_list = [int(i) for i in input().split()]

k = 0
for i in range(len(num_list)):
    if i == 0:
        temp_min = num_list[i]
    else:
        temp_min = min(temp_min, num_list[i])
        
    if i != len(num_list)-1:
        if temp_min == num_list[i]:
            k += 1
    else:
        if temp_min == num_list[i]:
            k += 1
    
print(k)

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

k = 0
for i in range(len(num_list)):
  if min(num_list[:i+1]) == num_list[i]:
    k += 1
    
print(k)

Fixed submission:
n = int(input())
num_list = [int(i) for i in input().split()]

k = 0
for i in range(len(num_list)):
    if i == 0:
        temp_min = num_list[i]
    else:
        temp_min = min(temp_min, num_list[i])
        
    if i != len(num_list)-1:
        if temp_min == num_list[i]:
            k += 1
    else:
        if temp_min == num_list[i]:
            k += 1
    
print(k)