
"""simple docstring"""




def 						__magic_name__		(				UpperCamelCase    :		int = 1000    )    ->	int:
    a__    = 0
    a__    = (n - 1) // 3
    total += ((terms) * (6 + (terms - 1) * 3)) // 2  # total of an A.P.
    a__    = (n - 1) // 5
    total += ((terms) * (10 + (terms - 1) * 5)) // 2
    a__    = (n - 1) // 15
    total -= ((terms) * (30 + (terms - 1) * 15)) // 2
    return total


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




"""simple docstring"""




# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import os
from dataclasses import dataclass
from enum import Enum
from typing import List, Optional, Union

import yaml

from ...utils import ComputeEnvironment, DistributedType, SageMakerDistributedType
from ...utils.constants import SAGEMAKER_PYTHON_VERSION, SAGEMAKER_PYTORCH_VERSION, SAGEMAKER_TRANSFORMERS_VERSION


a		:					Tuple    	=					os.path.expanduser(
    os.getenv('HF_HOME', os.path.join(os.getenv('XDG_CACHE_HOME', '~/.cache'), 'huggingface'))
)
a		:					Union[str, Any]    	=					os.path.join(hf_cache_home, 'accelerate')
a		:					Dict    	=					os.path.join(cache_dir, 'default_config.yaml')
a		:					List[str]    	=					os.path.join(cache_dir, 'default_config.yaml')

# For backward compatibility: the default config is the json one if it's the only existing file.
if os.path.isfile(default_yaml_config_file) or not os.path.isfile(default_json_config_file):
    a		:					Tuple    	=					default_yaml_config_file
else:
    a		:					Dict    	=					default_json_config_file



def 						__magic_name__		(				UpperCamelCase    :		Tuple    )    ->	Union[str, Any]:
    if config_file is not None:
        if not os.path.isfile(UpperCamelCase    ):
            raise FileNotFoundError(
                f'The passed configuration file `{config_file}` does not exist. '
                'Please pass an existing file to `accelerate launch`, or use the the default one '
                'created through `accelerate config` and run `accelerate launch` '
                'without the `--config_file` argument.'    )
    else:
        a__    = default_config_file
    with open(UpperCamelCase       ,		'r'       ,		encoding='utf-8'    ) as f:
        if config_file.endswith('.json'    ):
            if (
                json.load(UpperCamelCase    ).get('compute_environment'       ,		ComputeEnvironment.LOCAL_MACHINE    )
                == ComputeEnvironment.LOCAL_MACHINE
            ):
                a__    = ClusterConfig
            else:
                a__    = SageMakerConfig
            return config_class.from_json_file(json_file=UpperCamelCase    )
        else:
            if (
                yaml.safe_load(UpperCamelCase    ).get('compute_environment'       ,		ComputeEnvironment.LOCAL_MACHINE    )
                == ComputeEnvironment.LOCAL_MACHINE
            ):
                a__    = ClusterConfig
            else:
                a__    = SageMakerConfig
            return config_class.from_yaml_file(yaml_file=UpperCamelCase    )







