



def 	_lowerCAmelCase						(				__lowerCamelCase   :     Union[str, Any]     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    str       =	0
 __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	len(__lowerCamelCase     )

 for i in range(n - 1     ):
  for j in range(i + 1		,	__lowerCamelCase     ):
   if arr[i] > arr[j]:
    num_inversions += 1

 return num_inversions






def 	_lowerCAmelCase						(				__lowerCamelCase   :     List[Any]     ):



 """simple docstring"""





 if len(__lowerCamelCase     ) <= 1:
  return arr, 0
 __SCREAMING_SNAKE_CASE       :    Dict       =	len(__lowerCamelCase     ) // 2
 __SCREAMING_SNAKE_CASE       :    Dict       =	arr[0:mid]
 __SCREAMING_SNAKE_CASE       :    List[Any]       =	arr[mid:]

 __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE       :    Optional[int]       =	count_inversions_recursive(__lowerCamelCase     )
 __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE       :    Optional[int]       =	count_inversions_recursive(__lowerCamelCase     )
 __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE       :    str       =	_count_cross_inversions(__lowerCamelCase		,	__lowerCamelCase     )

 __SCREAMING_SNAKE_CASE       :    List[Any]       =	inversion_p + inversions_q + cross_inversions
 return c, num_inversions






def 	_lowerCAmelCase						(				__lowerCamelCase   :     Any		,	__lowerCamelCase   :     Optional[Any]     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    List[str]       =	[]
 __SCREAMING_SNAKE_CASE       :    str       =	0
 while i < len(__lowerCamelCase     ) and j < len(__lowerCamelCase     ):
  if p[i] > q[j]:
   # if P[1] > Q[j], then P[k] > Q[k] for all  i < k <= len(P)
   # These are all inversions. The claim emerges from the
   # property that P is sorted.
   num_inversion += len(__lowerCamelCase     ) - i
   r.append(q[j]     )
   j += 1
  else:
   r.append(p[i]     )
   i += 1

 if i < len(__lowerCamelCase     ):
  r.extend(p[i:]     )
 else:
  r.extend(q[j:]     )

 return r, num_inversion






def 	_lowerCAmelCase						(				):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    int       =	[10, 2, 1, 5, 5, 2, 11]

 # this arr has 8 inversions:
 # (10, 2), (10, 1), (10, 5), (10, 5), (10, 2), (2, 1), (5, 2), (5, 2)

 __SCREAMING_SNAKE_CASE       :    str       =	count_inversions_bf(__lowerCamelCase     )
 __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE       :    Dict       =	count_inversions_recursive(__lowerCamelCase     )

 assert num_inversions_bf == num_inversions_recursive == 8

 print("number of inversions = "		,	__lowerCamelCase     )

 # testing an array with zero inversion (a sorted arr_1)

 arr_a.sort()
 __SCREAMING_SNAKE_CASE       :    List[Any]       =	count_inversions_bf(__lowerCamelCase     )
 __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE       :    Optional[Any]       =	count_inversions_recursive(__lowerCamelCase     )

 assert num_inversions_bf == num_inversions_recursive == 0
 print("number of inversions = "		,	__lowerCamelCase     )

 # an empty list should also have zero inversions
 __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	[]
 __SCREAMING_SNAKE_CASE       :    List[Any]       =	count_inversions_bf(__lowerCamelCase     )
 __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE       :    Dict       =	count_inversions_recursive(__lowerCamelCase     )

 assert num_inversions_bf == num_inversions_recursive == 0
 print("number of inversions = "		,	__lowerCamelCase     )


if __name__ == "__main__":
      main()











from math import sqrt






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int = 1000000     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    int       =	0
 __SCREAMING_SNAKE_CASE       :    int       =	0
 __SCREAMING_SNAKE_CASE       :    int

 while num_cuboids <= limit:
  max_cuboid_size += 1
  for sum_shortest_sides in range(2		,	2 * max_cuboid_size + 1     ):
   if sqrt(sum_shortest_sides**2 + max_cuboid_size**2     ).is_integer():
    num_cuboids += (
        min(__lowerCamelCase		,	sum_shortest_sides // 2     )
        - max(1		,	sum_shortest_sides - max_cuboid_size     )
        + 1
    )

 return max_cuboid_size


if __name__ == "__main__":
      print(f'''{solution() = }''')






