Sherlock and Square Problem from Hackerrank