#include <iostream>
#include <vector>
using namespace std;
void combination(vector<int> vec, vector<int> comb, vector<vector<int>>& ret, int r, int index, int depth){
if (r==0){
ret.push_back(comb);
} else if (depth==vec.size()) return;
else {
comb[index]=vec[depth];
combination(vec, comb, ret, r-1, index+1, depth+1);
combination(vec, comb, ret, r, index, depth+1);
}
}
int main(void){
vector<int> vec={1, 2, 3, 4, 5};
int r=3;
vector<int> comb(r);
vector<vector<int>> ret;
combination(vec, comb, ret, r, 0, 0);
for(vector<int> tmp_vec: ret){
for(int tmp_int: tmp_vec) cout<<tmp_int<<" ";
cout<<endl;
}
return 0;
}