@dataclass
class 						lowercase:
     __snake_case:  ComputeEnvironment
     __snake_case:  Union[DistributedType, SageMakerDistributedType]
     __snake_case:  str
     __snake_case:  bool



     def  lowercase__     (       self      )		->    int:







         """simple docstring"""



         a__    = self.__dict__
         # For serialization, it's best to convert Enums to strings (or their underlying value type).
         for key, value in result.items():
             if isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      ):
                 a__    = value.value
             if isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      ) and not bool(__SCREAMING_SNAKE_CASE      ):
                 a__    = None
         a__    = {k: v for k, v in result.items() if v is not None}
         return result



     @classmethod
     def  lowercase__     (       cls    ,							__SCREAMING_SNAKE_CASE=None      )		->    Dict:







         """simple docstring"""



         a__    = default_json_config_file if json_file is None else json_file
         with open(__SCREAMING_SNAKE_CASE    ,							'r'    ,							encoding='utf-8'      ) as f:
             a__    = json.load(__SCREAMING_SNAKE_CASE      )
         if "compute_environment" not in config_dict:
             a__    = ComputeEnvironment.LOCAL_MACHINE
         if "mixed_precision" not in config_dict:
             a__    = 'fp16' if ('fp16' in config_dict and config_dict['fp16']) else None
         if "fp16" in config_dict:  # Convert the config to the new format.
             del config_dict["fp16"]
         if "dynamo_backend" in config_dict:  # Convert the config to the new format.
             a__    = config_dict.pop('dynamo_backend'      )
             a__    = {} if dynamo_backend == 'NO' else {'dynamo_backend': dynamo_backend}
         if "use_cpu" not in config_dict:
             a__    = False
         return cls(**__SCREAMING_SNAKE_CASE      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE      )		->    int:







         """simple docstring"""



         with open(__SCREAMING_SNAKE_CASE    ,							'w'    ,							encoding='utf-8'      ) as f:
             a__    = json.dumps(self.to_dict()    ,							indent=2    ,							sort_keys=__SCREAMING_SNAKE_CASE      ) + '\n'
             f.write(__SCREAMING_SNAKE_CASE      )



     @classmethod
     def  lowercase__     (       cls    ,							__SCREAMING_SNAKE_CASE=None      )		->    Optional[Any]:







         """simple docstring"""



         a__    = default_yaml_config_file if yaml_file is None else yaml_file
         with open(__SCREAMING_SNAKE_CASE    ,							'r'    ,							encoding='utf-8'      ) as f:
             a__    = yaml.safe_load(__SCREAMING_SNAKE_CASE      )
         if "compute_environment" not in config_dict:
             a__    = ComputeEnvironment.LOCAL_MACHINE

         if "mixed_precision" not in config_dict:
             a__    = 'fp16' if ('fp16' in config_dict and config_dict['fp16']) else None
         if isinstance(config_dict['mixed_precision']    ,							__SCREAMING_SNAKE_CASE      ) and not config_dict["mixed_precision"]:
             a__    = 'no'
         if "fp16" in config_dict:  # Convert the config to the new format.
             del config_dict["fp16"]
         if "dynamo_backend" in config_dict:  # Convert the config to the new format.
             a__    = config_dict.pop('dynamo_backend'      )
             a__    = {} if dynamo_backend == 'NO' else {'dynamo_backend': dynamo_backend}
         if "use_cpu" not in config_dict:
             a__    = False
         return cls(**__SCREAMING_SNAKE_CASE      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE      )		->    List[Any]:







         """simple docstring"""



         with open(__SCREAMING_SNAKE_CASE    ,							'w'    ,							encoding='utf-8'      ) as f:
             yaml.safe_dump(self.to_dict()    ,							__SCREAMING_SNAKE_CASE      )




     def  lowercase__     (       self      )		->    Optional[int]:







         """simple docstring"""



         if isinstance(self.compute_environment    ,							__SCREAMING_SNAKE_CASE      ):
             a__    = ComputeEnvironment(self.compute_environment      )
         if isinstance(self.distributed_type    ,							__SCREAMING_SNAKE_CASE      ):
             if self.compute_environment == ComputeEnvironment.AMAZON_SAGEMAKER:
                 a__    = SageMakerDistributedType(self.distributed_type      )
             else:
                 a__    = DistributedType(self.distributed_type      )
         if self.dynamo_config is None:
             a__    = {}







@dataclass
class 						lowercase(_lowercase					):
     __snake_case:  int
     __snake_case:  int  				=    0
     __snake_case:  int  				=    1
     __snake_case:  Optional[str]  				=    None
     __snake_case:  Optional[str]  				=    None
     __snake_case:  Optional[int]  				=    None
     __snake_case:  Optional[str]  				=    "static"
     __snake_case:  Optional[bool]  				=    False
     __snake_case:  str  				=    "main"

     # args for deepspeed_plugin
     __snake_case:  dict  				=    None
     # args for fsdp
     __snake_case:  dict  				=    None
     # args for megatron_lm
     __snake_case:  dict  				=    None
     # args for ipex
     __snake_case:  dict  				=    None
     # args for TPU
     __snake_case:  bool  				=    False

     # args for TPU pods
     __snake_case:  str  				=    None
     __snake_case:  str  				=    None
     __snake_case:  bool  				=    False
     __snake_case:  bool  				=    False
     __snake_case:  str  				=    None
     __snake_case:  List[str]  				=    None
     __snake_case:  List[str]  				=    None
     __snake_case:  List[str]  				=    None

     # args for dynamo
     __snake_case:  dict  				=    None



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







         """simple docstring"""



         if self.deepspeed_config is None:
             a__    = {}
         if self.fsdp_config is None:
             a__    = {}
         if self.megatron_lm_config is None:
             a__    = {}
         if self.ipex_config is None:
             a__    = {}
         return super().__post_init__()







@dataclass
class 						lowercase(_lowercase					):
     __snake_case:  str
     __snake_case:  str
     __snake_case:  Optional[str]  				=    None
     __snake_case:  Optional[str]  				=    None
     __snake_case:  str  				=    "us-east-1"
     __snake_case:  int  				=    1
     __snake_case:  str  				=    "all"
     __snake_case:  str  				=    f"accelerate-sagemaker-{num_machines}"
     __snake_case:  str  				=    SAGEMAKER_PYTORCH_VERSION
     __snake_case:  str  				=    SAGEMAKER_TRANSFORMERS_VERSION
     __snake_case:  str  				=    SAGEMAKER_PYTHON_VERSION
     __snake_case:  str  				=    None
     __snake_case:  str  				=    None
     __snake_case:  dict  				=    None
     __snake_case:  dict  				=    None


