Let $\mathcal B$ be a family of subsets of $\{1,2,\dots, N\}$. (Not necessarily all of them, just some collection.) Let also $n\leq N$. (Note: originally $n=N$.)
We define the polynomial
$$ g(x,y) = \sum_{J\subset B, \left|\bigcup_{A \in J} A \right|\leq n} x^{|J|}y^{\left|\bigcup_{A \in J} A \right|} $$
That is: we count all subsets of $B$ by their size and by the size of their union (and can ignore subsets whose union is larger than $n$).
For example if $\mathcal{B} = \{ \{1\}, \{2,4\}, \{1,2,3\}, \{2,4,5\} \}$ an example subset is $J = \{ \{1\}, \{2,4\}, \{2,4,5\} \}$ which gives the term $x^3y^4$ as $|J| = 3$ and the union is $\{1,2,4,5\}$ which has size $4$. The whole polynomial for this $\mathcal B$ is
$$ x^{4} y^{5} + 2 x^{3} y^{5} + 2 x^{3} y^{4} + x^{2} y^{5} + 2 x^{2} y^{4} + 3 x^{2} y^{3} + 2 x y^{3} + x y^{2} + x y + 1 $$
Is there a more efficient way of calculating $g$ for a given $B$, than just going through all the $2^{|B|}$ subsets. Can we use the poset structure of $\mathcal B$ somehow?
Background
I encountored this problem while thinking about inclusion-exclusion for solving this problem. So in that case we would have $N=100, n=10$ and $\mathcal B$ is all the subsets of at most size $n$ that sum to $N$. I think $|\mathcal B | = 435886$.
If we find $g(x,y)$, then I believe the solution to the link's question is given by turning $x^r$ into $(-1)^r$ and $y^u$ into $\binom{100-u}{10-u}$. So we would only need the value of $g$ after plugging in $x=-1$ and can that operation of $y^u$ be experessed somehow...
And I just realized: $\binom{N-u}{n-u} = 0$ if $n>10$, so we can add the restriction $u\leq n$.