jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        final int A = sc.nextInt();
        final int B = sc.nextInt();
        final int K = sc.nextInt();
        int cnt = 0;
        int ans = 0;
        
        for (int i = Math.max(A, B); i > 0; i--) {
            if (A % i == 0 && B % i == 0) cnt++;
            if (cnt == K) {
                ans = i;
                break;
            }
        }
        
        out.println(ans);

        out.flush();
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
//  [java]

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class Main {

	public void run() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		List<Integer> arrayData = new ArrayList<Integer>();
		String[] lineArray = line.split(" ");
		for (String token : lineArray) {
			arrayData.add(Integer.parseInt(token));
		}
		int A = arrayData.get(0);
		int B = arrayData.get(1);
		int K = arrayData.get(2);
		List<Integer> li = new ArrayList<Integer>();
		for(int i=1; i<=A;i++){
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		}
		
		
		System.out.println(li.get(K-1));
	}
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

}
//  [java]
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int num = 0;
        for (int i = 1; i < Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0)
                num++;
            if (num == k)
                System.out.println(i);
                if(num == k)
                    break;
        }
    }
}
//  [java]
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int num = 0;
        for (int i = 1; i < Math.max(a, b); i++) {
            if (a % i == 0 && b % 0 == 0)
                num++;
            if (num == k)
                System.out.println(i);
                if(num == k)
                    break;
        }
    }
}
//  [cpp]
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int cnt = 0;
  for (int i = a; i >= 1; i--) {
    if (a % i == 0 && b % i == 0) cnt++;
    if (cnt == c) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){

    int a, b, k; cin >> a >> b >> k;
    int num = 0;
    for(int i = max(a, b) ;; i--){
        if(a % i == 0 && b % i == 0){
            num++;
        }

        if(num == k){
            cout << i << endl;
            break;
        }
    }
    return 0;
}
//  [cpp]
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main (void)
{
  int i,a,b,k,d,gcd,c=0;
  cin>>a>>b>>k;
  while(1)
  {
    d=a%b;
    if(d==0){gcd=b;break;}
    a=b;
    b=d;
  }
  for(i=1;i<gcd;i++)
  {
    if(gcd%i==0)c++;
    if(c==k){break;}
  }
  cout<<i<<endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

#define printl(s) cout << s << endl;
#define print(s) cout << s << endl; return 0;
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n)+1; ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
int A,B,C,K,N, cnt;

int main(){
  cin >> A >> B >> K;
  int len;
  rep2(i,min(A,B)){
    if(A%i==0 && B%i==0){
      len++;
      if(len==K){
        print(i);
      }
    }
  }
  print(cnt);
}
//  [cpp]
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll x,y,k,val,val1;
    cin>>x>>y>>k;
    vector<ll>a;
    for(int i=1;i<=min(x,y);i++)
    {
        if(x%i==0 && y%i==0)
        {
            a.pb(i);
        }
    }
    sort(a.begin(),a.end());
    val=lower_bound(a.begin(),a.end(),k)-a.begin();
    cout<<a[val]<<endl;
}
//  [c]
#include <stdio.h>
 
int main(){
	int A,B,K;
  	int i,number,sum=0;
  	int wari[150]={0};
 
  
  if(scanf("%d %d %d", &A,&B,&K) < 3) {
    fprintf(stderr, "error: ill-formed fraction.\n");
}
  
  for(i=1;i<=110;i++){
  	if(A%i == 0 && B%i ==0) wari[i]=1;
    else;
   // printf("wari[%d]%d ",i,wari[i]);
  }
  
  
  for(i=110;i>0;i--){
  	sum+=wari[i];
    if(sum==K) break;
    else;
  }
  
  printf("%d",i);
  
  return 0;
}
//  [c]
#include <stdio.h>

int main(){
    int A,B,K ;
    int i,cnt,small;
    int a[101]={};
    int ans=0;
    cnt=0;
    
    scanf("%d %d %d",&A,&B,&K);
    if(A>B) small=B;
    else small=A;
    for(i=1;i<=small;i++){
        if(A%i==0 && B%i==0){
            cnt++;
            a[cnt]=i;
            // if(cnt==K) ans = i;
        }
    }
    //printf("%d\n",cnt);
    //for(i=0;i<=small;i++){
    //    printf("%d\n",a[i]);
    //}
    printf("%d\n",a[cnt-K+1]);

}
//  [c]
#include<stdio.h>
int main()
{
  int a,b,k,a_,amari,kouyaku,answer;
  scanf("%d %d %d",&a,&b,&k);
  if (a>b)  //bよりaを小さくする a<b
  {
    a_=a;
    a=b;
    b=a_;
  }
  while(1)
  {
    amari=b%a;
    if (amari==0)
    {
      kouyaku=a;
      break;
    }
    b=amari;
    a_=a;
    a=b;
    b=a_;
  }
  for( answer=kouyaku; answer>=1; answer-- )
  {
    if( kouyaku%answer == 0 ) k--;
    if (k==0) break;
  }
  printf("%d",answer);
  return 0;
}
//  [c]
#include<stdio.h>

