//sum it up, i just cant find an approach to get through all the test cases, someone please explain

#include
#include
#include
#include
using namespace std;
set s;
void fun(int *a, int *out, int i, int j, int n, int t)
{
if (i >= n)
{
int sum = 0;
string x = “”;
for (int k = 0; k < j; k++)
{
sum += out[k];
x += (char(out[k]) - ‘0’);

	}
	if (sum == t)
	{
		sort(x.begin(), x.end());
		// string y = x;
		s.insert(x);
	}
	return;
}
out[j] = a[i];
fun(a, out, i + 1, j + 1, n, t);
fun(a, out, i + 1, j, n, t);

}
int main()
{
s.clear();
int n;
int k = 0;
cin >> n;
int a[15];
for (int i = 0; i < n; i++)
cin >> a[i];
int t;
cin >> t;
int out[16];
fun(a, out, 0, 0, n, t);
for (auto it : s)
{
for (int k = 0; it[k] != ‘\0’; k++)
{
cout << it[k] + 48 << " ";
}
cout << endl;
}

}