#include #include #include #include #include #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) #define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) using ll = long long; using namespace std; int main() { int n; ll s; cin >> n >> s; vector p(n); repeat (i,n) cin >> p[i]; vector acc { 0 }; whole(partial_sum, p, back_inserter(acc)); vector > result; vector path; function go = [&](int i, ll q) { if (q == s) result.push_back(path); if (q >= s) return; if (q + acc[n] - acc[i] < s) return; if (i == n) return; go(i+1, q); path.push_back(i); go(i+1, q + p[i]); path.pop_back(); }; go(0, 0); whole(sort, result); for (auto path : result) { repeat (i,path.size()) cout << (i ? " " : "") << path[i]+1; cout << endl; } return 0; }