#include #include #include #include using namespace std; int main(){ int n, s; cin >> n >> s; vector v(n); for(int i = 0; i < n; i++) cin >> v[i]; vector>> vp; int n1 = n/2; for(int i = 0; i < 1< tmp; int tmpval = 0; for(int j = 0; j < n1; j++){ if((i>>j)&1){ tmp.insert(j+1); tmpval += v[j]; } } vp.push_back({tmpval, tmp}); } sort(vp.begin(), vp.end()); vector> ans; for(int i = 0; i < 1<<(n-n1); i++){ set tmp; int tmpval = 0; for(int j = 0; j < n-n1; j++){ if((i>>j)&1){ tmp.insert(n1+j+1); tmpval += v[n1+j]; } } if(tmpval > s) continue; set emp; int l = lower_bound(vp.begin(), vp.end(), make_pair(s-tmpval, emp)) - vp.begin(); int r = lower_bound(vp.begin(), vp.end(), make_pair(s-tmpval+1, emp)) - vp.begin(); r--; while(l <= r){ set copy = vp[l].second; copy.insert(tmp.begin(), tmp.end()); ans.push_back(copy); l++; } } sort(ans.begin(), ans.end()); for(set t : ans){ for(auto it = t.begin(); it != t.end(); it++){ if(it != t.begin()) cout << " "; cout << *it; } cout << endl; } return 0; }