qyliang/CodeNanoFix huggingface dataset:
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 20:59:27 2019

@author: doppe
"""
A, B, K = map(int, input().split())

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

print(i)


Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 20:59:27 2019

@author: doppe
"""
A, B, K = map(int, input().split())

num = 0
if (A > B):
    max = A
else:
    max = B

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

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


Fixed code:
[a, b, n] = [int(i) for i in input().split()]
hoge = []
for i in range(1, 101):
    if a%i==0 and b%i==0:
        hoge.append(i)
hoge.sort(reverse=True)
print(hoge[n-1])
Buggy code:
a,b,c = map(int,input().split())
l,x,y = [],min(a,b),max(a,b)
for i in range(1,x+1):
  if x%i==0:
    l.append(i)
l = sorted(l)[::-1]
print(l[c-1])

Fixed code:
a,b,c = map(int,input().split())
l,x,y = [],min(a,b),max(a,b)
for i in range(1,x+1):
  if x%i==0 and y%i==0: 
    l.append(i)
l = l[::-1]
#print(l)
print(l[c-1])
Buggy code:
import math
a, b, c = map(int, input().split())
A = list(range(min(a, b)+1))
d = 0
e = 0
A.reverse()
for i in A[:-1]:
    print(i)
    if a % i == 0 and b % i == 0:
        d += 1
        if c == d:
            e = i
            break
print(e)


Fixed code:
a, b, c = map(int, input().split())
A = list(range(min(a, b)+1))
d = 0
e = 0
A.reverse()
for i in A[:-1]:
    if a % i == 0 and b % i == 0:
        d += 1
        if c == d:
            e = i
            break
print(e)
Buggy code:
a, b, k = map(lambda x: int(x), input().split(' '))

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

gcd_res = 0
if a < b:
  gcd_res = gcd(b, a)
else:
  gcd_res = gcd(a, b)

count = 1
for i in reversed(range(1, 101)):
  if (gcd_res % i) == 0 and i == k:
    print(i)
    break
  count += 1


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

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

gcd_res = 0
if a < b:
  gcd_res = gcd(b, a)
else:
  gcd_res = gcd(a, b)

count = 1
for i in reversed(range(1, 101)):
  if (gcd_res % i) == 0:
    if count == k:
      print(i)
      break
    count += 1
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 = map(int,input().split())
res = []
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i == 0:
    res.append(i)
print(res[-k])
Buggy code:
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

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

yakusu = defaultdict(int)

for a in range(A):
    a += 1
    if A % a == 0:
        yakusu[a] += 1
    if B >= a and B % a == 0:
        yakusu[a] += 1

nums = sorted([x for x in yakusu.keys() if yakusu[x] == 2])
print(nums[K-1])


Fixed code:
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

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

yakusu = defaultdict(int)

for a in range(A):
    a += 1
    if A % a == 0:
        yakusu[a] += 1
    if B >= a and B % a == 0:
        yakusu[a] += 1

nums = sorted([x for x in yakusu.keys() if yakusu[x] == 2])
print(nums[-(K)])
Buggy code:
inp =[int(i) for i in input().split()]
li =[]
li2 =[]

for k in range(1,inp[0]+1):
  f = inp[0] / k
  if f.is_integer():
    li.append(k)

for k in range(1,inp[1]+1):
  f = inp[1] / k
  if f.is_integer():
    li2.append(k)
    
li3 = list(set(li) & set(li2))

print(li3[inp[2]-1])

Fixed code:
inp = [int(i) for i in input().split()]
li =[]
li2 =[]

for k in range(1,inp[0]+1):
  f = inp[0] / k
  if f.is_integer():
    li.append(k)

for m in range(1,inp[1]+1):
  h = inp[1] / m
  if h.is_integer():
    li2.append(m)
    
li3 = list(set(li) & set(li2))
li3.sort()
print(li3[-inp[2]])
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,101):
    if a%i == 0 and b%i == 0:
        l.append(i)

