Algorithmic Guarantees for Distilling Supervised and Offline RL Datasets