#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

template <typename T>
void Combination(const std::vector<T>& v, std::size_t count)
{
    assert(count <= v.size());
    std::vector<bool> bitset(v.size() - count, 0);
    bitset.resize(v.size(), 1);
 
    do {
        for (std::size_t i = 0; i != v.size(); ++i) {
            if (bitset[i]) {
                std::cout << v[i] << " ";
            }
        }
        std::cout << std::endl;
    } while (std::next_permutation(bitset.begin(), bitset.end()));
}

int main() {
	const std::vector<int> v = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
	
	Combination(v, 3);
}