print(l[-1*k])
Buggy code:
a,b,k = map(int,input().split(" "))

count = 0
for i in range(101,1,-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(max(a,b),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())

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

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

smaller = min(A, B)
cnt_div = 0
for i in range(1, smaller+1)[::-1]:
  if A%i == 0 and B%i == 0:
    cnt_div += 1
  if cnt_div >= K:
    print(i)
    break
Buggy code:
A, B, K = tuple(map(int, input().split()))

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

print(listQ)
print(listQ[-K])




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

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

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

def get(num):
    yakusuu_array = []
    for i in range(1,num + 1):
        if num % i == 0:
            yakusuu_array.append(i)
    return yakusuu_array

print(get(A))
a = list(set(get(A)) & set(get(B)))
a.sort(reverse=True)


print(a[(K-1)])



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

def get(num):
    yakusuu_array = []
    for i in range(1,num + 1):
        if num % i == 0:
            yakusuu_array.append(i)
    return yakusuu_array

a = list(set(get(A)) & set(get(B)))
a.sort(reverse=True)


print(a[(K-1)])
Buggy code:
#import sys
#import math
#import numpy as np

'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
a,b,k=map(int,input().split())
ans=s=0
li=[]
if a>b:
  s=a
  a=b
  b=s
for i in range(1,b+1):
  if a%i==0 and b%i==0:
    li.append(i)
li.sort()
print(li)
print(li[-k])


Fixed code:
#import sys
#import math
#import numpy as np

'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
a,b,k=map(int,input().split())
ans=s=0
li=[]
if a>b:
  s=a
  a=b
  b=s
for i in range(1,b+1):
  if a%i==0 and b%i==0:
    li.append(i)
li.sort()

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

Fixed code:
a, b, k = map(int, input().split())
num = 0
for i in reversed(range(1, 101)):
    if a % i == 0 and b % i == 0:
        num += 1
        if num == k:
            print(i)
            break
Buggy code:
S = input()

S = S.split()

S = list(map(int, S))

A = S[0]
B = S[1]
K = S[2]

list = []

if A > B:
  C = A
else:
  C = B

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

print(list[K])
  
  
  
  
  

Fixed code:
S = input()

S = S.split()

S = list(map(int, S))

A = S[0]
B = S[1]
K = S[2]

list = []

if A >= B:
  C = B
else:
  C = A

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

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

Fixed code:
A, B, K = map(int, input().split())
l = []
for i in range(1, max(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())
x=0
y=[0]
c=min(a,b)

if a==1 or b==1:
    print(1)
    exit()
    
for d in range(1,c):
    if a%d==0 and b%d==0:
            y.append(d)

print(y[k])
print(y)


Fixed code:
a,b,k = map(int,input().split())
x=0
y=[0]
c=min(a,b)

if a==1 or b==1:
    print(1)
    exit()
    
for d in range(1,c+1):
    if a%d==0 and b%d==0:
            y.append(d)

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

list.sort(cmn_dvs, reverse = True)
print(cmn_dvs)
print(cmn_dvs[k-1])

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

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

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

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

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

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

print(list(set(divisor(A)) & set(divisor(B)))[K-1])

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

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

print(sorted(list(set(divisor(A)) & set(divisor(B))), reverse=True)[K-1])
Buggy code:
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
ans_list =[]
for i in range(min(x,y)):
    
    if x % (i+1) == 0 and y % (i+1) == 0:
        ans_list.append(i+1)
print(ans_list[z-1])

Fixed code:
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
ans_list =[]
for i in range(min(x,y)):
    
    if x % (i+1) == 0 and y % (i+1) == 0:
        ans_list.append(i+1)
print(ans_list[len(ans_list)-z])
Buggy code:
a,b,k=map(int,input().split())
buf=0
for i in range(1,max(a,b)+1):
    if a%i==0 and b%i==0:
        buf+=1
    if buf==k:
        print(i)
        break

Fixed code:
a,b,k=map(int,input().split())
buf=0
a_b=max(a,b)
for i in range(a_b,0,-1):
    if a%i==0 and b%i==0:
        buf+=1
    if buf==k:
        print(i)
        break
Buggy code:
A, B, K = map(int, input().split()) 
if A > B:
    S = B
else:
    S = A
num = 0
correct = []  
for i in range(1,S+1):      
    if A % i == 0 and B % i == 0:
        correct.append(i)
    else:
        pass
print(correct)    
correct.reverse()
print(correct[K-1]) 

Fixed code:
A, B, K = map(int, input().split()) 
if A > B:
    S = B
else:
    S = A
num = 0
correct = []  
for i in range(1,S+1):      
    if A % i == 0 and B % i == 0:
        correct.append(i)
    else:
        pass  
correct.reverse()
print(correct[K-1])
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)
sorted(l)[::-1]
print(l[K-1])

Fixed 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])
Buggy code:
import math
A,B,K = map(int,input().split())
ans = []
if A>B:
    Max = A
