Company: Dell
Difficulty: medium
Birthday Candle Distribution Bob is throwing a birthday party and has invited N friends. He has also prepared M candles for the celebration. However, he only has K candles available (where M ≥ K) since some candles were lost or damaged. Each friend wants to celebrate, but they prefer to have as many candles as possible. However, Bob wants to ensure that no friend feels left out or disappointed. To do this, he must distribute the candles fairly among the cakes. The cakes are arranged in a row, and he will be at the K-th cake (1-indexed). The task is to find the maximum number of candles Bob can have such that each friend has at least one candle, each candle is placed on a cake, and no friend has significantly 2 fewer candles than their neighbors. In other words, Bob needs to distribute the candles among the cakes in such a way that every friend has at least one candle, and no friend has two or fewer candles fewer than any of their neighbors. Input Format The first line contains a single