<s>[INST] How to solve a system of linear equations modulo n? For example, 
$4x - 10y \equiv 8\pmod {20}$
$7x + 2y \equiv 5\pmod {20}$
It resembles linear diophantine equations and the Chinese Remainder Theorem, but I don't know how to actually solve it.. 
 [/INST] \begin{eqnarray}
   4x - 10y \equiv 8\pmod {20} \\
   7x + 2y \equiv 5\pmod {20}
\end{eqnarray}
Method 1 - Take advantage of a unit coefficient (7)
\begin{align}
   7x + 2y &\equiv 5\pmod {20} \\
   21x + 6y &\equiv 15\pmod {20} \\
   x + 6y &\equiv 15\pmod {20} \\
   x &\equiv 14y + 15 \pmod{20} \\
   \hline
   4(14y + 15) - 10y &\equiv 8\pmod {20} \\
   46y + 60 &\equiv 8 \pmod{20} \\
   6y &\equiv 8 \pmod{20} \\
   3y &\equiv 4 \pmod{10} \\
   21y &\equiv 28 \pmod{10} \\
   y &\equiv 8 \pmod{10} \\
   y &= 8 + 10 t \\
   \hline
   x &\equiv 14(8 + 10 t) + 15 \pmod{20} \\
   x &\equiv 112 + 140t + 15 \pmod{20} \\
   x &\equiv 7 \pmod{20} \\
   y &\equiv 8 \pmod{10} \\
\end{align}
Method 2 - Convert to prime-power moduli
\begin{eqnarray}
   2y &\equiv 0\pmod 4 \\
   3x + 2y &\equiv 1\pmod 4 \\
   \hline
   y &\equiv 0 \pmod 2 \\
   \hline
   3x &\equiv 1\pmod 4 \\
   9x &\equiv 3\pmod 4 \\
   x &\equiv 3 \pmod 4
\end{eqnarray}
\begin{eqnarray}
   4x &\equiv 3\pmod 5 \\
   2x + 2y &\equiv 0\pmod 5 \\
   \hline
   -4x &\equiv -3 \pmod 5 \\
   x &\equiv 2 \pmod 5 \\
   \hline
   4 + 2y &\equiv 0\pmod 5 \\
   2 + y &\equiv 0 \pmod 5 \\
   y &\equiv 3 \pmod 5
\end{eqnarray}
$\left\{
\begin{array}{c}
   x \equiv 3 \pmod 4 \\
   x \equiv 2 \pmod 5 \\
\end{array}
\right\}
\implies
\left\{
\begin{array}{c}
   5x \equiv 15 \pmod{20} \\
   -4x \equiv -8 \pmod{20} \\
\end{array}
\right\}
\implies
x \equiv 7 \pmod{20}$
$\left\{
\begin{array}{c}
   y \equiv 0 \pmod 2\\
   y \equiv 3 \pmod 5 \\
\end{array}
\right\}
\implies
\left\{
\begin{array}{c}
   -5y \equiv 0 \pmod{10} \\
   6y \equiv 18 \pmod{10} \\
\end{array}
\right\}
\implies
y \equiv 8 \pmod{10}$
</s>