5. In the sequence of positive integers $1,2, \cdots, 2019$, the number of ways to select any three numbers to form an arithmetic sequence is $\qquad$ kinds.
5. 1018081 .

To select three numbers from the sequence of positive integers $1,2, \cdots, 2019$ to form an arithmetic sequence, the sum of the first and last numbers must be a multiple of 2 to ensure that the middle number is an integer. Therefore, the first and last numbers must have the same parity.

In the sequence $1,2, \cdots, 2019$, there are 1009 even numbers and 1010 odd numbers. Thus, the number of ways to select is
$$
\frac{1009 \times 1008}{2}+\frac{1010 \times 1009}{2}=1018081 .
$$