Calculate how many ways you can give $7$ children $7$ identical candies My try:

Calculate how many ways you can give $7$ children $7$ identical candies if each child got at most 2 candies.

$$x_1+x_2+x_3+x_4+x_5+x_6+x_7=7 \text{    for   } x_i \in \left\{ 0,1,2\right\}$$
$$[t^7](1+t+t^2)^7[t^7](\frac{1-t^3}{1-t})^7=[t^7](1-t^3)^7 \sum {n+6 \choose 6}t^n$$
$$\begin{array}{|c|c|c|c||c|c|}
\hline
\text{first parenthesis} & \text{ways in the first} & \text{ways in the second }\\ \hline
\text{1} & 1 & { 13 \choose 6} \\ \hline
{t^3} & { 1 \choose 1} & { 10 \choose 6} \\ \hline
{t^6}  &  { 7 \choose 2} & { 7 \choose 6}\\ \hline
\end{array}$$
Sollution:$${ 7 \choose 2}{ 7 \choose 6}+{ 7 \choose 1}{ 10 \choose 6}+{ 13 \choose 6}=3333$$
But I checked it in Mathematica and I get $393$. So can you check where the error is?

There is a much simpler method to solve this problem. Generally these sort of problems are classified as NP and can only be solved numerically. 
OK! Back to the question, you can give each child exactly one candy which is possible in 1 way.
You can give 2 candies to one of them in 7 ways and the rest at most 1 candy each, in $\binom{6}{5}$ ways, totally leading to 42 ways.
You can give 2 candies to two of them in $\binom{7}{2}$ ways and the rest at most 1 candy each, in $\binom{5}{3}$ ways, totally leading to 210 ways.
You can give 2 candies to three of them in $\binom{7}{3}$ ways and the rest at most 1 candy each, in $\binom{4}{1}$ ways, totally leading to 140 ways.
Adding up all the cases, leads to a total of 393 different ways.
