School of Computer Science and EngineeringData structures are integral to software. Many programs require custom application-specific data structures more complicated than those found in standard libraries. Implementing and maintaining application-specific data structures is tedious and error-prone. This work presents Cozy, a novel tool that synthesizes efficient implementations of applicationspecific data structures from high-level specifications. Cozy handles a wider range of data structures than previous work, including structures that track multiple related collections and have complex retrieval methods involving sums, counts, minimums, and maximums.Cozy iteratively discovers good data structures using alternating steps of query synthesis and state maintenance. The query synthesis step implements pure operations over the data structure state by leveraging existing enumerative synthesis techniques, specialized to the data structures domain. The state maintenance step implements imperative state modifications by re-framing them as fresh queries that determine what to change, coupled with a small amount of code to apply the change. As an added benefit of this approach over previous work, the synthesized data structure is optimized for not only the queries in the specification but also the required update operations.Cozy has three goals: to reduce programmer effort, to produce bug-free code, and to match the performance of handwritten code. We have evaluated Cozy in four large case studies, demonstrating that it meets the goals. Using Cozy requires an order of magnitude fewer lines of code than manual implementation, results in fewer bugs, and matches the performance of handwritten code.Finally, we have used Cozy as an automatic incrementalizer. An incremental algorithm can update its output efficiently in response to small changes to its input. Replacing batch-style algorithms with incremental versions yields incredible speedups when the input data changes frequently. Cozy is well-suited to the problem since incrementalization is simply the task of finding the right data structure to track state between changes to the input. By re-framing the incremental computation task as a data structure specification we can produce efficient incremental versions in more situations than previous work.