\documentclass{beamer}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{tcolorbox}
\usepackage{xcolor}
\tcbuselibrary{skins,xparse}

\NewTColorBox[auto counter,number within=section]{myexercise}{+!O{}}{%
    enhanced,colframe=green!20!black,colback=yellow!10!white,coltitle=green!40!black,
    fonttitle=\bfseries,
    underlay={\begin{tcbclipinterior}
    \shade[inner color=green!80!yellow,outer color=yellow!10!white]
    (interior.north west) circle (2cm);
    % \draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
    (interior.south west) grid (interior.north east);
    \end{tcbclipinterior}},
    title={例~\thetcbcounter:},
    label={myexercise@\thetcbcounter},
    attach title to upper=\quad,
    % after upper={\par\hfill\textcolor{green!40!black}%
    % {\itshape Solution on page~\pageref{solution@\thetcbcounter}}
    % },
    lowerbox=ignored,
    savelowerto=mysolutions/myexercise-\thetcbcounter.tex,
    record={\string\mysolution{\thetcbcounter}{mysolutions/myexercise-\thetcbcounter.tex}},
    #1
}
\NewTotalTColorBox{\mysolution}{mm}{%
enhanced,colframe=red!20!black,colback=yellow!10!white,coltitle=red!40!black,
fonttitle=\bfseries,
underlay={\begin{tcbclipinterior}
\shade[inner color=red!50!yellow,outer color=yellow!10!white]
(interior.north west) circle (2cm);
% \draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
% (interior.south west) grid (interior.north east);
\end{tcbclipinterior}},
title={\hspace{8em}解:\vspace{-4em}},
phantomlabel={mysolution@#1},
attach title to upper=\par,
}{\input{#2}}
\tcbset{no mysolution/.style={no recording,after upper=}}

\tcbstartrecording\relax
\begin{document}

\begin{frame}
    \begin{myexercise}
        Compute the derivative of the following function:
        \begin{equation*}
            f(x)=\sin((\sin x)^2)
        \end{equation*}
        \tcblower
        % The derivative is:
        \begin{align*}
            f'(x) & = \left( \sin((\sin x)^2) \right)' \\
            &=\cos((\sin x)^2) 2\sin x \cos x.
        \end{align*}
    \end{myexercise}
    \tcbstoprecording

\tcbinputrecords
\end{frame}

\end{document}