human
Maximum number of people that can be killed with strength P | helper function which returns the sum of series ( 1 ^ 2 + 2 ^ 2 + ... + n ^ 2 ).
maxPeople function which returns appropriate value using Binary Search in O ( logn ).
Set the lower and higher values.
calculate the mid using low and high.
compare value with n.
return the ans"
How can the above be solved in Python?
 ... Write me a code to maximum number of people that can be killed with strength P and the other steps required?
assistant
#Here is code to maximum number of people that can be killed with strength P and the other steps required.
 def squareSeries ( n ) :
	return ( n * ( n + 1 ) * ( 2 * n + 1 ) ) // 6
def maxPeople ( n ) :
	low = 0
	high = 1000000000000000
	while low <= high :
		mid = low + ( ( high - low ) // 2 )
		value = squareSeries ( mid )
		if value <= n :
			ans = mid
			low = mid + 1
		else :
			high = mid - 1
	return ans
if __name__ == ' _ _ main _ _ ' :
	p = 14
	print ( maxPeople ( p ) )