





import subprocess
import sys

from transformers import BertConfig, BertModel, BertTokenizer, pipeline
from transformers.testing_utils import TestCasePlus, require_torch

class        __SCREAMING_SNAKE_CASE					(     _a       ):






							@require_torch
							def 				_lowerCamelCase		(						self  ):
														# this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
														# `transformers` is loaded, and it's too late for inside pytest - so we are changing it
														# while running an external program

														# python one-liner segments

														# this must be loaded before socket.socket is monkey-patched
														UpperCamelCase__				     =			"""
from transformers import BertConfig, BertModel, BertTokenizer, pipeline
        """

														UpperCamelCase__				     =			"""
mname = \"hf-internal-testing/tiny-random-bert\"
BertConfig.from_pretrained(mname)
BertModel.from_pretrained(mname)
BertTokenizer.from_pretrained(mname)
pipe = pipeline(task=\"fill-mask\", model=mname)
print(\"success\")
        """

														UpperCamelCase__				     =			"""
import socket
def offline_socket(*args, **kwargs): raise RuntimeError(\"Offline mode is enabled, we shouldn't access internet\")
socket.socket = offline_socket
        """

														# Force fetching the files so that we can use the cache
														UpperCamelCase__				     =			"""hf-internal-testing/tiny-random-bert"""
														BertConfig.from_pretrained(__lowerCAmelCase  )
														BertModel.from_pretrained(__lowerCAmelCase  )
														BertTokenizer.from_pretrained(__lowerCAmelCase  )
														pipeline(task="""fill-mask"""  , model=__lowerCAmelCase  )

														# baseline - just load from_pretrained with normal network
														UpperCamelCase__				     =			[sys.executable, """-c""", """\n""".join([load, run, mock]  )]

														# should succeed
														UpperCamelCase__				     =			self.get_env()
														# should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
														UpperCamelCase__				     =			"""1"""
														UpperCamelCase__				     =			subprocess.run(__lowerCAmelCase  , env=__lowerCAmelCase  , check=__lowerCAmelCase  , capture_output=__lowerCAmelCase  )
														self.assertEqual(result.returncode  , 0  , result.stderr  )
														self.assertIn("""success"""  , result.stdout.decode()  )






							@require_torch
							def 				_lowerCamelCase		(						self  ):
														# python one-liner segments
														# this must be loaded before socket.socket is monkey-patched
														UpperCamelCase__				     =			"""
from transformers import BertConfig, BertModel, BertTokenizer, pipeline
        """

														UpperCamelCase__				     =			"""
mname = \"hf-internal-testing/tiny-random-bert\"
BertConfig.from_pretrained(mname)
BertModel.from_pretrained(mname)
BertTokenizer.from_pretrained(mname)
pipe = pipeline(task=\"fill-mask\", model=mname)
print(\"success\")
        """

														UpperCamelCase__				     =			"""
import socket
def offline_socket(*args, **kwargs): raise socket.error(\"Faking flaky internet\")
socket.socket = offline_socket
        """

														# Force fetching the files so that we can use the cache
														UpperCamelCase__				     =			"""hf-internal-testing/tiny-random-bert"""
														BertConfig.from_pretrained(__lowerCAmelCase  )
														BertModel.from_pretrained(__lowerCAmelCase  )
														BertTokenizer.from_pretrained(__lowerCAmelCase  )
														pipeline(task="""fill-mask"""  , model=__lowerCAmelCase  )

														# baseline - just load from_pretrained with normal network
														UpperCamelCase__				     =			[sys.executable, """-c""", """\n""".join([load, run, mock]  )]

														# should succeed
														UpperCamelCase__				     =			self.get_env()
														UpperCamelCase__				     =			subprocess.run(__lowerCAmelCase  , env=__lowerCAmelCase  , check=__lowerCAmelCase  , capture_output=__lowerCAmelCase  )
														self.assertEqual(result.returncode  , 0  , result.stderr  )
														self.assertIn("""success"""  , result.stdout.decode()  )






							@require_torch
							def 				_lowerCamelCase		(						self  ):
														# this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
														# `transformers` is loaded, and it's too late for inside pytest - so we are changing it
														# while running an external program

														# python one-liner segments

														# this must be loaded before socket.socket is monkey-patched
														UpperCamelCase__				     =			"""
from transformers import BertConfig, BertModel, BertTokenizer
        """

														UpperCamelCase__				     =			"""
mname = \"hf-internal-testing/tiny-random-bert-sharded\"
BertConfig.from_pretrained(mname)
BertModel.from_pretrained(mname)
print(\"success\")
        """

														UpperCamelCase__				     =			"""
import socket
def offline_socket(*args, **kwargs): raise ValueError(\"Offline mode is enabled\")
socket.socket = offline_socket
        """

														# baseline - just load from_pretrained with normal network
														UpperCamelCase__				     =			[sys.executable, """-c""", """\n""".join([load, run]  )]

														# should succeed
														UpperCamelCase__				     =			self.get_env()
														UpperCamelCase__				     =			subprocess.run(__lowerCAmelCase  , env=__lowerCAmelCase  , check=__lowerCAmelCase  , capture_output=__lowerCAmelCase  )
														self.assertEqual(result.returncode  , 0  , result.stderr  )
														self.assertIn("""success"""  , result.stdout.decode()  )

														# next emulate no network
														UpperCamelCase__				     =			[sys.executable, """-c""", """\n""".join([load, mock, run]  )]

														# Doesn't fail anymore since the model is in the cache due to other tests, so commenting this.
														# env["TRANSFORMERS_OFFLINE"] = "0"
														# result = subprocess.run(cmd, env=env, check=False, capture_output=True)
														# self.assertEqual(result.returncode, 1, result.stderr)

														# should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
														UpperCamelCase__				     =			"""1"""
														UpperCamelCase__				     =			subprocess.run(__lowerCAmelCase  , env=__lowerCAmelCase  , check=__lowerCAmelCase  , capture_output=__lowerCAmelCase  )
														self.assertEqual(result.returncode  , 0  , result.stderr  )
														self.assertIn("""success"""  , result.stdout.decode()  )






							@require_torch
							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			"""
from transformers import pipeline
        """
														UpperCamelCase__				     =			"""
mname = \"hf-internal-testing/tiny-random-bert\"
pipe = pipeline(model=mname)
        """

														UpperCamelCase__				     =			"""
import socket
def offline_socket(*args, **kwargs): raise socket.error(\"Offline mode is enabled\")
socket.socket = offline_socket
        """
														UpperCamelCase__				     =			self.get_env()
														UpperCamelCase__				     =			"""1"""
														UpperCamelCase__				     =			[sys.executable, """-c""", """\n""".join([load, mock, run]  )]
														UpperCamelCase__				     =			subprocess.run(__lowerCAmelCase  , env=__lowerCAmelCase  , check=__lowerCAmelCase  , capture_output=__lowerCAmelCase  )
														self.assertEqual(result.returncode  , 1  , result.stderr  )
														self.assertIn(
														    """You cannot infer task automatically within `pipeline` when using offline mode"""  , result.stderr.decode().replace("""\n"""  , """"""  )  , )







							@require_torch
							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			"""
from transformers import AutoModel
        """
														UpperCamelCase__				     =			"""
mname = \"hf-internal-testing/test_dynamic_model\"
AutoModel.from_pretrained(mname, trust_remote_code=True)
print(\"success\")
        """

														# baseline - just load from_pretrained with normal network
														UpperCamelCase__				     =			[sys.executable, """-c""", """\n""".join([load, run]  )]

														# should succeed
														UpperCamelCase__				     =			self.get_env()
														UpperCamelCase__				     =			subprocess.run(__lowerCAmelCase  , env=__lowerCAmelCase  , check=__lowerCAmelCase  , capture_output=__lowerCAmelCase  )
														self.assertEqual(result.returncode  , 0  , result.stderr  )
														self.assertIn("""success"""  , result.stdout.decode()  )

														# should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
														UpperCamelCase__				     =			"""1"""
														UpperCamelCase__				     =			subprocess.run(__lowerCAmelCase  , env=__lowerCAmelCase  , check=__lowerCAmelCase  , capture_output=__lowerCAmelCase  )
														self.assertEqual(result.returncode  , 0  , result.stderr  )
														self.assertIn("""success"""  , result.stdout.decode()  )











