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

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

print(ans_ary[K-1])

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

print(ans_ary[-K])
Buggy code:
A,B,K=map(int,input().split())
lis=[]

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

print(lis[K-1])

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

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

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

Fixed code:
a,b,k = map(int,input().split())
min_ = min(a,b)
divisors = []
for i in range(1,min_+1,1):
    if(a%i == 0 and b%i == 0 ):
        divisors.append(i)
print(sorted(divisors,reverse=True)[k-1])
Buggy code:
abk = [int(i) for i in input().split()]
a = abk[0]
b = abk[1]
k = abk[2]

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

Fixed code:
abk = [int(i) for i in input().split()]
a = abk[0]
b = abk[1]
k = abk[2]

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

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


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

common_factors = []
for i in range(1, a+1):
    if a % i == 0 and b % i == 0:
        common_factors.append(i)
print(common_factors[-k])
Buggy code:
A, B, K = map(int, input().split())
ans = []
if max(A,B) == 1:
	print(1)
	exit()
for i in range(1,max(A,B)+1):
	if A % i == 0 and B % i == 0:
		ans.append(i)
ans.sort(reverse=True)
print(ans)
print(ans[K-1])


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


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

m = min(a, b)
count = 0
i = -1
for i in range(m, 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())
war=[]
for i in range(1,max(a,b)):
  if a%i==0 and b%i==0:
    war.append(i)
war.reverse()
print(war[k-1])

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

print(war[k-1])
Buggy code:
import math

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

minAB = min(A, B)
kcount = 1

if minAB == 1:
	print(1)
else:
	for i in range (0, minAB):
		if A%(minAB-i) == 0 and A%(minAB-i) == 0 and kcount <K:
			kcount+=1
		elif A%(minAB-i) == 0 and A%(minAB-i) == 0:
			print(minAB-i)
			exit()
		else:
			continue

Fixed code:
import math

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

minAB = min(A, B)
kcount = 1

if minAB == 1:
	print(1)
else:
	for i in range (0, minAB):
		if A%(minAB-i) == 0 and B%(minAB-i) == 0 and kcount <K:
			kcount+=1
		elif A%(minAB-i) == 0 and B%(minAB-i) == 0:
			print(minAB-i)
			exit()
		else:
			continue
Buggy code:
a,b,k = map(int,input().split())
m = []
for i in range(1,min(a,b)):
    if a%i == 0 and b%i == 0:
        m.append(i)
print(m)
print(m[k-1])

Fixed code:
a,b,k = map(int,input().split())
m = []
for i in range(min(a,b),0,-1):
    if a%i == 0 and b%i == 0:
        m.append(i)
m.sort(reverse=True)
print(m[k-1])
Buggy code:
A, B, K = map(int, input().split())
 
cand = []
for i in range(100,0,-1):
    if A%i == 0 and B%i == 0:
        cand += [i]        
