Removed <algorithm> and introduced short counter in 1st solution