# Path: hac/data.py
# class ISite(object):
#     """Site template.
#     """
# 
#     def __init__(self, name=None, id=None, url=None, time_limit_ms=2000,
#                  memory_limit_kbyte=262144, source_limit_kbyte=64):
#         self.name = name
#         self.id = id
#         # 'url' member used to distinguish between different sites.
#         self.url = url
#         self.time_limit_ms = time_limit_ms
#         self.memory_limit_kbyte = memory_limit_kbyte
#         self.source_limit_kbyte = source_limit_kbyte
# 
#         self._info = None
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url', 'time_limit_ms', 'memory_limit_kbyte',
#                 'source_limit_kbyte']
# 
#     @abstractmethod
#     def match_contest(self, conf):
#         """Generates well formated URL of the contest according to user input.
#         """
#         pass
# 
#     @abstractmethod
#     def get_contest(self, url):
#         """Fetches data from the provided contest URL and generates contest
#         object.
#         """
#         pass
# 
#     @abstractmethod
#     def match_problems(self, conf):
#         """Generates list of well formated problem URLs according to user
#         input.
#         """
#         pass
# 
#     @abstractmethod
#     def get_problems(self, urls):
#         """Fetches data from the provided problem URLs and generates list of
#         problem objects.
#         """
#         pass
# 
# class Contest(object):
#     """Contest info container.
#     """
# 
#     def __init__(self, name=None, id=None, url=None):
#         self.name = name
#         self.id = id
#         self.url = url
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url']
# 
# class Problem(object):
#     """Problem info container.
#     """
# 
#     def __init__(self, name=None, id=None, url=None, time_limit_ms=2000,
#                  memory_limit_kbyte=262144, source_limit_kbyte=64, inputs=None,
#                  outputs=None):
#         self.name = name
#         self.id = id
#         self.url = url
#         self.time_limit_ms = time_limit_ms
#         self.memory_limit_kbyte = memory_limit_kbyte
#         self.source_limit_kbyte = source_limit_kbyte
#         self.inputs = inputs or []
#         self.outputs = outputs or []
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url', 'time_limit_ms', 'memory_limit_kbyte',
#                 'source_limit_kbyte', 'inputs', 'outputs']
# 
# Path: hac/util_common.py
# def warn(msg):
#     sys.stderr.write("WARNING: " + msg + os.linesep)
# 
# Path: hac/util_data.py
# class RequestsCache(object):
# 
#     def __init__(self):
#         self._store = {}
# 
#     def get(self, url):
#         if url not in self._store:
#             self._store[url] = requests.get(url)
#         return self._store[url]


import os
import re
import sys
from lxml import html
    from urlparse import urlparse
    from urllib.parse import urlparse
from hac.data import ISite, Contest, Problem
from hac.util_common import warn
from hac.util_data import RequestsCache
            ids_available = [str(e.strip()) for e in e]

        ids = []
        # Match single problem from 'location'.
        location = urlparse(conf['location']).path or '/'
        tokens = SiteCodeforces.pattern_contest.search(location)
        if tokens is not None:
            id_raw = tokens.group('PROBLEM')
            id_problem = SiteCodeforces.resolve_problem_id(id_raw)
            if id_problem:
                ids.append(id_problem)

        # Match potentially multiple problems from 'problems'.
        for problem in conf['problems']:
            tokens = SiteCodeforces.pattern_problem.findall(problem)
            id_raw = tokens and tokens[-1]
            id_problem = SiteCodeforces.resolve_problem_id(id_raw)
            if id_problem:
                ids.append(id_problem)

        # If no problems are successfully manually selected, select them all.
        if not ids:
            ids = ids_available

        # Notify about selected but non-available problems.
        urls = []
        for id in ids:
            if id in ids_available:
                urls.append(url_template_problem.format(id))
            else:

# Path: hac/data.py
# class ISite(object):
#     """Site template.
#     """
# 
#     def __init__(self, name=None, id=None, url=None, time_limit_ms=2000,
#                  memory_limit_kbyte=262144, source_limit_kbyte=64):
#         self.name = name
#         self.id = id
#         # 'url' member used to distinguish between different sites.
#         self.url = url
#         self.time_limit_ms = time_limit_ms
#         self.memory_limit_kbyte = memory_limit_kbyte
#         self.source_limit_kbyte = source_limit_kbyte
# 
#         self._info = None
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url', 'time_limit_ms', 'memory_limit_kbyte',
#                 'source_limit_kbyte']
# 
#     @abstractmethod
#     def match_contest(self, conf):
#         """Generates well formated URL of the contest according to user input.
#         """
#         pass
# 
#     @abstractmethod
#     def get_contest(self, url):
#         """Fetches data from the provided contest URL and generates contest
#         object.
#         """
#         pass
# 
#     @abstractmethod
#     def match_problems(self, conf):
#         """Generates list of well formated problem URLs according to user
#         input.
#         """
#         pass
# 
#     @abstractmethod
#     def get_problems(self, urls):
#         """Fetches data from the provided problem URLs and generates list of
#         problem objects.
#         """
#         pass
# 
# class Contest(object):
#     """Contest info container.
#     """
# 
#     def __init__(self, name=None, id=None, url=None):
#         self.name = name
#         self.id = id
#         self.url = url
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url']
# 
# class Problem(object):
#     """Problem info container.
#     """
# 
#     def __init__(self, name=None, id=None, url=None, time_limit_ms=2000,
#                  memory_limit_kbyte=262144, source_limit_kbyte=64, inputs=None,
#                  outputs=None):
#         self.name = name
#         self.id = id
#         self.url = url
#         self.time_limit_ms = time_limit_ms
#         self.memory_limit_kbyte = memory_limit_kbyte
#         self.source_limit_kbyte = source_limit_kbyte
#         self.inputs = inputs or []
#         self.outputs = outputs or []
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url', 'time_limit_ms', 'memory_limit_kbyte',
#                 'source_limit_kbyte', 'inputs', 'outputs']
# 
# Path: hac/util_common.py
# def warn(msg):
#     sys.stderr.write("WARNING: " + msg + os.linesep)
# 
# Path: hac/util_data.py
# class RequestsCache(object):
# 
#     def __init__(self):
#         self._store = {}
# 
#     def get(self, url):
#         if url not in self._store:
#             self._store[url] = requests.get(url)
#         return self._store[url]


# Path: hac/config/site/codeforces.py
import os
import re
import sys
from lxml import html
    from urlparse import urlparse
    from urllib.parse import urlparse
from hac.data import ISite, Contest, Problem
from hac.util_common import warn
from hac.util_data import RequestsCache

            ids_available = [str(e.strip()) for e in e]

        ids = []
        # Match single problem from 'location'.
        location = urlparse(conf['location']).path or '/'
        tokens = SiteCodeforces.pattern_contest.search(location)
        if tokens is not None:
            id_raw = tokens.group('PROBLEM')
            id_problem = SiteCodeforces.resolve_problem_id(id_raw)
            if id_problem:
                ids.append(id_problem)

        # Match potentially multiple problems from 'problems'.
        for problem in conf['problems']:
            tokens = SiteCodeforces.pattern_problem.findall(problem)
            id_raw = tokens and tokens[-1]
            id_problem = SiteCodeforces.resolve_problem_id(id_raw)
            if id_problem:
                ids.append(id_problem)

        # If no problems are successfully manually selected, select them all.
        if not ids:
            ids = ids_available

        # Notify about selected but non-available problems.
        urls = []
        for id in ids:
            if id in ids_available:
                urls.append(url_template_problem.format(id))
            else:

                warn('Problem "' + id + '" does not exist in ' + url_contest)