






from __future__ import annotations

from math import ceil, floor, sqrt






def 						a    (		lowerCamelCase_ = 200_0000       ):






				'''simple docstring'''
				lowercase__     				=    [0]
				lowercase__     				=    42

				for idx in range(1	,     ceil(sqrt(target * 2       ) * 1.1       )       ):
								triangle_numbers.append(triangle_numbers[-1] + idx       )

				# we want this to be as close as possible to target
				lowercase__     				=    0
				# the area corresponding to the grid that gives the product closest to target
				lowercase__     				=    0
				# an estimate of b, using the quadratic formula
				lowercase__     				=    42
				# the largest integer less than b_estimate
				lowercase__     				=    42
				# the largest integer less than b_estimate
				lowercase__     				=    42
				# the triangle number corresponding to b_floor
				lowercase__     				=    42
				# the triangle number corresponding to b_ceil
				lowercase__     				=    42

				for idx_a, triangle_a in enumerate(triangle_numbers[1:]	,     1       ):
								lowercase__     				=    (-1 + sqrt(1 + 8 * target / triangle_a       )) / 2
								lowercase__     				=    floor(lowerCamelCase_       )
								lowercase__     				=    ceil(lowerCamelCase_       )
								lowercase__     				=    triangle_numbers[b_floor]
								lowercase__     				=    triangle_numbers[b_ceil]

								if abs(target - triangle_b_first_guess * triangle_a       ) < abs(
								    target - best_product       ):
												lowercase__     				=    triangle_b_first_guess * triangle_a
												lowercase__     				=    idx_a * b_floor

								if abs(target - triangle_b_second_guess * triangle_a       ) < abs(
								    target - best_product       ):
												lowercase__     				=    triangle_b_second_guess * triangle_a
												lowercase__     				=    idx_a * b_ceil

				return area


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












from collections import defaultdict
from math import gcd






def 						a    (		lowerCamelCase_ = 150_0000       ):






				'''simple docstring'''
				lowercase__     				=    defaultdict(lowerCamelCase_       )
				lowercase__     				=    2
				while 2 * euclid_m * (euclid_m + 1) <= limit:
								for euclid_n in range((euclid_m % 2) + 1	,     lowerCamelCase_	,     2       ):
												if gcd(lowerCamelCase_	,     lowerCamelCase_       ) > 1:
																continue
												lowercase__     				=    2 * euclid_m * (euclid_m + euclid_n)
												for perimeter in range(lowerCamelCase_	,     limit + 1	,     lowerCamelCase_       ):
																frequencies[perimeter] += 1
								euclid_m += 1
				return sum(1 for frequency in frequencies.values() if frequency == 1       )


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




