qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a, b, k = input().split()
a = int(a)
b = int(b)
k = int(k)
a_list = []
b_list = []
for j in range(a):
    i = j + 1
    if a % i == 0:
        a_list.append(i)
for j in range(b):
    i = j + 1
    if b % i == 0:
        b_list.append(i)

#a_list.extend(b_list)
#co_divisor = list(set(a_list))
a_list = set(a_list)
b_list = set(b_list)
co_divisor = list(a_list & b_list)
co_divisor.sort()
print(co_divisor)
print(co_divisor[k-1])

Fixed code:
a, b, k = input().split()
a = int(a)
b = int(b)
k = int(k)
a_list = []
b_list = []
for j in range(a):
    i = j + 1
    if a % i == 0:
        a_list.append(i)
for j in range(b):
    i = j + 1
    if b % i == 0:
        b_list.append(i)

#a_list.extend(b_list)
#co_divisor = list(set(a_list))
a_list = set(a_list)
b_list = set(b_list)
co_divisor = list(a_list & b_list)
co_divisor.sort(reverse=True)
print(co_divisor[k-1])
Buggy code:
A,B,K=map(int,input().split())
a=[]
b=[]
for i in range(A):
  if A%(i+1) == 0:
    a.append(i+1)
for ii in range(B):
  if B%(ii+1) == 0:
    b.append(ii+1)
s=set(a)&set(b)
print(sorted(list(s))[K])

Fixed code:
A,B,K=map(int,input().split())
a=[]
b=[]
for i in range(A):
  if A%(i+1) == 0:
    a.append(i+1)
for ii in range(B):
  if B%(ii+1) == 0:
    b.append(ii+1)
s=set(a)&set(b)
print(sorted(list(s))[-K])
Buggy code:
A, B, K = map(int, input().split())
list = [i for i in range(1, 101) if A % i == 0 and B % i == 0]
print(list[K-1])

Fixed code:
A, B, K = map(int, input().split())
list = [i for i in range(1, 101) if A % i == 0 and B % i == 0]
list.reverse()
print(list[K-1])
Buggy code:
A,B,K = [int(_) for _ in input().split()]
c = 0
i = 100
while True:
    if A%i == B%i == 0:
        c += 1
        print(i)
    if c == K:
        break
    i -= 1
print(i)

Fixed code:
A,B,K = [int(_) for _ in input().split()]
c = 0
i = 100
while True:
    if A%i == B%i == 0:
        c += 1
    if c == K:
        break
    i -= 1
print(i)
Buggy code:
a, b, k = map(int, input().split())

ans = 0

lista = range(a+1)
aa = lista.pop(0)

listb = range(b+1)
bb = listb.pop(0)

if (a < b):
    li = [i for i in listb if (a % i == 0 && b % i == 0)]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in lista if (a % i == 0 && b % i == 0)]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)

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

ans = 0

lista = list(range(a+1))
aa = lista.pop(0)

listb = list(range(b+1))
bb = listb.pop(0)

if (a < b):
    li = [i for i in lista if a % i == 0 and b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in listb if a % i == 0 and b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)
Buggy code:
def get_div(num):
    if num == 1:
        return [1]
    else:
        return [i for i in range(1,num) if num%i==0]

A, B, K  = [int(a) for a in input().split()]
cat = get_div(A) + get_div(B)
dup = [x for x in set(cat) if cat.count(x) > 1]
dup = sorted(dup)
print(dup[K-1])

Fixed code:
def get_div(num):
    if num == 1:
        return [1]
    else:
        return [i for i in range(1,num+1) if num%i==0]

A, B, K  = [int(a) for a in input().split()]
cat = get_div(A) + get_div(B)
dup = sorted([x for x in set(cat) if cat.count(x) > 1])
dup.reverse()
print(dup[K-1])
Buggy code:
a=input()
A=int(a.split()[0])
B=int(a.split()[1])
K=int(a.split()[2])

a=0
if(A>B): i=A
if(B>A): i=B
count=0
while(a==0):
  if(A%i==0 and B%i==0):
    count+=1
    if(count==K):
      print(i)
      break
  i-=1

