TITLE: Cosets representatives of congruence subgroups
QUESTION [7 upvotes]: I came across Shimura (1971) notes about cosets representatives of the congruence subgroups $ \Gamma_0(N) $. He firstly proves that its index in the modular group $\Gamma$ is 
\begin{equation} [\Gamma : \Gamma_0(N)]=N \cdot \prod_{p|N} (1+p^{-1} ) \end{equation}
Then he comes up with a sets of cosets representatives for $\Gamma_0(N)$ in $\Gamma$ made in this way: we first choose pairs $(c,d)$ of positive integers such that
\begin{equation} (c,d)=1, \qquad d|N, \qquad 0 < c \le N/d \end{equation}
then for each pairs we fix integers $a,b$ such that $ad-bc=1$. Our list of cosets representatives is made of the matrices with such entries.
However, let us take for example $N=12$ when we know the index is 24 and thus this is the cardinality of the set of cosets representatives.
Using the rule above, I only find 22 cosets representatives, namely the ones corresponding to the following $(c,d)$ pairs: $$(1,1),(2,1),\dots,(12,1),(1,2),(3,2),(5,2),(1,3),(2,3),(4,3),(1,4),(3,4),(1,6),(1,12).$$
I also tried to run SAGE and it gives me 24 cosets representatives but they seem redundant, for example $[[1, 0] [2, 1]]$ and $[[1, 2][2, 5]]$ are listed as different cosets representatives, but 
$$\begin{pmatrix} 1 & 0 \\ 2 & 1 \end{pmatrix} \cdot \begin{pmatrix} 1 & 2 \\ 0 & 1 \end{pmatrix}=\begin{pmatrix} 1 & 2 \\ 2 & 5 \end{pmatrix}$$
and thus it seems to me that these 2 matrices belong in fact to the same coset.
Something is clearly wrong, I hope you can help me.

REPLY [2 votes]: (2022.03.27, edited after Tireless and hardworking's remark.)
The quotient $\Gamma_0(N) \backslash \mathrm{SL}_2(\mathbf{Z})$ (right cosets) is in bijection with the set of pairs $(c,d)$ where $c$ is a positive divisor of $N$ and $1 \leq d \leq \frac{N}{c}$ satisfies $\operatorname{gcd}(d,c,\frac{N}{c})=1$.
To get the image of a matrix $M = \begin{pmatrix} \alpha & \beta \\ \gamma & \delta \end{pmatrix} \in \mathrm{SL}_2(\mathbf{Z})$, first find $u \in (\mathbf{Z}/N\mathbf{Z})^\times$ such that $\gamma u \equiv \operatorname{gcd}(\gamma,N) \bmod{N}$. Then $M$ is mapped to $(c,d):=(\operatorname{gcd}(\gamma,N), \delta u \bmod{\frac{N}{c}})$. It is a good exercice to check that this gives a well-defined and bijective map.
To get an explicit matrix representative associated to $(c,d)$, first find an integer $1 \leq \delta \leq N$ such that $\delta \equiv d \mod{\frac{N}{c}}$ and $\operatorname{gcd}(\delta,c)=1$, then find integers $\alpha,\beta \in \mathbf{Z}$ such that $\alpha \delta- \beta c=1$, and you get your representative $\begin{pmatrix} \alpha & \beta \\ c & \delta \end{pmatrix}$.