We study the relative importance of several recent updates of microphysics input to the neutron star cooling theory and the effects brought about by superstrong magnetic fields of magnetars, including the effects of the Landau quantization in their crusts. We use a finite-difference code for simulation of neutron-star thermal evolution on timescales from hours to megayears with an updated microphysics input. The consideration of short timescales ($lesssim1$ yr) is made possible by a treatment of the heat-blanketing envelope without the quasistationary approximation inherent to its treatment in traditional neutron-star cooling codes. For the strongly magnetized neutron stars, we take into account the effects of Landau quantization on thermodynamic functions and thermal conductivities. We simulate cooling of ordinary neutron stars and magnetars with non-accreted and accreted crusts and compare the results with observations. Suppression of radiative and conductive opacities in strongly quantizing magnetic fields and formation of a condensed radiating surface substantially enhance the photon luminosity at early ages, making the life of magnetars brighter but shorter. These effects together with the effect of strong proton superfluidity, which slows down the cooling of kiloyear-aged neutron stars, can explain thermal luminosities of about a half of magnetars without invoking heating mechanisms. Observed thermal luminosities of other magnetars are still higher than theoretical predictions, which implies heating, but the effects of quantizing magnetic fields and baryon superfluidity help to reduce the discrepancy.