Fixed code:
a=input()
A=int(a.split()[0])
B=int(a.split()[1])
K=int(a.split()[2])

a=0
if(A>B): i=A
else: i=B
count=0
while(a==0):
  if(A%i==0 and B%i==0):
    count+=1
    if(count==K):
      print(i)
      break
  i-=1
Buggy code:
str_in = input().split()
a = int(str_in[0])
b = int(str_in[1])
k = int(str_in[2])

if(a >= b):
  div = b
else:
  div = a

cnt = 0

for i in range(div):
  res_a = a % (div - i)
  res_b = b % (div - i)
  
  print(res_a, res_b, div-i,cnt)

  if ((res_a == 0) & (res_b == 0)):
    cnt += 1
    if(cnt == k):
      print (div - i)
      break

Fixed code:
str_in = input().split()
a = int(str_in[0])
b = int(str_in[1])
k = int(str_in[2])

if(a >= b):
  div = b
else:
  div = a

cnt = 0

for i in range(div):
  res_a = a % (div - i)
  res_b = b % (div - i)

  if ((res_a == 0) & (res_b == 0)):
    cnt += 1
    if(cnt == k):
      print (div - i)
      break
Buggy code:
a, b, k = map(int, input().split())
mx = max(a, b) * 0.5
match, ans = 0, 0

for i in range(mx):
    if ((a % (mx - i)) == 0) 
    and ((b % (mx - i)) == 0):
        match += 1
        ans = mx - i
        
        if match == k:
            break
print(ans)


Fixed code:
a, b, k = map(int, input().split())
mx = max(a, b)
match, ans = 0, 0

for i in range(mx):
    if ((a % (mx - i)) == 0) and ((b % (mx - i)) == 0):
        
        match += 1
        ans = mx - i
        
        if match == k:
            break
print(ans)
Buggy code:
def compute():
  from sys import stdin
  A, B, K = list(map(int, stdin.readline().split()))
  
  cur = 0
  while K>0 and cur<=max(A,B):
    cur += 1
    if (A%cur==0) and (B%cur==0):
      K-=1
  
  print(cur if K<1 else -1)

if __name__ == "__main__":
  compute()


Fixed code:
def compute():
  from sys import stdin
  A, B, K = list(map(int, stdin.readline().split()))
  
  cur = min(A,B) + 1
  while K>0 and cur>0:
    cur -= 1
    if (A%cur==0) and (B%cur==0):
      K-=1
  
  print(cur if K<1 else -1)

if __name__ == "__main__":
  compute()
Buggy code:
a, b, k = map(int, input().strip().split(' '))
i = 1
l = []
while len(l)<k:
    if a%i==0 and b%i==0:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-1])

Fixed code:
a, b, k = map(int, input().strip().split(' '))
i = 1
l = []
while i<=a or i<=b:
    if a%i==0 and b%i==0:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-k])
Buggy code:
a, b ,k =map(int, input().split())

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

print(l[k-1])

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

print(ans_list[-k])
Buggy code:
A,B,K=map(int,input().split())
k=0
n=1
while 1:
  if A%n==0 and B%n==0:
    k+=1
  if K==k:
    break
  n+=1
print (n)

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

Fixed code:
a,b,k = map(int,input().split())
count = 0
if b >= a:
    count = a
    a = b
    b = count
ch = 1
for i in range(a,0,-1):
    if a % i == 0 and b % i == 0 and k == ch:
        print(i)
        break
    elif a % i == 0 and b % i == 0:
        ch += 1
