Generic rules for high temperature dimensional reduction and their application to the Standard Model