import math





def     _UpperCamelCase     (a__   :int       ):






							"""simple docstring"""





							UpperCamelCase__				     =			[True] * n
							UpperCamelCase__				     =			False
							UpperCamelCase__				     =			False
							UpperCamelCase__				     =			True

							for i in range(3   ,			int(n**0.5 + 1       )   ,			2       ):
														UpperCamelCase__				     =			i * 2
														while index < n:
																					UpperCamelCase__				     =			False
																					UpperCamelCase__				     =			index + i

							UpperCamelCase__				     =			[2]

							for i in range(3   ,			a__   ,			2       ):
														if is_prime[i]:
																					primes.append(a__       )

							return primes





def     _UpperCamelCase     (a__   :int = 9999_6666_3333       ):






							"""simple docstring"""





							UpperCamelCase__				     =			math.floor(math.sqrt(a__       )       ) + 100
							UpperCamelCase__				     =			prime_sieve(a__       )

							UpperCamelCase__				     =			0
							UpperCamelCase__				     =			0
							UpperCamelCase__				     =			primes[prime_index]

							while (last_prime**2) <= limit:
														UpperCamelCase__				     =			primes[prime_index + 1]

														UpperCamelCase__				     =			last_prime**2
														UpperCamelCase__				     =			next_prime**2

														# Get numbers divisible by lps(current)
														UpperCamelCase__				     =			lower_bound + last_prime
														while upper_bound > current <= limit:
																					matches_sum += current
																					current += last_prime

														# Reset the upper_bound
														while (upper_bound - next_prime) > limit:
																					upper_bound -= next_prime

														# Add the numbers divisible by ups(current)
														UpperCamelCase__				     =			upper_bound - next_prime
														while current > lower_bound:
																					matches_sum += current
																					current -= next_prime

														# Remove the numbers divisible by both ups and lps
														UpperCamelCase__				     =			0
														while upper_bound > current <= limit:
																					if current <= lower_bound:
																												# Increment the current number
																												current += last_prime * next_prime
																												continue

																					if current > limit:
																												break

																					# Remove twice since it was added by both ups and lps
																					matches_sum -= current * 2

																					# Increment the current number
																					current += last_prime * next_prime

														# Setup for next pair
														UpperCamelCase__				     =			next_prime
														prime_index += 1

							return matches_sum


if __name__ == "__main__":
					print(solution())