int main()
{
    int A,B,K,i,x;
    int div[10];
    int n=0;
    scanf("%d %d %d", &A, &B, &K);
    if(A<B)
        x = A;
    else
        x=B;
    
    n=0;
    for(i=1; i<=x; i++)
    {
        if(A%i==0 && B%i==0)
        {
            div[n]=i;
            n++;
        }


    }

    printf("%d", div[K-1]);

    return 0;

}
//  [c]
#include<stdio.h>
int main()
{
    int a,b,c,i,sum=0;

    scanf("%d %d %d",&a,&b,&c);

    for(i=1;i>0;i++)
    {
        if(a%i==0 && b%i==0) sum++;

            if(sum==c) break;
            else continue;
    }

    printf("%d",i);

    return 0;
}
//  [c]
#include<stdio.h>

int main()
{
    int A,B,K,i,temp;
    int div[10];
    int n=0;
    scanf("%d %d %d", &A, &B, &K);

    if(B>A)
    {
        temp = A;
        A = B;
        B = temp;
    }
    n=0;
    for(i=1; i<=B; i++)
    {
        if(A%i==0 && B%i==0)
        {
            div[n]=i;
            n++;
        }


    }

    printf("%d", div[K-1]);

    return 0;

}
//  [javascript]
function Main(input) {

    input = input.split(" ");

    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    var k = parseInt(input[2], 10);

    var count = 0;
    var value = 0;

    for (var i = 100; i > -1; i--) {

        if ((a % i == 0) && (b % i == 0)) {
            count++;
        }

        if (count == k) {
            value = i;
            break;
        }

    }




    console.log(value);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
    input = input.split("\n");
    tmp = input[0].split(" ");
    const a = parseInt(tmp[0], 10);
    const b = parseInt(tmp[1], 10);
    const c = parseInt(tmp[2], 10);
    
    //console.log(a,b,c);
    function divisor(num){
    var results = [];
   for(var i=1; i<=num; i++) {
        if( (num%i == 0) ) {
            results.push(i);
        }
    }
    return results;

    }
// テスト
p = divisor(a);
//console.log(p);
  q = divisor(b);
//console.log(q);
p1=p.length;q1=q.length;
//console.log(p1,q1);
var cnt =0;

ppp = [];qqq=[];
  if (p1 >= q1){
     for(i = 0;i<q1;i++){
      for (l=i;l<p1;l++){ if(q[i]==p[l]){ppp[cnt] = p[l];
                                     cnt =cnt +1;
                                   //  console.log(ppp);
                                     break; }
                                       
                        }
                       }
                   }
  else   
    { for(i = 0;i<p1;i++){
      for (l=i;l<q1;l++){ if(p[i]==q[l]){ppp[cnt] = q[l];
                                     cnt =cnt +1;
                                  //   console.log(ppp);
                                     break; }
                         }
                         } 
                        }
                
    t =ppp.length; 
//  console.log(t-c);
    var t=t-c;
    console.log(ppp[t]);     
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict';

function Main(input) {
  const A = Number(input.split(" ")[0])
  const B = Number(input.split(" ")[1])
  const K = Number(input.split(" ")[2])
  let counter = 0

  for (let i = Math.max(A, B); i > 0; i--) {
      if (A % i === 0 && B % i === 0) {
          counter++
      }
      if (counter === K) {
          console.log(i)
          return
      }
  }
  
};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function main(input) {
  const args = input.split(' ').map(n => parseInt(n, 10));
  const A = args[0],
        B = args[1],
        K = args[2];
  let cnt = 0;
  
  for (let i = 1; i <= 100; i++) {
    if (A % i === 0 && B % i === 0) {
      cnt++;
      if (cnt === K) {
        console.log(i);
        break;
      }
    }
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
// Atcoder120 - B
function divisor(n) {var ret=[]; for (var i=1;i*i<=n;i++){if(n%i==0){ret.push(i);if(i*i!=n)ret.push(n/i);}}return ret;}
function main(input) {
  var inputs = input.split('\n');
  var abks = inputs[0].split(' ');
  var a = abks[0];
  var b = abks[1];
  var k = abks[2];

  var aDivisors = divisor(a);
  var bDivisors = divisor(b);

  var counter = 0;
  var kthCd = 0;
  aDivisors.sort((i, j) => i - j).some((item) => {
    counter += bDivisors.indexOf(item) >= 0 ? 1 : 0;
    if (counter == k) {
      kthCd = item;
      return true;
    }
  });

  console.log(kthCd);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
// Atcoder120 - B
function divisor(n) {var ret=[]; for (var i=1;i*i<=n;i++){if(n%i==0){ret.push(i);if(i*i!=n)ret.push(n/i);}}return ret;}
function main(input) {
  var inputs = input.split('\n');
  var abks = inputs[0].split(' ');
  var a = abks[0];
  var b = abks[1];
  var k = abks[2];

  var aDivisors = divisor(a);
  var bDivisors = divisor(b);

  var counter = 0;
  var kthCd = 0;
  console.log(aDivisors.sort((i, j) => j - i));
  aDivisors.sort((i, j) => i - j).some((item) => {
    counter += bDivisors.indexOf(item) >= 0 ? 1 : 0;
    if (counter == k) {
      kthCd = item;
      return true;
    }
  });

  console.log(kthCd);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	fmt.Printf("%d\n", resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (int, int, int) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	a, b, k := scanInt(sc), scanInt(sc), scanInt(sc)
	return a, b, k
}

func resolve(a, b, k int) int {
	max := min(a, b)
	count := 0
	for i := max; i > 0; i-- {
		if a%i == 0 && b%i == 0 {
			count++
		}
		if count == k {
			return i
		}
	}
	// out of scope
	return -1
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main 

import (
  "fmt"
)

func main() {
  var a, b, k int
  fmt.Scan(&a, &b, &k)
  
  var large int

  if a >= b {
    large = a
  } else if a < b{
  	large = b
  }

  ans := 0
  count := 0

  for i := large; i > 0; i-- {
//    fmt.Println("i:",i)
    if a%i == 0 && b%i == 0{
    	ans = i
    	count ++
    }

//    fmt.Println("ans:",ans)
//    fmt.Println("count:",count)
    
    if count == k {
    	break
    }
    
  }
  
  fmt.Println(ans)
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main (){
	var a,b,k int
	fmt.Scan(&a, &b, &k)
	as := enumDivisions(a)
	bs := enumDivisions(b)
	cnt := 0
	for i := len(as)-1; i  > 0; i-- {
		for j := len(bs)-1; j > 0;j-- {
			if bs[j] == as[i] {
				cnt++
			}
			if cnt == k {
				fmt.Println(bs[j])
				return
			}

		}
	}

}

// 約数列挙
func enumDivisions(n int) []int {
	var res []int
	for i := 1; i * i <= n; i++ {
		if n % i == 0 {
			res = append(res, i)

			// 重複しないならばiの相方である n/i もappend
			if n/i != i {
				res = append(res, n/i)
			}
		}
	}
	// 小さい順に並び替える
	sort.Ints(res)
	return res
}
//  [go]
package main

import (
	"fmt"
	"math"
	"sort"
)

func divs(n, m int) (div []int) {
	min := int(math.Min(float64(n), float64(m)))
	if min == 1 {
		div = []int{1}
		return div
	}
	for i := 1; i < min; i++ {
		if n%i == 0 && m%1 == 0 {
			div = append(div, i)
		}
	}
	return div
}

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	divs := divs(a, b)
	sort.Sort(sort.Reverse(sort.IntSlice(divs)))

	fmt.Println(divs[k-1])
}
//  [ruby]
inputs = STDIN.gets.chomp.split(' ').map(&:to_i)

# inputs => [A, B, K]

def factor(num)
  f = []
  i = 1
  while i <= num do
    if num % i == 0
      f << i
    end
    i += 1
  end
  f
end

div_a = factor inputs[0]
div_b = factor inputs[1]
div_common = div_a & div_b
div_common.reverse

puts div_common.reverse[inputs[2]-1]
//  [ruby]
input = gets
ary = input.split(" ")
ans=Array.new
ary[0].to_i.times{|n|
if (ary[0].to_i % (n+1) == 0 )and(ary[1].to_i % (n+1) == 0 )then
 ans.push(n+1)
end
}
print ans[ans.length-ary[2].to_i]
//  [ruby]
A, B, K = gets.split.map(&:to_i)

g = A.gcd(B)
puts g.downto(1).select{|x| g % x == 0}[K - 1]
//  [ruby]
line = gets.split(' ').map(&:to_i)

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

num = 1
for i in 1..99 do
  if A % (100-i) == 0 and B % (100-i) == 0 then
    if num == K then
      puts 100 - i
      break
    else
      num += 1
    end
  end
end
//  [ruby]
line = gets.split(' ').map(&:to_i)

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

num = 1
for i in 1..100 do
  if A % (100-i) == 0 and B % (100-i) == 0 then
    if num == K then
      puts 100 - i
      break
    else
      num += 1
    end
  end
end
//  [ruby]
line = gets.split(' ').map(&:to_i)

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

num = 1
for i in 1..100 do
  if A % i == 0 and B % i == 0 then
    if num == K then
      puts i
      break
    else
      num += 1
    end
  end
end
//  [rust]
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let k: usize = read();
    let mut arr = Vec::new();
    for i in 1..min(a, b) + 1 {
        if a % i == 0 && b % i == 0 {
            arr.push(i);
        }
    }
    arr.reverse();
    println!("{}", arr[k - 1]);
}
//  [rust]
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input! {
        a: usize,
        b: usize,
        k: usize
    }

    println!(
        "{}",
        (1..101)
            .filter(|&x| a % x == 0 && b % x == 0)
            .rev()
            .nth(k - 1)
            .unwrap()
    );
}
//  [rust]
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let k = v[2];
	let mut cnt = 0;
	for i in (1..(a+1)).rev() {
		if a%i == 0 && b%i == 0 {
			cnt += 1;
		}
		if cnt == k {
			println!("{}", i);
			break;
		}
	}
}
//  [rust]
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let (a,b,k):(i64,i64,i64)=(read(),read(),read());
    let mut index:i64 =0;
    for i in 1..101{
        if a%i==0 {
            index+=1;
        }
        if index==k{
            println!("{}",i);
            return;
        }
    }
}
//  [rust]
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}


fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
      a
    } else {
      gcd(b, a % b)
    }
}  

