qyliang/CodeNanoFix huggingface dataset:
Buggy code:
A,B,K = [int(x) for x in input().split(' ')]

k=0
for i in range(min(A,B),0,-1):
    if A % i == 0 and B % i == 0:
        k += 1
        if k == K:
            print(i,K)
            break



Fixed code:
A,B,K = [int(x) for x in input().split(' ')]

k=0
for i in range(min(A,B),0,-1):
    if A % i == 0 and B % i == 0:
        k += 1
        if k == K:
            print(i)
            break
Buggy code:
A, B, K = map(int, input().split())
c = 0
ans = 0
for i in range(min(A, B)):
    if A % (i + 1) == 0 and B % (i + 1) == 0:
        ans = i + 1
        c += 1
        if c == K:
            print(ans)
            exit()
        else:
            pass


Fixed code:
A, B, K = map(int, input().split())
c = 0
ans = []
for i in reversed(range(min(A, B))):
    if A % (i + 1) == 0 and B % (i + 1) == 0:
        ans = i + 1
        c += 1
        if c == K:
            print(ans)
            exit()
        else:
            pass
Buggy code:
A,B,K = map(int,input().split())

list = []
for i in range(1,101):
    if A % i == 0 and B % i == 0:
        list.append(i)

print(list)
print(list[K-1])

Fixed code:
A,B,K = map(int,input().split())

list = []
for i in range(1,101):
    if A % i == 0 and B % i == 0:
        list.append(i)

list.sort(reverse=True)
print(list[K-1])
Buggy code:
a, b, k = map(int, input().split())
list = []
for i in range(1, 101):
  if a%i == 0 and b %i == 0:
    list.append(i)
print(list[k-1])

Fixed code:
a, b, k = map(int, input().split())
ans = []

for i in range(1, 101):
    if a%i == 0 and b%i == 0:
        ans.append(i)

print(ans[-k])
Buggy code:
A, B, K = list(map(lambda x: int(x), input().split(" ")))
cd = []
for i in range(min([A,B])):
  if A % (i + 1) == 0 and B % (i + 1) == 0:
    cd.append(i+1)

print(cd[K - 1])

Fixed code:
A, B, K = list(map(lambda x: int(x), input().split(" ")))
cd = []
for i in range(min([A,B])):
  if A % (i + 1) == 0 and B % (i + 1) == 0:
    cd.append(i+1)
 
print(cd[-K])
Buggy code:
a, b, k = map(int, input().split())
ans = []
for i in range(1, 100):
    if a % i == 0 and b % i == 0:
        ans.append(i)
print(ans[k-1])

Fixed code:
a,b,k = map(int,input().split())
ans = []
for i in range(101,0,-1):
  if a % i == 0 and b % i == 0:
    ans.append(i)

print(ans[k-1])
Buggy code:
A,B,K = map(int,input().split())
L = 0
ans = 0
for i in reversed(range(1,min(A,B))):
  if A%i == 0:
    if B%i == 0:
      L += 1
    else:
      L += 0
  else:
    L += 0
  if L == K:
    ans = i
    break
print(ans)

Fixed code:
A,B,K = map(int,input().split())
L = 0
ans = 0
for i in reversed(range(1,2000)):
  if A%i == 0:
    if B%i == 0:
      L += 1
    else:
      L += 0
  else:
    L += 0
  if L == K:
    ans = i
    break
print(ans)
Buggy code:
A,B,K= (int(i) for i in input().split())

def gcd(a,b):
  if b>a:
    a,b=b,a

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

first=gcd(A,B)
k=1

for i in reversed(range(1,first)):
  if A%i==0:
    if B%i==0:
      k=k+1
      if k==K:
        print(i)
        break

Fixed code:
A,B,K= (int(i) for i in input().split())

def gcd(a,b):
  if b>a:
    a,b=b,a

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

first=gcd(A,B)
if first==1:
  print(1)
else:
  k=1
  if K==1:
    print(first)
  else:
    for i in reversed(range(1,first)):
      if A%i==0:
        if B%i==0:
          k=k+1
          if k==K:
            print(i)
            break