print(cand[K-1]

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

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

Fixed code:
a, b, k = map(int, input().split())
l = []
for i in range(1, a+1):
  if a%i == 0 and b%i == 0:
    l.append(i)
print(l[-k])
Buggy code:
a,b,k = map(int,input().split())
for i in range(1,min(a,b)):
  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())
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:
a,b,k=(int(x) for x in 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=(int(x) for x in 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:
tmp = list(map(int, input().split()))
A, B, K= tmp[0], tmp[1], tmp[2]

i, j = A, B
if A > B:
  i, j = B, A

for k in range(i):
  tmp = k + 1
  if i % tmp == 0 and j % tmp == 0:
    K -= 1
  if K == 0:
    print(tmp)
    break


Fixed code:
tmp = list(map(int, input().split()))
A, B, K= tmp[0], tmp[1], tmp[2]

i, j = A, B
if A > B:
  i, j = B, A

for k in reversed(range(i)):
  tmp = k + 1
  if i % tmp == 0 and j % tmp == 0:
    K -= 1
  if K == 0:
    print(tmp)
    break
Buggy code:
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

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

a_divisor = divisor(A)
b_divisor = divisor(B)

print(sorted(list(set(a_divisor) & set(b_divisor)), reverse=True)[1])

Fixed code:
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

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

a_divisor = divisor(A)
b_divisor = divisor(B)

print(sorted(list(set(a_divisor) & set(b_divisor)), reverse=True)[K-1])
Buggy code:
a,b,c=map(int,input().split())
ct=1
ct2=1
while 1:
    if (a%ct==0)and(b%ct==0):
        ct2+=1
    if ct2==c:
        break
    ct+=1
print(ct)

Fixed code:
a,b,c=map(int,input().split())
ct=a
ct2=0
while 1:
    if (a%ct==0)and(b%ct==0):
        ct2+=1
    if ct2==c:
        break
    ct-=1
print(ct)
Buggy code:
A,B,K=map(int,input().split())
 l = []
for i in reversed(range(0, min(A, B)+1)):
    if (A%i==0)&(B%i==0):
        l.append(i)
    if len(l)==K:
        break        
print(l[-1])

Fixed code:
A,B,K=map(int,input().split())
l = []
for i in reversed(range(0, min(A, B)+1)):
    if (A%i==0)&(B%i==0):
        l.append(i)
    if len(l)==K:
        break        
print(l[-1])
Buggy code:
#A
"""
a, b, c = map(int, input().split())
print(min(a//b, c))
"""

#B
a, b, k = map(int, input().split())
for i in range(1,max(a, b)+1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)

Fixed code:
#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B

a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)
Buggy code:
a,b,k=map(int,input().split())
s=set()
x=1
while(x*x<=a):
  if(a%x==0):
    s.add(x)
  if(a//x!=x and a%(a//x)==0):
    s.add(a//x)
  x+=1
x=1
while(x*x<=b):
  if(b%x==0):
    s.add(x)
  if(b//x!=x and b%(b//x)==0):
    s.add(b//x)
  x+=1
s=list(sorted(s))
count=0
for i in range(len(s)):
    if(a%s[i]==0 and b%s[i]==0):
        count+=1
    if(count==k):
        print(s[i])
        exit()

Fixed code:
a,b,k=map(int,input().split())
s=set()
x=1
while(x*x<=a):
  if(a%x==0):
    s.add(x)
  if(a//x!=x and a%(a//x)==0):
    s.add(a//x)
  x+=1
x=1
while(x*x<=b):
  if(b%x==0):
    s.add(x)
  if(b//x!=x and b%(b//x)==0):
    s.add(b//x)
  x+=1
s=list(sorted(s))
s.sort(reverse=True)
count=0
for i in range(len(s)):
    if(a%s[i]==0 and b%s[i]==0):
        count+=1
    if(count==k):
        print(s[i])
        exit()
Buggy code:
a, b, k = map(int, input().split())
l1 = [i for i in range(1, a) if (a % i == 0)]
l2 = [i for i in range(1, b) if (b % i == 0)]
l = list(set(l1) & set(l2))
l.sort()
print(l[k-1])

Fixed code:
a, b, k = map(int, input().split())
l1 = [i for i in range(1, a+1) if (a % i == 0)]
l2 = [i for i in range(1, b+1) if (b % i == 0)]
l = list(set(l1) & set(l2))
l.sort(reverse = True)
print(l[k-1])
Buggy code:
Aa,Bb,Cc=input().split()
A=int(Aa)
B=int(Bb)
C=int(Cc)
count=0
kazu=min(A,B)
S=[]
for i in range(1,kazu+1):
    if A%i==0 and B%i==0:
        S.append(i)
   
print(S[C-1])
    

Fixed code:
Aa,Bb,Cc=input().split()
A=int(Aa)
B=int(Bb)
C=int(Cc)
count=0
kazu=min(A,B)
S=[]
for i in range(1,kazu+1):
    if A%i==0 and B%i==0:
        S.append(i)
S.reverse()
print(S[C-1])
Buggy code:
a, b, k = [int(x) for x  in input().split()]

divisors = []
for x in range(1, max(a, b)+1):
  if a % x == 0 and b % x == 0:
    divisors.append(x)

print(divisors[k-1])

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

divisors = []
for x in range(1, max(a, b)+1):
  if a % x == 0 and b % x == 0:
    divisors.append(x)

divisors.reverse()
print(divisors[k-1])
Buggy code:
a,b,c=map(int, input().split())
al=[]
bl=[]
for i in range(1,a+1):
    if a%i==0:
        al.append(i)
for i in range(1,b+1):
    if b%i==0:
        bl.append(i))
co=sorted(list(set(al)&set(bl)))
print(co[-c])

Fixed code:
a,b,c=map(int, input().split())
al=[]
bl=[]
for i in range(1,a+1):
    if a%i==0:
        al.append(i)
for i in range(1,b+1):
    if b%i==0:
        bl.append(i)
co=sorted(list(set(al)&set(bl)))
print(co[-c])
Buggy code:
import fractions

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

a_re = []
b_re = []

for i in range(max(A,B)//2 +1):
    if i == 0:
        continue
    if A % i ==0:
        a_re.append(i)
    if B % i ==0:
        b_re.append(i)

result = list (set(a_re) & set( b_re))
result.sort(reverse=True)

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

Fixed code:
import fractions

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

a_re = []
b_re = []

for i in range(max(A,B) + 1):
    if i == 0:
        continue
    #print(i)
    if A % i ==0:
        a_re.append(i)
    if B % i ==0:
        b_re.append(i)
#print(a_re)

result = list (set(a_re) & set( b_re))

result.sort(reverse=True)
print(result[K-1])
Buggy code:
def main():
    a, b, c = list(map(int, input().split()))
    ans = [i for i in range(1, max(a, b)+1) if a%i == 0 and b%i == 0]
    print(ans[c - 1])


if __name__ == "__main__":
    main()



Fixed code:
def main():
    a, b, c = list(map(int, input().split()))
    ans = [i for i in range(1, max(a, b)+1) if a%i == 0 and b%i == 0]
    print(ans[-c])


if __name__ == "__main__":
    main()
Buggy code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

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

Fixed code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

a,b,k = MI()
c = 0
for i in range(a):
    s = a-i
    if a % s == 0 and b % s == 0:
        c += 1
    if c == k:
        print(s)
        sys.exit()
Buggy code:
[a,b,k]=map(int,input().split())
a_set=set([])
b_set=set([])
for i in range(1,101):
    if a%i == 0:
        a_set.add(i)
for i in range(1,101):
    if b%i ==0:
        b_set.add(i)
res=a_set&b_set
res=list(res)
res.sort()
print(res[k-1])

Fixed code:
[a,b,k]=map(int,input().split())
a_set=set([])
b_set=set([])
for i in range(1,101):
    if a%i == 0:
        a_set.add(i)
for i in range(1,101):
    if b%i ==0:
        b_set.add(i)
res=a_set&b_set
res=list(res)
res.sort(reverse=True)
print(res[k-1])
Buggy code:
a,b,k=map(int,input().split())
c=100,d=0
while d<k:
  if a%c==0 and b%c==0:
    d+=1
  c-=1
print(c+1)


Fixed code:
a,b,k=map(int,input().split())
c=100
d=0
while d<k:
  if a%c==0 and b%c==0:
    d+=1
  c-=1
print(c+1)
Buggy code:
a,b,c = map(int, input().split())
def m(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

print(m(a), m(b))
list = m(a)+ m(b)
res = [e for e in set(list) if list.count(e) > 1]
print(res[c])

Fixed code:
a,b,c = map(int, input().split())
def m(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list


list = m(a)+ m(b)
res = [e for e in set(list) if list.count(e) > 1]
res.sort(reverse=True)
print(res[c-1])
Buggy code:
a,b,k = map(int,input().rstrip().split())
c = []

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

print(str(c[k-1]))

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

for num in range(1,max(a,b)+1):
  if(a%num==0 and b%num==0):
    c.append(num)

print(str(c[-k]))
Buggy code:
A, B, K=map(int, input().split())
if A>B:
    tmp=A
    A=B
    B=tmp
count=0
for i in range(A, 0, -1):
    if A%i ==0 & B%i==0:
        count+=1
    if count ==K:
        break
print(i)

Fixed code:
A, B, K=map(int, input().split())
if A>B:
    tmp=A
    A=B
    B=tmp
count=0
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 = list(map(int,input().split()))
n = min(a,b)
lst = []
for i in range(1,n+1):
    if a%i == 0 and b%i == 0:
        lst.append(i)
print(lst[k-1])

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

n = 0
for i in range(1, min(a, b)+1):
    if(a%i==0 and b%i==0):
        n +=1
    if(n == k):
        ans = i
        break
print(ans)



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

n = 0
for i in reversed(range(1, min(a, b)+1)):
    if(a%i==0 and b%i==0):
        n +=1
    if(n == k):
        ans = i
        break
print(ans)
Buggy code:
A, B, K = input().split()

if int(A)==1 or int(B)==1:
    print(1)
else:
    div = [x for x in range(1, min(int(A),int(B))) if int(A)%x==0 and int(B)%x==0]
    print(div[-int(K)])

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

if A==1 or B==1:
    print(1)
else:
    div = [x for x in range(1, min(A,B)+1) if A%x==0 and B%x==0]
    print(div[-K])
Buggy code:
a,b,k = map(int,input().split())
ans = [1]
for i in range(2,min(a,b)):
    if a%i==0 and b%i==0:
        ans.append(i)
ans.sort(reverse = True)
print(ans[k-1])

Fixed code:
a,b,k = map(int,input().split())
ans = [1]
for i in range(2,min(a,b)+1):
    if a%i==0 and b%i==0:
        ans.append(i)
ans.sort(reverse = True)
print(ans[k-1])
Buggy code:
a,b,k = map(int,input().split())
count =[]
for i in range(1,101):
  if a%i == 0 and b%i == 0:
    count.append(i)
  else:
    pass
print(count[k-1])
    

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

print(count[-k])
Buggy code:
a, b, k = map(int, input().split())

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

res.sort(reverse=True)
print(res[k-1])


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

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

res.sort(reverse=True)
print(res[k-1])
Buggy code:
A,B,K = list(map(int, input().split()))
x=[]

for i in range(max(A,B)):
  if A%i==B%i==0:
    x.append(i)

print(x[K-1])

Fixed code:
A,B,K = list(map(int, input().split()))
x=[]
count=0 
for i in range(max(A,B)+1):
  if A%(i+1)==B%(i+1)==0:
    x.append(i+1)
    count+=1
 
print(x[count-K])
Buggy 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[-1-k])

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:
def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

A, B, K = reads()
print([i for i in range(1, A+1) if A % i == B % i == 0][K-1])

Fixed code:
def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

A, B, K = reads()
print([i for i in range(1, A+1) if A % i == B % i == 0][-K])
Buggy code:
A, B, K = map(int, input().split())
res = 0
cnt = 0

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


Fixed code:
A, B, K = map(int, input().split())
res = 0
cnt = 0
 
for i in range(min(A, B), 0, -1):
  if A % i == 0 and B % i == 0:
    cnt += 1
  if cnt == K:
    res = i
    break
print(res)
Buggy code:
A,B,K=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)
      exit(0)

Fixed code:
A,B,K=map(int,input().split())
for i in range(min(A,B)+1,0,-1):
  if A%i==0 and B%i==0:
    K-=1
    if K==0:
      print(i)
      exit(0)
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(1,101):
  if (A % i)== 0 and (B % i) == 0:
    ans.append(i)

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


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

print(list[c-1])

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

Fixed code:
a, b, k = map(int, input().split())
result = []
if a > b:
    for i in range(1, b+1):
        if a % i == 0 and b % i == 0:
            result.append(i)
else:
    for i in range(1, a+1):
        if a % i == 0 and b % i == 0:
            result.append(i)
print(result[len(result) - k])
Buggy code:
A,B,K=map(int,input().split())
l=[]
for i in range(101):
    if A%i==0 and B%i==0:
        l.append(i)
print(l[i-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)
print(l[-K])
Buggy code:
A,B,K = map(int,input().split())
result = []
for i in range(1,100,1):
  if A%i == 0 and B%i == 0:
    result.append(i)
print(result,result[-K])


Fixed code:
A,B,K = map(int,input().split())
result = []
for i in range(1,101,1):
  if A%i == 0 and B%i == 0:
    result.append(i)
print(result[-K])
Buggy code:
a, b, k = [int(_) for _ in 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 = [int(_) for _ in 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)
        exit()
Buggy code:
A, B, K =map(int, input().split())
tmp = []
for i in range(2,min(A,B)+1):
    if A%i == 0 and B%i == 0:
        emp.append(i)
tmp.sort(reverse=True)
print(tmp[K-1])

Fixed code:
A, B, K =map(int, input().split())
tmp = []
try:
    for i in range(2,min(A,B)+1):
        if A%i == 0 and B%i == 0:
            tmp.append(i)
    tmp.sort(reverse=True)
    print(tmp[K-1])
except:
    print(1)
Buggy code:
a, b, k = map(int,input().split())
#n = int(input())
#b = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
#s = input()
ls = []
for i in range(1,min([a,b])+1):
  if a%i == 0 and b%i == 0:
    ls.append(i)
print(ls[k-1])

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

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

Fixed code:
a,b,k=map(int,input().split())
f=0
c=min(a,b)
for i in range(c):
  d=c-i
  if(a%d==0 and b%d==0):
    f+=1
    if(f==k):
      print(d)
Buggy 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)
print(ans[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:
# /user/bin/python
# -*- coding: utf-8 -*-
import sys

a,b,k = map(int, sys.stdin.readline().rstrip().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-1])



Fixed code:
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
 
a,b,k = map(int, sys.stdin.readline().rstrip().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*(-1)])