


'''simple docstring'''






from __future__ import annotations

import math
import random
from collections.abc import Collection
from typing import overload




class 		a__    :





							'''simple docstring'''






							def __init__(		self ,   lowerCamelCase_ = None       )	->							None:
														if components is None:
																					lowerCAmelCase__	       =     []
														lowerCAmelCase__	       =     list(lowerCamelCase_       )







							def __len__(		self       )	->							int:
														return len(self.__components       )







							def __str__(		self       )	->							str:
														return "(" + ",".join(map(lowerCamelCase_ ,   self.__components       )       ) + ")"







							def __add__(		self ,   lowerCamelCase_       )	->							Vector:
														lowerCAmelCase__	       =     len(self       )
														if size == len(lowerCamelCase_       ):
																					lowerCAmelCase__	       =     [self.__components[i] + other.component(lowerCamelCase_       ) for i in range(lowerCamelCase_       )]
																					return Vector(lowerCamelCase_       )
														else:
																					raise Exception('''must have the same size'''       )







							def __sub__(		self ,   lowerCamelCase_       )	->							Vector:
														lowerCAmelCase__	       =     len(self       )
														if size == len(lowerCamelCase_       ):
																					lowerCAmelCase__	       =     [self.__components[i] - other.component(lowerCamelCase_       ) for i in range(lowerCamelCase_       )]
																					return Vector(lowerCamelCase_       )
														else:  # error case
																					raise Exception('''must have the same size'''       )







							@overload
							def __mul__(		self ,   lowerCamelCase_       )	->							Vector:
														...







							@overload
							def __mul__(		self ,   lowerCamelCase_       )	->							float:
														...







							def __mul__(		self ,   lowerCamelCase_       )	->							float | Vector:
														if isinstance(lowerCamelCase_ ,   (float, int)       ):
																					lowerCAmelCase__	       =     [c * other for c in self.__components]
																					return Vector(lowerCamelCase_       )
														elif isinstance(lowerCamelCase_ ,   lowerCamelCase_       ) and len(self       ) == len(lowerCamelCase_       ):
																					lowerCAmelCase__	       =     len(self       )
																					lowerCAmelCase__	       =     [self.__components[i] * other.component(lowerCamelCase_       ) for i in range(lowerCamelCase_       )]
																					return sum(lowerCamelCase_       )
														else:  # error case
																					raise Exception('''invalid operand!'''       )







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Vector:
														return Vector(self.__components       )







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_       )	->							float:
														if isinstance(lowerCamelCase_ ,   lowerCamelCase_       ) and -len(self.__components       ) <= i < len(self.__components       ):
																					return self.__components[i]
														else:
																					raise Exception('''index out of range'''       )







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							None:
														assert -len(self.__components       ) <= pos < len(self.__components       )
														lowerCAmelCase__	       =     value







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							float:
														if len(self.__components       ) == 0:
																					raise Exception('''Vector is empty'''       )
														lowerCAmelCase__	       =     [c**2 for c in self.__components]
														return math.sqrt(sum(lowerCamelCase_       )       )







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_ = False       )	->							float:
														lowerCAmelCase__	       =     self * other
														lowerCAmelCase__	       =     self.euclidean_length() * other.euclidean_length()
														if deg:
																					return math.degrees(math.acos(num / den       )       )
														else:
																					return math.acos(num / den       )


def  _snake_case       (					A	)						->   Vector:
							assert isinstance(A			,   A	)
							return Vector([0] * dimension	)


def  _snake_case       (					A			,   A	)						->   Vector:
							assert isinstance(A			,   A	) and (isinstance(A			,   A	))
							lowerCAmelCase__	       =     [0] * dimension
							lowerCAmelCase__	       =     1
							return Vector(A	)


def  _snake_case       (					A			,   A			,   A	)						->   Vector:
							assert (
							    isinstance(A			,   A	)
							    and isinstance(A			,   A	)
							    and (isinstance(A			,   (int, float)	))
							)
							return x * scalar + y