fn divisors(n: u64) -> Vec<u64> {
    let mut divisors: Vec<u64> = Vec::new();
    for i in 1..(n+1) {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            divisors.push(i);
            if i * i != n {
                divisors.push(n / i);
            }
        }
    }
    divisors
}

fn main() {
    let (a, b, k) = input_tuple();
    let mut divisors = divisors(gcd(a, b));
    divisors.sort();
    println!("{:?}", divisors[(k-1) as usize]);
}
//  [swift]
import Foundation

extension String {
    func split(separator: String) -> [Int] {
        return self.componentsSeparatedByString(separator).map { Int($0)! }
    }
}

let input = readLine()!.split(" ")
let A = input[0]
let B = input[1]
let K = input[2]

var divisor = [1]
for i in 2...100 {
    if (A % i == 0) && (B % i == 0) {
        divisor.append(i)
    }
}

print(divisor[divisor.count-K])
//  [swift]
import Foundation

extension String {
    func split(separator: String) -> [Int] {
        return self.componentsSeparatedByString(separator).map { Int($0)! }
    }
}

let input = readLine()!.split(" ")
let A = input[0]
let B = input[1]
let K = input[2]

var divisor = [1]
for i in 2...100 {
    if (A % i == 0) && (B % i == 0) {
        divisor.append(i)
    }
}

