When resampling/reweighting improves feature learning in imbalanced classification?: A toy-model study