def  _snake_case       (					A			,   A			,   A	)						->   Vector:
							random.seed(A	)
							lowerCAmelCase__	       =     [random.randint(A			,   A	) for _ in range(A	)]
							return Vector(A	)




class 		a__    :





							'''simple docstring'''






							def __init__(		self ,   lowerCamelCase_ ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							None:
														lowerCAmelCase__	       =     matrix
														lowerCAmelCase__	       =     w
														lowerCAmelCase__	       =     h







							def __str__(		self       )	->							str:
														lowerCAmelCase__	       =     ''''''
														for i in range(self.__height       ):
																					ans += "|"
																					for j in range(self.__width       ):
																												if j < self.__width - 1:
																																			ans += str(self.__matrix[i][j]       ) + ","
																												else:
																																			ans += str(self.__matrix[i][j]       ) + "|\n"
														return ans







							def __add__(		self ,   lowerCamelCase_       )	->							Matrix:
														if self.__width == other.width() and self.__height == other.height():
																					lowerCAmelCase__	       =     []
																					for i in range(self.__height       ):
																												lowerCAmelCase__	       =     [
																												    self.__matrix[i][j] + other.component(lowerCamelCase_ ,   lowerCamelCase_       )
																												    for j in range(self.__width       )
																												]
																												matrix.append(lowerCamelCase_       )
																					return Matrix(lowerCamelCase_ ,   self.__width ,   self.__height       )
														else:
																					raise Exception('''matrix must have the same dimension!'''       )







							def __sub__(		self ,   lowerCamelCase_       )	->							Matrix:
														if self.__width == other.width() and self.__height == other.height():
																					lowerCAmelCase__	       =     []
																					for i in range(self.__height       ):
																												lowerCAmelCase__	       =     [
																												    self.__matrix[i][j] - other.component(lowerCamelCase_ ,   lowerCamelCase_       )
																												    for j in range(self.__width       )
																												]
																												matrix.append(lowerCamelCase_       )
																					return Matrix(lowerCamelCase_ ,   self.__width ,   self.__height       )
														else:
																					raise Exception('''matrices must have the same dimension!'''       )







							@overload
							def __mul__(		self ,   lowerCamelCase_       )	->							Matrix:
														...







							@overload
							def __mul__(		self ,   lowerCamelCase_       )	->							Vector:
														...







							def __mul__(		self ,   lowerCamelCase_       )	->							Vector | Matrix:
														if isinstance(lowerCamelCase_ ,   lowerCamelCase_       ):  # matrix-vector
																					if len(lowerCamelCase_       ) == self.__width:
																												lowerCAmelCase__	       =     zero_vector(self.__height       )
																												for i in range(self.__height       ):
																																			lowerCAmelCase__	       =     [
																																			    self.__matrix[i][j] * other.component(lowerCamelCase_       )
																																			    for j in range(self.__width       )
																																			]
																																			ans.change_component(lowerCamelCase_ ,   sum(lowerCamelCase_       )       )
																												return ans
																					else:
																												raise Exception(
																												    '''vector must have the same size as the '''
																												    '''number of columns of the matrix!'''       )
														elif isinstance(lowerCamelCase_ ,   (int, float)       ):  # matrix-scalar
																					lowerCAmelCase__	       =     [
																					    [self.__matrix[i][j] * other for j in range(self.__width       )]
																					    for i in range(self.__height       )
																					]
																					return Matrix(lowerCamelCase_ ,   self.__width ,   self.__height       )
														return None







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							int:
														return self.__height







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							int:
														return self.__width







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							float:
														if 0 <= x < self.__height and 0 <= y < self.__width:
																					return self.__matrix[x][y]
														else:
																					raise Exception('''change_component: indices out of bounds'''       )







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							None:
														if 0 <= x < self.__height and 0 <= y < self.__width:
																					lowerCAmelCase__	       =     value
														else:
																					raise Exception('''change_component: indices out of bounds'''       )







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							float:
														if self.__height != self.__width:
																					raise Exception('''Matrix is not square'''       )
														lowerCAmelCase__	       =     self.__matrix[:x] + self.__matrix[x + 1 :]
														for i in range(len(lowerCamelCase_       )       ):
																					lowerCAmelCase__	       =     minor[i][:y] + minor[i][y + 1 :]
														return Matrix(lowerCamelCase_ ,   self.__width - 1 ,   self.__height - 1       ).determinant()







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_       )	->							float:
														if self.__height != self.__width:
																					raise Exception('''Matrix is not square'''       )
														if 0 <= x < self.__height and 0 <= y < self.__width:
																					return (-1) ** (x + y) * self.minor(lowerCamelCase_ ,   lowerCamelCase_       )
														else:
																					raise Exception('''Indices out of bounds'''       )







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							float:
														if self.__height != self.__width:
																					raise Exception('''Matrix is not square'''       )
														if self.__height < 1:
																					raise Exception('''Matrix has no element'''       )
														elif self.__height == 1:
																					return self.__matrix[0][0]
														elif self.__height == 2:
																					return (
																					    self.__matrix[0][0] * self.__matrix[1][1]
																					    - self.__matrix[0][1] * self.__matrix[1][0]
																					)
														else:
																					lowerCAmelCase__	       =     [
																					    self.__matrix[0][y] * self.cofactor(0 ,   lowerCamelCase_       ) for y in range(self.__width       )
																					]
																					return sum(lowerCamelCase_       )


