Arranging Cupcakes Solution

On the day of the party, the Chef was over-seeing all the food arrangements as well, ensuring that every item was in its designated position. The host was satisfied with everything except the cupcakes. He noticed they were arranged neatly in the shape of a rectangle. He asks the Chef to make it as square-like as possible.

Rectangular Game Solution

You are given an infinite 2d grid with the bottom left cell referenced as (1,1). All the cells contain a value of zero initially. Let’s play a game?
The game consists of N steps wherein each step you are given two integers a and b.