Buggy code:
A, B, K = map(int, input().split())
S = []
for i in range(100):
  if A%i==0 and B%i==0:
    S.append(i)
print(S[K-1])

Fixed code:
A, B, K = map(int, input().split())
S = []
for i in range(100):
  if A%(i+1)==0 and B%(i+1)==0:
    S.append(i+1)
print(S[len(S)-K])
Buggy code:


A,B,K =map(int,input().split())
k = 0
for i in range(1, 101):
    if A % K == 0 and B % K ==0:
        k += 1
    if k == K:
        break
print(i)

Fixed code:


A,B,K =map(int,input().split())
k = 0
for i in reversed(range(1, 101)):
    if (A % i) == 0 and (B % i) ==0:
        k += 1
    if k == K:
        break
print(i)
Buggy code:
a,b,c=(map(int,input().split()))
gcd = 0
d = min(a,b)
for i in range(1,d+1):
  if a%i==0 and b%i==0:
    gcd +=1
    if gcd ==c:
      print(i)

Fixed code:
a,b,c=(map(int,input().split()))
gcd = 0
d = min(a,b)
for i in range(d,0,-1):
  if a%i==0 and b%i==0:
    gcd +=1
    if gcd ==c:
      print(i)
Buggy code:
A,B,K = map(int,input().split())
count = min(A,B)
k = 0
while count > 0:
  if A%count == 0 nad B%count == 0:
    k += 1
  if k == K:
    print(count)
    break
  else:
    count -= 1

Fixed code:
A,B,K = map(int,input().split())
count = min(A,B)
k = 0
while count > 0:
  if A%count == 0 and B%count == 0:
    k += 1
  if k == K:
    print(count)
    break
  else:
    count -= 1
Buggy code:
A,B,K = map(int,input().split())
cd = []
for i in range(1,101):
    if A % i == 0  and B % i == 0:
        cd.append(i)
print(cd[len(cd)-K])
print(cd)

Fixed code:
A,B,K = map(int,input().split())
cd = []
for i in range(1,101):
    if A % i == 0  and B % i == 0:
        cd.append(i)
print(cd[len(cd)-K])
Buggy code:
import sys
import os
import math

A,B,K=map(int, input().split())

C = min(A, B)
hairetu = []

for i in range(1, C+1):
    if A % i == 0 and B % i == 0:
        hairetu.append(i)

print(hairetu[K-1])

Fixed code:
import sys
import os
import math

A,B,K=map(int, input().split())

C = min(A, B)
hairetu = []

for i in range(1, C+1):
    if A % i == 0 and B % i == 0:
        hairetu.append(i)

print(hairetu[-K])
Buggy code:
a, b, k = list(map(int, input().split()))
la = []
lb = []
for i in range(1, a+1):
    if a % i == 0:
        la.append(i)
        lsas = sorted(la)
        for j in lsas:
            if b % j == 0:
                lb.append(j)

lsbs = sorted(lb)
print(lsbs[len(lsbs)-k])


Fixed code:
a, b, k = list(map(int, input().split()))
la = []
lb = []
for i in range(1, a+1):
    if a % i == 0:
        la.append(i)
        lsas = sorted(set(la), key=la.index)
        for j in lsas:
            if b % j == 0:
                lb.append(j)

lsbs = sorted(set(lb), key=lb.index)
print(lsbs[len(lsbs)-k])
Buggy code:
A,B,K = [int(x) for x in input().split()]
cnt =0
for i in range(1,max(A,B)):
  if A%i==0 and B%i==0:
    cnt+=1
    if cnt==K:
      print(i)

Fixed code:
A,B,K = [int(x) for x in input().split()]
cnt =0
for i in range(max(A,B),0,-1):
  if A%i==0 and B%i==0:
    cnt+=1
    if cnt==K:
      print(i)
      exit()
Buggy code:
A, B, K = map(int, input().rstrip().split())

li = []
for i in range(1, max(A, B)+1):
    if A % i == 0 and B % i == 0:
        li.append(i)

print(li[K-1])

Fixed code:
A, B, K = map(int, input().rstrip().split())

