Minimal model for the fermion flavor structure, mass hierarchy, dark matter, leptogenesis, and the electron and muon anomalous magnetic moments