else:
    Max = B
for i in range(1,Max):
    if (A%i==0) & (B%i==0):
        ans.append(i)
print(ans[len(ans)-K])


Fixed code:
import math
A,B,K = map(int,input().split())
ans = []
if A>B:
    Max = A
else:
    Max = B
for i in range(1,Max+1):
    if (A%i==0) & (B%i==0):
        ans.append(i)
print(ans[len(ans)-K])
Buggy code:
A,B,K=map(int,input().split())
y=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        y.append(i)
print(y[K-1])

Fixed code:
A, B, K = map(int, input().split())
X = []
for i in range(1, min(A, B) + 1):
  if A % i == 0 and B % i == 0:
    X.append(i)
print(X[-K])
Buggy code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
a, b, k = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

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


Fixed code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
a, b, k = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

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

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

Fixed code:
a,b,k=map(int,input().split())
ans = []
for i in range(1,101):
    if a % i == b % i == 0:
        ans.append(i)
print(ans[-k])
Buggy code:
a, b, k = 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
A = cf(a, b)
print(A[k-1])

Fixed code:
a, b, k = 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
A = cf(a, b)
A.sort(reverse = True)
print(A[k-1])
Buggy code:
A, B, K = [int(akb) for akb in input().split()]
a, b = min(A, B), max(A, B)
r = b % a
while r > 0:
  b = a
  a = r
  r = b % a
gcd = a
ans = a
if K > 1:
  for i in range(100):
    if gcd % (i+1) == 0:
      ans = gcd / i
      K -= 1
    if K == 1:
      break
print(ans)

Fixed code:
A, B, K = [int(akb) for akb in input().split()]
a, b = min(A, B), max(A, B)
r = b % a
while r > 0:
  b = a
  a = r
  r = b % a
gcd = a
ans = a
if K > 1:
  for i in range(1, 100):
    if gcd % (i+1) == 0:
      ans = gcd / (i+1)
      K -= 1
    if K == 1:
      break
print(int(ans))
Buggy code:
a,b,k = [int(s) for s in input().rstrip().split()]
j=0
for i in range(1,101):
    if (a%i == 0) and (b%i == 0):
        j+=1
        if j == k:
            break

print(j)

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

print(i)
Buggy code:
import fractions
a, b, k = map(int, input().split())

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

print(mklist(a,b)[k-1])


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

def mklist(a, b):
  nums = []
  for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
      nums.append(i)
  nums.sort(reverse=True)
  return nums

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

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

cnt = 0
for i in range(101, 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())
ans=[]
for i in range(1,max(a,b)):
    if a%i==0 and b%i==0:
        ans.append(i)
print(ans[-k])

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


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
temp = 0
for i in range(1, max(A, B)+1):
    if A % 2 == 0 and B % 2 == 0:
        temp += 1
    if temp == K:
        print(i)
        exit()


