Reimplementation of combinations using a vector, it has less memory overhead