#include #include #include #include //#include #include #include #include #include #include //#include #include #include #include //#include #include #include //#include #include #include #include const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; typedef complex C; const int MAXN = 32; int P[MAXN]; struct pll { ll first; ll second; }; bool operator<(const pll& lhs, const pll& rhs) { return lhs.first < rhs.first; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N, S; cin >> N >> S; for (int i = 0; i < N; i++) { cin >> P[i]; } int n = N/2; vector first, second; for (ll s = 0; s < (1<>i)&1) item.first += P[i]; } first.push_back(item); } for (ll s = 0; s < (1<<(N-n)); s++) { pll item; item.first = 0; item.second = (s<>i)&1) item.first += P[i+n]; } second.push_back(item); } sort(first.begin(), first.end()); sort(second.begin(), second.end()); vector ans; for (pll p : first) { pll q; q.first = S-p.first; q.second = p.second; auto it1 = lower_bound(second.begin(), second.end(), q); auto it2 = upper_bound(second.begin(), second.end(), q); for (auto it = it1; it < it2; it++) { ans.push_back(p.second|(it->second)); } } vector ANS; for (ll el : ans) { vi tmp; for (int i = 0; i < 32; i++) { if ((el>>i)&1) tmp.push_back(i+1); } sort(tmp.begin(), tmp.end()); ANS.push_back(tmp); } sort(ANS.begin(), ANS.end()); for (vi v : ANS) { int n = v.size(); for (int i = 0; i < n; i++) { cout << v[i]; if (i != n-1) cout << " "; } cout << endl; } return 0; }