The Erdös discrepancy problem over the squarefree and cubefree integers