On a problem of Kodama concerning the Hasse-Witt matrix and the distribution of residues