print(divisor[divisor.count - (K-1)])
//  [swift]
import Foundation

extension String {
    func split(separator: String) -> [Int] {
        return self.componentsSeparatedByString(separator).map { Int($0)! }
    }
}

let input = readLine()!.split(" ")
let A = input[0]
let B = input[1]
let K = input[2]

var divisor = [1]
for i in 2...100 {
    if (A % i == 0) && (B % i == 0) {
        divisor.append(i)
    }
    if divisor.count > K {
        break
    }
}

print(divisor[divisor.count - (K-1)])
//  [swift]
import Foundation

extension String {
    func split(separator: String) -> [Int] {
        return self.componentsSeparatedByString(separator).map { Int($0)! }
    }
}

let input = readLine()!.split(" ")
let A = input[0]
let B = input[1]
let K = input[2]

var divisor: [Int] = []
for i in 1...100 {
    if (A % i == 0) && (B % i == 0) {
        divisor.append(i)
    }
    if divisor.count > K {
        break
    }
}

print(divisor[K-1])
//  [typescript]
const main = (input: string) => {
  const [A, B, K] = input.split(" ").map(str => parseInt(str))
  let divisorList = [];

  for (let i = 1; i <= A; i++) {
    if(A % i === 0 && B % i === 0) {
      divisorList.push(i)
    }
  }

  const answer = divisorList.reverse();
  console.log(answer[K - 1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
 
const inputlist = input.split(' ');
 
const a = Number(inputlist[0]);
 
const b = Number(inputlist[1]);
 
const k = Number(inputlist[2]);
 
const arr = [];

let e = 0;

if (a>b) {
  e = b;
} else {
  e = a;
}
 
for (let i=1;i<=e;i++) {
  if (a % i === 0 && b % i === 0) {
    arr.push(i);
  }
}

const f = arr.length - k;
 
console.log(arr[f]);
//  [typescript]
function main(input) {
  input = input.trim();
  const [a, b, k] = input.split(' ').map(n => Number(n));
  const array = [];
  for (let i = 1; i <= 100; i++) {
    if (a%i === 0 && b%i === 0) array.push(i);
  }
  const result = array[array.length-k]
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function main(input) {
  const args = input.split(' ');
  let A = Number(args[0]);
  let B = Number(args[1]);
  let K = Number(args[2]);
  let cu = 0;
  let sum;
  let count = 0;
  for (cu = A; cu > 0; --cu) {
    if (Number.isInteger(A / cu) && Number.isInteger(B / cu)) {
      count++;
      if (count === K) {
        sum = cu;
        break;
      }
    }
  }
  console.log(sum);
}
//  [typescript]
function main(input) {
  const args = input.split(' ');
  let A = Number(args[0]);
  let B = Number(args[1]);
  let K = Number(args[2]);
  let Arr = A < B ? [A, B] : [B, A];
  let result = Array.from(Array(Arr[0]), (v, i) => i + 1).reduce((sum, cu) => {
    if (
      Number.isInteger(Arr[1] / cu)
    ) {
      sum.push(cu);
      return sum;
    }
    return sum;
  }, []);
  const res = result.splice(result.length - K, 1)[0];
  console.log(res);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function main(input) {
  const args = input.split(' ');
  let A = Number(args[0]);
  let B = Number(args[1]);
  let K = Number(args[2]);
  let [min, max] = A < B ? [A, B] : [B, A];
  let result = Array.from(Array(min), (v, i) => i + 1).reduce((sum, cu) => {
    if (Number.isInteger(min / cu) && Number.isInteger(max / cu)) {
      sum.push(cu);
      return sum;
    }
    return sum;
  }, []);
  const res = result.splice(result.length - K, 1)[0];
  console.log(res);
}
//  [python]
A,B=map(int,input().split())
if A==2 or B==2:
	print("No")
elif A==4 or A==6 or A==9 or A==11:
	if B==4 or B==6 or B==9 or B==11:
		print("Yes")
	else:
		print("No")
else:
	if B==4 or B==6 or B==9 or B==11:
		print("No")
	else:
		print("Yes")
//  [python]
n,m=map(int,input().split())

a=[4,6,9,11]
b=[1,3,5,7,8,10,12]

if (n in a and m in a) or (n in b and m in b):print('Yes')
  
else:print('No')
//  [python]
a={1,3,5,7,8,10,12}
b={4,6,9,11}
c={2}
xy=set(map(int,input().split()))
if xy.issubset(a) or xy.issubset(b) or xy.issubset(c):
  print("Yes")
else:
  print("No")
//  [python]
x, y = map(int,input().split())
S1 = [1, 3, 5, 7, 8, 10, 12]
S2 = [4, 6, 9, 11]
for i in range(len(S1)):
  for j in range(len(S1)):
    if (S1[i] == x and s1[j] == y) or (S2[i] == x adn S2[j] == y):
      print("Yes")
    else:
      print("No")
//  [python]
H, W = [int(x) for x in input().split()]
pic = [list(input()) for _ in range(H)]
ans = [['#' for i in range(W+2)] for j in range(H+2)]
for i in range(W):
  for j in range(H):
    ans[j+1][i+1] = pic[j][i]
for i in range(H+2):
  print(*ans[i])
//  [python]
x,y=map(int,input().split())
group_A=[1,3,5,7,8,10,12]
group_B=[4,6,9,11]
if x in group_A ==True and y in group_A ==True:
  print("Yes")
elif x in group_B == True and y in group_B ==True:
  print("Yes")
else:
  print("No")
//  [java]
//package com.zhangyong.algorithm;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        private FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        private FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

    }

    private void solve() {
        //0 31 29 31 30 31 30 31 31 30 31 30 31
        int[] arr = new int[]{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int x, y;
        x = in.nextInt();
        y = in.nextInt();
        if (arr[x] == arr[y]) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

    private void run() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public static void main(String[] args) {
        new Main().run();
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");

		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);

		if ((a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12)
				&& (b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12)) {
			System.out.println("Yes");
		} else if ((a == 4 || a == 6 || a == 9 || a == 11) && (b == 4 || b == 6 || b == 9 || b == 11)) {
			System.out.println("Yes");
		} else if ((a == 2) && (b == 2)) {
			System.out.println("Yes");
		} else
			System.out.println("No");
		{

		}
	}
}
//  [java]
import java.io.*;
import java.util.*;

public class Main{
    public void run(){
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] arg = br.readLine().split(" ");
            List<Integer> list = Arrays.asList(1,3,5,7,8,10,12);
            List<Integer> list2 = Arrays.asList(4,6,9,11);
            List<Integer> list3 = Arrays.asList(2);
            if(list.contains(Integer.parseInt(arg[0])) && list.contains(Integer.parseInt(arg[1]))){
                System.out.println("Yes");
                return;
            }
            if(list2.contains(Integer.parseInt(arg[0])) && list2.contains(Integer.parseInt(arg[1]))){
                System.out.println("Yes");
                return;
            }
            if(list3.contains(Integer.parseInt(arg[0])) && list3.contains(Integer.parseInt(arg[1]))){
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
        }catch(Exception e){

        }
    }
    public static void main(String... args){
        new Main().run();
    }}
//  [java]

import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args)  throws IOException,NumberFormatException{
		try {
		FastScanner sc=new FastScanner();
		int x=sc.nextInt(),y=sc.nextInt();
		String a="1 3 5 7 8 10 12";
		String b="4 6 9 11";
		String c="2";
		boolean ans=false;
		if(a.contains(String.valueOf(x))&&a.contains(String.valueOf(y)))ans=true;
		if(b.contains(String.valueOf(x))&&b.contains(String.valueOf(y)))ans=true;
		if(c.contains(String.valueOf(x))&&c.contains(String.valueOf(y)))ans=true;
		
		System.out.println(ans?"Yes":"No");
		
		}
		catch(Exception e) {
			return ;
		}
		
	}
	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;
		for(int i=0;i<n;i++) {
			int oi=random.nextInt(n),temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try { 
                                      st=new StringTokenizer(br.readLine());				               
                              } catch (IOException e) {}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for(int i=0; i<n ; i++) a[i]=nextLong();
			return a;
		}
		
		String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
	}

}
//  [java]
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args)  throws IOException,NumberFormatException{
		try {
		FastScanner sc=new FastScanner();
		int x=sc.nextInt(),y=sc.nextInt();
		String a="135781012";
		String b="46911";
		String c="2";
		boolean ans=false;
		if(a.contains(String.valueOf(x))&&a.contains(String.valueOf(y)))ans=true;
		if(b.contains(String.valueOf(x))&&b.contains(String.valueOf(y)))ans=true;
		System.out.println(ans?"Yes":"No");
		
		}
		catch(Exception e) {
			return ;
		}
		
	}
	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;
		for(int i=0;i<n;i++) {
			int oi=random.nextInt(n),temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try { 
                                      st=new StringTokenizer(br.readLine());				               
                              } catch (IOException e) {}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for(int i=0; i<n ; i++) a[i]=nextLong();
			return a;
		}
		
		String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
	}

}
//  [java]

