<s>[INST] Finding the number of 3-element subsets from the set {1,2,3,...,11,12,13} such that the sum of the 3 elements is divisible by 3 I found this problem from an old math questionnaire.
How many 3-element subsets of {1,2,3,...,11,12,13} are there for which the sum of the 3 elements is divisible by 3?
At first, I tried listing down all of them. But then, I realized they were too many and so, I just stopped. Next, I tried using stars and bars technique. I represented the 3 elements as a,b,c and their sum as a+b+c=m where m is the set of positive integers divisible by 3 from 3 to 39. From there, I tried out each equation with stars and bars from a+b+c=3 to a+b+c=15, and found a total of 185 subsets satisfying the given conditions. I stopped at here since I noticed that if I continued doing this from a+b+c=18 to a+b+c=39, I would have an error since I was not able to limit the values of a,b,c at most 13. 
I do not know how to proceed right now. Can anyone help? 
 [/INST] A more general approach is given by generating functions.
We may consider the bivariate polynomial
$$ q(x,y)=(1+yx)(1+yx^2)\cdot\ldots\cdot(1+yx^{12})(1+yx^{13}) $$
and the coefficient of $y^3$ in $q(x,y)$, that is
$$ [y^3]\,q(x,y) = r(x) = x^6+x^7+2 x^8+3 x^9+4 x^{10}+5 x^{11}+7 x^{12}+8 x^{13}+10 x^{14}+12 x^{15}+14 x^{16}+15 x^{17}+17 x^{18}+17 x^{19}+18 x^{20}+18 x^{21}+18 x^{22}+17 x^{23}+17 x^{24}+15 x^{25}+14 x^{26}+12 x^{27}+10 x^{28}+8 x^{29}+7 x^{30}+5 x^{31}+4 x^{32}+3 x^{33}+2 x^{34}+x^{35}+x^{36} $$
then sum the coefficients of the monomials of the form $x^{3k}$. If $\omega=\exp\left(\frac{2\pi i}{3}\right)$, that sum is just
$$ \frac{1}{3}\left( r(1)+r(\omega)+r(\omega^2) \right) $$
or the coefficient of $y^3$ in the polynomial $\frac{1}{3}\left(q(1,y)+q(\omega,y)+q(\omega^2, y)\right)$, where:
$$\frac{1}{3}\left(q(1,y)+q(\omega,y)+q(\omega^2, y)\right) = (1+y)^4\cdot\left(1+20 y^2+14 y^3+\ldots\right)$$
gives us the answer:
$$ 14+4\cdot 20+4 = \color{red}{98}. $$
Not by chance, this number is close to one third of the total number of $3$-subsets, given by $\binom{13}{3}=286$.
</s>