// Trick: initialize a vector of k 1's, then resize to 'n' and fill with 0's
// use next_permutation (in reverse) to "bitmask" and enumerate all options
int enumerate_combinations(int n, int k, vector<int> &A) {
vector<int> b(k, 1);
b.resize(n, 0);
// very basic, store count
int cnt = 0;
do {
// pass over all n items, take/save/print the ones that match the "bitmask"
for (int i = 0; i < n; i++) {
if (b[i]) {
cout << A[i] << " ";
}
}
cnt++;
cout << endl;
} while (next_permutation(b.rbegin(), b.rend()));
return cnt;
}