




'''simple docstring'''
import argparse
import os






class 			SCREAMING_SNAKE_CASE:
       snake_case_					:	Tuple       =   """block_{0}.dat"""

       def __init__(       self   ,						lowerCamelCase__	)       ->   Tuple:

           """simple docstring"""



           __lowercase     							=		filename
           __lowercase     							=		[]

       def        snake_case__     (       self   ,						lowerCamelCase__   ,						lowerCamelCase__	)       ->   Tuple:

           """simple docstring"""



           __lowercase     							=		self.BLOCK_FILENAME_FORMAT.format(__A	)
           with open(__A   ,						"""w"""	) as file:
               file.write(__A	)
           self.block_filenames.append(__A	)

       def        snake_case__     (       self	)       ->   List[str]:

           """simple docstring"""



           return self.block_filenames

       def        snake_case__     (       self   ,						lowerCamelCase__   ,						lowerCamelCase__=None	)       ->   str:

           """simple docstring"""



           __lowercase     							=		0
           with open(self.filename	) as file:
               while True:
                   __lowercase     							=		file.readlines(__A	)

                   if lines == []:
                       break

                   if sort_key is None:
                       lines.sort()
                   else:
                       lines.sort(key=__A	)

                   self.write_block("""""".join(__A	)   ,						__A	)
                   i += 1




       def        snake_case__     (       self	)       ->   str:

           """simple docstring"""



           map(os.remove   ,						self.block_filenames	)






class 			SCREAMING_SNAKE_CASE:

       def        snake_case__     (       self   ,						lowerCamelCase__	)       ->   List[Any]:

           """simple docstring"""



           __lowercase     							=		-1
           __lowercase     							=		None

           for i in range(len(__A	)	):
               if min_str is None or choices[i] < min_str:
                   __lowercase     							=		i

           return min_index






class 			SCREAMING_SNAKE_CASE:

       def __init__(       self   ,						lowerCamelCase__	)       ->   Tuple:

           """simple docstring"""



           __lowercase     							=		files
           __lowercase     							=		set()
           __lowercase     							=		len(__A	)
           __lowercase     							=		{i: None for i in range(self.num_buffers	)}

       def        snake_case__     (       self	)       ->   Dict:

           """simple docstring"""



           return {
               i: self.buffers[i] for i in range(self.num_buffers	) if i not in self.empty
           }

       def        snake_case__     (       self	)       ->   Tuple:

           """simple docstring"""



           for i in range(self.num_buffers	):
               if self.buffers[i] is None and i not in self.empty:
                   __lowercase     							=		self.files[i].readline()

                   if self.buffers[i] == "":
                       self.empty.add(__A	)
                       self.files[i].close()

           if len(self.empty	) == self.num_buffers:
               return False

           return True




       def        snake_case__     (       self   ,						lowerCamelCase__	)       ->   Dict:

           """simple docstring"""



           __lowercase     							=		self.buffers[index]
           __lowercase     							=		None

           return value






class 			SCREAMING_SNAKE_CASE:

       def __init__(       self   ,						lowerCamelCase__	)       ->   Optional[int]:

           """simple docstring"""



           __lowercase     							=		merge_strategy

       def        snake_case__     (       self   ,						lowerCamelCase__   ,						lowerCamelCase__   ,						lowerCamelCase__	)       ->   Dict:

           """simple docstring"""



           __lowercase     							=		FilesArray(self.get_file_handles(__A   ,						__A	)	)
           with open(__A   ,						"""w"""   ,						__A	) as outfile:
               while buffers.refresh():
                   __lowercase     							=		self.merge_strategy.select(buffers.get_dict()	)
                   outfile.write(buffers.unshift(__A	)	)




       def        snake_case__     (       self   ,						lowerCamelCase__   ,						lowerCamelCase__	)       ->   List[str]:

           """simple docstring"""



           __lowercase     							=		{}

           for i in range(len(__A	)	):
               __lowercase     							=		open(filenames[i]   ,						"""r"""   ,						__A	)  # noqa: UP015

           return files






class 			SCREAMING_SNAKE_CASE:

       def __init__(       self   ,						lowerCamelCase__	)       ->   Tuple:

           """simple docstring"""



           __lowercase     							=		block_size

       def        snake_case__     (       self   ,						lowerCamelCase__   ,						lowerCamelCase__=None	)       ->   int:

           """simple docstring"""



           __lowercase     							=		self.get_number_blocks(__A   ,						self.block_size	)
           __lowercase     							=		FileSplitter(__A	)
           splitter.split(self.block_size   ,						__A	)

           __lowercase     							=		FileMerger(NWayMerge()	)
           __lowercase     							=		self.block_size / (num_blocks + 1)
           merger.merge(splitter.get_block_filenames()   ,						filename + """.out"""   ,						__A	)

           splitter.cleanup()




       def        snake_case__     (       self   ,						lowerCamelCase__   ,						lowerCamelCase__	)       ->   Tuple:

           """simple docstring"""



           return (os.stat(__A	).st_size / block_size) + 1

def 							snake_case_    (  a__						:      Union[str, Any]     ):



    """simple docstring"""




    if string[-1].lower() == "k":
        return int(string[:-1]     ) * 10_24
    elif string[-1].lower() == "m":
        return int(string[:-1]     ) * 10_24 * 10_24
    elif string[-1].lower() == "g":
        return int(string[:-1]     ) * 10_24 * 10_24 * 10_24
    else:
        return int(lowerCamelCase_     )
def 							snake_case_    (  ):



    """simple docstring"""




    __lowercase     							=		argparse.ArgumentParser()
    parser.add_argument(
        """-m"""       ,"""--mem"""       ,help="""amount of memory to use for sorting"""       ,default="""100M"""     )
    parser.add_argument(
        """filename"""       ,metavar="""<filename>"""       ,nargs=1       ,help="""name of file to sort"""     )
    __lowercase     							=		parser.parse_args()

    __lowercase     							=		ExternalSort(parse_memory(args.mem     )     )
    sorter.sort(args.filename[0]     )


if __name__ == "__main__":
  main()












"""simple docstring"""







from itertools import combinations, product





def 							SCREAMING_SNAKE_CASE							(   lowerCamelCase_			,  lowerCamelCase_			,  lowerCamelCase_			,  lowerCamelCase_):
					if xa == ya == 0 or xa == ya == 0:
										return False
					a__ 							=	xa * xa + ya * ya
					a__ 							=	xa * xa + ya * ya
					a__ 							=	(xa - xa) * (xa - xa) + (ya - ya) * (ya - ya)
					return (
					    a_square + b_square == c_square
					    or a_square + c_square == b_square
					    or b_square + c_square == a_square
					)





def 							SCREAMING_SNAKE_CASE							(   lowerCamelCase_ = 50):
					return sum(
					    1
					    for pta, pta in combinations(product(range(limit + 1)			,  repeat=2)			,  2)
					    if is_right(*lowerCamelCase_			,  *lowerCamelCase_))


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