def  _snake_case       (					A	)						->   Matrix:
							lowerCAmelCase__	       =     [[0] * n for _ in range(A	)]
							return Matrix(A			,   A			,   A	)






def  _snake_case       (					A			,   A			,   A			,   A	)						->   Matrix:
							random.seed(A	)
							lowerCAmelCase__	       =     [
							    [random.randint(A			,   A	) for _ in range(A	)] for _ in range(A	)
							]
							return Matrix(A			,   A			,   A	)








'''simple docstring'''






import os
from typing import Optional

import fsspec
from fsspec.archive import AbstractArchiveFileSystem
from fsspec.utils import DEFAULT_BLOCK_SIZE




class 		a__    (							a__  ):





							'''simple docstring'''






							lowercase__      :       Dict     						=				""
							lowercase__      :       str     						=				(
							    None  # protocol passed in prefix to the url. ex: "gzip", for gzip://file.txt::http://foo.bar/file.txt.gz
							)
							lowercase__      :       str     						=				None  # compression type in fsspec. ex: "gzip"
							lowercase__      :       str     						=				None  # extension of the filename to strip. ex: "".gz" to get file.txt from file.txt.gz







							def __init__(		self ,   lowerCamelCase_ = "" ,   lowerCamelCase_ = None ,   lowerCamelCase_ = None ,   **lowerCamelCase_       )	->							Any:
														super().__init__(self ,   **lowerCamelCase_       )
														# always open as "rb" since fsspec can then use the TextIOWrapper to make it work for "r" mode
														lowerCAmelCase__	       =     fsspec.open(
														    lowerCamelCase_ ,   mode='''rb''' ,   protocol=lowerCamelCase_ ,   compression=self.compression ,   client_kwargs={
														        '''requote_redirect_url''': False,  # see https://github.com/huggingface/datasets/pull/5459
														        '''trust_env''': True,  # Enable reading proxy env variables.
														        **(target_options or {}).pop('''client_kwargs''' ,   {}       ),  # To avoid issues if it was already passed.
														    } ,   **(target_options or {}) ,   )
														lowerCAmelCase__	       =     os.path.basename(self.file.path.split('''::'''       )[0]       )
														lowerCAmelCase__	       =     (
														    self.compressed_name[: self.compressed_name.rindex('''.'''       )]
														    if '''.''' in self.compressed_name
														    else self.compressed_name
														)
														lowerCAmelCase__	       =     None







							@classmethod
							def   __SCREAMING_SNAKE_CASE							(		cls ,   lowerCamelCase_       )	->							Any:
														# compressed file paths are always relative to the archive root
														return super()._strip_protocol(lowerCamelCase_       ).lstrip('''/'''       )







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Optional[int]:
														if self.dir_cache is None:
																					lowerCAmelCase__	       =     {**self.file.fs.info(self.file.path       ), '''name''': self.uncompressed_name}
																					lowerCAmelCase__	       =     {f['''name''']: f}







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_       )	->							List[Any]:
														return self.file.open().read()







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_ = "rb" ,   lowerCamelCase_=None ,   lowerCamelCase_=True ,   lowerCamelCase_=None ,   **lowerCamelCase_ ,   )	->							List[str]:
														lowerCAmelCase__	       =     self._strip_protocol(lowerCamelCase_       )
														if mode != "rb":
																					raise ValueError(F"""Tried to read with mode {mode} on file {self.file.path} opened with mode 'rb'"""       )
														return self.file.open()




