Solve SRM 145, Div 2, Problem ExerciseMachine