Online Learning via Offline Greedy Algorithms: Applications in Market Design and Optimization