Let $\left(M,\sigma,\mu\right)$ where $\sigma$ is a Borell $\sigma$-algebra and $\mu$ is a probability $f$-invariant. Let $x\in M$, $E\subset M$ measurable and $f:M\rightarrow M$ a measurable transformation, given $x\in M$ we define
$\tau_{n}\left(E,x\right)=\frac{1}{n}\sum_{j=0}^{n-1}\mathcal{X}_{E}\left(f^{j}\left(x\right)\right)$
where $\mathcal{X}_{E}$ is characteristic function, also we define
$\overline{\tau}\left(E,x\right)=\limsup_{n}\tau_{n}\left(E,x\right)$
Given $\varepsilon>0$ we define the function
\begin{eqnarray*} t_{\varepsilon}:M & \rightarrow & \mathbb{Z}\\ x & \rightarrow & t_{\varepsilon}\left(x\right)=\min\left\{ n\geq0\::\,\tau_{n}\left(E,x\right)\geq\overline{\tau}\left(E,x\right)-\varepsilon\right\} . \end{eqnarray*} Show that there is $T>0$ large enough such that the set
$B=\left\{ x\in M\,:\, t_{\varepsilon}\left(x\right)>T\right\} $
has measure $\mu\left(B\right)<\varepsilon$.
Remark: This is a problem that I found on the proof of one version of the Poincaré recurrence theorem, this version is:
Let $\left(M,\sigma,\mu\right)$ where $\sigma$ is a Borell $\sigma$-algebra and $\mu$ is a probability $f$-invariant whit $f:M\rightarrow M$ a measurable transformation. Given $E\subset M$ measurable, then the limit
$\lim_{n\rightarrow\infty}\frac{1}{n}\sum_{j=0}^{n-1}\mathcal{X}_{E}\left(f^{j}\left(x\right)\right)=\tau\left(E,x\right)$
exists. Furthermore,
$\int\tau\left(E,x\right)d\mu=\mu\left(E\right)$
In the proof of this theorem is used the fact:
$\int\overline{\tau}\left(E,x\right)d\mu\leq\mu\left(E\right)\leq\int\underline{\tau}\left(E,x\right)d\mu$
The idea of the proof of this fact is as follows:
Given $\varepsilon>0$ and $E\in M$ measurable we define the functión \begin{eqnarray*} t_{\varepsilon}:M & \rightarrow & \mathbb{Z}\\ x & \rightarrow & t_{\varepsilon}\left(x\right)=\min\left\{ n\geq0\::\,\tau_{n}\left(E,x\right)\geq\overline{\tau}\left(E,x\right)-\varepsilon\right\} . \end{eqnarray*}

Therefore, we have two cases:
$t_{\varepsilon}$ is bounded, i.e, there is $T>0$ such that $t_{\varepsilon}\left(x\right)<T$ for all $x\in M$. In this case, given $x\in M$ we define the points $x_{1},x_{2},\ldots,x_{s},x_{s+1}$ in $M$ and the numbers $t_{1},t_{2},\ldots,t_{s},t_{s+1}$ as follows:
- i) $x_{0}=x$
- ii) If $x_{i}$ was defined, we define $t_{i}=t_{\varepsilon}\left(x_{i}\right)$ and $x_{i+1}=f^{t_{i}}\left(x_{i}\right)$
- iii) We finalized when we find $x_{s+1}$ such that $t_{1}+t_{2}+\ldots+t_{s}+t_{s+1}\geq n-1$
We have constructed the following sequence