Fixed code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
temp = 0
for i in range(min(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        temp += 1
        if temp == K:
            print(i)
            exit()
Buggy code:
A,B,K=map(int,input().split())
if K== 1:
  print(1)
else:
  count=1
  ans=0
  for i in reversed(range(2,min(A,B))):
    if A % i == 0 and B % i == 0:
      count+= 1
      if count==5:
        ans=i
  print(ans)


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

count=0
ans=0
for i in reversed(range(1,min(A,B)+1)):
  if A % i == 0 and B % i == 0:
    count+= 1
    if count==K:
      ans=i
print(ans)
Buggy code:
def gcd(a,b):
  return [i for i in range(1,min(a,b)+1) if a%i == 0 and b%i == 0]
   
A, B, K = map(int, input().split())
ans = gcd(A,B)
print(ans[K+1])

Fixed code:
def gcd(a,b):
  return [i for i in range(1,min(a,b)+1) if a%i == 0 and b%i == 0]
   
A, B, K = map(int, input().split())
ans = gcd(A,B)
print(ans[-1*K])
Buggy code:
A,B,K=[int(i) for i in input().split()]
a=[]
for i in range(1,max(A,B)):
  if A%i==0 and B%i==0:
    a.append(i)
print(a[-k])
  

Fixed code:
A,B,K=[int(i) for i in input().split()]
a=[]
for i in range(1,max(A,B)+1):
  if A%i==0 and B%i==0:
    a.append(i)
print(a[-K])
Buggy code:
str_lis = input().split()
A, B, K = [int(x) for x in str_lis]
N = min(A, B)
num_lis = [n for n in range(1, N + 1) if A % n == 0 and B % n == 0]
print(num_lis[K]

Fixed code:
str_lis = input().split()
A, B, K = [int(x) for x in str_lis]
N = min(A, B)
num_lis = [n for n in range(1, N + 1) if A % n == 0 and B % n == 0]
lis = num_lis[::-1]
print(lis[K - 1])
Buggy code:
A, B, k = map(int, input().split())
lst = []
for i in range(1, 100):
  if A % i and B % i == 0:
    lst.append(i)
print(lst[-k])


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

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

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

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

n = 0
cd_list = []

if a < b:
  n = a
else:
  n = b

i = 1

while i <= n:
  if a % i == 0 and b % i == 0:
    cd_list.append(i)
  i += 1

print(cd_list[k-1])
  

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

n = 0
if a < b:
  n = a
else:
  n = b

cd_list = []
i = 1
while i <= n:
  if a % i == 0 and b % i == 0:
    cd_list.append(i)
  i += 1

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

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

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

print(i)

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

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

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

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

counter = 0
for i in range(min(a, b), 1, -1):
    if a % i == 0 and b % i == 0:
        counter += 1
        if counter == k:
            print("{}".format(int(i)))

Fixed code:
a, b, k = map(int, input().split())
counter = 0
for i in range(100, 0, -1):
    if a % i == 0 and b % i == 0:
        counter += 1
        if counter == k:
            print("{}".format(int(i)))
            break
Buggy code:
# https://atcoder.jp/contests/abc120/tasks/abc120_b

import itertools
import collections
import bisect

def main():
    A, B, K = map(int, input().split())
    count = 0
    for i in range(1, max(A, B) + 1):
        # print(i)
        if A % i == 0 and B % i == 0:
            count += 1
            # print(i)
            if count == K:
                print(i)
                exit()

if __name__ == '__main__':
    main()


Fixed code:
# https://atcoder.jp/contests/abc120/tasks/abc120_b

import itertools
import collections
import bisect

def main():
    A, B, K = map(int, input().split())
    count = 0
    for i in range(max(A, B) + 1, 0, -1):
        # print(i)
        if A % i == 0 and B % i == 0:
            count += 1
            # print(i)
            if count == K:
                print(i)
                exit()

if __name__ == '__main__':
    main()
Buggy code:
a, b, k = map(int, input().split())
ans = []
for i in range(1, max(a, b)):
    if a % i == 0 and b % i == 0:
        ans.append(i)
print(ans[-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])