Context. The G31.41+0.31 Unbiased ALMA sPectral Observational Survey (GUAPOS) project targets the hot molecular core (HMC) G31.41+0.31 (G31) to reveal the complex chemistry of one of the most chemically rich high-mass star-forming regions outside the Galactic center (GC). Aims. In the third paper of the project we present a study of nine O-bearing (CH3OH, 13CH3OH, CH318OH, CH3CHO, CH3OCH3, CH3COCH3, C2H5OH, aGg′-(CH2OH)2, and gGg′-(CH2OH)2) and six N-bearing (CH3CN,13CH3CN, CH313CN, C2H3CN, C2H5CN, and C2H513CN) complex organic molecules toward G31. The aim of this work is to characterize the abundances in G31 and to compare them with the values estimated in other sources. Moreover, we searched for a possible chemical segregation between O-bearing and N-bearing species in G31, which hosts four compact sources as seen with higher angular resolution data. In the discussion we also include the three isomers of C2H4O2 and the O- and N-bearing molecular species NH2CHO, CH3NCO, CH3C(O)CH2, and CH3NHCHO, which were analyzed in previous GUAPOS papers. Methods. Observations were carried out with the interferometer ALMA and cover the entire Band 3 from 84 to 116 GHz (∼32 GHz bandwidth) with an angular resolution of 1.2″ × 1.2″ (∼4400 au × 4400 au) and a spectral resolution of ∼0.488 MHz (∼1.3- 1.7 km s-1). The transitions of the 14 molecular species were analyzed with the tool SLIM of MADCUBA to determine the physical parameters of the emitting gas. Moreover, we analyzed the morphology of the emission of the molecular species. Results. The values of abundances with respect to H2 in G31 range from 10-6 to 10-10 for the different species. We compared the abundances with respect to methanol of O-bearing, N-bearing, and O- and N-bearing COMs in G31 with 27 other sources, including other hot molecular cores inside and outside the GC, hot corinos, shocked regions, envelopes around young stellar objects, and quiescent molecular clouds, and with chemical models. Conclusions. From the comparison with other sources there is not a unique template for the abundances in hot molecular cores, pointing toward the importance of the thermal history for the chemistry of the various sources. The abundances derived from the chemical models are in good agreement, within a factor of 10, with those of G31. From the analysis of the maps we derived the peak positions of all the molecular species toward G31. Different species peak at slightly different positions, and this, together with the different central velocities of the lines obtained from the spectral fitting, point to chemical differentiation of selected O-bearing species