import java.util.*;
import java.io.*;

public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	        int n=sc.nextInt();
	       long a[]=new long[3*n];
	        for(int i=0;i<3*n;i++) {
	          a[i]=sc.nextLong();  
	        }
	        long ans=Long.MIN_VALUE;
	        PriorityQueue<Long> pq=new PriorityQueue<>();
	        ArrayList<Long> sum=new ArrayList<>();
	        ArrayList<Long> sum2=new ArrayList<>();
	        long summ=0;
	        for(int i=0;i<n;i++) {
	          pq.add(a[i]);
	          summ+=a[i];
	          
	        }
	       sum.add(summ);
	        for(int i=n;i<2*n;i++) {
	          pq.add(a[i]);
	          summ+=a[i];
	           summ-= pq.poll();
	        
	          
	            sum.add(summ);
	          
	        }
	        PriorityQueue<Long> pq1=new PriorityQueue<>(Collections.reverseOrder());
	        long summ1=0;
         for(int i=3*n-1;i>=2*n;i--) {
           pq1.add(a[i]);
           summ1+=a[i];
           
         }
         sum2.add(summ1);
         for(int i=2*n-1;i>=n;i--) {
           pq1.add(a[i]);
           summ1+=a[i];
            summ1-= pq1.poll();
            
             
             sum2.add(summ1);
           
         }
         
         for(int i=1;i<=n;i++) {
           ans=Math.max(sum.get(i)-sum2.get(n-i),ans);
         }

	        System.out.println(ans);
	}
	static long solve(PriorityQueue<Long> pq) {
	  
	  long sum=0;
	    
	       while(!pq.isEmpty()) {
	         sum+=pq.poll();
	       
	       }
	       return sum;
	}
 static long solve1(long a[],int i,int j,int n) {
   
   PriorityQueue<Long> pq=new PriorityQueue<>();
   for(int k=i;k<j;k++) {
   
     pq.add(a[k]);
   }
   
   long sum=0;
  while(n!=0) {
    sum+=pq.poll();
    n--;
  }
  return sum;
}
	
	static int  prime[]=new int[100001];
	static void sieve() {
	  Arrays.fill(prime,1);
	  prime[0]=0;
	  prime[1]=1;
	  for(int i=2;i*i<100001;i++) {
	   if(prime[i]!=0) {
	     for(int j=i;j<10001;j+=i) {
	       prime[j]=0;
	     }
	   }
	  }
	}
	      static long gcd(long a, long b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 

static long nCr(int n,int r) {
  int dp[][]=new int[2001][2001];
  for(int i=0;i<2001;i++) {
    dp[0][i]=0;
  }
  for(int i=0;i<2001;i++) {
    dp[i][0]=1;
  }
  for(int i=1;i<2001;i++) {
    for(int j=1;j<2001;j++) {
      if(i==j) {
        dp[i][j]=1;
      }else {
        dp[i][j]=dp[i-1][j-1]+dp[i][j-1];
      }
    }
  }
  return dp[n][r];
}


      
}
class pair {
  int src;
 int  des;
 long val;
  pair(int src,int des,long val){
    this.src=src;
    this.des=des;
    this.val=val;
    
  }

//  @Override
//  public int compareTo(pair o) {
//   
//    return this.wt-o.wt;
//  }
}
//  [cpp]
#include <stdio.h>
#include <algorithm>
int main() {
	int x, y;
	scanf("%d %d", &x, &y);
	int gx, gy;
	switch (x)
	{
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		gx = 0;
		break;
	case 4:
	case 6:
	case 9:
	case 11:
		gx = 1;
		break;
	case 2:
		gx = 2;
		break;
	default:
		gx = 3;
		break;
	}
	switch (y)
	{
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		gy = 0;
		break;
	case 4:
	case 6:
	case 9:
	case 11:
		gy = 1;
		break;
	case 2:
		gy = 2;
		break;
	default:
		gy = 3;
		break;
	}
	printf("%s\n", (gx == gy ? "Yes" : "No"));
}
//  [cpp]
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int flag[15];
int x,y;

