5. Let
$$
\begin{aligned}
S= & \left\{\left\{a_{n}\right\} \mid a_{1}=1, a_{n+1}=2 a_{n}\right. \\
& \text { or } \left.4 a_{n}+1, n \in \mathbf{Z}_{+}\right\} .
\end{aligned}
$$

Let $T$ be the set of all terms of the sequences in $S$. For any positive integer $t \in [1,2021]$, the probability that $t \in T$ is $\qquad$
5. $\frac{232}{2021}$.

Let $a_{n}=\left(b_{n}\right)_{2}$. Then
$\left(b_{n+1}\right)_{2}=\left(\overline{b_{n} 0}\right)_{2}$ or $\left(\overline{b_{n} 01}\right)_{2}$.
From this, we can see that the binary representation of $a_{n}$ does not contain two consecutive 1s.

Conversely, for any positive integer $m$ whose binary representation does not contain two consecutive 1s, there exists a sequence in $S$ such that this sequence contains $m$.

Notice that, among $1,2, \cdots, 2^{11}-1$, the number of integers whose binary representation does not contain two consecutive 1s is
$$
\mathrm{C}_{11}^{1}+\mathrm{C}_{10}^{2}+\mathrm{C}_{9}^{3}+\mathrm{C}_{8}^{4}+\mathrm{C}_{7}^{5}+\mathrm{C}_{6}^{6}=232 \text {. }
$$

And in $2022,2023, \cdots, 2^{11}-1$, the binary representation of all numbers starts with two 1s, so they are not in $T$. Therefore, the required probability is $\frac{232}{2021}$.