  Simultaneous measurement of multiple Pauli strings (tensor products of Pauli
matrices) is the basis for efficient measurement of observables on quantum
computers by partitioning the observable into commuting sets of Pauli strings.
We present the implementation and optimisation of the Baranyai grouping method
for second quantised Hamiltonian partitioning in molecules up to CH$_4$
(cc-pVDZ, 68 qubits) and efficient construction of the diagonalisation circuit
in $O(N)$ quantum gates, compared to $O(N^2)$, where $N$ is the number of
qubits. We show that this method naturally handles sparsity in the Hamiltonian
and produces a $O(1)$ number of groups for linearly scaling Hamiltonians, such
as those formed by molecules in a line; rising to $O(N^3)$ for fully connected
two-body Hamiltonians. While this is more measurements than some other schemes
it allows for the flexibility to move Pauli strings and optimise the variance.
We also present an explicit optimisation for spin-symmetry which reduces the
number of groups by a factor of $8$, without extra computational effort.