li = []
for i in range(1, max(A, B)+1):
    if A % i == 0 and B % i == 0:
        li.append(i)

print(li[-K])
Buggy code:
a,b,k=map(int,input().split())
lists=[]
for i in range(1,a+1):
  if a%i==0 and b%i==0:
    lists.append(i)
print(lists[k-1])

Fixed code:
a,b,k=map(int,input().split())
lists=[]
for i in range(1,a+1):
  if a%i==0 and b%i==0:
    lists.append(i)
lists.reverse()
print(lists[k-1])
Buggy code:
import math

a,b,k=map(int,input().split())
cnt=0

for i in range(math.gcd(a,b),1,-1):
    if a%i==0 and b%i==0:
        cnt += 1
    
    if cnt==k:
        print(i)
        break

Fixed code:
import math

a,b,k=map(int,input().split())
cnt=0

for i in range(math.gcd(a,b),0,-1):
    if a%i==0 and b%i==0:
        cnt+=1
    
    if cnt==k:
        print(i)
        break
Buggy code:
a,b,c=map(int,input().split())
lis=list(range(1,min(a,b)+1))
lis=[x for x in lis if a%x==0 and b%x==0]
print(lis[c-1])


Fixed code:
a,b,c=map(int,input().split())
lis=list(range(1,min(a,b)+1))
lis=[x for x in lis if a%x==0 and b%x==0]
print(lis[-c])
Buggy code:
A,B,K = map(int,input.split())
ans =[]
for i in range(1, min(A,B)+1):
  if A%i == 0 and B%i == 0:
    ans.append(i)
  if len(ans) == K:
    print(len(ans))
    exit(1)
    
      


Fixed code:
A,B,K = map(int,input().split())
ans =[]
for i in range(1, min(A,B)+1):
    if A%i == 0 and B%i == 0:
        ans.append(i)
    

print(ans[-K])
Buggy code:
a, b, k = map(int, input().split())
print([x for x in range(1, min(a,b)+1) if a%x == b%x == 0][k-1])


Fixed code:
a, b, k = map(int, input().split())
print([x for x in range(1, min(a,b)+1) if a%x == b%x == 0][-k])
Buggy code:
a,b,k=[int(s) for s in input().split()]

c=[]
for i in range(1,101):
    if a%i==0 and b%i==0:
        c = c+[i]
print(c)
print(c[-k])

Fixed code:
a,b,k=[int(s) for s in input().split()]

c=[]
for i in range(1,101):
    if a%i==0 and b%i==0:
        c = c+[i]
print(c[-k])
Buggy code:
a,b,k = list(map(int, input().split()))

r=[]

for i in range(100):
  if(a%(i+1)==0 and b%(i+1)==0):
    r.append(i+1)
    
print(r[k-1])

Fixed code:
a,b,k = list(map(int, input().split()))

r=[]

for i in range(100):
  if(a%(i+1)==0 and b%(i+1)==0):
    r.append(i+1)
    
print(r[-k])
Buggy code:
a, b, k = list(map(int, input().split()))
just_list = []

for i in range(1,b+1):
    if a % i == 0 and b % i == 0:
        just_list.append(i)

print(just_list[k-1])

Fixed code:
a, b ,k = map(int, input().split())
ans = []
for i in list(range(1,max(a,b)+1))[::-1]:
  if a%i == 0 and b%i == 0:
    ans.append(i)
print(ans[k-1])
Buggy code:
a, b, k = map(int, input().split())
ans_l = []
for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
        ans_l.append(i)
ans_l = sorted(ans_l)
print(ans_l[k-1])

Fixed code:
a, b, k = map(int, input().split())
ans_l = []
for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
        ans_l.append(i)
ans_l = sorted(ans_l)
print(ans_l[-k])
Buggy code:
A, B, C = map(int, input().split())


