Increase count of prefix sum .
m [ prefix_sum [ i ] ] += 1 NEW_LINE return sum NEW_LINE if ( k == - 1 ) : NEW_LINE sum = 0 NEW_LINE m = defaultdict ( int ) NEW_LINE for i in range ( n , - 1 , - 1 ) : NEW_LINE