Buggy code:
a,b,k =map(int,input().split())
p=[]
for i in range(int((a+b)//4)):
  if i>0:
    if a%i == 0 and b%i == 0:
      p +=[i]
print(p[-k+1])

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

count=1
num=0
while count<=ABK[2]:
 count=count+1
 flag=0
 while flag==0:
  num=num+1
  if ABK[0]%num==0 and ABK[1]%num==0:
    flag=1
  
  
print(num)

Fixed code:
ABK=list(map(int,input().split()))

count=1
num=min(ABK[0],ABK[1])+1

while count<=ABK[2]:
 count=count+1
 flag=0
 while flag==0:
  num=num-1
  if ABK[0]%num==0 and ABK[1]%num==0:
    flag=1
  
  
print(num)
Buggy code:
a, b, k = (int(i) for i in input().split())
x = []
c = max(a, b)
for i in  range(1, c):
    if (a % i == 0) and (b % i == 0):
        x.append(i)

print(x[-k])




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

print(x[-k])
Buggy code:
import sys
A,B,K=[int(i) for i in input().split(" ")]
count=0
for i in range(1,101):
    if A%i==0 and B%i==0:
        count+=1
    if count==K:
        print(i)
        sys.exit()


Fixed code:
import sys
A,B,K=[int(i) for i in input().split(" ")]
count=0
for i in range(101,0,-1):
    if A%i==0 and B%i==0:
        count+=1
    if count==K:
        print(i)
        sys.exit()
Buggy code:
A,B,K = map(int, input().split())
count = 0
i = 0

while count < K:
  i += 1
  if( A%i==0 and B%i==0 ):
    count += 1

print(i)

Fixed code:
A,B,K = map(int, input().split())
count = 0
i = 101

while count < K:
  i -= 1
  if( A%i==0 and B%i==0 ):
    count += 1

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

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

l = []

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:
def cf(x1,x2):
    cf=[1]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

A,B,K=map(int,input().split())
print(cf(A,B)[K-1])


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

A,B,K=map(int,input().split())
print(cf(A,B)[-K])
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)
print(ans)
print(ans[k-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[len(ans)-k])
Buggy code:
def factor(num):
    factor_set = set()
    for i in range(1,num+1):
        if num%i == 0:
            factor_set.add(i)
    return factor_set

l = [int(i) for i in input().split(" ")]
a = l[0]
b = l[1]
k = l[2]

and_list = sorted(list(factor(a) & factor(b)))
print(and_list)
print(and_list[k-1])


Fixed code:
def factor(num):
    factor_set = set()
    for i in range(1,num+1):
        if num%i == 0:
            factor_set.add(i)
    return factor_set

l = [int(i) for i in input().split(" ")]
a = l[0]
b = l[1]
k = l[2]

and_list = sorted(list(factor(a) & factor(b)),reverse=True)
print(and_list[k-1])
Buggy code:
def ls_devider(num):
    fs = set()
    fs.add(1)

    if num > 1:
        for i in range(2, num):
            if num % i == 0:
                fs.add(i)

    return fs


a, b, k = map(int, input().split(' '))
a_dvs = ls_devider(a)
b_dvs = ls_devider(b)

print(sorted(a_dvs&b_dvs)[k-1])




Fixed code:
def ls_devider(num):
    fs = set()
    fs.add(1)

    if num > 1:
        for i in range(2, num+1):
            if num % i == 0:
                fs.add(i)

    return fs


a, b, k = map(int, input().split(' '))
a_dvs = ls_devider(a)
b_dvs = ls_devider(b)

print(sorted(a_dvs&b_dvs, reverse=True)[k-1])
Buggy code:
A,B,K = (int(x) for x in input().split())
i = 1
n = 0
NUM = [0]*min(A,B)
for i in range(1,min(A,B)+1):
    if A%i ==0 and B%i ==0:
        NUM[n] = i
        n+=1
        
print(NUM[K-1])

Fixed code:
A,B,K = (int(x) for x in input().split())
i = 1
n = 0
NUM = [0]*min(A,B)

for i in range(1,min(A,B)+1):
    if A%i ==0 and B%i ==0:
        NUM[n] = i
        n+=1
NUM.sort(reverse = 1)

print(NUM[K-1])
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)
        if len(ans) == K:
            print(ans[-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 = 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(min(A,B)):
	if A % (i + 1) == 0 and B % (i + 1) == 0:
		ans.append(i + 1)

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


Fixed code:
a,b,k = map(int,input().split())
cnt = 0
for i in range(100,-1,-1):
  if a%i == b%i == 0:
    cnt += 1
  if cnt == k:
    print(i)
    exit()
Buggy code:
A,B,K=map(int,input().split())
ans_list=[]
C=max(A,B)+1
for i in range(1,C):
    if A%i == B%i == 0:
        ans_list.append(i)
print(ans_list[K-1])

Fixed code:
A,B,K=map(int,input().split())
ans_list=[]
C=min(A,B)+1
for i in range(1,C):
    if A%i == 0 and B%i == 0:
        ans_list.append(i)
print(ans_list[-K])
Buggy code:
A, B, K = map(int, input().split())
#A, B, K = 12, 8, 2


if A > B:
	tmp = B
	B = A
	A = tmp
	#print(A,B)

d = []

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

print(d[K-1])

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


if A > B:
	tmp = B
	B = A
	A = tmp
	#print(A,B)

d = []

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

d.reverse()
print(d[K-1])
Buggy code:
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 code:
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 code:
a, b, k = map(int, input().split())
x = [i for i in range(1, min(a, b)+1) if (a % i == 0 and b % i == 0)]
print(x[k-1])


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

Fixed code:
a,b,k=map(int,input().split())
for i in range(min([100,a,b]),0,-1):
  if a%i==0 and b%i==0:
    k-=1
  if k==0:
    print(i)
    exit()
Buggy code:
num= [int(i) for i in input().split()]
max_n = min(num[0],num[1])
a = sorted(list(range(1,max_n+1)),reverse=True)
[i for i in a if (num[0]%i==0 and num[1]%i==0)][num[2]-1]

Fixed code:
num= [int(i) for i in input().split()]
max_n = min(num[0],num[1])
a = sorted(list(range(1,max_n+1)),reverse=True)
print([i for i in a if (num[0]%i==0 and num[1]%i==0)][num[2]-1])
Buggy code:
a,b,k = map(int,input().split())
cnt = 0
for i in range(min(a,b),1,-1):
    if a%i == 0 and b%i == 0:
        cnt += 1
    
    if cnt == k:
        print(i)
        break


Fixed code:
a,b,k = map(int,input().split())
cnt = 0
for i in range(min(a,b),0,-1):
    if a%i == 0 and b%i == 0:
        cnt += 1
    
    if cnt == k:
        print(i)
        break
Buggy code:
x,y,z = map(int,input().split())
n = (y if x < y else x) 
array = []
for i in range(1,n):
	if (x%i==0 and y%i==0):
		array.append(i)
print(array[z-1])


Fixed code:
x,y,z = map(int,input().split())
n = (y if x < y else x) 
n += 1
array = [1]
for i in range(1,n):
	if (x%i==0 and y%i==0):
		array.append(i)
array.reverse()
print(array[z-1])
Buggy code:
a, b, k = map(int, input().split())
print([j for j in [i for i in range(1, 101) if a % i == 0] if b % j == 0][k - 1])

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

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

Fixed code:
a, b, k = map(int, input().split())
arr = []
for i in range(1, a + 1):
    if (a % i == 0 and b % i == 0):
        arr.append(i)
print(arr[-k])
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)
l.sort(reverse=True)
print(l)
print(l[K - 1])

Fixed 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)
l.sort(reverse=True)
print(l[K - 1])
Buggy code:
a,b,k = map(int, input().split())

q = []

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

print(q[k-1])

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

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

Fixed code:
a, b, k = map(int, input().split())
cnt = 0
for i in range(1, 101):
    if a % (101 - i) == 0 and b % (101 - i) == 0:
        cnt += 1
    if cnt == k:
        print(101 - i)
        exit()
Buggy code:
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)

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

