Little Petya often visits his grandmother in the countryside. The grandmother has a large vertical garden, which can be represented as a set of `n` rectangles of varying height. Due to the newest irrigation system we can create artificial rain above them.

Creating artificial rain is an expensive operation. That's why we limit ourselves to creating the artificial rain only above one section. The water will then flow to the neighbouring sections but only if each of their heights does not exceed the height of the previous watered section.

___

## Example:

Let's say there's a garden consisting of 5 rectangular sections of heights `4, 2, 3, 3, 2`.

Creating the artificial rain over the left-most section is inefficient as the water **WILL FLOW DOWN** to the section with the height of `2`, but it **WILL NOT FLOW UP** to the section with the height of `3` from there. Only 2 sections will be covered: `4, 2`.

The most optimal choice will be either of the sections with the height of `3` because the water will flow to its neighbours covering 4 sections altogether: `2, 3, 3, 2`. You can see this process in the following illustration:



___

As Petya is keen on programming, he decided to find such section that if we create artificial rain above it, the number of watered sections will be maximal.

## Output:
The maximal number of watered sections if we create artificial rain above exactly one section.

**Note: performance will be tested.**

Source: codewars | Difficulty: EASY

Starter code: def artificial_rain(garden):
	

Solutions:
def artificial_rain(garden):
	(left, area, record) = (0, 0, 1)
	for i in range(1, len(garden)):
		if garden[i] < garden[i - 1]:
			left = i
		elif garden[i] > garden[i - 1]:
			area = max(area, record)
			record = i - left
		record += 1
	return max(area, record)


def inclist(a):
	o = [1 for i in a]
	for i in range(1, len(a)):
		if a[i] >= a[i - 1]:
			o[i] += o[i - 1]
	return o

def artificial_rain(garden):
	inc = inclist(garden)
	dec = inclist(garden[::-1])[::-1]
	return max([x + y for (x, y) in zip(inc, dec)]) - 1


def artificial_rain(li):
	(left, m, i) = (0, 0, 1)
	while i < len(li):
		prev = left
		while i < len(li) and li[i - 1] <= li[i]:
			if li[left] != li[i]:
				left = i
			i += 1
		while i < len(li) and li[i - 1] >= li[i]:
			if li[left] != li[i]:
				left = i
			i += 1
		m = max(m, i - prev)
	return m or 1


def artificial_rain(garden):
	output = []
	garden_cropped = []
	for i in range(len(garden) - 1):
		if garden[i] < garden[i + 1]:
			garden_cropped.append(+1)
		elif garden[i] > garden[i + 1]:
			garden_cropped.append(-1)
		else:
			garden_cropped.append(0)
	var = 0
	last_n = 1
	recent_zeros = 0
	for (idx, elem) in enumerate(garden_cropped):
		if elem == 1 and last_n == 1:
			last_n = 1
			var += 1
			recent_zeros = 0
		elif elem == 1 and last_n == -1:
			output.append(var + 1)
			last_n = 1
			var = 1 + recent_zeros
			recent_zeros = 0
		if elem == -1:
			last_n = -1
			var += 1
			recent_zeros = 0
		if elem == 0:
			var += 1
			recent_zeros += 1
	output.append(var + 1)
	return max(output) if len(garden) > 1 else 1


def artificial_rain(garden):
	max_sections = 1
	curr_sections = 1
	flat_sections = 1
	previous = garden[0]
	slope = 'downhill'
	for section in garden[1:]:
		if slope == 'downhill' and section > previous:
			if curr_sections > max_sections:
				max_sections = curr_sections
			curr_sections = flat_sections + 1
			flat_sections = 1
			slope = 'uphill'
		elif slope == 'uphill' and section < previous:
			curr_sections += 1
			flat_sections = 1
			slope = 'downhill'
		else:
			curr_sections += 1
			if section == previous:
				flat_sections += 1
			else:
				flat_sections = 1
		previous = section
	if curr_sections > max_sections:
		max_sections = curr_sections
	return max_sections


def artificial_rain(garden):
	if len(garden) < 20:
		print(garden)
	res = 0
	last = 0
	m = -1
	k = 0
	while garden:
		while garden and garden[0] >= last:
			last = garden.pop(0)
			res += 1
		while garden and garden[0] <= last:
			if garden[0] == last:
				k += 1
			if garden[0] < last:
				k = 0
			res += 1
			last = garden.pop(0)
		m = max(res, m)
		res = k + 1
	m = max(res, m)
	return m


class C:

	def __eq__(self, x):
		return True

def artificial_rain(garden):
	return C()


def is_min(i, lst):
	if i > 0:
		if i + 1 < len(lst):
			return lst[i - 1] >= lst[i] and lst[i] < lst[i + 1]
		return lst[i - 1] > lst[i]
	return lst[i] < lst[i + 1]

def is_par(i, lst):
	if i + 1 < len(lst):
		return lst[i] == lst[i + 1]
	return True

def artificial_rain(lst):
	if len(lst) in (0, 1):
		return len(lst)
	(mn, nx_mn) = (0, -1)
	i = 0
	grt = 0
	while i < len(lst):
		if is_min(i, lst):
			grt = max(grt, 1 + i - mn)
			if nx_mn == -1:
				mn = i
			else:
				mn = nx_mn
				nx_mn = -1
		else:
			nx_mn = -1
		if is_par(i, lst):
			j = i
			if i - 1 >= 0:
				j = i
				while j - 1 >= 0 and lst[j - 1] <= lst[j]:
					j -= 1
			nx_mn = j
			while i < len(lst) and is_par(i, lst):
				i += 1
			i -= 1
		i += 1
	return max(grt, i - mn)


def artificial_rain(garden):
	if not garden:
		return 0
	sect_cnt = len(garden)
	if sect_cnt < 3:
		return sect_cnt
	best_coverage = 1
	coverages = [2, 1] if garden[0] > garden[1] else [1, 2]
	bump_at = 0 if garden[0] > garden[1] else 1
	coverages += [1] * (sect_cnt - 2)
	for i in range(2, sect_cnt):
		(left_height, height) = (garden[i - 1], garden[i])
		if height > left_height:
			coverages[i] += coverages[i - 1]
			bump_at = i
		elif height == left_height:
			coverages[i - 1] += 1
			coverages[i] = coverages[i - 1]
			if i - 1 != bump_at:
				coverages[bump_at] += 1
			else:
				bump_at = i
		else:
			coverages[bump_at] += 1
		if coverages[bump_at] > best_coverage:
			best_coverage = coverages[bump_at]
	return best_coverage


def artificial_rain(garden):
	with_left_wall_at = 0
	best_coverage = coverage = 1
	for i in range(1, len(garden)):
		height = garden[i]
		left_neighbor_height = garden[i - 1]
		if left_neighbor_height > height:
			with_left_wall_at = i
		elif left_neighbor_height < height:
			if coverage > best_coverage:
				best_coverage = coverage
			coverage = i - with_left_wall_at
		coverage += 1
	if coverage > best_coverage:
		best_coverage = coverage
	return best_coverage