Problem: Count the number of subsequences of length k having equal LCM and HCF
Given an array Arr and an integer K . The task is to find the number of subsequences of size K such that the LCM and HCF of the sequence is same.

Sample Input: Arr = {1, 2, 2, 3, 3}, K = 2
Sample Output: 2
Subsequences are - {2, 2} and {3, 3}

Solution (cpp14):
// C++ implementation
#include <bits/stdc++.h>
using namespace std;

// Returns factorial of n
long long fact(int n)
{
    long long res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}

// Returns nCr for the
// given values of r and n
long long nCr(int n, int r)
{
    return fact(n) / (1LL * fact(r)
                      * fact(n - r));
}

long long number_of_subsequences(int arr[],
                                 int k,
                                 int n)
{

    long long s = 0;

    // Map to store the frequencies
    // of each elements
    map<int, int> m;

    // Loop to store the
    // frequencies of elements
    // in the map
    for (int i = 0; i < n; i++) {
        m[arr[i]]++;
    }

    for (auto j : m) {

        // Using nCR formula to
        // calculate the number
        // of subsequences of a
        // given length
        s = s + 1LL * nCr(j.second, k);
    }

    return s;
}

// Driver Code
int main()
{
    int arr[] = { 1, 1, 1, 1, 2, 2, 2 };
    int k = 2;
    int n = sizeof(arr) / sizeof(arr[0]);

    // Function calling
    cout << number_of_subsequences(arr, k, n);
    return 0;
}