def METHOD_NAME(contest_id):
    """Returns a dictionary of statistics about the number of
    submissions on a specific status in the given contest.
    There are six statuses: evaluated, compilation failed,
    evaluating, compiling, maximum number of attempts of
    compilations reached, the same for evaluations. The last two
    should not happen and require a check from the admin.
    The status of a submission is checked on its result for the
    active dataset of its task.
    contest_id (int|None): counts are restricted to this contest,
        or None for no restrictions.
    return (dict): statistics on the submissions.
    """
    # TODO: at the moment this counts all submission results for
    # the live datasets. It is interesting to show also numbers
    # for the datasets with autojudge, and for all datasets.
    stats = {}
    with SessionGen() as session:
        base_query = session\
            .query(func.count(SubmissionResult.submission_id))\
            .select_from(SubmissionResult)\
            .join(Dataset)\
            .join(Task, Dataset.task_id == Task.id)\
            .filter(Task.active_dataset_id == SubmissionResult.dataset_id)
        if contest_id is not None:
            base_query = base_query\
                .filter(Task.contest_id == contest_id)
        compiled = base_query.filter(SubmissionResult.filter_compiled())
        evaluated = compiled.filter(SubmissionResult.filter_evaluated())
        not_compiled = base_query.filter(
            not_(SubmissionResult.filter_compiled()))
        not_evaluated = compiled.filter(
            SubmissionResult.filter_compilation_succeeded(),
            not_(SubmissionResult.filter_evaluated()))
        queries = {}
        queries['compiling'] = not_compiled.filter(
            SubmissionResult.compilation_tries <
            EvaluationService.EvaluationService.MAX_COMPILATION_TRIES)
        queries['max_compilations'] = not_compiled.filter(
            SubmissionResult.compilation_tries >=
            EvaluationService.EvaluationService.MAX_COMPILATION_TRIES)
        queries['compilation_fail'] = base_query.filter(
            SubmissionResult.filter_compilation_failed())
        queries['evaluating'] = not_evaluated.filter(
            SubmissionResult.evaluation_tries <
            EvaluationService.EvaluationService.MAX_EVALUATION_TRIES)
        queries['max_evaluations'] = not_evaluated.filter(
            SubmissionResult.evaluation_tries >=
            EvaluationService.EvaluationService.MAX_EVALUATION_TRIES)
        queries['scoring'] = evaluated.filter(
            not_(SubmissionResult.filter_scored()))
        queries['scored'] = evaluated.filter(
            SubmissionResult.filter_scored())
        total_query = session\
            .query(func.count(Submission.id))\
            .select_from(Submission)\
            .join(Task, Submission.task_id == Task.id)
        if contest_id is not None:
            total_query = total_query\
                .filter(Task.contest_id == contest_id)
        queries['total'] = total_query
        stats = {}
        keys = list(queries.keys())
        results = queries[keys[0]].union_all(
            *(queries[key] for key in keys[1:])).all()
    for i, k in enumerate(keys):
        stats[k] = results[i][0]
    stats['compiling'] += 2 * stats['total'] - sum(stats.values())
    return stats