Fixed code:
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)

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

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

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

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

print(li[len(li)-K])
Buggy code:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while True:
            if x % y != 0:
                z = x % y
                x = y
                y = z
            else:
                break
        return z
A, B, K = map(int, input().split())
A_B_gcd = gcd(A, B)
yakusuu_arr = []
for i in range(1, A_B_gcd):
    if A_B_gcd % i == 0:
        yakusuu_arr.append(i)
print(yakusuu_arr[K-1])

Fixed code:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while True:
            if x % y != 0:
                z = x % y
                x = y
                y = z
            else:
                break
        return z
A, B, K = map(int, input().split())
A_B_gcd = gcd(A, B)
yakusuu_arr = []
for i in range(1, A_B_gcd+1):
    if A_B_gcd % i == 0:
        yakusuu_arr.append(i)
yakusuu_arr.sort(reverse=True)
print(yakusuu_arr[K-1])
Buggy code:

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

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

def cd(a,k):
    for i in range(1,a+1):
        if a%i == 0:
            k = k-1
            if k==0:
                return i
    return -1

print(cd(gcd(a,b),k))


Fixed code:

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

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

def cd(a,k):
    for i in reversed(range(1,a+1)):
        if a%i == 0:
            k = k-1
            if k==0:
                return i
    return -1