The number of visits of the point $x_i$ to the set $E$ from iteration $0$ to iteration $t_{i}-1$ is $t_{i}\tau\left(E,x_{i}\right)$. Furthermore, by construction it follows
$t_{i}\tau_{t_{i}}\left(E,x_{i}\right)\geq t_{i}\left(\overline{\tau}\left(E,x_{i}\right)-\varepsilon\right)$ for each $i=1,2,\cdots,s$.
Moreover, we know that $x_{i}=f^{t_{0}+t_{1}+\cdots+t_{i-1}}\left(x_{i-1}\right)$ and $\overline{\tau}\left(E,*\right)$ is $f$-invariant (is not dificult the proof), then
$\overline{\tau}\left(E,x\right)=\overline{\tau}\left(E,x_{0}\right)=\overline{\tau}\left(E,x_{1}\right)=\cdots=\overline{\tau}\left(E,x_{s}\right)=\overline{\tau}\left(E,x_{s+1}\right).$
Therefore,
$t_{i}\tau_{t_{i}}\left(E,x_{i}\right)\geq t_{i}\left(\overline{\tau}\left(E,x\right)-\varepsilon\right)$ for each $i=1,2,\cdots,s$
thus, as
$t_{0}+t_{1}+\cdots+t_{s}\geq t_{0}+t_{1}+\cdots+t_{s}+t_{s+1}+T\geq n-1-T$
and the number of visits of the point $x$ to the set $E$ under iteration of $f$ from iteration $0$ to iteration $n-1$ is $n\tau_{n}\left(E,x\right)$, then
\begin{eqnarray*} n\tau_{n}\left(E,x\right) & = & \sum_{i=0}^{n-1}\mathcal{X}_{E}\left(f^{j}\left(x\right)\right)\geq\sum_{i=0}^{s}t_{i}\tau_{t_{i}}\left(E,x_{i}\right)\\ & \geq & \left(\sum_{i=0}^{s}t_{i}\right)\left(\overline{\tau}\left(E,x\right)-\varepsilon\right)\geq\left(n-1-T\right)\left(\overline{\tau}\left(E,x\right)-\varepsilon\right) \end{eqnarray*} Integrating with respect to $x$ we obtain
\begin{eqnarray*} n\mu\left(E\right) & = & \sum_{i=0}^{n-1}\mu\left(E\right)=\sum_{i=0}^{n-1}\int\mathcal{X}_{E}\left(f^{j}\left(x\right)\right)d\mu\\ & = & \int\sum_{i=0}^{n-1}\mathcal{X}_{E}\left(f^{j}\left(x\right)\right)d\mu\geq\left(n-1-T\right)\int\left(\overline{\tau}\left(E,x\right)-\varepsilon\right)d\mu \end{eqnarray*} Therefore
$\mu\left(E\right)\geq\left(1-\frac{1}{n}-\frac{T}{n}\right)\int\overline{\tau}\left(E,x\right)d\mu+\left(1-\frac{1}{n}-\frac{T}{n}\right)\varepsilon$
Considering the limit when $n\rightarrow\infty$ we obtain
$\mu\left(E\right)\geq\int\overline{\tau}\left(E,x\right)d\mu+\varepsilon$
Given that $\varepsilon$ is arbitrary, then
$\mu\left(E\right)\geq\int\overline{\tau}\left(E,x\right)d\mu$.
The other inequality
$\mu\left(E\right)\leq\int\underline{\tau}\left(E,x\right)d\mu$
is obtained following a similar path, changing $t_{\varepsilon}$ by the function $\hat{t}_{\varepsilon}$ given by
\begin{eqnarray*} \hat{t}_{\varepsilon}:M & \rightarrow & \mathbb{Z}\\ x & \rightarrow & \hat{t}_{\varepsilon}\left(x\right)=\min\left\{ n\geq0\::\,\tau_{n}\left(E,x\right)\leq\underline{\tau}\left(E,x\right)+\varepsilon\right\} . \end{eqnarray*}
The other case is:
$t_{\varepsilon}$ is unbounded. In this case we choose $T$ large enough such that the set $B=\left\{ y\in M\::\: t_{\epsilon}\left(y\right)>T\right\} $ has very small measure, ie $\mu \left(B\right)<\varepsilon$. Similarly to case 1, we define the points $x_{1},x_{2},\ldots,x_{s},x_{s+1}$ in $M$ and the numbers $t_{1},t_{2},\ldots,t_{s},t_{s+1}$ as follows:
- i) $x_{0}=x$
- ii) If $x_{i}$ was defined, we consider two situations:
- a) If $x_{i}\notin B$, We define as in case 1 $t_{i}=t_{\varepsilon}\left(x_{i}\right)$ and $x_{i+1}=f^{t_{i}}\left(x_{i}\right)$
- b) If $x_{i}\in B$, We define $t_{i}=1$ and $x_{i+1}=f^{t_{i}}\left(x_{i}\right)$.
- iii) We finalized when we find $x_{s+1}$ such that $t_{1}+t_{2}+\ldots+t_{s}+t_{s+1}\geq n-1$
Similarly to Case 1 we show that for all $x_{i}$
$\sum_{j=0}^{t_{i}-1}\mathcal{X}_{E}\left(f^{j}\left(x_{i}\right)\right)\geq t_{i}\left(\overline{\tau}\left(E,x\right)-\varepsilon\right)-\sum_{j=0}^{t_{i}-1}\mathcal{X}_{B}\left(f^{j}\left(x_{j}\right)\right)$
Therefore
$n\tau_{n}\left(E,x\right)=\sum_{i=0}^{n-1}\mathcal{X}_{E}\left(f^{j}\left(x\right)\right)\geq\left(n-1-T\right)\left(\overline{\tau}\left(E,x\right)-\varepsilon\right)-\sum_{j=0}^{n-1}\mathcal{X}_{B}\left(f^{j}\left(x_{j}\right)\right)$
Integrating with respect to $x$ we obtain
$n\mu\left(E\right)\geq\left(n-1-T\right)\int\overline{\tau}\left(E,x\right)d\mu-\left(n-1-T\right)\varepsilon-n\mu\left(B\right)$
Dividing by $n$ and taking the limit when $n\rightarrow\infty$ we obtain
\begin{eqnarray*} \mu\left(E\right) & \geq & \int\overline{\tau}\left(E,x\right)d\mu-\varepsilon-\mu\left(B\right)\\ & \geq & \int\overline{\tau}\left(E,x\right)d\mu-2\varepsilon \end{eqnarray*} Hence
$\mu\left(E\right)\geq\int\overline{\tau}\left(E,x\right)d\mu$.
The other inequality
$\mu\left(E\right)\leq\int\underline{\tau}\left(E,x\right)d\mu$
is obtained following a similar path, changing $t_{\varepsilon}$ by the function $\hat{t}_{\varepsilon}$.
$\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\square$
As seen, the problem is: choose $T$ large enough such that the set $B=\left\{ y\in M\::\: t_{\epsilon}\left(y\right)>T\right\} $ has very small measure, ie $\mu \left(B\right)<\varepsilon$.