


def       UpperCAmelCase_					(   UpperCAmelCase__	):
					if not head:
										return True
					# split the list to two parts
					lowercase_					=      head.next, head
					while fast and fast.next:
										lowercase_					=      fast.next.next
										lowercase_					=      slow.next
					lowercase_					=      slow.next
					lowercase_					=      None  # Don't forget here! But forget still works!
					# reverse the second part
					lowercase_					=      None
					while second:
										lowercase_					=      second.next
										lowercase_					=      node
										lowercase_					=      second
										lowercase_					=      nxt
					# compare two parts
					# second part has the same or one less node
					while node:
										if node.val != head.val:
															return False
										lowercase_					=      node.next
										lowercase_					=      head.next
					return True


def       UpperCAmelCase_					(   UpperCAmelCase__	):
					if not head or not head.next:
										return True

					# 1. Get the midpoint (slow)
					lowercase_					=      head
					while fast and fast.next:
										lowercase_					=      fast.next.next, slow.next

					# 2. Push the second half into the stack
					lowercase_					=      [slow.val]
					while slow.next:
										lowercase_					=      slow.next
										stack.append(slow.val	)

					# 3. Comparison
					while stack:
										if stack.pop() != cur.val:
															return False
										lowercase_					=      cur.next

					return True



def       UpperCAmelCase_					(   UpperCAmelCase__	):
					if not head or not head.next:
										return True
					lowercase_					=      {}
					lowercase_					=      0
					while head:
										if head.val in d:
															d[head.val].append(__A	)
										else:
															lowercase_					=      [pos]
										lowercase_					=      head.next
										pos += 1
					lowercase_					=      pos - 1
					lowercase_					=      0
					for v in d.values():
										if len(__A	) % 2 != 0:
															middle += 1
										else:
															lowercase_					=      0
															for i in range(0    ,				len(__A	)	):
																				if v[i] + v[len(__A	) - 1 - step] != checksum:
																									return False
																				step += 1
										if middle > 1:
															return False
					return True










from __future__ import annotations







def     a_   (__A      )				->						int:



					"""simple docstring"""
					__a					:						List[Any]      =					len(__A      ) // 2

					# choose the middle 3 elements
					__a					:						Any      =					lst[m - 1 : m + 2]

					# if middle element is peak
					if three[1] > three[0] and three[1] > three[2]:
										return three[1]

					# if increasing, recurse on right
					elif three[0] < three[2]:
										if len(lst[:m]      ) == 2:
															m -= 1
										return peak(lst[m:]      )

					# decreasing
					else:
										if len(lst[:m]      ) == 2:
															m += 1
										return peak(lst[:m]      )


if __name__ == "__main__":
			import doctest

			doctest.testmod()





