#include<iostream>                                                                                                                                
#include<stdio.h>                                                                                                                                 
using namespace std;                                                                                                                              
                                                                                                                                                  
int main()                                                                                                                                        
{                                                                                                                                                 
        int a, b, k, i = 0, ans;                                                                                                                  
        scanf("%d%d%d", &a, &b, &k);                                                                                                              
        if (a < b)                                                                                                                                
                i = a;                                                                                                                            
        else                                                                                                                                      
                i = b;                                                                                                                            
                                                                                                                                                  
        while (k != 0) {                                                                                                                          
                if ((a % i == 0) && (b % i ==0)) {                                                                                                
                        ans = i;                                                                                                                  
                        k--;                                                                                                                      
                }                                                                                                                                 
                i--;                                                                                                                              
        }                                                                                                                                         
        printf("%d", ans);                                                                                                                        
        return 0;                                                                                                                                 
}

Measured memory_bytes: 256