int main()
{
	scanf("%d%d",&x,&y);
	flag[1] = flag[3] = flag[5] = flag[7] = flag[8] = flag[10] = flag[12] = 1;
    flag[4] = flag[6] = flag[9] = flag[11] = 2;
    if(flag[x] == flag[y]) printf("Yes\n");
    else printf("No\n");

	return 0;
}
//  [cpp]
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
	int x,y;
	int n[13]={0,1,2,1,3,1,3,1,1,3,1,3,1};
	scanf("%d%d",&x,&y);
	if(n[x]==n[y])	printf("Yes\n");
	else	printf("No\n");
	return 0;
}
//  [cpp]
#include <iostream>
using namespace std;
int main()
{
  int gp[3][7] = {
    {1,3,5,7,8,10,12},
    {4,6,9,11},
    {2},
  };
  int x, y;
  cin >> x >> y;
  int xg= 0, yg = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < sizeof(gp[i]/sizeof(int)); j++) {
      if (gp[i][j] == x) {
        xg = i;
      }
      if (gp[i][j] == y) {
        yg = i;
      }
    }
  }
  if (xg == yg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
//  [cpp]
#include <iostream>
using namespace std;
int main()
{
  int gp[3][] = {
    {1,3,5,7,8,10,12},
    {4,6,9,11},
    {2},
  };
  int x, y;
  cin >> x >> y;
  int xg= 0, yg = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < sizeof(gp[i]/sizeof(int)); j++) {
      if (gp[i][j] == x) {
        xg = i;
      }
      if (gp[i][j] == y) {
        yg = i;
      }
    }
  }
  if (xg == yg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main(){
	vector<int> x(2);
	cin >> x.at(0) >> x.at(1);
	for(int i=0; i<2; i++){
		if(x.at(i)==2) x.at(i)=2;
		if(x.at(i)==4 || x.at(i)==6 || x.at(i)==9 || x.at(i)==11) x.at(i)=1;
		else x.at(i)=0;
	}
	if(x.at(0)==x.at(1)) cout << "Yes" << endl;
	else cout << "No" << endl;
}
//  [c]
#include <stdio.h>
 
int main(){
    int g[12] = {1,3,1,2,1,2,1,1,2,1,2,1};
    int a, b;
    scanf("%d%d", &a, &b);
    printf(g[a-1] == g[b-1] ? "Yes\n" : "No");
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
  int i, j;
  int x, y;

  int nums[] = {-1, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

  scanf("%d %d", &x, &y);

  if (nums[x] == nums[y]) {
    printf("Yes");
  }
  else {
    printf("No");
  }

  return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
  int g1[7]={1,3,5,7,8,10,12};
  int g2[4]={4,6,9,11};
  int x,y;
  scanf("%d %d",&x,&y);

  if(x==y){
    puts("Yes");
    return 0;
  }

  int flag1=0;
  for(int i=0;i<7;i++){
    if(g1[i]==x){
      flag1=1;
    }
    if(flag1==1&&g1[i]==y){
      puts("Yes");
      return 0;
    }
  }

  int flag2=0;
  for(int i=0;i<4;i++){
    if(g2[i]==x){
      flag2=1;
    }
    if(flag2==1&&g2[i]==y){
      puts("Yes");
      return 0;
    }
  }

  puts("No");

  return 0;
}
//  [c]
#include<stdio.h>
int main()
{

int x, y;
scanf("%d %d", &x, &y);

    if(x==2||y==2){
        printf("No\n");
    }
    else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))
    {
        printf("Yes\n");
    }
    else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))
    {
        printf("YES");
    }
    else{
        printf("NO");
    }