def cf(x1, x2):
    cf = []
    for i in range(1, min(x1, x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


cf_list = cf(A, B)
print(cf_list[C - 1])


Fixed code:
A, B, C = map(int, input().split())


def cf(x1, x2):
    cf = []
    for i in range(1, min(x1, x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


cf_list = cf(A, B)
print(cf_list[-C])
Buggy code:
S = list(map(int, input().split()))
A=S[0]
B=S[1]
K=S[2]
i=1
cnt=0
while True:
    if(A%i==0 and B%i==0):
        cnt+=1
        if(cnt==K):
            print(i)
            exit()
    i+=1


Fixed code:
S = list(map(int, input().split()))
A=S[0]
B=S[1]
K=S[2]
i=1
cnt=0
m=min(A,B)
while True:
    if(A%m==0 and B%m==0):
        cnt+=1
        if(cnt==K):
            print(m)
            exit()
    m-=1
Buggy code:
import math
A,B,C=map(int,input().split())
res=0
for i in range(99):
  if A%(100-i)==0 and B%(100-i)==0:
      res+=1
      if res==C:
        print(100-i)
      

Fixed code:
import math
A,B,C=map(int,input().split())
res=0
for i in range(100):
  if A%(100-i)==0 and B%(100-i)==0:
      res+=1
      if res==C:
        print(100-i)
Buggy code:

K=list(map(int,input().split()))
ans=0
num_list=[]
for i in range(1,min(K[0],K[1]+1)):
    if K[0]%i==0 and K[1]%i==0:num_list.append(i)
num_list.reverse()
print(num_list[K[2]-1])

Fixed code:

K=list(map(int,input().split()))
ans=0
num_list=[]
for i in range(1,min(K[0],K[1])+1):
    if K[0]%i==0 and K[1]%i==0:num_list.append(i)
num_list.reverse()
print(num_list[K[2]-1])
Buggy code:
# B
A,B,K = list(map(int, input().split()))

cnt = 0
for i in range(1,101)[::-1]:
    if A%i == 0 and B%i == 0:
        print(i)
        cnt += 1
    if cnt == K:
        break
        
print(i)

Fixed code:
# B
A,B,K = list(map(int, input().split()))

cnt = 0
for i in range(1,101)[::-1]:
    if A%i == 0 and B%i == 0:
        cnt += 1
    if cnt == K:
        break
        
print(i)
Buggy code:
a, b , k = map(int, input().split(' '))
count = 0
result = 1
if a < b:
    i = a
else:
    i = b
while count != k:
    if a%i == 0 and b%i == 0:
        count += 1
        result = i
        print(i)
    i -= 1
print(result)

Fixed code:
a, b , k = map(int, input().split(' '))
count = 0
result = 1
if a < b:
    i = a
else:
    i = b
while count != k:
    if a%i == 0 and b%i == 0:
        count += 1
        result = i
    i -= 1
print(result)
Buggy code:
A,B,K =  map(int,input().split())
C=[]

N = min(A,B)

for i in range(N):
    if A % (i+1) == 0:
        if B % (i+1) ==0:
            C.append(i+1)

print(int(C[K-1]))

Fixed code:
A,B,K =  map(int,input().split())
C=[]


N = min(A,B)

for i in range(N):
    if A % (i+1) == 0:
        if B % (i+1) ==0:
            C.append(i+1)

N = len(C)
print(int(C[N-K]))
Buggy code:
"""B - K-th Common Divisor"""
A,B,K=(int(i) for i in input().split())
result=[]
for i in range(max(A,B)):
  if A%(i+1)==0 and B%(i+1)==0:
    result.append(i+1)
print(result[K-1])

Fixed code:
"""B - K-th Common Divisor"""
A,B,K=(int(i) for i in input().split())
result=[]
for i in range(1,min(A,B)+1):
  if A%i==0 and B%i==0:
    result.append(i)
result.reverse()
print(result[K-1])
Buggy code:
"""B - K-th Common Divisor"""
A,B,K=(int(i) for i in input().split())
result=[]
for i in range(1,max(A,B)):
    if A%i==0 and B%i==0:
        result.append(i)
print(result[K-1])

Fixed code:
"""B - K-th Common Divisor"""
A,B,K=(int(i) for i in input().split())
result=[]
for i in range(1,101):
    if A%i==0 and B%i==0:
        result.append(i)
result.reverse()
print(result[K-1])
Buggy code:
a,b,k=map(int,input().split())
print([i for i in range(min(a,b)) if i%a==0 and i%b==0][-k])

Fixed code:
a,b,k=map(int,input().split())
print([i for i in range(1,min([a,b])+1) if a%i==0 and b%i==0][-k])
Buggy code:

a,b,k = map(int,input().split())
c = min(a,b)
t = []

for i in range(1,c):
    if a % i == 0 and b % i == 0:
        t.append(i)
print(t[1])




Fixed code:

a,b,k = map(int,input().split())
c = min(a,b)
t = []

for i in range(1,c+1):
    if a % i == 0 and b % i == 0:
        t.append(i)
print(t[k*(-1)])
Buggy code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,n=INTM()
    ct=0
    for i in range(1,101):
        if a%i==0 and b%i==0:
            ct+=1
            if ct==n:
                ans=i
    print(ans)
if __name__ == '__main__':
    do()

Fixed code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,n=INTM()
    ct=0
    c=min(a,b)
    for i in range(c,0,-1):
        if a%i==0 and b%i==0:
            ct+=1
            if ct==n:
                ans=i
    print(ans)
if __name__ == '__main__':
    do()
Buggy code:
a,b,k = map(int, input().split())
sp =[i for i in range(1, max(a,b)+1) if a%i == 0 and b%i==0]
print(sp[k-1])

Fixed code:
a,b,k = map(int, input().split())
sp =[i for i in range(1, max(a,b)+1) if a%i == 0 and b%i==0]
sp.sort(reverse=True)
print(sp[k-1])
Buggy code:

a,b,k = map(int,input().split())
l = []
c = min(a,b)
d = max(a,b)

for i in range(1,c+1):
    if c % i == 0 and d % i == 0:
        l.append(i)

#print(l)
print(l[k-1])


Fixed code:

a,b,k = map(int,input().split())
l = []
c = min(a,b)
d = max(a,b)

for i in range(1,c+1):
    if c % i == 0 and d % i == 0:
        l.append(i)

#print(l)
print(l[-k])
Buggy code:
A, B, K = map(int, input().split())

ans = []
for i in range(1, 1000):
    if A % i == 0 and B % i == 0:
        ans.append(i)
print(ans[K - 1])


Fixed code:
A, B, K = map(int, input().split())

l = []
for i in range(1, 1000):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])
Buggy code:
import sys
import math
import itertools

a,b,k=list(map(int,input().split()))
ans=[]
for i in range (1,max(a,b),1):
	if a%i==0 and b%i==0:
		ans.append(i)
print(ans[-k])

Fixed code:
import sys
import math
import itertools

a,b,k=list(map(int,input().split()))
ans=[]
for i in range (1,max(a,b)+1,1):
	if a%i==0 and b%i==0:
		ans.append(i)
print(ans[-k])
Buggy code:
val = input().split(" ")
A = int(val[0])
B = int(val[1])
K = int(val[2])

arr1 = [i for i in range(1,A + 1) if A % i == 0]
arr2 = [j for j in range(1,B + 1) if A % j == 0]

result = list(set(arr1) & set(arr2))
result.sort()

print(result[k - 1])

Fixed code:
val = input().split(" ")
A = int(val[0])
B = int(val[1])
K = int(val[2])
 
arr1 = [i for i in range(1,A + 1) if A % i == 0]
arr2 = [j for j in range(1,B + 1) if B % j == 0]
 
result = list(set(arr1) & set(arr2))
result.sort(reverse=True)
print(result[K - 1])
Buggy code:
a, b, k=map(int, input().split())
ans=[]
lim=min(a, b)
for i in range(1, lim+1):
    if a%i==0 and b%i==0:
        ans.append(i)
print(ans[k-1])

Fixed code:
a, b, k = map(int, input().split())
l = [1]
for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
        l.append(i)
print(l[-k])
Buggy code:
a,b,k = map(int,input().split())
count = 0
for i in range(1,min(a,b)+1):
  if a%i == 0 and b%i == 0:
    count += 1
  if count == k:
    print(i)
    exit()

Fixed code:
a,b,k = map(int,input().split())
count = 0
for i in range(min(a,b),0,-1):
  if a%i == 0 and b%i == 0:
    count += 1
  if count == k:
    print(i)
    exit()
Buggy code:
def main():
    A,B,K=list(map(int, input().split()))
    print(A,B,K)
    divisors=[]
    count = 0
    for i in range(1,min(A,B)+1):
        if min(A,B)%i==0:
            divisors.append(i)
    for divisor in divisors:
        if max(A,B)%divisor==0:
            count+=1
            if count==K:
                print(divisor)
if __name__ =='__main__':
    main()


Fixed code:
def main():
    A,B,K=list(map(int, input().split()))
    divisors=[]
    count = 0
    for i in range(1,min(A,B)+1):
        if min(A,B)%i==0:
            divisors.append(i)
    divisors.reverse()
    for divisor in divisors:
        if max(A,B)%divisor==0:
            count+=1
            if count==K:
                print(divisor)
if __name__ =='__main__':
    main()
Buggy code:
def divde(argv):

    dlist=[]
    i = 1
    for i in range (1,int(argv)+1):
        if(int(argv)%i==0):
            dlist.append(i)
    return dlist

def compare(A,B):
    D =[]
    for i in range (len(A)):
        for j in range(len(B)):
            if A[i]==B[j]:
                D.append(B[j])
    return D

if __name__ == "__main__":
    string = input()
    a, b, c = string.split()

    A = []
    A = divde(a)
    B = []
    B = divde(int(b))
    D = []
    D = compare(A,B)

    D.reverse()

    q = D.index(int(c))
    print(q+1)

Fixed code:
def divde(argv):

    dlist=[]
    i = 1
    for i in range (1,int(argv)+1):
        if(int(argv)%i==0):
            dlist.append(i)
    return dlist

def compare(A,B):
    D =[]
    for i in range (len(A)):
        for j in range(len(B)):
            if A[i]==B[j]:
                D.append(B[j])
    return D

if __name__ == "__main__":
    string = input()
    a, b, c = string.split()

    A = []
    A = divde(a)
    B = []
    B = divde(int(b))
    D = []
    D = compare(A,B)

    D.reverse()

    q = int(c)-1
    print(D[q])
Buggy code:
ABK=input().split()
A=int(ABK[0]);B=int(ABK[1]);K=int(ABK[2])
list=[]
for i in range(1,min(A,B)+1):
    if (A/i).is_integer() and (B/i).is_integer():
        list.append(i)
print(str(list[K-1]))


Fixed code:
ABK=input().split()
A=int(ABK[0]);B=int(ABK[1]);K=int(ABK[2])
list=[]
for i in range(1,min(A,B)+1):
    if (A/i).is_integer() and (B/i).is_integer():
        list.append(i)
list.sort(reverse=True)
print(str(list[K-1]))
Buggy code:
A, B, K = map(int, input().split())
clist = []

for i in range(1, min(A,B)+1):
    if A % i == 0 and B % i == 0:
        clist.append(i)
print(clist[-K+1])

Fixed code:
A, B, K = map(int, input().split())
clist = []

for i in range(1, min(A,B)+1):
    if A % i == 0 and B % i == 0:
        clist.append(i)
print(clist[-K])
Buggy code:
a, b, k = map(int, input().split())
count = 0
ans = 1
while count != k:
    if a%ans == b %ans == 0:
        count += 1
    ans += 1
print(ans-1)


Fixed code:
a, b, k = map(int, input().split())
count = 0
ans = min(a,b)
while count != k:
    if a%ans == b %ans == 0:
        count += 1
    ans -= 1
print(ans+1)
Buggy code:
A, B, times = map(int,input().split())

temp = 0
temp1 = 0
divisor = []
counter = 0

if A >= B:
  temp = A
  temp1 = B

else:
  temp = B
  temp1 = A

for i in range(1,temp):
  if temp % i == 0:
    divisor.append(i)

for j in divisor:
  if temp1 % j ==0:
    counter += 1
    if counter == times:
      print(j)
      break

Fixed code:
A, B, times = map(int,input().split())

temp = 0
temp1 = 0
divisor = []
counter = 0

if A >= B:
  temp = A
  temp1 = B

else:
  temp = B
  temp1 = A

for i in range(1,temp1+1):
  if temp1 % i == 0:
    divisor.append(i)

for j in (reversed(divisor)):
  if temp % j ==0:
    counter += 1
    if counter == times:
      print(j)
      break
Buggy code:
#!/usr/bin/env python3

def main():
    A, B, K = map(int, open(0).read().split())

    ANS = []
    for i in range(1, max(A+1, B+1)):
        if (A % i == 0) and (B % i == 0):
            ANS.append(i)
    print(ANS[K-1])


main()

Fixed code:
#!/usr/bin/env python3

def main():
    A, B, K = map(int, open(0).read().split())

    ANS = []
    for i in range(1, max(A+1, B+1)):
        if (A % i == 0) and (B % i == 0):
            ANS.append(i)
    print(ANS[-K])


main()
Buggy code:
a,b,k=map(int,input().split())
cnt = 0
div = 1
while cnt < k:
    if a%div == 0 and b%div == 0:
        cnt += 1
    div += 1
print(div - 1)


Fixed code:
a,b,k=map(int,input().split())
cnt = 0
div = min(a,b)
while cnt < k:
    if a%div == 0 and b%div == 0:
        cnt += 1
    div -= 1
print(div + 1)
Buggy code:
a,b,k = map(int,input().split())
R =[]

for i in range(1, min(a,b)+1):
	if a%i==0 and b%i==0:
		R.append([i])
print(R[-k])

Fixed code:
a,b,k = map(int,input().split())
ans = []
for i in range(1,min(a,b)+1):
    if a%i==0 and b%i==0:ans.append(i)
print(ans[-k])
Buggy code:
a,b,k = list(map(int,input().split()))
c= 1
d=0
if b < a:
    a,b=b,a
while True:
    d = b%a
    if d == 0:
        c=a
        break
    else:
        b = a
        a = d
e = 0
for i in range(1,(c//2)+1):
    if c%i == 0:
        e +=1
        if e == k:
            print(int(c/i))

Fixed code:
a,b,k = list(map(int,input().split()))
c= 1
d=0
if b < a:
    a,b=b,a
while True:
    d = b%a
    if d == 0:
        c=a
        break
    else:
        b = a
        a = d
e = 0
for i in range(1,c+1):
    if c%i == 0:
        e +=1
        if e == k:
            print(int(c/i))
            break
Buggy code:
a,b,k = list(map(int,input().split()))
for i in range(1,min(a,b)+1):
  if a%i == 0 and b%i == 0:
    k -= 1
    if k == 0:
      print(i)
      break

Fixed code:
a,b,k=map(int,input().split())
ans=0
for i in range(min(a,b)):
    if a%(min(a,b)-i)==0 and b%(min(a,b)-i)==0:
        ans+=1
        if ans==k:
            print(min(a,b)-i)
            break
Buggy code:
a,b,k = map(int,input().split())
l=[]
for i in range(1,101):
    if a%i ==0 and b%i ==0:
        l.append(i)

print(l[-2])

Fixed code:
a,b,k = map(int,input().split())
cnt = []
for i in range(1,101):
    if a % i == 0 and b % i == 0:
        cnt.append(i)
print(cnt[-k])
Buggy code:
a,b,k=map(int,input().split())
numlst=[]
for i in range(1,max(a,b)):
    if a%i==0 and b%i==0:
        numlst.append(i)

print(numlst[k-1])

Fixed code:
a,b,k=map(int,input().split())
numlst=[]
for i in range(max(a,b)):
    if a%(i+1)==0 and b%(i+1)==0:
        numlst.append(i+1)

print(numlst[len(numlst)-k])
Buggy code:
a,b,c = (int(x) for x in input().split())
for i in range(100,1,-1):
    if a % i == 0 and b % i == 0:
        c -= 1
        if c == 0:
            print(i)


Fixed code:
a,b,c = (int(x) for x in input().split())
for i in range(100,0,-1):
    if a % i == 0 and b % i == 0:
        c -= 1
        if c == 0:
            print(i)