print(cd(gcd(a,b),k))
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[k - 1])

Fixed code:
a,b,k = map(int,input().split())
L = []
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())

cnt = 0
n = 1
while (cnt != K):
    if (A % n == 0 and B % n == 0): cnt += 1
    # print (n, cnt)
    n += 1

print (n - 1)


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

cnt = 0
n = min(A, B)
while (cnt != K):
    if (A % n == 0 and B % n == 0): cnt += 1
    # print (n, cnt)
    n -= 1

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



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


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

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


Fixed code:
A,B,K=map(int,input().split())
ans=[]
i=1
for i in range(1,101):
  if A%i==0 and B%i==0:
    ans.append(i)
    i+=1
ans.reverse()
print(ans[K-1])
Buggy code:
import numpy as np
import math
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
count_k = 0
for d in range(100,0, -1):
    if a % d == 0 and b % d == 0:
        count_k += 1

print(d)


Fixed code:
import numpy as np
import math
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
count_k = 0
for d in range(100,0, -1):
    if a % d == 0 and b % d == 0:
        count_k += 1
        if count_k == k:
            break

print(d)
Buggy code:
in_str = input()
a,b,k = (int(x) for x in in_str.split(' '))
x = 0
while k > 0:
  x += 1
  if a % x == 0 and b % x == 0:
    k -= 1
print (x)



Fixed code:
in_str = input()
a,b,k = (int(x) for x in in_str.split(' '))
x = min(a,b) + 1
while k > 0:
  x += -1  
  if a % x == 0 and b % x == 0:
    k -= 1
print (x)
Buggy code:
A, B, K = map(int, input().split())

count=0
if A > B:
    for i in range(1,B+1):
        if A%i==0 and B%i==0:
            count += 1
            if count == K:
                break
else:
    for i in range(1,A+1):
        if A%i==0 and B%i==0:
            count += 1
            if count == K:
                break

print(i)

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

count=0
if A > B:
    for i in range(B, 0, -1):
        if A%i==0 and B%i==0:
            count += 1
            if count == K:
                break
else:
    for i in range(A, 0, -1):
        if A%i==0 and B%i==0:
            count += 1
            if count == K:
                break

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

Fixed code:
A,B,K=map(int,input().split())
cnt=0
for i in range(1,1000):
    if A%(1000-i)==0 and B%(1000-i)==0:
        cnt+=1
    if cnt==K:
        break
    
print(1000-i)
Buggy code:
a, b, k = map(int, input().split())
zero_list = []
i_len = min(a, b)
for i in range(1, i_len+1):
    if a%i==0 and b%i==0:
        zero_list.append(i)
print(zero_list[k-1])


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

cnt=0
s=min(a,b)

for i in range(1,s+1):
  if a%i==0 and b%i==0:
    cnt+=1
    if cnt==k:
      print(i)
      exit()

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

cnt=0
s=min(a,b)

for i in range(s,0,-1):
  if a%i==0 and b%i==0:
    cnt+=1
    #print(i)
    if cnt==k:
      print(i)
      exit()