# Path: misc/numerical.py
# INF = float('inf')


from collections import Iterator
from itertools import islice
from .numerical import INF
  return islice(iterable, n)

class GeneratorWrapper(Iterator):
  def __init__(self, generator):
    self.generator = generator
  def next(self):
    return self.generator.next()
  def __call__(self):
    return self.next()

class SafeGeneratorWrapper(GeneratorWrapper):
  def __init__(self, generator):
    self.generator = generator
    self.stop = False
    self.generations = 0
  def __iter__(self):
    while True:
      result = self.next()
      if result is False: break
      yield result
  def next(self):
    try:
      result = self.generator.next()
      assert result is not False
      self.generations += 1
      return result
    except StopIteration:
      self.stop = True
      return False


# Path: misc/numerical.py
# INF = float('inf')


# Path: misc/generators.py
from collections import Iterator
from itertools import islice
from .numerical import INF

  return islice(iterable, n)

class GeneratorWrapper(Iterator):
  def __init__(self, generator):
    self.generator = generator
  def next(self):
    return self.generator.next()
  def __call__(self):
    return self.next()

class SafeGeneratorWrapper(GeneratorWrapper):
  def __init__(self, generator):
    self.generator = generator
    self.stop = False
    self.generations = 0
  def __iter__(self):
    while True:
      result = self.next()
      if result is False: break
      yield result
  def next(self):
    try:
      result = self.generator.next()
      assert result is not False
      self.generations += 1
      return result
    except StopIteration:
      self.stop = True
      return False


class Counter(Iterator):