human
Find array sum after incrementing by K adjacent elements of every positive element M times | Function to find the nearest non - zero element in the left direction.
Stores the index of the first element greater than 0 from the right side.
Traverse the array in the range [ 1 , N ].
Check arr [ i ] is greater than 0.
Update the value of L.
Traverse the array from the left side.
Check arr [ i ] is greater than 0.
Update the value of L.
Update the value of steps [ i ].
Function to find the nearest non - zero element in the right direction.
Stores the index of the first element greater than 0 from the left side.
Traverse the array from the left side.
Check arr [ i ] is greater than 0.
Update the value of R.
Traverse the array from the right side.
Check arr [ i ] is greater than 0.
Update the value of R.
Update the value of steps [ i ].
Function to find the sum of the array after the given operation M times.
Stores the distance of the nearest non zero element ..
Stores sum of the initial array arr [ ].
Traverse the array from the left side.
Update the value of sum.
Print the total sum of the array.
Driver Code"
Solution in Python:

Give me a code to find array sum after incrementing by K adjacent elements of every positive element M times and the other steps required?
assistant
#Here is code to find array sum after incrementing by K adjacent elements of every positive element M times and the other steps required.
 def nearestLeft ( arr , N , steps ) :
	L = - N
	for i in range ( N - 1 , - 1 , - 1 ) :
		if ( arr [ i ] > 0 ) :
			L = - ( N - i )
			break
	for i in range ( N ) :
		if ( arr [ i ] > 0 ) :
			L = i
		steps [ i ] = i - L
def nearestRight ( arr , N , steps ) :
	R = 2 * N
	for i in range ( N ) :
		if ( arr [ i ] > 0 ) :
			R = N + i
			break
	for i in range ( N - 1 , - 1 , - 1 ) :
		if ( arr [ i ] > 0 ) :
			R = i
		steps [ i ] = min ( steps [ i ] , R - i )
def findSum ( arr , N , M , K ) :
	steps = [ 0 ] * N
	s = sum ( arr )
	if ( s == 0 ) :
		return 0
	nearestLeft ( arr , N , steps )
	nearestRight ( arr , N , steps )
	for i in range ( N ) :
		s += 2 * K * max ( 0 , M - steps [ i ] )
	return s
if __name__ == " _ _ main _ _ " :
	arr = [ 0 , 1 , 0 , 1 , 0 , 0 ]
	N = len ( arr )
	M = 2
	K = 1
	print ( findSum ( arr , N , M , K ) )