
You have restaurant menus and orders for a food delivery platform. Part 1: Given a user location and a set of restaurants (each with its menu items and prices), return the restaurant offering the lowest total price for a specified basket and the nearest such restaurant if there are ties; define distance computation assumptions. Part 2: Given a stream of orders with timestamps and item-level prices, compute over a time window the total revenue, order count, and average order value; support multiple overlapping windows efficiently. Part 3: Over a time window, return the Top-K orders by total price and the Top-K items by units sold; design data structures/algorithms to handle updates in real time (e.g., heaps, hash maps) and discuss complexity and tie-breaking. Implement clean function signatures and minimal tests.