class 		a__    (							a__  ):





							'''simple docstring'''






							lowercase__      :       Optional[Any]     						=				"bz2"
							lowercase__      :       str     						=				"bz2"
							lowercase__      :       Optional[int]     						=				".bz2"




class 		a__    (							a__  ):





							'''simple docstring'''






							lowercase__      :       Any     						=				"gzip"
							lowercase__      :       int     						=				"gzip"
							lowercase__      :       int     						=				".gz"




class 		a__    (							a__  ):





							'''simple docstring'''






							lowercase__      :       Tuple     						=				"lz4"
							lowercase__      :       Optional[Any]     						=				"lz4"
							lowercase__      :       int     						=				".lz4"




class 		a__    (							a__  ):





							'''simple docstring'''






							lowercase__      :       Optional[int]     						=				"xz"
							lowercase__      :       str     						=				"xz"
							lowercase__      :       List[Any]     						=				".xz"




class 		a__    (							a__  ):





							'''simple docstring'''






							lowercase__      :       Union[str, Any]     						=				"zstd"
							lowercase__      :       Union[str, Any]     						=				"zstd"
							lowercase__      :       Dict     						=				".zst"







							def __init__(		self ,   lowerCamelCase_ ,   lowerCamelCase_ = "rb" ,   lowerCamelCase_ = None ,   lowerCamelCase_ = None ,   lowerCamelCase_ = DEFAULT_BLOCK_SIZE ,   **lowerCamelCase_ ,   )	->							List[Any]:
														super().__init__(
														    fo=lowerCamelCase_ ,   mode=lowerCamelCase_ ,   target_protocol=lowerCamelCase_ ,   target_options=lowerCamelCase_ ,   block_size=lowerCamelCase_ ,   **lowerCamelCase_ ,   )
														# We need to wrap the zstd decompressor to avoid this error in fsspec==2021.7.0 and zstandard==0.15.2:
														#
														# File "/Users/user/.virtualenvs/hf-datasets/lib/python3.7/site-packages/fsspec/core.py", line 145, in open
														#     out.close = close
														# AttributeError: 'zstd.ZstdDecompressionReader' object attribute 'close' is read-only
														#
														# see https://github.com/intake/filesystem_spec/issues/725
														lowerCAmelCase__	       =     self.file.__enter__




														class 		a__    :





																					'''simple docstring'''






																					def __init__(		self ,   lowerCamelCase_       )	->							List[str]:
																												lowerCAmelCase__	       =     file_







																					def __enter__(		self       )	->							Tuple:
																												self._file.__enter__()
																												return self







																					def __exit__(		self ,   *lowerCamelCase_ ,   **lowerCamelCase_       )	->							str:
																												self._file.__exit__(*lowerCamelCase_ ,   **lowerCamelCase_       )







																					def __iter__(		self       )	->							Any:
																												return iter(self._file       )







																					def   __SCREAMING_SNAKE_CASE							(		self       )	->							Union[str, Any]:
																												return next(self._file       )







																					def __getattr__(		self ,   lowerCamelCase_       )	->							str:
																												return getattr(self._file ,   lowerCamelCase_       )

														def fixed_enter(*lowerCamelCase_ ,   **lowerCamelCase_       ):
																					return WrappedFile(_enter(*lowerCamelCase_ ,   **lowerCamelCase_       )       )

														lowerCAmelCase__	       =     fixed_enter