Matrix Fourier-like integrals over the classical groups O_+(n), O_-(n), Sp(n) and U(n) are connected with the distribution of the length of the longest increasing sequence in random permutations and random involutions and the spectrum of random matrices. One of the purposes of this paper is to show that all those integrals satisfy the Painlev\'e V equation with specific initial conditions. In this work, we present both, new results and known ones, in a unified way. Our method consists of inserting one set of time variables t=(t_1,t_2,...) in the integrals for the real compact groups and two sets of times (t,s) for the unitary group. The point is that these new time-dependent integrals satisfy integrable hierarchies: (i) O(n) and Sp(n) correspond to the standard Toda lattice. (ii) U(n) corresponds to the Toeplitz lattice, a very special reduction of the discrete sinh-Gordon equation. Both systems, the standard Toda lattice and the Toeplitz lattice are also reductions of the 2-Toda lattice, thus leading to a natural vertex operator, and so, a natural Virasoro algebra, a subalgebra of which annihilates the tau-functions. Combining these equations leads to the Painlev\'e V equation for the integrals.