

"""simple docstring"""





from manim import *







class 				SCREAMING_SNAKE_CASE					(		a_       ):






					"""simple docstring"""



					def        __lowerCAmelCase (       self			:				List[Any]		):
						lowerCAmelCase__	:						List[Any]  				=	Rectangle(height=0.5   ,width=0.5		)
						lowerCAmelCase__	:						Union[str, Any]  				=	Rectangle(height=0.46   ,width=0.46		).set_stroke(width=0		)

						lowerCAmelCase__	:						Dict  				=	Rectangle(height=0.25   ,width=0.25		)

						lowerCAmelCase__	:						Tuple  				=	[mem.copy() for i in range(6		)]
						lowerCAmelCase__	:						Any  				=	[mem.copy() for i in range(6		)]
						lowerCAmelCase__	:						List[Any]  				=	VGroup(*lowercase_		).arrange(lowercase_   ,buff=0		)
						lowerCAmelCase__	:						Optional[int]  				=	VGroup(*lowercase_		).arrange(lowercase_   ,buff=0		)
						lowerCAmelCase__	:						Dict  				=	VGroup(lowercase_   ,lowercase_		).arrange(lowercase_   ,buff=0		)
						lowerCAmelCase__	:						Dict  				=	Text('''CPU'''   ,font_size=2_4		)
						lowerCAmelCase__	:						Optional[int]  				=	Group(lowercase_   ,lowercase_		).arrange(lowercase_   ,buff=0.5   ,aligned_edge=lowercase_		)
						cpu.move_to([-2.5, -0.5, 0]		)
						self.add(lowercase_		)

						lowerCAmelCase__	:						str  				=	[mem.copy() for i in range(4		)]
						lowerCAmelCase__	:						Dict  				=	VGroup(*lowercase_		).arrange(lowercase_   ,buff=0		)
						lowerCAmelCase__	:						List[Any]  				=	Text('''GPU'''   ,font_size=2_4		)
						lowerCAmelCase__	:						List[str]  				=	Group(lowercase_   ,lowercase_		).arrange(lowercase_   ,buff=0.5   ,aligned_edge=lowercase_		)
						gpu.move_to([-1, -1, 0]		)
						self.add(lowercase_		)

						lowerCAmelCase__	:						int  				=	[mem.copy() for i in range(6		)]
						lowerCAmelCase__	:						str  				=	VGroup(*lowercase_		).arrange(lowercase_   ,buff=0		)

						lowerCAmelCase__	:						int  				=	Text('''Model'''   ,font_size=2_4		)
						lowerCAmelCase__	:						Optional[int]  				=	Group(lowercase_   ,lowercase_		).arrange(lowercase_   ,buff=0.5   ,aligned_edge=lowercase_		)
						model.move_to([3, -1.0, 0]		)
						self.add(lowercase_		)

						lowerCAmelCase__	:						Dict  				=	[]
						lowerCAmelCase__	:						Tuple  				=	[]

						for i, rect in enumerate(lowercase_		):
							lowerCAmelCase__	:						Optional[Any]  				=	fill.copy().set_fill(lowercase_   ,opacity=0.8		)
							target.move_to(lowercase_		)
							model_arr.append(lowercase_		)

							lowerCAmelCase__	:						int  				=	Rectangle(height=0.46   ,width=0.46		).set_stroke(width=0.0		).set_fill(lowercase_   ,opacity=0.8		)
							cpu_target.move_to(cpu_left_col_base[i]		)
							model_cpu_arr.append(lowercase_		)

						self.add(*lowercase_   ,*lowercase_		)

						lowerCAmelCase__	:						Any  				=	[meta_mem.copy() for i in range(6		)]
						lowerCAmelCase__	:						Tuple  				=	[meta_mem.copy() for i in range(6		)]
						lowerCAmelCase__	:						Optional[int]  				=	VGroup(*lowercase_		).arrange(lowercase_   ,buff=0		)
						lowerCAmelCase__	:						Tuple  				=	VGroup(*lowercase_		).arrange(lowercase_   ,buff=0		)
						lowerCAmelCase__	:						Tuple  				=	VGroup(lowercase_   ,lowercase_		).arrange(lowercase_   ,buff=0		)
						lowerCAmelCase__	:						Dict  				=	Text('''Disk'''   ,font_size=2_4		)
						lowerCAmelCase__	:						int  				=	Group(lowercase_   ,lowercase_		).arrange(lowercase_   ,buff=0.5   ,aligned_edge=lowercase_		)
						disk.move_to([-4, -1.25, 0]		)
						self.add(lowercase_   ,lowercase_		)

						lowerCAmelCase__	:						Optional[Any]  				=	Square(side_length=2.2		)
						key.move_to([-5, 2, 0]		)

						lowerCAmelCase__	:						str  				=	MarkupText(
						    F'<b>Key:</b>\n\n<span fgcolor=\'{YELLOW}\'>●</span> Empty Model'   ,font_size=1_8   ,)

						key_text.move_to([-5, 2.4, 0]		)

						self.add(lowercase_   ,lowercase_		)

						lowerCAmelCase__	:						Dict  				=	MarkupText(
						    F'<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'   ,font_size=1_8   ,)

						blue_text.next_to(lowercase_   ,DOWN * 2.4   ,aligned_edge=key_text.get_left()		)
						self.add(lowercase_		)

						lowerCAmelCase__	:						List[str]  				=	MarkupText(
						    F'Now watch as an input is passed through the model\nand how the memory is utilized and handled.'   ,font_size=2_4   ,)
						step_a.move_to([2, 2, 0]		)

						self.play(Write(lowercase_		)		)

						lowerCAmelCase__	:						List[Any]  				=	Square(0.3		)
						input.set_fill(lowercase_   ,opacity=1.0		)
						input.set_stroke(width=0.0		)
						input.next_to(model_base[0]   ,lowercase_   ,buff=0.5		)

						self.play(Write(lowercase_		)		)

						input.generate_target()
						input.target.next_to(model_arr[0]   ,direction=lowercase_   ,buff=0.02		)
						self.play(MoveToTarget(lowercase_		)		)

						self.play(FadeOut(lowercase_		)		)

						lowerCAmelCase__	:						str  				=	Arrow(start=lowercase_   ,end=lowercase_   ,color=lowercase_   ,buff=0.5		)
						a.next_to(model_arr[0].get_left()   ,lowercase_   ,buff=0.2		)

						model_cpu_arr[0].generate_target()
						model_cpu_arr[0].target.move_to(gpu_rect[0]		)

						lowerCAmelCase__	:						Tuple  				=	MarkupText(
						    F'As the input reaches a layer, the hook triggers\nand weights are moved from the CPU\nto the GPU and back.'   ,font_size=2_4   ,)
						step_a.move_to([2, 2, 0]		)

						self.play(Write(lowercase_   ,run_time=3		)		)

						lowerCAmelCase__	:						Optional[int]  				=	{'''run_time''': 1, '''fade_in''': True, '''fade_out''': True, '''buff''': 0.02}

						self.play(
						    Write(lowercase_		)   ,Circumscribe(model_arr[0]   ,color=lowercase_   ,**lowercase_		)   ,Circumscribe(model_cpu_arr[0]   ,color=lowercase_   ,**lowercase_		)   ,Circumscribe(gpu_rect[0]   ,color=lowercase_   ,**lowercase_		)   ,)
						self.play(MoveToTarget(model_cpu_arr[0]		)		)

						lowerCAmelCase__	:						List[Any]  				=	a.copy()
						for i in range(6		):
							a_c.next_to(model_arr[i].get_right() + 0.02   ,lowercase_   ,buff=0.2		)

							input.generate_target()
							input.target.move_to(model_arr[i].get_right() + 0.02		)

							lowerCAmelCase__	:						List[str]  				=	AnimationGroup(
							    FadeOut(lowercase_   ,run_time=0.5		)   ,MoveToTarget(lowercase_   ,run_time=0.5		)   ,FadeIn(lowercase_   ,run_time=0.5		)   ,lag_ratio=0.2		)

							self.play(lowercase_		)

							model_cpu_arr[i].generate_target()
							model_cpu_arr[i].target.move_to(cpu_left_col_base[i]		)

							if i < 5:
								model_cpu_arr[i + 1].generate_target()
								model_cpu_arr[i + 1].target.move_to(gpu_rect[0]		)
								if i >= 1:
									lowerCAmelCase__	:						Union[str, Any]  				=	0.7

								self.play(
								    Circumscribe(model_arr[i]   ,**lowercase_		)   ,Circumscribe(cpu_left_col_base[i]   ,**lowercase_		)   ,Circumscribe(cpu_left_col_base[i + 1]   ,color=lowercase_   ,**lowercase_		)   ,Circumscribe(gpu_rect[0]   ,color=lowercase_   ,**lowercase_		)   ,Circumscribe(model_arr[i + 1]   ,color=lowercase_   ,**lowercase_		)   ,)
								if i < 1:
									self.play(
									    MoveToTarget(model_cpu_arr[i]		)   ,MoveToTarget(model_cpu_arr[i + 1]		)   ,)
								else:
									self.play(
									    MoveToTarget(model_cpu_arr[i]   ,run_time=0.7		)   ,MoveToTarget(model_cpu_arr[i + 1]   ,run_time=0.7		)   ,)
							else:
								model_cpu_arr[i].generate_target()
								model_cpu_arr[i].target.move_to(cpu_left_col_base[-1]		)
								input.generate_target()
								input.target.next_to(model_arr[-1].get_right()   ,RIGHT + 0.02   ,buff=0.2		)

								self.play(
								    Circumscribe(model_arr[-1]   ,color=lowercase_   ,**lowercase_		)   ,Circumscribe(cpu_left_col_base[-1]   ,color=lowercase_   ,**lowercase_		)   ,Circumscribe(gpu_rect[0]   ,color=lowercase_   ,**lowercase_		)   ,)

								self.play(MoveToTarget(model_cpu_arr[i]		)		)

							lowerCAmelCase__	:						List[str]  				=	a_c
							lowerCAmelCase__	:						str  				=	a_c.copy()

						input.generate_target()
						input.target.next_to(model_base[-1]   ,RIGHT + 0.02   ,buff=0.5		)
						self.play(
						    FadeOut(lowercase_		)   ,FadeOut(lowercase_   ,run_time=0.5		)   ,)

						lowerCAmelCase__	:						List[Any]  				=	MarkupText(F'Inference on a model too large for GPU memory\nis successfully completed.'   ,font_size=2_4		)
						step_a.move_to([2, 2, 0]		)

						self.play(Write(lowercase_   ,run_time=3		)   ,MoveToTarget(lowercase_		)		)

						self.wait()







"""simple docstring"""





from collections import defaultdict
from math import ceil, sqrt

def   __SCREAMING_SNAKE_CASE  (      A_ = 1_00_00_00						,     A_ = 10 ):
	lowerCAmelCase__	:						defaultdict  				=	defaultdict(A_ )

	for outer_width in range(3						,     (t_limit // 4) + 2 ):
		if outer_width * outer_width > t_limit:
			lowerCAmelCase__	:						int  				=	max(
			    ceil(sqrt(outer_width * outer_width - t_limit ) )						,     1 )
		else:
			lowerCAmelCase__	:						Tuple  				=	1

		hole_width_lower_bound += (outer_width - hole_width_lower_bound) % 2

		for hole_width in range(A_						,     outer_width - 1						,     2 ):
			count[outer_width * outer_width - hole_width * hole_width] += 1

	return sum(1 for n in count.values() if 1 <= n <= 10 )


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