return 0;

}
//  [c]
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,z;
    cin>>x>>y;
    if(x==2 || y==2)
        cout<<"No"<<endl;
    else if(x==4 || x==6 || x==9 || x==12)
        if(y==4 || y==6 || y==9 || y==12)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    else if(x== 3 || x==1 || x==5 || x==7 || x==8 || x==10 || x==12)
        if(y==3 || y==1 || y==5 || y==7 || y==8 || y==10 || y==12)
            cout<<"yes"<<endl;
        else
            cout<<"No"<<endl;
    else
        cout<<"No"<<endl;
    return 0;

}
//  [c]
int main()
{
    int x,y,z;
    cin>>x>>y;
    if(x==2 || y==2)
        cout<<"No"<<endl;
    else if(x==4 || x==6 || x==9 || x==12)
        if(y==4 || y==6 || y==9 || y==12)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    else if(x== 3 || x==1 || x==5 || x==7 || x==8 || x==10 || x==12)
        if(y==3 || y==1 || y==5 || y==7 || y==8 || y==10 || y==12)
            cout<<"yes"<<endl;
        else
            cout<<"No"<<endl;
    else
        cout<<"No"<<endl;
    return 0;

}
//  [javascript]
function Main(input){
  input = input.split(' ');
  var x = Number(input[0]);
  var y = Number(input[1]);

  var group_a = [1,3,5,7,8,10,12];
  var group_b = [4,6,9,11];
  var group_c = [2];

  if( group_a.indexOf(x) > -1 && group_a.indexOf(y) > -1 || 
  group_b.indexOf(x) > -1 && group_b.indexOf(y) > -1 ||
  group_c.indexOf(x) > -1 && group_c.indexOf(y) > -1) {
      console.log('Yes');
  } else {
      console.log('No');
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict"

function main(input) {

  input = input.split(' ').map(v => ~~v)
  const x = input[0]
  const y = input[1]
  const a = [1, 3, 5, 7, 8, 10, 12]
  const b = [4, 6, 9, 11]
  // const c = [2]

  // console.log(a.indexOf(x), a.indexOf(y), b.indexOf(x), b.indexOf(y))
  if ((a.indexOf(x) >= 0 && a.indexOf(y) >= 0) ||
    (b.indexOf(x) >= 0 && b.indexOf(y) >= 0)) {
    console.log('Yes')
    return
  }
  console.log('No')
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const x = parseInt(args[0][0], 10)
	const y = parseInt(args[0][1], 10)
	const group1 = [1, 3, 5, 7, 8, 10, 12]
	const group2 = [4, 6, 9, 11]

	let f1 = false 
	let f2 = false

	for (let i = 0; i < group1.length; i++) {
		if (x === group1[i]) f1 = true 
		if (y === group1[i]) f2 = true
	}

	let f3 = false 
	let f4 = false

	for (let i = 0; i < group2.length; i++) {
		if (x === group2[i]) f3 = true 
		if (y === group2[i]) f4 = true
	}

	if (f1 && f2) console.log('Yes')
	else if (f3 && f4) console.log('Yes')
	else console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function Main(input) {
  input = input.trim()
  input = input.split(" ");
  if(hoge(input[1])==hoge(input[0])){
  console.log("Yes")
  }else{
  console.log("No")
  }
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));
function hoge(n){
if(n==1||n==3|n==5||n==7||n==8||n==12) return 1;
  else if(n==2) return 3;
  else return 2;
}
//  [javascript]
function main(input) {
  input=input.trim();
  const x = parseInt(input.split(" ")[0], 10);
  const y = parseInt(input.split(" ")[1], 10);
  var wake=function(n){
    if(n==1||n==3||n==5||n==7||n==8||n==10||n==12){
      return a
    }else if(n==4||n==6||n==9||n==11){
      return b
    }else{
      return c
    }
  }
  if(wake(x)==wake(y)){
    console.log("Yes");
  }else{
    console.log("No");
  }
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  const numbers = input.split(' ').map(n => Number(n));
  const x = numbers[0];
  const y = numbers[1];
  const array1 = [1,3, 5, 7, 8, 10, 12];
  const array2 = [4, 6, 9, 11];
  const array3 = [2]

  if((array1.includes(x) && array1.includes(y))
   || (array2.includes(x) && array2.includes(y))
   || (array3.includes(x) && array3.includes(y))) {
     console.log('Yes');
  } else {
    console.log('No');
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import "fmt"

func main() {
	group := make([]int, 12+1)
	for _, b := range []int{4, 6, 9, 11} {
		group[b] = 1
	}
	for _, c := range []int{2} {
		group[c] = 2
	}
	
	var x, y int
	fmt.Scanf("%d %d", &x, &y)
	if group[x] == group[y] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	s := []int{0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0}
	var x, y int
	fmt.Scan(&x, &y)
	if s[x-1] == s[y-1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}