<s>[INST] How many students in the school? 
If they put the rows of 13, there are 8 students left; if they put the rows of 15, there are 3 students left and if they put the rows of 17, there are 9 students left. How many students are there given that the total students are < 5000?

The following congruences are: $$x\equiv 8 \pmod {13} \\ x\equiv 3 \pmod {15} \\ x\equiv 9 \pmod {17}$$
I'm still new to this, how can I apply Chinese Remainder Theorem to these congruences to find the total students?
 [/INST] Let $N$ be the number of students. Let $M = 13\times 15 \times 17 = 3315$
$\qquad\ M_1 = 15 \times 17 = \color{#c00}{255},\,\ \ y_1 = 255^{-1} \equiv \ \ 8^{-1}\equiv \ \ \color{#c00}{5}\ \pmod{13} $
$\qquad\ M_2 = 13 \times 17 = \color{#0a0}{221},\,\ \ y_2 = 221^{-1} \equiv 11^{-1} \equiv \color{#0a0}{11}\pmod{15} $
$\qquad\ M_3 = 13 \times 15 = \color{#90f}{195},\,\ \ y_3 = 195^{-1} \equiv\ \ 8^{-1}\equiv \color{#90f}{15} \pmod{17} $
Thus $\ N \equiv 8 \times \color{#c00}{255 \times 5}\, +\, 3 \times \color{#0a0}{221 \times 11}\, +\, 9 \times \color{#90f}{195 \times 15}\,\equiv\, 723\pmod{3315} $
So the number of students $\, N =  723 + 3315 \times k $
With $\,N < 5000,\ N = 4038\,$ with $\,k = 1$
You can read more here (Vietnamese wiki page on CRT)
</s>