How to build generating function when there is restriction on number of occurrences Let me ask my question in this way:
Suppose we are going to represent number $20$ as sum of $1$s and $2$s and $3$s, the coefficient of $x^{20}$ in this generating function is the answer :

$(1+x+x^2+x^3+...)(1+x^2+x^4+...)(1+x^3+x^6+...)$

Now if we put this restriction that the number of occurrences of $1$s must be more than number of occurrences of $2$s in the sequence of numbers that build $20$ then what generating function is going to be the answer. actually this problem can be generalized to many other cases.

Summing the cases for the number of $1$s, we get
$$
\begin{align}
&\left(\vphantom{\frac12}\right.\overbrace{x\overbrace{\frac{1-x^2}{1-x^2}}^{1}}^{\text{one $1$ and $\lt$ one $2$}}+\overbrace{x^2\overbrace{\frac{1-x^4}{1-x^2}}^{1+x^2}}^{\text{two $1$s and $\lt$ two $2$s}}+\overbrace{x^3\overbrace{\frac{1-x^6}{1-x^2}}^{1+x^2+x^4}}^{\text{three $1$s and $\lt$ three $2$s}}+\dots\left.\vphantom{\frac12}\right)\overbrace{\overset{\vphantom{\overbrace{a^2}}}{\frac1{1-x^3}}}^{\text{any $3$s}}\\
&=\left(\frac{x}{1-x}-\frac{x^3}{1-x^3}\right)\frac1{(1-x^2)(1-x^3)}\\
&=\frac{x(1+x)}{(1-x^2)(1-x^3)^2}\\
&=\bbox[5px,border:2px solid #C00000]{\frac{x}{(1-x)(1-x^3)^2}}\tag{1}
\end{align}
$$
Now find the coefficient of $x^{20}$ in $(1)$.
We can compute the coefficients
$$
x\sum_{j=0}^\infty x^j\sum_{k=0}^\infty(k+1)x^{3k}
=\sum_{n=1}^\infty\frac12\left\lfloor\frac{n+2}3\right\rfloor\left\lfloor\frac{n+5}3\right\rfloor x^n\tag{2}
$$
since all $k\le\frac{n-1}3$ contributes $k+1$. That is,
$$
\begin{align}
\sum_{k=0}^{\left\lfloor\frac{n-1}3\right\rfloor}(k+1)
&=\frac12\left(\left\lfloor\frac{n-1}3\right\rfloor+1\right)\left(\left\lfloor\frac{n-1}3\right\rfloor+2\right)\\
&=\frac12\left\lfloor\frac{n+2}3\right\rfloor\left\lfloor\frac{n+5}3\right\rfloor
\end{align}
$$
For $n=20$, this gives $28$.
