Regret Minimization for Piecewise Linear Rewards: Contracts, Auctions, and Beyond