~/algor $ cat problems/bit-qism-toplamlarni-sanash
Enumerating subsets
Easy
1000 ms
128 MB
33%
$n$ numbers $a_{0}, a_{1}, \ldots, a_{n-1}$ are given. Every number $0 \le m \lt 2^{n}$ defines one subset: if the $j$-th bit of $m$ is $1$, then $a_{j}$ belongs to the subset. Print every subset on a separate line in the order $m = 0, 1, 2, \ldots, 2^{n} - 1$: first the number of elements, then the elements themselves (in increasing order of $j$).
Input
The first line contains a positive integer $n$. The second line contains $n$ positive integers $a_{j}$.
Output
$2^{n}$ lines: each with the number of elements and the elements of the subset.
Note
$1 \le n \le 15$
$1 \le a_{j} \le 100$
Examples
Input #1
3 5 8 2
Output #1
0 1 5 1 8 2 5 8 1 2 2 5 2 2 8 2 3 5 8 2
Input #2
1 7
Output #2
0 1 7