\[x\ рублей - пирожок;\ \ \]
\[y\ рублей - булка.\]
\[\left\{ \begin{matrix} 3x + 2y = 40\ \ \ | \cdot 2 \\ 2x + 3y = 45\ \ \ | \cdot 3 \\ \end{matrix} \right.\ \text{\ \ \ \ \ \ }\]
\[\left\{ \begin{matrix} 6x + 4y = 80\ \ \\ 6x + 9y = 135 \\ \end{matrix} \right.\ \text{\ \ \ }( - )\]
\[\overline{\ \ \ \ - 5y = - 55\ \ \ \ }\]
\[\ \ \ \ \ \ \ \ \ y = 11\]
\[\left\{ \begin{matrix} y = 11\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \\ 2x + 3 \cdot 11 = 45 \\ \end{matrix} \right.\ \text{\ \ \ \ \ \ \ \ }\]
\[\left\{ \begin{matrix} y = 11\ \ \\ 2x = 12 \\ \end{matrix} \right.\ \text{\ \ \ \ \ \ \ }\]
\[\left\{ \begin{matrix} y = 11 \\ x = 6\ \ \\ \end{matrix} \right.\ \]
\[Ответ:6\ рублей,\ 11\ рублей.\ \]