broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(teams):
    names = sorted(teams)
    n = len(names)
    def value(t, cat):
        d = teams[t]
        if cat in ('hr', 'sb'):
            return Fraction(d[cat])
        if d['outs'] == 0:
            return None
        if cat == 'era':
            return Fraction(d['er'] * 27 // d['outs'])
        return Fraction((d['bb'] + d['h']) * 3, d['outs'])
    total = {t: 0 for t in names}
    for cat in ('hr', 'sb', 'era', 'whip'):
        low = cat in ('era', 'whip')
        def key(t):
            v = value(t, cat)
            if v is None:
                return (1, 0)
            return (0, v if low else -v)
        ranked = sorted(names, key=key)
        i = 0
        while i < n:
            j = i
            while j < n and key(ranked[j]) == key(ranked[i]):
                j += 1
            pts2 = sum(2 * (n - r) for r in range(i, j)) // (j - i)
            for t in ranked[i:j]:
                total[t] += pts2
            i = j
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: ratio precision',
   [{'R0': {'bb': 9, 'er': 11, 'h': 21, 'hr': 15, 'outs': 60, 'sb': 5},
     'R1': {'bb': 5, 'er': 3, 'h': 1, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 6, 'er': 2, 'h': 1, 'hr': 15, 'outs': 81, 'sb': 8},
     'R3': {'bb': 3, 'er': 13, 'h': 9, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 15, 'R1': 17, 'R2': 31, 'R3': 17}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 1, 'er': 8, 'h': 16, 'hr': 12, 'outs': 63, 'sb': 3},
     'R1': {'bb': 8, 'er': 3, 'h': 3, 'hr': 15, 'outs': 73, 'sb': 3},
     'R2': {'bb': 3, 'er': 2, 'h': 12, 'hr': 10, 'outs': 48, 'sb': 5},
     'R3': {'bb': 6, 'er': 8, 'h': 16, 'hr': 10, 'outs': 0, 'sb': 5},
     'R4': {'bb': 10, 'er': 7, 'h': 18, 'hr': 10, 'outs': 30, 'sb': 8}}],
   {'R0': 25, 'R1': 33, 'R2': 25, 'R3': 15, 'R4': 22}),
  ('second regression',
   [{'R0': {'bb': 6, 'er': 11, 'h': 3, 'hr': 10, 'outs': 54, 'sb': 8},
     'R1': {'bb': 6, 'er': 10, 'h': 10, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 3, 'er': 14, 'h': 23, 'hr': 12, 'outs': 81, 'sb': 5},
     'R3': {'bb': 6, 'er': 5, 'h': 2, 'hr': 12, 'outs': 54, 'sb': 3},
     'R4': {'bb': 10, 'er': 8, 'h': 19, 'hr': 10, 'outs': 27, 'sb': 3},
     'R5': {'bb': 2, 'er': 12, 'h': 15, 'hr': 10, 'outs': 49, 'sb': 3}}],
   {'R0': 32, 'R1': 35, 'R2': 35, 'R3': 38, 'R4': 12, 'R5': 16}),
  ('normal control 1',
   [{'R0': {'bb': 2, 'er': 13, 'h': 9, 'hr': 15, 'outs': 30, 'sb': 8},
     'R1': {'bb': 4, 'er': 0, 'h': 21, 'hr': 10, 'outs': 27, 'sb': 5},
     'R2': {'bb': 5, 'er': 5, 'h': 6, 'hr': 10, 'outs': 81, 'sb': 3},
     'R3': {'bb': 4, 'er': 4, 'h': 3, 'hr': 10, 'outs': 0, 'sb': 5}}],
   {'R0': 26, 'R1': 21, 'R2': 20, 'R3': 13}),
  ('normal control 2',
   [{'R0': {'bb': 9, 'er': 12, 'h': 18, 'hr': 15, 'outs': 48, 'sb': 8},
     'R1': {'bb': 0, 'er': 9, 'h': 0, 'hr': 15, 'outs': 81, 'sb': 3},
     'R2': {'bb': 8, 'er': 11, 'h': 11, 'hr': 12, 'outs': 0, 'sb': 3},
     'R3': {'bb': 8, 'er': 1, 'h': 2, 'hr': 12, 'outs': 81, 'sb': 3},
     'R4': {'bb': 10, 'er': 8, 'h': 24, 'hr': 12, 'outs': 30, 'sb': 5},
     'R5': {'bb': 6, 'er': 5, 'h': 5, 'hr': 12, 'outs': 0, 'sb': 8}}],
   {'R0': 38, 'R1': 37, 'R2': 15, 'R3': 31, 'R4': 25, 'R5': 22}),
  ('normal control 3',
   [{'R0': {'bb': 4, 'er': 7, 'h': 3, 'hr': 10, 'outs': 0, 'sb': 5},
     'R1': {'bb': 8, 'er': 2, 'h': 6, 'hr': 15, 'outs': 0, 'sb': 8},
     'R2': {'bb': 3, 'er': 12, 'h': 24, 'hr': 10, 'outs': 81, 'sb': 8},
     'R3': {'bb': 6, 'er': 0, 'h': 15, 'hr': 12, 'outs': 0, 'sb': 5},
     'R4': {'bb': 7, 'er': 12, 'h': 2, 'hr': 12, 'outs': 27, 'sb': 3}}],
   {'R0': 16, 'R1': 27, 'R2': 31, 'R3': 20, 'R4': 26}),
  ('normal control 4',
   [{'R0': {'bb': 0, 'er': 2, 'h': 12, 'hr': 10, 'outs': 54, 'sb': 5},
     'R1': {'bb': 5, 'er': 12, 'h': 23, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 3, 'er': 9, 'h': 23, 'hr': 15, 'outs': 0, 'sb': 3},
     'R3': {'bb': 3, 'er': 10, 'h': 25, 'hr': 15, 'outs': 0, 'sb': 5}}],
   {'R0': 24, 'R1': 22, 'R2': 15, 'R3': 19})],
 [('regression: ratio precision',
   [{'R0': {'bb': 8, 'er': 6, 'h': 7, 'hr': 12, 'outs': 90, 'sb': 5},
     'R1': {'bb': 6, 'er': 2, 'h': 14, 'hr': 12, 'outs': 81, 'sb': 3},
     'R2': {'bb': 9, 'er': 7, 'h': 13, 'hr': 12, 'outs': 81, 'sb': 5},
     'R3': {'bb': 5, 'er': 1, 'h': 0, 'hr': 12, 'outs': 30, 'sb': 8}}],
   {'R0': 21, 'R1': 19, 'R2': 14, 'R3': 26}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 6, 'er': 8, 'h': 14, 'hr': 15, 'outs': 71, 'sb': 5},
     'R1': {'bb': 3, 'er': 5, 'h': 24, 'hr': 10, 'outs': 27, 'sb': 5},
     'R2': {'bb': 8, 'er': 6, 'h': 9, 'hr': 15, 'outs': 54, 'sb': 3},
     'R3': {'bb': 10, 'er': 10, 'h': 16, 'hr': 12, 'outs': 30, 'sb': 5},
     'R4': {'bb': 1, 'er': 13, 'h': 24, 'hr': 12, 'outs': 27, 'sb': 5}}],
   {'R0': 34, 'R1': 17, 'R2': 29, 'R3': 22, 'R4': 18}),
  ('second regression',
   [{'R0': {'bb': 6, 'er': 5, 'h': 23, 'hr': 12, 'outs': 27, 'sb': 8},
     'R1': {'bb': 1, 'er': 6, 'h': 16, 'hr': 15, 'outs': 27, 'sb': 5},
     'R2': {'bb': 10, 'er': 7, 'h': 14, 'hr': 12, 'outs': 30, 'sb': 8},
     'R3': {'bb': 10, 'er': 1, 'h': 12, 'hr': 15, 'outs': 83, 'sb': 8},
     'R4': {'bb': 8, 'er': 10, 'h': 5, 'hr': 10, 'outs': 30, 'sb': 5}}],
   {'R0': 23, 'R1': 24, 'R2': 21, 'R3': 37, 'R4': 15}),
  ('normal control 1',
   [{'R0': {'bb': 2, 'er': 13, 'h': 11, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 10, 'er': 7, 'h': 4, 'hr': 12, 'outs': 81, 'sb': 3},
     'R2': {'bb': 8, 'er': 3, 'h': 20, 'hr': 10, 'outs': 18, 'sb': 5},
     'R3': {'bb': 9, 'er': 0, 'h': 20, 'hr': 10, 'outs': 81, 'sb': 3},
     'R4': {'bb': 3, 'er': 14, 'h': 5, 'hr': 12, 'outs': 0, 'sb': 8},
     'R5': {'bb': 7, 'er': 0, 'h': 4, 'hr': 12, 'outs': 30, 'sb': 8}}],
   {'R0': 22, 'R1': 32, 'R2': 22, 'R3': 27, 'R4': 26, 'R5': 39}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 8, 'h': 7, 'hr': 10, 'outs': 36, 'sb': 5},
     'R1': {'bb': 1, 'er': 1, 'h': 20, 'hr': 10, 'outs': 54, 'sb': 8},
     'R2': {'bb': 5, 'er': 9, 'h': 11, 'hr': 10, 'outs': 0, 'sb': 5},
     'R3': {'bb': 9, 'er': 14, 'h': 22, 'hr': 15, 'outs': 21, 'sb': 8}}],
   {'R0': 21, 'R1': 25, 'R2': 11, 'R3': 23}),
  ('normal control 3',
   [{'R0': {'bb': 8, 'er': 1, 'h': 8, 'hr': 10, 'outs': 30, 'sb': 8},
     'R1': {'bb': 9, 'er': 10, 'h': 12, 'hr': 12, 'outs': 12, 'sb': 5},
     'R2': {'bb': 10, 'er': 4, 'h': 3, 'hr': 12, 'outs': 30, 'sb': 3},
     'R3': {'bb': 5, 'er': 4, 'h': 14, 'hr': 10, 'outs': 16, 'sb': 5},
     'R4': {'bb': 6, 'er': 6, 'h': 22, 'hr': 15, 'outs': 30, 'sb': 8},
     'R5': {'bb': 1, 'er': 12, 'h': 2, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 34, 'R1': 18, 'R2': 30, 'R3': 17, 'R4': 35, 'R5': 34}),
  ('normal control 4',
   [{'R0': {'bb': 1, 'er': 6, 'h': 24, 'hr': 12, 'outs': 0, 'sb': 8},
     'R1': {'bb': 3, 'er': 0, 'h': 4, 'hr': 10, 'outs': 27, 'sb': 5},
     'R2': {'bb': 2, 'er': 4, 'h': 22, 'hr': 15, 'outs': 0, 'sb': 3},
     'R3': {'bb': 10, 'er': 9, 'h': 0, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 19, 'R1': 21, 'R2': 16, 'R3': 24})],
 [('regression: ratio precision',
   [{'R0': {'bb': 8, 'er': 7, 'h': 22, 'hr': 12, 'outs': 81, 'sb': 3},
     'R1': {'bb': 8, 'er': 6, 'h': 24, 'hr': 12, 'outs': 81, 'sb': 5},
     'R2': {'bb': 3, 'er': 11, 'h': 17, 'hr': 15, 'outs': 54, 'sb': 3},
     'R3': {'bb': 3, 'er': 9, 'h': 8, 'hr': 12, 'outs': 35, 'sb': 8}}],
   {'R0': 18, 'R1': 20, 'R2': 20, 'R3': 22}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 2, 'er': 9, 'h': 2, 'hr': 12, 'outs': 81, 'sb': 8},
     'R1': {'bb': 2, 'er': 6, 'h': 1, 'hr': 15, 'outs': 0, 'sb': 5},
     'R2': {'bb': 9, 'er': 9, 'h': 4, 'hr': 12, 'outs': 82, 'sb': 5},
     'R3': {'bb': 1, 'er': 6, 'h': 10, 'hr': 10, 'outs': 27, 'sb': 3},
     'R4': {'bb': 8, 'er': 11, 'h': 6, 'hr': 12, 'outs': 27, 'sb': 8},
     'R5': {'bb': 1, 'er': 14, 'h': 16, 'hr': 15, 'outs': 54, 'sb': 8}}],
   {'R0': 38, 'R1': 20, 'R2': 33, 'R3': 18, 'R4': 24, 'R5': 35}),
  ('second regression',
   [{'R0': {'bb': 2, 'er': 11, 'h': 11, 'hr': 12, 'outs': 81, 'sb': 8},
     'R1': {'bb': 0, 'er': 7, 'h': 2, 'hr': 15, 'outs': 54, 'sb': 3},
     'R2': {'bb': 6, 'er': 5, 'h': 9, 'hr': 12, 'outs': 30, 'sb': 5}}],
   {'R0': 17, 'R1': 20, 'R2': 11}),
  ('normal control 1',
   [{'R0': {'bb': 1, 'er': 12, 'h': 5, 'hr': 12, 'outs': 4, 'sb': 8},
     'R1': {'bb': 10, 'er': 5, 'h': 22, 'hr': 12, 'outs': 30, 'sb': 3},
     'R2': {'bb': 7, 'er': 5, 'h': 12, 'hr': 12, 'outs': 0, 'sb': 3},
     'R3': {'bb': 9, 'er': 1, 'h': 15, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 8, 'er': 4, 'h': 5, 'hr': 12, 'outs': 0, 'sb': 5},
     'R5': {'bb': 6, 'er': 8, 'h': 13, 'hr': 15, 'outs': 0, 'sb': 5}}],
   {'R0': 34, 'R1': 29, 'R2': 17, 'R3': 38, 'R4': 22, 'R5': 28}),
  ('normal control 2',
   [{'R0': {'bb': 0, 'er': 8, 'h': 20, 'hr': 12, 'outs': 8, 'sb': 5},
     'R1': {'bb': 2, 'er': 11, 'h': 15, 'hr': 12, 'outs': 27, 'sb': 5},
     'R2': {'bb': 4, 'er': 4, 'h': 3, 'hr': 12, 'outs': 81, 'sb': 3},
     'R3': {'bb': 7, 'er': 1, 'h': 15, 'hr': 12, 'outs': 81, 'sb': 3},
     'R4': {'bb': 4, 'er': 6, 'h': 3, 'hr': 12, 'outs': 0, 'sb': 8},
     'R5': {'bb': 9, 'er': 14, 'h': 18, 'hr': 12, 'outs': 27, 'sb': 3}}],
   {'R0': 24, 'R1': 32, 'R2': 33, 'R3': 33, 'R4': 23, 'R5': 23}),
  ('normal control 3',
   [{'R0': {'bb': 4, 'er': 14, 'h': 19, 'hr': 12, 'outs': 30, 'sb': 5},
     'R1': {'bb': 3, 'er': 3, 'h': 13, 'hr': 12, 'outs': 27, 'sb': 8},
     'R2': {'bb': 0, 'er': 7, 'h': 20, 'hr': 10, 'outs': 33, 'sb': 5},
     'R3': {'bb': 5, 'er': 7, 'h': 17, 'hr': 10, 'outs': 27, 'sb': 8},
     'R4': {'bb': 7, 'er': 11, 'h': 17, 'hr': 12, 'outs': 20, 'sb': 3}}],
   {'R0': 23, 'R1': 37, 'R2': 24, 'R3': 22, 'R4': 14}),
  ('normal control 4',
   [{'R0': {'bb': 9, 'er': 4, 'h': 14, 'hr': 10, 'outs': 0, 'sb': 8},
     'R1': {'bb': 2, 'er': 0, 'h': 6, 'hr': 10, 'outs': 27, 'sb': 5},
     'R2': {'bb': 6, 'er': 5, 'h': 2, 'hr': 12, 'outs': 30, 'sb': 3},
     'R3': {'bb': 4, 'er': 11, 'h': 19, 'hr': 12, 'outs': 81, 'sb': 3}}],
   {'R0': 15, 'R1': 21, 'R2': 22, 'R3': 22})],
 [('regression: ratio precision',
   [{'R0': {'bb': 4, 'er': 2, 'h': 19, 'hr': 15, 'outs': 65, 'sb': 5},
     'R1': {'bb': 0, 'er': 12, 'h': 21, 'hr': 10, 'outs': 54, 'sb': 3},
     'R2': {'bb': 4, 'er': 2, 'h': 7, 'hr': 15, 'outs': 27, 'sb': 3},
     'R3': {'bb': 5, 'er': 5, 'h': 23, 'hr': 15, 'outs': 54, 'sb': 5},
     'R4': {'bb': 2, 'er': 9, 'h': 3, 'hr': 12, 'outs': 9, 'sb': 3}}],
   {'R0': 37, 'R1': 18, 'R2': 26, 'R3': 27, 'R4': 12}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 1, 'er': 5, 'h': 0, 'hr': 10, 'outs': 81, 'sb': 5},
     'R1': {'bb': 4, 'er': 8, 'h': 15, 'hr': 15, 'outs': 0, 'sb': 3},
     'R2': {'bb': 6, 'er': 1, 'h': 13, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 1, 'er': 8, 'h': 7, 'hr': 12, 'outs': 54, 'sb': 5},
     'R4': {'bb': 6, 'er': 7, 'h': 4, 'hr': 12, 'outs': 40, 'sb': 3},
     'R5': {'bb': 6, 'er': 14, 'h': 1, 'hr': 12, 'outs': 81, 'sb': 8}}],
   {'R0': 32, 'R1': 19, 'R2': 31, 'R3': 31, 'R4': 20, 'R5': 35}),
  ('second regression',
   [{'R0': {'bb': 0, 'er': 1, 'h': 0, 'hr': 12, 'outs': 27, 'sb': 5},
     'R1': {'bb': 9, 'er': 5, 'h': 25, 'hr': 15, 'outs': 81, 'sb': 5},
     'R2': {'bb': 1, 'er': 12, 'h': 23, 'hr': 15, 'outs': 0, 'sb': 8}}],
   {'R0': 17, 'R1': 16, 'R2': 15}),
  ('normal control 1',
   [{'R0': {'bb': 9, 'er': 14, 'h': 22, 'hr': 12, 'outs': 30, 'sb': 3},
     'R1': {'bb': 10, 'er': 7, 'h': 19, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 9, 'er': 14, 'h': 1, 'hr': 12, 'outs': 54, 'sb': 5}}],
   {'R0': 14, 'R1': 13, 'R2': 21}),
  ('normal control 2',
   [{'R0': {'bb': 8, 'er': 3, 'h': 21, 'hr': 12, 'outs': 81, 'sb': 5},
     'R1': {'bb': 3, 'er': 11, 'h': 25, 'hr': 10, 'outs': 50, 'sb': 5},
     'R2': {'bb': 7, 'er': 0, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 5},
     'R3': {'bb': 2, 'er': 4, 'h': 24, 'hr': 12, 'outs': 0, 'sb': 3},
     'R4': {'bb': 4, 'er': 14, 'h': 16, 'hr': 15, 'outs': 0, 'sb': 5}}],
   {'R0': 29, 'R1': 21, 'R2': 33, 'R3': 14, 'R4': 23}),
  ('normal control 3',
   [{'R0': {'bb': 0, 'er': 1, 'h': 13, 'hr': 15, 'outs': 55, 'sb': 5},
     'R1': {'bb': 10, 'er': 1, 'h': 16, 'hr': 10, 'outs': 27, 'sb': 3},
     'R2': {'bb': 3, 'er': 5, 'h': 5, 'hr': 10, 'outs': 54, 'sb': 8},
     'R3': {'bb': 2, 'er': 7, 'h': 18, 'hr': 12, 'outs': 27, 'sb': 5}}],
   {'R0': 27, 'R1': 13, 'R2': 23, 'R3': 17}),
  ('normal control 4',
   [{'R0': {'bb': 8, 'er': 11, 'h': 20, 'hr': 15, 'outs': 30, 'sb': 8},
     'R1': {'bb': 5, 'er': 3, 'h': 14, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 7, 'er': 13, 'h': 22, 'hr': 12, 'outs': 30, 'sb': 5}}],
   {'R0': 20, 'R1': 18, 'R2': 10})],
 [('regression: ratio precision',
   [{'R0': {'bb': 9, 'er': 5, 'h': 21, 'hr': 10, 'outs': 81, 'sb': 8},
     'R1': {'bb': 6, 'er': 7, 'h': 15, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 6, 'er': 6, 'h': 25, 'hr': 15, 'outs': 54, 'sb': 3},
     'R3': {'bb': 3, 'er': 4, 'h': 14, 'hr': 12, 'outs': 30, 'sb': 5},
     'R4': {'bb': 6, 'er': 6, 'h': 17, 'hr': 15, 'outs': 30, 'sb': 8}}],
   {'R0': 31, 'R1': 16, 'R2': 25, 'R3': 24, 'R4': 24}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 2, 'er': 14, 'h': 3, 'hr': 15, 'outs': 86, 'sb': 5},
     'R1': {'bb': 1, 'er': 6, 'h': 5, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 8, 'er': 9, 'h': 8, 'hr': 15, 'outs': 82, 'sb': 5},
     'R3': {'bb': 7, 'er': 1, 'h': 9, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 7, 'er': 14, 'h': 20, 'hr': 12, 'outs': 18, 'sb': 5}}],
   {'R0': 29, 'R1': 24, 'R2': 29, 'R3': 24, 'R4': 14}),
  ('second regression',
   [{'R0': {'bb': 0, 'er': 12, 'h': 12, 'hr': 12, 'outs': 30, 'sb': 5},
     'R1': {'bb': 5, 'er': 14, 'h': 15, 'hr': 12, 'outs': 32, 'sb': 5},
     'R2': {'bb': 10, 'er': 0, 'h': 7, 'hr': 10, 'outs': 30, 'sb': 5},
     'R3': {'bb': 9, 'er': 1, 'h': 21, 'hr': 12, 'outs': 30, 'sb': 5},
     'R4': {'bb': 8, 'er': 7, 'h': 15, 'hr': 12, 'outs': 81, 'sb': 5},
     'R5': {'bb': 1, 'er': 1, 'h': 9, 'hr': 10, 'outs': 81, 'sb': 3}}],
   {'R0': 29, 'R1': 23, 'R2': 29, 'R3': 27, 'R4': 33, 'R5': 27}),
  ('normal control 1',
   [{'R0': {'bb': 10, 'er': 6, 'h': 21, 'hr': 10, 'outs': 0, 'sb': 3},
     'R1': {'bb': 5, 'er': 10, 'h': 16, 'hr': 15, 'outs': 54, 'sb': 5},
     'R2': {'bb': 3, 'er': 9, 'h': 24, 'hr': 15, 'outs': 27, 'sb': 3}}],
   {'R0': 9, 'R1': 23, 'R2': 16}),
  ('normal control 2',
   [{'R0': {'bb': 8, 'er': 14, 'h': 6, 'hr': 15, 'outs': 27, 'sb': 5},
     'R1': {'bb': 9, 'er': 8, 'h': 20, 'hr': 15, 'outs': 0, 'sb': 8},
     'R2': {'bb': 1, 'er': 10, 'h': 1, 'hr': 12, 'outs': 78, 'sb': 3}}],
   {'R0': 17, 'R1': 15, 'R2': 16}),
  ('normal control 3',
   [{'R0': {'bb': 2, 'er': 13, 'h': 0, 'hr': 15, 'outs': 81, 'sb': 8},
     'R1': {'bb': 2, 'er': 0, 'h': 12, 'hr': 12, 'outs': 16, 'sb': 3},
     'R2': {'bb': 2, 'er': 3, 'h': 8, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 22, 'R1': 15, 'R2': 11}),
  ('normal control 4',
   [{'R0': {'bb': 7, 'er': 2, 'h': 22, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 9, 'er': 11, 'h': 25, 'hr': 10, 'outs': 30, 'sb': 5},
     'R2': {'bb': 2, 'er': 5, 'h': 0, 'hr': 10, 'outs': 81, 'sb': 3},
     'R3': {'bb': 7, 'er': 3, 'h': 13, 'hr': 12, 'outs': 30, 'sb': 3},
     'R4': {'bb': 2, 'er': 14, 'h': 5, 'hr': 15, 'outs': 10, 'sb': 3},
     'R5': {'bb': 4, 'er': 8, 'h': 0, 'hr': 12, 'outs': 30, 'sb': 8}}],
   {'R0': 21, 'R1': 22, 'R2': 31, 'R3': 30, 'R4': 26, 'R5': 38})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(teams):
    names = sorted(teams)
    n = len(names)
    def value(t, cat):
        d = teams[t]
        if cat in ('hr', 'sb'):
            return Fraction(d[cat])
        if d['outs'] == 0:
            return None
        if cat == 'era':
            return Fraction(round(d['er'] * 27 / d['outs'], 1))
        return Fraction((d['bb'] + d['h']) * 3, d['outs'])
    total = {t: 0 for t in names}
    for cat in ('hr', 'sb', 'era', 'whip'):
        low = cat in ('era', 'whip')
        def key(t):
            v = value(t, cat)
            if v is None:
                return (1, 0)
            return (0, v if low else -v)
        ranked = sorted(names, key=key)
        i = 0
        while i < n:
            j = i
            while j < n and key(ranked[j]) == key(ranked[i]):
                j += 1
            pts2 = sum(2 * (n - r) for r in range(i, j)) // (j - i)
            for t in ranked[i:j]:
                total[t] += pts2
            i = j
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: ratio precision',
   [{'R0': {'bb': 9, 'er': 11, 'h': 21, 'hr': 15, 'outs': 60, 'sb': 5},
     'R1': {'bb': 5, 'er': 3, 'h': 1, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 6, 'er': 2, 'h': 1, 'hr': 15, 'outs': 81, 'sb': 8},
     'R3': {'bb': 3, 'er': 13, 'h': 9, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 15, 'R1': 17, 'R2': 31, 'R3': 17}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 1, 'er': 8, 'h': 16, 'hr': 12, 'outs': 63, 'sb': 3},
     'R1': {'bb': 8, 'er': 3, 'h': 3, 'hr': 15, 'outs': 73, 'sb': 3},
     'R2': {'bb': 3, 'er': 2, 'h': 12, 'hr': 10, 'outs': 48, 'sb': 5},
     'R3': {'bb': 6, 'er': 8, 'h': 16, 'hr': 10, 'outs': 0, 'sb': 5},
     'R4': {'bb': 10, 'er': 7, 'h': 18, 'hr': 10, 'outs': 30, 'sb': 8}}],
   {'R0': 25, 'R1': 33, 'R2': 25, 'R3': 15, 'R4': 22}),
  ('second regression',
   [{'R0': {'bb': 6, 'er': 11, 'h': 3, 'hr': 10, 'outs': 54, 'sb': 8},
     'R1': {'bb': 6, 'er': 10, 'h': 10, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 3, 'er': 14, 'h': 23, 'hr': 12, 'outs': 81, 'sb': 5},
     'R3': {'bb': 6, 'er': 5, 'h': 2, 'hr': 12, 'outs': 54, 'sb': 3},
     'R4': {'bb': 10, 'er': 8, 'h': 19, 'hr': 10, 'outs': 27, 'sb': 3},
     'R5': {'bb': 2, 'er': 12, 'h': 15, 'hr': 10, 'outs': 49, 'sb': 3}}],
   {'R0': 32, 'R1': 35, 'R2': 35, 'R3': 38, 'R4': 12, 'R5': 16}),
  ('normal control 1',
   [{'R0': {'bb': 2, 'er': 13, 'h': 9, 'hr': 15, 'outs': 30, 'sb': 8},
     'R1': {'bb': 4, 'er': 0, 'h': 21, 'hr': 10, 'outs': 27, 'sb': 5},
     'R2': {'bb': 5, 'er': 5, 'h': 6, 'hr': 10, 'outs': 81, 'sb': 3},
     'R3': {'bb': 4, 'er': 4, 'h': 3, 'hr': 10, 'outs': 0, 'sb': 5}}],
   {'R0': 26, 'R1': 21, 'R2': 20, 'R3': 13}),
  ('normal control 2',
   [{'R0': {'bb': 9, 'er': 12, 'h': 18, 'hr': 15, 'outs': 48, 'sb': 8},
     'R1': {'bb': 0, 'er': 9, 'h': 0, 'hr': 15, 'outs': 81, 'sb': 3},
     'R2': {'bb': 8, 'er': 11, 'h': 11, 'hr': 12, 'outs': 0, 'sb': 3},
     'R3': {'bb': 8, 'er': 1, 'h': 2, 'hr': 12, 'outs': 81, 'sb': 3},
     'R4': {'bb': 10, 'er': 8, 'h': 24, 'hr': 12, 'outs': 30, 'sb': 5},
     'R5': {'bb': 6, 'er': 5, 'h': 5, 'hr': 12, 'outs': 0, 'sb': 8}}],
   {'R0': 38, 'R1': 37, 'R2': 15, 'R3': 31, 'R4': 25, 'R5': 22}),
  ('normal control 3',
   [{'R0': {'bb': 4, 'er': 7, 'h': 3, 'hr': 10, 'outs': 0, 'sb': 5},
     'R1': {'bb': 8, 'er': 2, 'h': 6, 'hr': 15, 'outs': 0, 'sb': 8},
     'R2': {'bb': 3, 'er': 12, 'h': 24, 'hr': 10, 'outs': 81, 'sb': 8},
     'R3': {'bb': 6, 'er': 0, 'h': 15, 'hr': 12, 'outs': 0, 'sb': 5},
     'R4': {'bb': 7, 'er': 12, 'h': 2, 'hr': 12, 'outs': 27, 'sb': 3}}],
   {'R0': 16, 'R1': 27, 'R2': 31, 'R3': 20, 'R4': 26}),
  ('normal control 4',
   [{'R0': {'bb': 0, 'er': 2, 'h': 12, 'hr': 10, 'outs': 54, 'sb': 5},
     'R1': {'bb': 5, 'er': 12, 'h': 23, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 3, 'er': 9, 'h': 23, 'hr': 15, 'outs': 0, 'sb': 3},
     'R3': {'bb': 3, 'er': 10, 'h': 25, 'hr': 15, 'outs': 0, 'sb': 5}}],
   {'R0': 24, 'R1': 22, 'R2': 15, 'R3': 19})],
 [('regression: ratio precision',
   [{'R0': {'bb': 8, 'er': 6, 'h': 7, 'hr': 12, 'outs': 90, 'sb': 5},
     'R1': {'bb': 6, 'er': 2, 'h': 14, 'hr': 12, 'outs': 81, 'sb': 3},
     'R2': {'bb': 9, 'er': 7, 'h': 13, 'hr': 12, 'outs': 81, 'sb': 5},
     'R3': {'bb': 5, 'er': 1, 'h': 0, 'hr': 12, 'outs': 30, 'sb': 8}}],
   {'R0': 21, 'R1': 19, 'R2': 14, 'R3': 26}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 6, 'er': 8, 'h': 14, 'hr': 15, 'outs': 71, 'sb': 5},
     'R1': {'bb': 3, 'er': 5, 'h': 24, 'hr': 10, 'outs': 27, 'sb': 5},
     'R2': {'bb': 8, 'er': 6, 'h': 9, 'hr': 15, 'outs': 54, 'sb': 3},
     'R3': {'bb': 10, 'er': 10, 'h': 16, 'hr': 12, 'outs': 30, 'sb': 5},
     'R4': {'bb': 1, 'er': 13, 'h': 24, 'hr': 12, 'outs': 27, 'sb': 5}}],
   {'R0': 34, 'R1': 17, 'R2': 29, 'R3': 22, 'R4': 18}),
  ('second regression',
   [{'R0': {'bb': 6, 'er': 5, 'h': 23, 'hr': 12, 'outs': 27, 'sb': 8},
     'R1': {'bb': 1, 'er': 6, 'h': 16, 'hr': 15, 'outs': 27, 'sb': 5},
     'R2': {'bb': 10, 'er': 7, 'h': 14, 'hr': 12, 'outs': 30, 'sb': 8},
     'R3': {'bb': 10, 'er': 1, 'h': 12, 'hr': 15, 'outs': 83, 'sb': 8},
     'R4': {'bb': 8, 'er': 10, 'h': 5, 'hr': 10, 'outs': 30, 'sb': 5}}],
   {'R0': 23, 'R1': 24, 'R2': 21, 'R3': 37, 'R4': 15}),
  ('normal control 1',
   [{'R0': {'bb': 2, 'er': 13, 'h': 11, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 10, 'er': 7, 'h': 4, 'hr': 12, 'outs': 81, 'sb': 3},
     'R2': {'bb': 8, 'er': 3, 'h': 20, 'hr': 10, 'outs': 18, 'sb': 5},
     'R3': {'bb': 9, 'er': 0, 'h': 20, 'hr': 10, 'outs': 81, 'sb': 3},
     'R4': {'bb': 3, 'er': 14, 'h': 5, 'hr': 12, 'outs': 0, 'sb': 8},
     'R5': {'bb': 7, 'er': 0, 'h': 4, 'hr': 12, 'outs': 30, 'sb': 8}}],
   {'R0': 22, 'R1': 32, 'R2': 22, 'R3': 27, 'R4': 26, 'R5': 39}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 8, 'h': 7, 'hr': 10, 'outs': 36, 'sb': 5},
     'R1': {'bb': 1, 'er': 1, 'h': 20, 'hr': 10, 'outs': 54, 'sb': 8},
     'R2': {'bb': 5, 'er': 9, 'h': 11, 'hr': 10, 'outs': 0, 'sb': 5},
     'R3': {'bb': 9, 'er': 14, 'h': 22, 'hr': 15, 'outs': 21, 'sb': 8}}],
   {'R0': 21, 'R1': 25, 'R2': 11, 'R3': 23}),
  ('normal control 3',
   [{'R0': {'bb': 8, 'er': 1, 'h': 8, 'hr': 10, 'outs': 30, 'sb': 8},
     'R1': {'bb': 9, 'er': 10, 'h': 12, 'hr': 12, 'outs': 12, 'sb': 5},
     'R2': {'bb': 10, 'er': 4, 'h': 3, 'hr': 12, 'outs': 30, 'sb': 3},
     'R3': {'bb': 5, 'er': 4, 'h': 14, 'hr': 10, 'outs': 16, 'sb': 5},
     'R4': {'bb': 6, 'er': 6, 'h': 22, 'hr': 15, 'outs': 30, 'sb': 8},
     'R5': {'bb': 1, 'er': 12, 'h': 2, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 34, 'R1': 18, 'R2': 30, 'R3': 17, 'R4': 35, 'R5': 34}),
  ('normal control 4',
   [{'R0': {'bb': 1, 'er': 6, 'h': 24, 'hr': 12, 'outs': 0, 'sb': 8},
     'R1': {'bb': 3, 'er': 0, 'h': 4, 'hr': 10, 'outs': 27, 'sb': 5},
     'R2': {'bb': 2, 'er': 4, 'h': 22, 'hr': 15, 'outs': 0, 'sb': 3},
     'R3': {'bb': 10, 'er': 9, 'h': 0, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 19, 'R1': 21, 'R2': 16, 'R3': 24})],
 [('regression: ratio precision',
   [{'R0': {'bb': 8, 'er': 7, 'h': 22, 'hr': 12, 'outs': 81, 'sb': 3},
     'R1': {'bb': 8, 'er': 6, 'h': 24, 'hr': 12, 'outs': 81, 'sb': 5},
     'R2': {'bb': 3, 'er': 11, 'h': 17, 'hr': 15, 'outs': 54, 'sb': 3},
     'R3': {'bb': 3, 'er': 9, 'h': 8, 'hr': 12, 'outs': 35, 'sb': 8}}],
   {'R0': 18, 'R1': 20, 'R2': 20, 'R3': 22}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 2, 'er': 9, 'h': 2, 'hr': 12, 'outs': 81, 'sb': 8},
     'R1': {'bb': 2, 'er': 6, 'h': 1, 'hr': 15, 'outs': 0, 'sb': 5},
     'R2': {'bb': 9, 'er': 9, 'h': 4, 'hr': 12, 'outs': 82, 'sb': 5},
     'R3': {'bb': 1, 'er': 6, 'h': 10, 'hr': 10, 'outs': 27, 'sb': 3},
     'R4': {'bb': 8, 'er': 11, 'h': 6, 'hr': 12, 'outs': 27, 'sb': 8},
     'R5': {'bb': 1, 'er': 14, 'h': 16, 'hr': 15, 'outs': 54, 'sb': 8}}],
   {'R0': 38, 'R1': 20, 'R2': 33, 'R3': 18, 'R4': 24, 'R5': 35}),
  ('second regression',
   [{'R0': {'bb': 2, 'er': 11, 'h': 11, 'hr': 12, 'outs': 81, 'sb': 8},
     'R1': {'bb': 0, 'er': 7, 'h': 2, 'hr': 15, 'outs': 54, 'sb': 3},
     'R2': {'bb': 6, 'er': 5, 'h': 9, 'hr': 12, 'outs': 30, 'sb': 5}}],
   {'R0': 17, 'R1': 20, 'R2': 11}),
  ('normal control 1',
   [{'R0': {'bb': 1, 'er': 12, 'h': 5, 'hr': 12, 'outs': 4, 'sb': 8},
     'R1': {'bb': 10, 'er': 5, 'h': 22, 'hr': 12, 'outs': 30, 'sb': 3},
     'R2': {'bb': 7, 'er': 5, 'h': 12, 'hr': 12, 'outs': 0, 'sb': 3},
     'R3': {'bb': 9, 'er': 1, 'h': 15, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 8, 'er': 4, 'h': 5, 'hr': 12, 'outs': 0, 'sb': 5},
     'R5': {'bb': 6, 'er': 8, 'h': 13, 'hr': 15, 'outs': 0, 'sb': 5}}],
   {'R0': 34, 'R1': 29, 'R2': 17, 'R3': 38, 'R4': 22, 'R5': 28}),
  ('normal control 2',
   [{'R0': {'bb': 0, 'er': 8, 'h': 20, 'hr': 12, 'outs': 8, 'sb': 5},
     'R1': {'bb': 2, 'er': 11, 'h': 15, 'hr': 12, 'outs': 27, 'sb': 5},
     'R2': {'bb': 4, 'er': 4, 'h': 3, 'hr': 12, 'outs': 81, 'sb': 3},
     'R3': {'bb': 7, 'er': 1, 'h': 15, 'hr': 12, 'outs': 81, 'sb': 3},
     'R4': {'bb': 4, 'er': 6, 'h': 3, 'hr': 12, 'outs': 0, 'sb': 8},
     'R5': {'bb': 9, 'er': 14, 'h': 18, 'hr': 12, 'outs': 27, 'sb': 3}}],
   {'R0': 24, 'R1': 32, 'R2': 33, 'R3': 33, 'R4': 23, 'R5': 23}),
  ('normal control 3',
   [{'R0': {'bb': 4, 'er': 14, 'h': 19, 'hr': 12, 'outs': 30, 'sb': 5},
     'R1': {'bb': 3, 'er': 3, 'h': 13, 'hr': 12, 'outs': 27, 'sb': 8},
     'R2': {'bb': 0, 'er': 7, 'h': 20, 'hr': 10, 'outs': 33, 'sb': 5},
     'R3': {'bb': 5, 'er': 7, 'h': 17, 'hr': 10, 'outs': 27, 'sb': 8},
     'R4': {'bb': 7, 'er': 11, 'h': 17, 'hr': 12, 'outs': 20, 'sb': 3}}],
   {'R0': 23, 'R1': 37, 'R2': 24, 'R3': 22, 'R4': 14}),
  ('normal control 4',
   [{'R0': {'bb': 9, 'er': 4, 'h': 14, 'hr': 10, 'outs': 0, 'sb': 8},
     'R1': {'bb': 2, 'er': 0, 'h': 6, 'hr': 10, 'outs': 27, 'sb': 5},
     'R2': {'bb': 6, 'er': 5, 'h': 2, 'hr': 12, 'outs': 30, 'sb': 3},
     'R3': {'bb': 4, 'er': 11, 'h': 19, 'hr': 12, 'outs': 81, 'sb': 3}}],
   {'R0': 15, 'R1': 21, 'R2': 22, 'R3': 22})],
 [('regression: ratio precision',
   [{'R0': {'bb': 4, 'er': 2, 'h': 19, 'hr': 15, 'outs': 65, 'sb': 5},
     'R1': {'bb': 0, 'er': 12, 'h': 21, 'hr': 10, 'outs': 54, 'sb': 3},
     'R2': {'bb': 4, 'er': 2, 'h': 7, 'hr': 15, 'outs': 27, 'sb': 3},
     'R3': {'bb': 5, 'er': 5, 'h': 23, 'hr': 15, 'outs': 54, 'sb': 5},
     'R4': {'bb': 2, 'er': 9, 'h': 3, 'hr': 12, 'outs': 9, 'sb': 3}}],
   {'R0': 37, 'R1': 18, 'R2': 26, 'R3': 27, 'R4': 12}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 1, 'er': 5, 'h': 0, 'hr': 10, 'outs': 81, 'sb': 5},
     'R1': {'bb': 4, 'er': 8, 'h': 15, 'hr': 15, 'outs': 0, 'sb': 3},
     'R2': {'bb': 6, 'er': 1, 'h': 13, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 1, 'er': 8, 'h': 7, 'hr': 12, 'outs': 54, 'sb': 5},
     'R4': {'bb': 6, 'er': 7, 'h': 4, 'hr': 12, 'outs': 40, 'sb': 3},
     'R5': {'bb': 6, 'er': 14, 'h': 1, 'hr': 12, 'outs': 81, 'sb': 8}}],
   {'R0': 32, 'R1': 19, 'R2': 31, 'R3': 31, 'R4': 20, 'R5': 35}),
  ('second regression',
   [{'R0': {'bb': 0, 'er': 1, 'h': 0, 'hr': 12, 'outs': 27, 'sb': 5},
     'R1': {'bb': 9, 'er': 5, 'h': 25, 'hr': 15, 'outs': 81, 'sb': 5},
     'R2': {'bb': 1, 'er': 12, 'h': 23, 'hr': 15, 'outs': 0, 'sb': 8}}],
   {'R0': 17, 'R1': 16, 'R2': 15}),
  ('normal control 1',
   [{'R0': {'bb': 9, 'er': 14, 'h': 22, 'hr': 12, 'outs': 30, 'sb': 3},
     'R1': {'bb': 10, 'er': 7, 'h': 19, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 9, 'er': 14, 'h': 1, 'hr': 12, 'outs': 54, 'sb': 5}}],
   {'R0': 14, 'R1': 13, 'R2': 21}),
  ('normal control 2',
   [{'R0': {'bb': 8, 'er': 3, 'h': 21, 'hr': 12, 'outs': 81, 'sb': 5},
     'R1': {'bb': 3, 'er': 11, 'h': 25, 'hr': 10, 'outs': 50, 'sb': 5},
     'R2': {'bb': 7, 'er': 0, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 5},
     'R3': {'bb': 2, 'er': 4, 'h': 24, 'hr': 12, 'outs': 0, 'sb': 3},
     'R4': {'bb': 4, 'er': 14, 'h': 16, 'hr': 15, 'outs': 0, 'sb': 5}}],
   {'R0': 29, 'R1': 21, 'R2': 33, 'R3': 14, 'R4': 23}),
  ('normal control 3',
   [{'R0': {'bb': 0, 'er': 1, 'h': 13, 'hr': 15, 'outs': 55, 'sb': 5},
     'R1': {'bb': 10, 'er': 1, 'h': 16, 'hr': 10, 'outs': 27, 'sb': 3},
     'R2': {'bb': 3, 'er': 5, 'h': 5, 'hr': 10, 'outs': 54, 'sb': 8},
     'R3': {'bb': 2, 'er': 7, 'h': 18, 'hr': 12, 'outs': 27, 'sb': 5}}],
   {'R0': 27, 'R1': 13, 'R2': 23, 'R3': 17}),
  ('normal control 4',
   [{'R0': {'bb': 8, 'er': 11, 'h': 20, 'hr': 15, 'outs': 30, 'sb': 8},
     'R1': {'bb': 5, 'er': 3, 'h': 14, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 7, 'er': 13, 'h': 22, 'hr': 12, 'outs': 30, 'sb': 5}}],
   {'R0': 20, 'R1': 18, 'R2': 10})],
 [('regression: ratio precision',
   [{'R0': {'bb': 9, 'er': 5, 'h': 21, 'hr': 10, 'outs': 81, 'sb': 8},
     'R1': {'bb': 6, 'er': 7, 'h': 15, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 6, 'er': 6, 'h': 25, 'hr': 15, 'outs': 54, 'sb': 3},
     'R3': {'bb': 3, 'er': 4, 'h': 14, 'hr': 12, 'outs': 30, 'sb': 5},
     'R4': {'bb': 6, 'er': 6, 'h': 17, 'hr': 15, 'outs': 30, 'sb': 8}}],
   {'R0': 31, 'R1': 16, 'R2': 25, 'R3': 24, 'R4': 24}),
  ('partial repair probe: ratio precision',
   [{'R0': {'bb': 2, 'er': 14, 'h': 3, 'hr': 15, 'outs': 86, 'sb': 5},
     'R1': {'bb': 1, 'er': 6, 'h': 5, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 8, 'er': 9, 'h': 8, 'hr': 15, 'outs': 82, 'sb': 5},
     'R3': {'bb': 7, 'er': 1, 'h': 9, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 7, 'er': 14, 'h': 20, 'hr': 12, 'outs': 18, 'sb': 5}}],
   {'R0': 29, 'R1': 24, 'R2': 29, 'R3': 24, 'R4': 14}),
  ('second regression',
   [{'R0': {'bb': 0, 'er': 12, 'h': 12, 'hr': 12, 'outs': 30, 'sb': 5},
     'R1': {'bb': 5, 'er': 14, 'h': 15, 'hr': 12, 'outs': 32, 'sb': 5},
     'R2': {'bb': 10, 'er': 0, 'h': 7, 'hr': 10, 'outs': 30, 'sb': 5},
     'R3': {'bb': 9, 'er': 1, 'h': 21, 'hr': 12, 'outs': 30, 'sb': 5},
     'R4': {'bb': 8, 'er': 7, 'h': 15, 'hr': 12, 'outs': 81, 'sb': 5},
     'R5': {'bb': 1, 'er': 1, 'h': 9, 'hr': 10, 'outs': 81, 'sb': 3}}],
   {'R0': 29, 'R1': 23, 'R2': 29, 'R3': 27, 'R4': 33, 'R5': 27}),
  ('normal control 1',
   [{'R0': {'bb': 10, 'er': 6, 'h': 21, 'hr': 10, 'outs': 0, 'sb': 3},
     'R1': {'bb': 5, 'er': 10, 'h': 16, 'hr': 15, 'outs': 54, 'sb': 5},
     'R2': {'bb': 3, 'er': 9, 'h': 24, 'hr': 15, 'outs': 27, 'sb': 3}}],
   {'R0': 9, 'R1': 23, 'R2': 16}),
  ('normal control 2',
   [{'R0': {'bb': 8, 'er': 14, 'h': 6, 'hr': 15, 'outs': 27, 'sb': 5},
     'R1': {'bb': 9, 'er': 8, 'h': 20, 'hr': 15, 'outs': 0, 'sb': 8},
     'R2': {'bb': 1, 'er': 10, 'h': 1, 'hr': 12, 'outs': 78, 'sb': 3}}],
   {'R0': 17, 'R1': 15, 'R2': 16}),
  ('normal control 3',
   [{'R0': {'bb': 2, 'er': 13, 'h': 0, 'hr': 15, 'outs': 81, 'sb': 8},
     'R1': {'bb': 2, 'er': 0, 'h': 12, 'hr': 12, 'outs': 16, 'sb': 3},
     'R2': {'bb': 2, 'er': 3, 'h': 8, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 22, 'R1': 15, 'R2': 11}),
  ('normal control 4',
   [{'R0': {'bb': 7, 'er': 2, 'h': 22, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 9, 'er': 11, 'h': 25, 'hr': 10, 'outs': 30, 'sb': 5},
     'R2': {'bb': 2, 'er': 5, 'h': 0, 'hr': 10, 'outs': 81, 'sb': 3},
     'R3': {'bb': 7, 'er': 3, 'h': 13, 'hr': 12, 'outs': 30, 'sb': 3},
     'R4': {'bb': 2, 'er': 14, 'h': 5, 'hr': 15, 'outs': 10, 'sb': 3},
     'R5': {'bb': 4, 'er': 8, 'h': 0, 'hr': 12, 'outs': 30, 'sb': 8}}],
   {'R0': 21, 'R1': 22, 'R2': 31, 'R3': 30, 'R4': 26, 'R5': 38})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Teams with ERAs of 3.10 and 3.90 are ranked as tied.

Rotisserie categories HR and SB rank high-to-low; ERA (earned runs x 27 / outs) and WHIP ((walks + hits) x 3 / outs) rank low-to-high using exact ratios. A team with zero outs has no ERA/WHIP and ranks last. With n teams the best rank earns n points and the worst 1; tied teams share the average of the positions they occupy. Return team -> doubled roto points (integers).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(teams):
    names = sorted(teams)
    n = len(names)
    def value(t, cat):
        d = teams[t]
        if cat in ('hr', 'sb'):
            return Fraction(d[cat])
        if d['outs'] == 0:
            return None
        if cat == 'era':
            return Fraction(d['er'] * 27, d['outs'])
        return Fraction((d['bb'] + d['h']) * 3, d['outs'])
    total = {t: 0 for t in names}
    for cat in ('hr', 'sb', 'era', 'whip'):
        low = cat in ('era',)
        def key(t):
            v = value(t, cat)
            if v is None:
                return (1, 0)
            return (0, v if low else -v)
        ranked = sorted(names, key=key)
        i = 0
        while i < n:
            j = i
            while j < n and key(ranked[j]) == key(ranked[i]):
                j += 1
            pts2 = sum(2 * (n - r) for r in range(i, j)) // (j - i)
            for t in ranked[i:j]:
                total[t] += pts2
            i = j
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 11, 'h': 1, 'hr': 10, 'outs': 88, 'sb': 5},
     'R1': {'bb': 1, 'er': 5, 'h': 4, 'hr': 15, 'outs': 0, 'sb': 8},
     'R2': {'bb': 6, 'er': 2, 'h': 3, 'hr': 12, 'outs': 30, 'sb': 8},
     'R3': {'bb': 6, 'er': 0, 'h': 12, 'hr': 12, 'outs': 27, 'sb': 5},
     'R4': {'bb': 4, 'er': 7, 'h': 7, 'hr': 15, 'outs': 81, 'sb': 8}}],
   {'R0': 19, 'R1': 21, 'R2': 27, 'R3': 22, 'R4': 31}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 13, 'h': 18, 'hr': 12, 'outs': 24, 'sb': 5},
     'R1': {'bb': 2, 'er': 8, 'h': 4, 'hr': 12, 'outs': 0, 'sb': 8},
     'R2': {'bb': 5, 'er': 13, 'h': 14, 'hr': 12, 'outs': 54, 'sb': 5},
     'R3': {'bb': 7, 'er': 7, 'h': 24, 'hr': 12, 'outs': 55, 'sb': 3},
     'R4': {'bb': 10, 'er': 0, 'h': 20, 'hr': 15, 'outs': 27, 'sb': 8}}],
   {'R0': 20, 'R1': 18, 'R2': 26, 'R3': 23, 'R4': 33}),
  ('second regression',
   [{'R0': {'bb': 9, 'er': 8, 'h': 16, 'hr': 10, 'outs': 0, 'sb': 8},
     'R1': {'bb': 9, 'er': 5, 'h': 16, 'hr': 15, 'outs': 54, 'sb': 5},
     'R2': {'bb': 4, 'er': 1, 'h': 20, 'hr': 10, 'outs': 50, 'sb': 5},
     'R3': {'bb': 4, 'er': 9, 'h': 2, 'hr': 12, 'outs': 27, 'sb': 3},
     'R4': {'bb': 0, 'er': 5, 'h': 0, 'hr': 10, 'outs': 30, 'sb': 8},
     'R5': {'bb': 7, 'er': 5, 'h': 7, 'hr': 10, 'outs': 0, 'sb': 8}}],
   {'R0': 21, 'R1': 35, 'R2': 28, 'R3': 28, 'R4': 35, 'R5': 21}),
  ('normal control 1',
   [{'R0': {'bb': 9, 'er': 12, 'h': 22, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 2, 'er': 8, 'h': 16, 'hr': 15, 'outs': 18, 'sb': 5},
     'R2': {'bb': 9, 'er': 7, 'h': 19, 'hr': 15, 'outs': 0, 'sb': 5}}],
   {'R0': 12, 'R1': 21, 'R2': 15}),
  ('normal control 2',
   [{'R0': {'bb': 7, 'er': 1, 'h': 5, 'hr': 10, 'outs': 0, 'sb': 5},
     'R1': {'bb': 10, 'er': 6, 'h': 20, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 4, 'er': 7, 'h': 20, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 12, 'R1': 21, 'R2': 15}),
  ('normal control 3',
   [{'R0': {'bb': 5, 'er': 10, 'h': 6, 'hr': 15, 'outs': 0, 'sb': 5},
     'R1': {'bb': 1, 'er': 5, 'h': 19, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 7, 'er': 7, 'h': 10, 'hr': 10, 'outs': 54, 'sb': 5}}],
   {'R0': 16, 'R1': 14, 'R2': 18})],
 [('regression: lower-is-better categories',
   [{'R0': {'bb': 7, 'er': 8, 'h': 11, 'hr': 15, 'outs': 30, 'sb': 5},
     'R1': {'bb': 1, 'er': 12, 'h': 20, 'hr': 15, 'outs': 30, 'sb': 3},
     'R2': {'bb': 1, 'er': 12, 'h': 8, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 4, 'er': 3, 'h': 5, 'hr': 15, 'outs': 90, 'sb': 8},
     'R4': {'bb': 3, 'er': 11, 'h': 19, 'hr': 12, 'outs': 81, 'sb': 5},
     'R5': {'bb': 8, 'er': 8, 'h': 11, 'hr': 12, 'outs': 54, 'sb': 5}}],
   {'R0': 27, 'R1': 18, 'R2': 21, 'R3': 46, 'R4': 31, 'R5': 25}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 8, 'er': 11, 'h': 0, 'hr': 12, 'outs': 81, 'sb': 3},
     'R1': {'bb': 7, 'er': 12, 'h': 15, 'hr': 15, 'outs': 27, 'sb': 3},
     'R2': {'bb': 7, 'er': 10, 'h': 3, 'hr': 12, 'outs': 27, 'sb': 8}}],
   {'R0': 18, 'R1': 13, 'R2': 17}),
  ('second regression',
   [{'R0': {'bb': 3, 'er': 3, 'h': 17, 'hr': 12, 'outs': 88, 'sb': 5},
     'R1': {'bb': 6, 'er': 8, 'h': 18, 'hr': 10, 'outs': 81, 'sb': 5},
     'R2': {'bb': 6, 'er': 10, 'h': 21, 'hr': 10, 'outs': 0, 'sb': 5},
     'R3': {'bb': 4, 'er': 12, 'h': 25, 'hr': 12, 'outs': 30, 'sb': 8},
     'R4': {'bb': 10, 'er': 9, 'h': 13, 'hr': 15, 'outs': 0, 'sb': 5},
     'R5': {'bb': 8, 'er': 6, 'h': 23, 'hr': 12, 'outs': 0, 'sb': 8}}],
   {'R0': 37, 'R1': 28, 'R2': 16, 'R3': 35, 'R4': 25, 'R5': 27}),
  ('normal control 1',
   [{'R0': {'bb': 4, 'er': 3, 'h': 18, 'hr': 12, 'outs': 27, 'sb': 3},
     'R1': {'bb': 9, 'er': 2, 'h': 1, 'hr': 12, 'outs': 0, 'sb': 3},
     'R2': {'bb': 9, 'er': 10, 'h': 3, 'hr': 10, 'outs': 0, 'sb': 3}}],
   {'R0': 21, 'R1': 15, 'R2': 12}),
  ('extra case 1',
   [{'R0': {'bb': 1, 'er': 8, 'h': 4, 'hr': 15, 'outs': 27, 'sb': 5},
     'R1': {'bb': 2, 'er': 8, 'h': 9, 'hr': 12, 'outs': 30, 'sb': 8},
     'R2': {'bb': 7, 'er': 9, 'h': 15, 'hr': 10, 'outs': 28, 'sb': 8},
     'R3': {'bb': 4, 'er': 11, 'h': 16, 'hr': 15, 'outs': 81, 'sb': 3},
     'R4': {'bb': 2, 'er': 11, 'h': 10, 'hr': 10, 'outs': 81, 'sb': 5},
     'R5': {'bb': 9, 'er': 10, 'h': 11, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 31, 'R1': 28, 'R2': 18, 'R3': 29, 'R4': 30, 'R5': 32}),
  ('extra case 2',
   [{'R0': {'bb': 9, 'er': 5, 'h': 18, 'hr': 12, 'outs': 81, 'sb': 5},
     'R1': {'bb': 10, 'er': 4, 'h': 22, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 7, 'er': 6, 'h': 1, 'hr': 12, 'outs': 81, 'sb': 8}}],
   {'R0': 17, 'R1': 11, 'R2': 20})],
 [('regression: lower-is-better categories',
   [{'R0': {'bb': 7, 'er': 9, 'h': 2, 'hr': 12, 'outs': 34, 'sb': 5},
     'R1': {'bb': 9, 'er': 10, 'h': 17, 'hr': 10, 'outs': 51, 'sb': 3},
     'R2': {'bb': 4, 'er': 11, 'h': 4, 'hr': 12, 'outs': 30, 'sb': 8},
     'R3': {'bb': 3, 'er': 11, 'h': 4, 'hr': 12, 'outs': 51, 'sb': 8},
     'R4': {'bb': 6, 'er': 0, 'h': 1, 'hr': 12, 'outs': 30, 'sb': 5},
     'R5': {'bb': 6, 'er': 7, 'h': 14, 'hr': 12, 'outs': 9, 'sb': 5}}],
   {'R0': 28, 'R1': 18, 'R2': 29, 'R3': 39, 'R4': 36, 'R5': 18}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 0, 'h': 17, 'hr': 12, 'outs': 30, 'sb': 8},
     'R1': {'bb': 0, 'er': 8, 'h': 17, 'hr': 12, 'outs': 81, 'sb': 8},
     'R2': {'bb': 9, 'er': 1, 'h': 19, 'hr': 12, 'outs': 54, 'sb': 3}}],
   {'R0': 17, 'R1': 17, 'R2': 14}),
  ('second regression',
   [{'R0': {'bb': 2, 'er': 3, 'h': 13, 'hr': 15, 'outs': 0, 'sb': 5},
     'R1': {'bb': 6, 'er': 0, 'h': 25, 'hr': 10, 'outs': 30, 'sb': 5},
     'R2': {'bb': 5, 'er': 4, 'h': 24, 'hr': 15, 'outs': 54, 'sb': 5}}],
   {'R0': 13, 'R1': 16, 'R2': 19}),
  ('normal control 1',
   [{'R0': {'bb': 7, 'er': 1, 'h': 6, 'hr': 12, 'outs': 81, 'sb': 5},
     'R1': {'bb': 10, 'er': 10, 'h': 8, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 8, 'er': 7, 'h': 21, 'hr': 15, 'outs': 0, 'sb': 5},
     'R3': {'bb': 7, 'er': 4, 'h': 2, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 25, 'R1': 17, 'R2': 21, 'R3': 17}),
  ('extra case 1',
   [{'R0': {'bb': 9, 'er': 12, 'h': 20, 'hr': 15, 'outs': 27, 'sb': 3},
     'R1': {'bb': 4, 'er': 8, 'h': 21, 'hr': 10, 'outs': 30, 'sb': 3},
     'R2': {'bb': 8, 'er': 9, 'h': 25, 'hr': 12, 'outs': 81, 'sb': 5},
     'R3': {'bb': 1, 'er': 6, 'h': 1, 'hr': 15, 'outs': 81, 'sb': 8},
     'R4': {'bb': 5, 'er': 7, 'h': 9, 'hr': 12, 'outs': 27, 'sb': 8},
     'R5': {'bb': 3, 'er': 11, 'h': 12, 'hr': 15, 'outs': 0, 'sb': 8}}],
   {'R0': 21, 'R1': 17, 'R2': 31, 'R3': 44, 'R4': 31, 'R5': 24}),
  ('extra case 2',
   [{'R0': {'bb': 4, 'er': 10, 'h': 11, 'hr': 12, 'outs': 30, 'sb': 8},
     'R1': {'bb': 10, 'er': 1, 'h': 5, 'hr': 12, 'outs': 11, 'sb': 5},
     'R2': {'bb': 6, 'er': 14, 'h': 23, 'hr': 10, 'outs': 30, 'sb': 5}}],
   {'R0': 21, 'R1': 16, 'R2': 11})],
 [('regression: lower-is-better categories',
   [{'R0': {'bb': 6, 'er': 4, 'h': 23, 'hr': 10, 'outs': 30, 'sb': 5},
     'R1': {'bb': 4, 'er': 9, 'h': 22, 'hr': 12, 'outs': 67, 'sb': 8},
     'R2': {'bb': 2, 'er': 14, 'h': 10, 'hr': 10, 'outs': 0, 'sb': 5},
     'R3': {'bb': 4, 'er': 2, 'h': 19, 'hr': 15, 'outs': 30, 'sb': 5}}],
   {'R0': 17, 'R1': 26, 'R2': 11, 'R3': 26}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 2, 'er': 11, 'h': 16, 'hr': 12, 'outs': 54, 'sb': 8},
     'R1': {'bb': 7, 'er': 0, 'h': 19, 'hr': 15, 'outs': 52, 'sb': 8},
     'R2': {'bb': 9, 'er': 1, 'h': 12, 'hr': 15, 'outs': 54, 'sb': 5},
     'R3': {'bb': 4, 'er': 9, 'h': 10, 'hr': 12, 'outs': 0, 'sb': 8},
     'R4': {'bb': 2, 'er': 11, 'h': 21, 'hr': 10, 'outs': 6, 'sb': 3}}],
   {'R0': 29, 'R1': 33, 'R2': 29, 'R3': 17, 'R4': 12}),
  ('second regression',
   [{'R0': {'bb': 6, 'er': 3, 'h': 4, 'hr': 15, 'outs': 0, 'sb': 5},
     'R1': {'bb': 4, 'er': 13, 'h': 0, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 4, 'er': 0, 'h': 2, 'hr': 10, 'outs': 81, 'sb': 3},
     'R3': {'bb': 1, 'er': 12, 'h': 6, 'hr': 15, 'outs': 81, 'sb': 5},
     'R4': {'bb': 9, 'er': 12, 'h': 11, 'hr': 10, 'outs': 54, 'sb': 5},
     'R5': {'bb': 7, 'er': 0, 'h': 2, 'hr': 12, 'outs': 27, 'sb': 3}}],
   {'R0': 24, 'R1': 28, 'R2': 29, 'R3': 38, 'R4': 22, 'R5': 27}),
  ('normal control 1',
   [{'R0': {'bb': 7, 'er': 8, 'h': 19, 'hr': 15, 'outs': 0, 'sb': 8},
     'R1': {'bb': 2, 'er': 1, 'h': 17, 'hr': 12, 'outs': 81, 'sb': 8},
     'R2': {'bb': 7, 'er': 0, 'h': 23, 'hr': 15, 'outs': 0, 'sb': 8}}],
   {'R0': 15, 'R1': 18, 'R2': 15}),
  ('extra case 1',
   [{'R0': {'bb': 1, 'er': 4, 'h': 6, 'hr': 12, 'outs': 54, 'sb': 5},
     'R1': {'bb': 4, 'er': 5, 'h': 14, 'hr': 15, 'outs': 0, 'sb': 5},
     'R2': {'bb': 4, 'er': 6, 'h': 16, 'hr': 12, 'outs': 30, 'sb': 5},
     'R3': {'bb': 3, 'er': 4, 'h': 4, 'hr': 12, 'outs': 30, 'sb': 5}}],
   {'R0': 25, 'R1': 17, 'R2': 17, 'R3': 21}),
  ('extra case 2',
   [{'R0': {'bb': 10, 'er': 0, 'h': 7, 'hr': 15, 'outs': 0, 'sb': 3},
     'R1': {'bb': 6, 'er': 9, 'h': 2, 'hr': 15, 'outs': 0, 'sb': 3},
     'R2': {'bb': 4, 'er': 8, 'h': 7, 'hr': 12, 'outs': 81, 'sb': 8},
     'R3': {'bb': 6, 'er': 3, 'h': 15, 'hr': 12, 'outs': 54, 'sb': 5},
     'R4': {'bb': 7, 'er': 12, 'h': 15, 'hr': 12, 'outs': 27, 'sb': 3}}],
   {'R0': 19, 'R1': 19, 'R2': 32, 'R3': 30, 'R4': 20})],
 [('regression: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 9, 'h': 5, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 3, 'er': 4, 'h': 25, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 3, 'er': 0, 'h': 4, 'hr': 12, 'outs': 27, 'sb': 8},
     'R3': {'bb': 7, 'er': 10, 'h': 3, 'hr': 12, 'outs': 54, 'sb': 5},
     'R4': {'bb': 3, 'er': 14, 'h': 16, 'hr': 12, 'outs': 81, 'sb': 8},
     'R5': {'bb': 9, 'er': 9, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 8}}],
   {'R0': 15, 'R1': 25, 'R2': 37, 'R3': 27, 'R4': 33, 'R5': 31}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 12, 'h': 4, 'hr': 12, 'outs': 0, 'sb': 3},
     'R1': {'bb': 2, 'er': 7, 'h': 23, 'hr': 15, 'outs': 27, 'sb': 3},
     'R2': {'bb': 3, 'er': 7, 'h': 4, 'hr': 10, 'outs': 27, 'sb': 8}}],
   {'R0': 11, 'R1': 18, 'R2': 19}),
  ('second regression',
   [{'R0': {'bb': 9, 'er': 5, 'h': 16, 'hr': 15, 'outs': 0, 'sb': 3},
     'R1': {'bb': 2, 'er': 5, 'h': 3, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 3, 'er': 7, 'h': 15, 'hr': 15, 'outs': 66, 'sb': 5},
     'R3': {'bb': 7, 'er': 5, 'h': 19, 'hr': 10, 'outs': 27, 'sb': 5}}],
   {'R0': 15, 'R1': 16, 'R2': 29, 'R3': 20}),
  ('normal control 1',
   [{'R0': {'bb': 10, 'er': 0, 'h': 8, 'hr': 15, 'outs': 0, 'sb': 8},
     'R1': {'bb': 7, 'er': 3, 'h': 7, 'hr': 12, 'outs': 0, 'sb': 8},
     'R2': {'bb': 4, 'er': 6, 'h': 2, 'hr': 15, 'outs': 0, 'sb': 8}}],
   {'R0': 17, 'R1': 14, 'R2': 17}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 6, 'h': 4, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 3, 'er': 9, 'h': 16, 'hr': 10, 'outs': 40, 'sb': 5},
     'R2': {'bb': 9, 'er': 8, 'h': 2, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 15, 'R1': 18, 'R2': 15}),
  ('normal control 3',
   [{'R0': {'bb': 7, 'er': 4, 'h': 2, 'hr': 12, 'outs': 54, 'sb': 5},
     'R1': {'bb': 1, 'er': 13, 'h': 0, 'hr': 15, 'outs': 0, 'sb': 5},
     'R2': {'bb': 9, 'er': 0, 'h': 15, 'hr': 10, 'outs': 0, 'sb': 5},
     'R3': {'bb': 5, 'er': 8, 'h': 13, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 26, 'R1': 21, 'R2': 15, 'R3': 18})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(teams):
    names = sorted(teams)
    n = len(names)
    def value(t, cat):
        d = teams[t]
        if cat in ('hr', 'sb'):
            return Fraction(d[cat])
        if d['outs'] == 0:
            return None
        if cat == 'era':
            return Fraction(d['er'] * 27, d['outs'])
        return Fraction((d['bb'] + d['h']) * 3, d['outs'])
    total = {t: 0 for t in names}
    for cat in ('hr', 'sb', 'era', 'whip'):
        low = cat != 'hr'
        def key(t):
            v = value(t, cat)
            if v is None:
                return (1, 0)
            return (0, v if low else -v)
        ranked = sorted(names, key=key)
        i = 0
        while i < n:
            j = i
            while j < n and key(ranked[j]) == key(ranked[i]):
                j += 1
            pts2 = sum(2 * (n - r) for r in range(i, j)) // (j - i)
            for t in ranked[i:j]:
                total[t] += pts2
            i = j
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 11, 'h': 1, 'hr': 10, 'outs': 88, 'sb': 5},
     'R1': {'bb': 1, 'er': 5, 'h': 4, 'hr': 15, 'outs': 0, 'sb': 8},
     'R2': {'bb': 6, 'er': 2, 'h': 3, 'hr': 12, 'outs': 30, 'sb': 8},
     'R3': {'bb': 6, 'er': 0, 'h': 12, 'hr': 12, 'outs': 27, 'sb': 5},
     'R4': {'bb': 4, 'er': 7, 'h': 7, 'hr': 15, 'outs': 81, 'sb': 8}}],
   {'R0': 19, 'R1': 21, 'R2': 27, 'R3': 22, 'R4': 31}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 13, 'h': 18, 'hr': 12, 'outs': 24, 'sb': 5},
     'R1': {'bb': 2, 'er': 8, 'h': 4, 'hr': 12, 'outs': 0, 'sb': 8},
     'R2': {'bb': 5, 'er': 13, 'h': 14, 'hr': 12, 'outs': 54, 'sb': 5},
     'R3': {'bb': 7, 'er': 7, 'h': 24, 'hr': 12, 'outs': 55, 'sb': 3},
     'R4': {'bb': 10, 'er': 0, 'h': 20, 'hr': 15, 'outs': 27, 'sb': 8}}],
   {'R0': 20, 'R1': 18, 'R2': 26, 'R3': 23, 'R4': 33}),
  ('second regression',
   [{'R0': {'bb': 9, 'er': 8, 'h': 16, 'hr': 10, 'outs': 0, 'sb': 8},
     'R1': {'bb': 9, 'er': 5, 'h': 16, 'hr': 15, 'outs': 54, 'sb': 5},
     'R2': {'bb': 4, 'er': 1, 'h': 20, 'hr': 10, 'outs': 50, 'sb': 5},
     'R3': {'bb': 4, 'er': 9, 'h': 2, 'hr': 12, 'outs': 27, 'sb': 3},
     'R4': {'bb': 0, 'er': 5, 'h': 0, 'hr': 10, 'outs': 30, 'sb': 8},
     'R5': {'bb': 7, 'er': 5, 'h': 7, 'hr': 10, 'outs': 0, 'sb': 8}}],
   {'R0': 21, 'R1': 35, 'R2': 28, 'R3': 28, 'R4': 35, 'R5': 21}),
  ('normal control 1',
   [{'R0': {'bb': 9, 'er': 12, 'h': 22, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 2, 'er': 8, 'h': 16, 'hr': 15, 'outs': 18, 'sb': 5},
     'R2': {'bb': 9, 'er': 7, 'h': 19, 'hr': 15, 'outs': 0, 'sb': 5}}],
   {'R0': 12, 'R1': 21, 'R2': 15}),
  ('normal control 2',
   [{'R0': {'bb': 7, 'er': 1, 'h': 5, 'hr': 10, 'outs': 0, 'sb': 5},
     'R1': {'bb': 10, 'er': 6, 'h': 20, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 4, 'er': 7, 'h': 20, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 12, 'R1': 21, 'R2': 15}),
  ('normal control 3',
   [{'R0': {'bb': 5, 'er': 10, 'h': 6, 'hr': 15, 'outs': 0, 'sb': 5},
     'R1': {'bb': 1, 'er': 5, 'h': 19, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 7, 'er': 7, 'h': 10, 'hr': 10, 'outs': 54, 'sb': 5}}],
   {'R0': 16, 'R1': 14, 'R2': 18})],
 [('regression: lower-is-better categories',
   [{'R0': {'bb': 7, 'er': 8, 'h': 11, 'hr': 15, 'outs': 30, 'sb': 5},
     'R1': {'bb': 1, 'er': 12, 'h': 20, 'hr': 15, 'outs': 30, 'sb': 3},
     'R2': {'bb': 1, 'er': 12, 'h': 8, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 4, 'er': 3, 'h': 5, 'hr': 15, 'outs': 90, 'sb': 8},
     'R4': {'bb': 3, 'er': 11, 'h': 19, 'hr': 12, 'outs': 81, 'sb': 5},
     'R5': {'bb': 8, 'er': 8, 'h': 11, 'hr': 12, 'outs': 54, 'sb': 5}}],
   {'R0': 27, 'R1': 18, 'R2': 21, 'R3': 46, 'R4': 31, 'R5': 25}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 8, 'er': 11, 'h': 0, 'hr': 12, 'outs': 81, 'sb': 3},
     'R1': {'bb': 7, 'er': 12, 'h': 15, 'hr': 15, 'outs': 27, 'sb': 3},
     'R2': {'bb': 7, 'er': 10, 'h': 3, 'hr': 12, 'outs': 27, 'sb': 8}}],
   {'R0': 18, 'R1': 13, 'R2': 17}),
  ('second regression',
   [{'R0': {'bb': 3, 'er': 3, 'h': 17, 'hr': 12, 'outs': 88, 'sb': 5},
     'R1': {'bb': 6, 'er': 8, 'h': 18, 'hr': 10, 'outs': 81, 'sb': 5},
     'R2': {'bb': 6, 'er': 10, 'h': 21, 'hr': 10, 'outs': 0, 'sb': 5},
     'R3': {'bb': 4, 'er': 12, 'h': 25, 'hr': 12, 'outs': 30, 'sb': 8},
     'R4': {'bb': 10, 'er': 9, 'h': 13, 'hr': 15, 'outs': 0, 'sb': 5},
     'R5': {'bb': 8, 'er': 6, 'h': 23, 'hr': 12, 'outs': 0, 'sb': 8}}],
   {'R0': 37, 'R1': 28, 'R2': 16, 'R3': 35, 'R4': 25, 'R5': 27}),
  ('normal control 1',
   [{'R0': {'bb': 4, 'er': 3, 'h': 18, 'hr': 12, 'outs': 27, 'sb': 3},
     'R1': {'bb': 9, 'er': 2, 'h': 1, 'hr': 12, 'outs': 0, 'sb': 3},
     'R2': {'bb': 9, 'er': 10, 'h': 3, 'hr': 10, 'outs': 0, 'sb': 3}}],
   {'R0': 21, 'R1': 15, 'R2': 12}),
  ('extra case 1',
   [{'R0': {'bb': 1, 'er': 8, 'h': 4, 'hr': 15, 'outs': 27, 'sb': 5},
     'R1': {'bb': 2, 'er': 8, 'h': 9, 'hr': 12, 'outs': 30, 'sb': 8},
     'R2': {'bb': 7, 'er': 9, 'h': 15, 'hr': 10, 'outs': 28, 'sb': 8},
     'R3': {'bb': 4, 'er': 11, 'h': 16, 'hr': 15, 'outs': 81, 'sb': 3},
     'R4': {'bb': 2, 'er': 11, 'h': 10, 'hr': 10, 'outs': 81, 'sb': 5},
     'R5': {'bb': 9, 'er': 10, 'h': 11, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 31, 'R1': 28, 'R2': 18, 'R3': 29, 'R4': 30, 'R5': 32}),
  ('extra case 2',
   [{'R0': {'bb': 9, 'er': 5, 'h': 18, 'hr': 12, 'outs': 81, 'sb': 5},
     'R1': {'bb': 10, 'er': 4, 'h': 22, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 7, 'er': 6, 'h': 1, 'hr': 12, 'outs': 81, 'sb': 8}}],
   {'R0': 17, 'R1': 11, 'R2': 20})],
 [('regression: lower-is-better categories',
   [{'R0': {'bb': 7, 'er': 9, 'h': 2, 'hr': 12, 'outs': 34, 'sb': 5},
     'R1': {'bb': 9, 'er': 10, 'h': 17, 'hr': 10, 'outs': 51, 'sb': 3},
     'R2': {'bb': 4, 'er': 11, 'h': 4, 'hr': 12, 'outs': 30, 'sb': 8},
     'R3': {'bb': 3, 'er': 11, 'h': 4, 'hr': 12, 'outs': 51, 'sb': 8},
     'R4': {'bb': 6, 'er': 0, 'h': 1, 'hr': 12, 'outs': 30, 'sb': 5},
     'R5': {'bb': 6, 'er': 7, 'h': 14, 'hr': 12, 'outs': 9, 'sb': 5}}],
   {'R0': 28, 'R1': 18, 'R2': 29, 'R3': 39, 'R4': 36, 'R5': 18}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 0, 'h': 17, 'hr': 12, 'outs': 30, 'sb': 8},
     'R1': {'bb': 0, 'er': 8, 'h': 17, 'hr': 12, 'outs': 81, 'sb': 8},
     'R2': {'bb': 9, 'er': 1, 'h': 19, 'hr': 12, 'outs': 54, 'sb': 3}}],
   {'R0': 17, 'R1': 17, 'R2': 14}),
  ('second regression',
   [{'R0': {'bb': 2, 'er': 3, 'h': 13, 'hr': 15, 'outs': 0, 'sb': 5},
     'R1': {'bb': 6, 'er': 0, 'h': 25, 'hr': 10, 'outs': 30, 'sb': 5},
     'R2': {'bb': 5, 'er': 4, 'h': 24, 'hr': 15, 'outs': 54, 'sb': 5}}],
   {'R0': 13, 'R1': 16, 'R2': 19}),
  ('normal control 1',
   [{'R0': {'bb': 7, 'er': 1, 'h': 6, 'hr': 12, 'outs': 81, 'sb': 5},
     'R1': {'bb': 10, 'er': 10, 'h': 8, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 8, 'er': 7, 'h': 21, 'hr': 15, 'outs': 0, 'sb': 5},
     'R3': {'bb': 7, 'er': 4, 'h': 2, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 25, 'R1': 17, 'R2': 21, 'R3': 17}),
  ('extra case 1',
   [{'R0': {'bb': 9, 'er': 12, 'h': 20, 'hr': 15, 'outs': 27, 'sb': 3},
     'R1': {'bb': 4, 'er': 8, 'h': 21, 'hr': 10, 'outs': 30, 'sb': 3},
     'R2': {'bb': 8, 'er': 9, 'h': 25, 'hr': 12, 'outs': 81, 'sb': 5},
     'R3': {'bb': 1, 'er': 6, 'h': 1, 'hr': 15, 'outs': 81, 'sb': 8},
     'R4': {'bb': 5, 'er': 7, 'h': 9, 'hr': 12, 'outs': 27, 'sb': 8},
     'R5': {'bb': 3, 'er': 11, 'h': 12, 'hr': 15, 'outs': 0, 'sb': 8}}],
   {'R0': 21, 'R1': 17, 'R2': 31, 'R3': 44, 'R4': 31, 'R5': 24}),
  ('extra case 2',
   [{'R0': {'bb': 4, 'er': 10, 'h': 11, 'hr': 12, 'outs': 30, 'sb': 8},
     'R1': {'bb': 10, 'er': 1, 'h': 5, 'hr': 12, 'outs': 11, 'sb': 5},
     'R2': {'bb': 6, 'er': 14, 'h': 23, 'hr': 10, 'outs': 30, 'sb': 5}}],
   {'R0': 21, 'R1': 16, 'R2': 11})],
 [('regression: lower-is-better categories',
   [{'R0': {'bb': 6, 'er': 4, 'h': 23, 'hr': 10, 'outs': 30, 'sb': 5},
     'R1': {'bb': 4, 'er': 9, 'h': 22, 'hr': 12, 'outs': 67, 'sb': 8},
     'R2': {'bb': 2, 'er': 14, 'h': 10, 'hr': 10, 'outs': 0, 'sb': 5},
     'R3': {'bb': 4, 'er': 2, 'h': 19, 'hr': 15, 'outs': 30, 'sb': 5}}],
   {'R0': 17, 'R1': 26, 'R2': 11, 'R3': 26}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 2, 'er': 11, 'h': 16, 'hr': 12, 'outs': 54, 'sb': 8},
     'R1': {'bb': 7, 'er': 0, 'h': 19, 'hr': 15, 'outs': 52, 'sb': 8},
     'R2': {'bb': 9, 'er': 1, 'h': 12, 'hr': 15, 'outs': 54, 'sb': 5},
     'R3': {'bb': 4, 'er': 9, 'h': 10, 'hr': 12, 'outs': 0, 'sb': 8},
     'R4': {'bb': 2, 'er': 11, 'h': 21, 'hr': 10, 'outs': 6, 'sb': 3}}],
   {'R0': 29, 'R1': 33, 'R2': 29, 'R3': 17, 'R4': 12}),
  ('second regression',
   [{'R0': {'bb': 6, 'er': 3, 'h': 4, 'hr': 15, 'outs': 0, 'sb': 5},
     'R1': {'bb': 4, 'er': 13, 'h': 0, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 4, 'er': 0, 'h': 2, 'hr': 10, 'outs': 81, 'sb': 3},
     'R3': {'bb': 1, 'er': 12, 'h': 6, 'hr': 15, 'outs': 81, 'sb': 5},
     'R4': {'bb': 9, 'er': 12, 'h': 11, 'hr': 10, 'outs': 54, 'sb': 5},
     'R5': {'bb': 7, 'er': 0, 'h': 2, 'hr': 12, 'outs': 27, 'sb': 3}}],
   {'R0': 24, 'R1': 28, 'R2': 29, 'R3': 38, 'R4': 22, 'R5': 27}),
  ('normal control 1',
   [{'R0': {'bb': 7, 'er': 8, 'h': 19, 'hr': 15, 'outs': 0, 'sb': 8},
     'R1': {'bb': 2, 'er': 1, 'h': 17, 'hr': 12, 'outs': 81, 'sb': 8},
     'R2': {'bb': 7, 'er': 0, 'h': 23, 'hr': 15, 'outs': 0, 'sb': 8}}],
   {'R0': 15, 'R1': 18, 'R2': 15}),
  ('extra case 1',
   [{'R0': {'bb': 1, 'er': 4, 'h': 6, 'hr': 12, 'outs': 54, 'sb': 5},
     'R1': {'bb': 4, 'er': 5, 'h': 14, 'hr': 15, 'outs': 0, 'sb': 5},
     'R2': {'bb': 4, 'er': 6, 'h': 16, 'hr': 12, 'outs': 30, 'sb': 5},
     'R3': {'bb': 3, 'er': 4, 'h': 4, 'hr': 12, 'outs': 30, 'sb': 5}}],
   {'R0': 25, 'R1': 17, 'R2': 17, 'R3': 21}),
  ('extra case 2',
   [{'R0': {'bb': 10, 'er': 0, 'h': 7, 'hr': 15, 'outs': 0, 'sb': 3},
     'R1': {'bb': 6, 'er': 9, 'h': 2, 'hr': 15, 'outs': 0, 'sb': 3},
     'R2': {'bb': 4, 'er': 8, 'h': 7, 'hr': 12, 'outs': 81, 'sb': 8},
     'R3': {'bb': 6, 'er': 3, 'h': 15, 'hr': 12, 'outs': 54, 'sb': 5},
     'R4': {'bb': 7, 'er': 12, 'h': 15, 'hr': 12, 'outs': 27, 'sb': 3}}],
   {'R0': 19, 'R1': 19, 'R2': 32, 'R3': 30, 'R4': 20})],
 [('regression: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 9, 'h': 5, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 3, 'er': 4, 'h': 25, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 3, 'er': 0, 'h': 4, 'hr': 12, 'outs': 27, 'sb': 8},
     'R3': {'bb': 7, 'er': 10, 'h': 3, 'hr': 12, 'outs': 54, 'sb': 5},
     'R4': {'bb': 3, 'er': 14, 'h': 16, 'hr': 12, 'outs': 81, 'sb': 8},
     'R5': {'bb': 9, 'er': 9, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 8}}],
   {'R0': 15, 'R1': 25, 'R2': 37, 'R3': 27, 'R4': 33, 'R5': 31}),
  ('partial repair probe: lower-is-better categories',
   [{'R0': {'bb': 3, 'er': 12, 'h': 4, 'hr': 12, 'outs': 0, 'sb': 3},
     'R1': {'bb': 2, 'er': 7, 'h': 23, 'hr': 15, 'outs': 27, 'sb': 3},
     'R2': {'bb': 3, 'er': 7, 'h': 4, 'hr': 10, 'outs': 27, 'sb': 8}}],
   {'R0': 11, 'R1': 18, 'R2': 19}),
  ('second regression',
   [{'R0': {'bb': 9, 'er': 5, 'h': 16, 'hr': 15, 'outs': 0, 'sb': 3},
     'R1': {'bb': 2, 'er': 5, 'h': 3, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 3, 'er': 7, 'h': 15, 'hr': 15, 'outs': 66, 'sb': 5},
     'R3': {'bb': 7, 'er': 5, 'h': 19, 'hr': 10, 'outs': 27, 'sb': 5}}],
   {'R0': 15, 'R1': 16, 'R2': 29, 'R3': 20}),
  ('normal control 1',
   [{'R0': {'bb': 10, 'er': 0, 'h': 8, 'hr': 15, 'outs': 0, 'sb': 8},
     'R1': {'bb': 7, 'er': 3, 'h': 7, 'hr': 12, 'outs': 0, 'sb': 8},
     'R2': {'bb': 4, 'er': 6, 'h': 2, 'hr': 15, 'outs': 0, 'sb': 8}}],
   {'R0': 17, 'R1': 14, 'R2': 17}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 6, 'h': 4, 'hr': 12, 'outs': 0, 'sb': 5},
     'R1': {'bb': 3, 'er': 9, 'h': 16, 'hr': 10, 'outs': 40, 'sb': 5},
     'R2': {'bb': 9, 'er': 8, 'h': 2, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 15, 'R1': 18, 'R2': 15}),
  ('normal control 3',
   [{'R0': {'bb': 7, 'er': 4, 'h': 2, 'hr': 12, 'outs': 54, 'sb': 5},
     'R1': {'bb': 1, 'er': 13, 'h': 0, 'hr': 15, 'outs': 0, 'sb': 5},
     'R2': {'bb': 9, 'er': 0, 'h': 15, 'hr': 10, 'outs': 0, 'sb': 5},
     'R3': {'bb': 5, 'er': 8, 'h': 13, 'hr': 12, 'outs': 0, 'sb': 5}}],
   {'R0': 26, 'R1': 21, 'R2': 15, 'R3': 18})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The staff allowing the most baserunners collects the most WHIP points.

Rotisserie categories HR and SB rank high-to-low; ERA (earned runs x 27 / outs) and WHIP ((walks + hits) x 3 / outs) rank low-to-high using exact ratios. A team with zero outs has no ERA/WHIP and ranks last. With n teams the best rank earns n points and the worst 1; tied teams share the average of the positions they occupy. Return team -> doubled roto points (integers).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(teams):
    names = sorted(teams)
    n = len(names)
    def value(t, cat):
        d = teams[t]
        if cat in ('hr', 'sb'):
            return Fraction(d[cat])
        if d['outs'] == 0:
            return None
        if cat == 'era':
            return Fraction(d['er'] * 27, d['outs'])
        return Fraction((d['bb'] + d['h']) * 3, d['outs'])
    total = {t: 0 for t in names}
    for cat in ('hr', 'sb', 'era', 'whip'):
        low = cat in ('era', 'whip')
        def key(t):
            v = value(t, cat)
            if v is None:
                return (0, 0)
            return (0, v if low else -v)
        ranked = sorted(names, key=key)
        i = 0
        while i < n:
            j = i
            while j < n and key(ranked[j]) == key(ranked[i]):
                j += 1
            pts2 = sum(2 * (n - r) for r in range(i, j)) // (j - i)
            for t in ranked[i:j]:
                total[t] += pts2
            i = j
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: zero innings ratio',
   [{'R0': {'bb': 8, 'er': 11, 'h': 9, 'hr': 15, 'outs': 50, 'sb': 3},
     'R1': {'bb': 4, 'er': 8, 'h': 6, 'hr': 15, 'outs': 0, 'sb': 3},
     'R2': {'bb': 3, 'er': 5, 'h': 3, 'hr': 15, 'outs': 49, 'sb': 3}}],
   {'R0': 16, 'R1': 12, 'R2': 20}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 2, 'er': 13, 'h': 5, 'hr': 12, 'outs': 30, 'sb': 5},
     'R1': {'bb': 3, 'er': 10, 'h': 0, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 7, 'er': 0, 'h': 6, 'hr': 12, 'outs': 0, 'sb': 5},
     'R3': {'bb': 8, 'er': 5, 'h': 21, 'hr': 12, 'outs': 30, 'sb': 5},
     'R4': {'bb': 9, 'er': 1, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 8},
     'R5': {'bb': 1, 'er': 11, 'h': 8, 'hr': 10, 'outs': 0, 'sb': 5}}],
   {'R0': 30, 'R1': 34, 'R2': 20, 'R3': 30, 'R4': 40, 'R5': 14}),
  ('second regression',
   [{'R0': {'bb': 2, 'er': 0, 'h': 19, 'hr': 12, 'outs': 81, 'sb': 3},
     'R1': {'bb': 8, 'er': 12, 'h': 12, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 6, 'er': 0, 'h': 3, 'hr': 12, 'outs': 0, 'sb': 5},
     'R3': {'bb': 8, 'er': 11, 'h': 25, 'hr': 15, 'outs': 30, 'sb': 5}}],
   {'R0': 22, 'R1': 20, 'R2': 14, 'R3': 24}),
  ('normal control 1',
   [{'R0': {'bb': 3, 'er': 5, 'h': 17, 'hr': 10, 'outs': 40, 'sb': 8},
     'R1': {'bb': 0, 'er': 0, 'h': 18, 'hr': 12, 'outs': 54, 'sb': 3},
     'R2': {'bb': 5, 'er': 2, 'h': 6, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 6, 'er': 2, 'h': 24, 'hr': 12, 'outs': 27, 'sb': 5},
     'R4': {'bb': 4, 'er': 5, 'h': 20, 'hr': 12, 'outs': 30, 'sb': 3}}],
   {'R0': 22, 'R1': 30, 'R2': 29, 'R3': 23, 'R4': 16}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 0, 'h': 25, 'hr': 12, 'outs': 54, 'sb': 5},
     'R1': {'bb': 10, 'er': 11, 'h': 10, 'hr': 10, 'outs': 81, 'sb': 8},
     'R2': {'bb': 3, 'er': 5, 'h': 3, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 10, 'er': 9, 'h': 7, 'hr': 10, 'outs': 55, 'sb': 8},
     'R4': {'bb': 8, 'er': 8, 'h': 20, 'hr': 12, 'outs': 22, 'sb': 5},
     'R5': {'bb': 0, 'er': 1, 'h': 3, 'hr': 12, 'outs': 30, 'sb': 5}}],
   {'R0': 30, 'R1': 30, 'R2': 28, 'R3': 26, 'R4': 18, 'R5': 36}),
  ('normal control 3',
   [{'R0': {'bb': 3, 'er': 4, 'h': 20, 'hr': 12, 'outs': 30, 'sb': 8},
     'R1': {'bb': 8, 'er': 5, 'h': 5, 'hr': 15, 'outs': 27, 'sb': 5},
     'R2': {'bb': 8, 'er': 13, 'h': 15, 'hr': 10, 'outs': 81, 'sb': 5},
     'R3': {'bb': 2, 'er': 7, 'h': 17, 'hr': 12, 'outs': 54, 'sb': 8},
     'R4': {'bb': 0, 'er': 10, 'h': 21, 'hr': 15, 'outs': 54, 'sb': 5},
     'R5': {'bb': 8, 'er': 4, 'h': 17, 'hr': 12, 'outs': 54, 'sb': 3}}],
   {'R0': 27, 'R1': 24, 'R2': 26, 'R3': 37, 'R4': 28, 'R5': 26}),
  ('normal control 4',
   [{'R0': {'bb': 3, 'er': 14, 'h': 9, 'hr': 12, 'outs': 32, 'sb': 3},
     'R1': {'bb': 6, 'er': 12, 'h': 1, 'hr': 10, 'outs': 67, 'sb': 8},
     'R2': {'bb': 0, 'er': 0, 'h': 7, 'hr': 15, 'outs': 80, 'sb': 8}}],
   {'R0': 10, 'R1': 15, 'R2': 23})],
 [('regression: zero innings ratio',
   [{'R0': {'bb': 6, 'er': 8, 'h': 1, 'hr': 15, 'outs': 81, 'sb': 3},
     'R1': {'bb': 1, 'er': 5, 'h': 0, 'hr': 12, 'outs': 81, 'sb': 3},
     'R2': {'bb': 1, 'er': 13, 'h': 4, 'hr': 15, 'outs': 27, 'sb': 3},
     'R3': {'bb': 9, 'er': 2, 'h': 7, 'hr': 12, 'outs': 7, 'sb': 3},
     'R4': {'bb': 7, 'er': 3, 'h': 9, 'hr': 10, 'outs': 0, 'sb': 8},
     'R5': {'bb': 2, 'er': 14, 'h': 20, 'hr': 12, 'outs': 81, 'sb': 8}}],
   {'R0': 36, 'R1': 35, 'R2': 28, 'R3': 21, 'R4': 17, 'R5': 31}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 9, 'er': 13, 'h': 4, 'hr': 10, 'outs': 81, 'sb': 5},
     'R1': {'bb': 9, 'er': 4, 'h': 14, 'hr': 10, 'outs': 0, 'sb': 8},
     'R2': {'bb': 9, 'er': 12, 'h': 24, 'hr': 15, 'outs': 6, 'sb': 5},
     'R3': {'bb': 3, 'er': 5, 'h': 11, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 6, 'er': 0, 'h': 4, 'hr': 10, 'outs': 0, 'sb': 5}}],
   {'R0': 27, 'R1': 20, 'R2': 27, 'R3': 31, 'R4': 15}),
  ('second regression',
   [{'R0': {'bb': 9, 'er': 2, 'h': 1, 'hr': 12, 'outs': 0, 'sb': 3},
     'R1': {'bb': 1, 'er': 8, 'h': 3, 'hr': 12, 'outs': 0, 'sb': 8},
     'R2': {'bb': 5, 'er': 13, 'h': 13, 'hr': 15, 'outs': 54, 'sb': 3}}],
   {'R0': 12, 'R1': 15, 'R2': 21}),
  ('normal control 1',
   [{'R0': {'bb': 1, 'er': 4, 'h': 12, 'hr': 12, 'outs': 30, 'sb': 3},
     'R1': {'bb': 3, 'er': 5, 'h': 18, 'hr': 12, 'outs': 75, 'sb': 3},
     'R2': {'bb': 10, 'er': 2, 'h': 21, 'hr': 12, 'outs': 54, 'sb': 5},
     'R3': {'bb': 9, 'er': 10, 'h': 7, 'hr': 12, 'outs': 81, 'sb': 8},
     'R4': {'bb': 6, 'er': 3, 'h': 8, 'hr': 15, 'outs': 36, 'sb': 3}}],
   {'R0': 15, 'R1': 25, 'R2': 25, 'R3': 29, 'R4': 26}),
  ('normal control 2',
   [{'R0': {'bb': 6, 'er': 10, 'h': 20, 'hr': 12, 'outs': 81, 'sb': 3},
     'R1': {'bb': 7, 'er': 5, 'h': 13, 'hr': 12, 'outs': 18, 'sb': 5},
     'R2': {'bb': 9, 'er': 11, 'h': 24, 'hr': 10, 'outs': 45, 'sb': 8},
     'R3': {'bb': 4, 'er': 6, 'h': 8, 'hr': 10, 'outs': 77, 'sb': 3},
     'R4': {'bb': 6, 'er': 6, 'h': 0, 'hr': 15, 'outs': 54, 'sb': 8}}],
   {'R0': 22, 'R1': 17, 'R2': 20, 'R3': 24, 'R4': 37}),
  ('normal control 3',
   [{'R0': {'bb': 2, 'er': 5, 'h': 11, 'hr': 12, 'outs': 81, 'sb': 5},
     'R1': {'bb': 5, 'er': 6, 'h': 4, 'hr': 10, 'outs': 30, 'sb': 5},
     'R2': {'bb': 3, 'er': 6, 'h': 15, 'hr': 10, 'outs': 54, 'sb': 8},
     'R3': {'bb': 5, 'er': 12, 'h': 19, 'hr': 10, 'outs': 27, 'sb': 8},
     'R4': {'bb': 0, 'er': 6, 'h': 2, 'hr': 10, 'outs': 30, 'sb': 8},
     'R5': {'bb': 7, 'er': 7, 'h': 17, 'hr': 10, 'outs': 27, 'sb': 3}}],
   {'R0': 39, 'R1': 26, 'R2': 32, 'R3': 21, 'R4': 35, 'R5': 15}),
  ('normal control 4',
   [{'R0': {'bb': 2, 'er': 6, 'h': 4, 'hr': 15, 'outs': 81, 'sb': 5},
     'R1': {'bb': 1, 'er': 3, 'h': 23, 'hr': 15, 'outs': 49, 'sb': 5},
     'R2': {'bb': 5, 'er': 2, 'h': 11, 'hr': 10, 'outs': 90, 'sb': 5},
     'R3': {'bb': 0, 'er': 0, 'h': 2, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 4, 'er': 13, 'h': 16, 'hr': 12, 'outs': 81, 'sb': 5},
     'R5': {'bb': 9, 'er': 2, 'h': 22, 'hr': 12, 'outs': 54, 'sb': 8}}],
   {'R0': 31, 'R1': 27, 'R2': 26, 'R3': 36, 'R4': 20, 'R5': 28})],
 [('regression: zero innings ratio',
   [{'R0': {'bb': 9, 'er': 6, 'h': 16, 'hr': 12, 'outs': 27, 'sb': 3},
     'R1': {'bb': 6, 'er': 7, 'h': 19, 'hr': 10, 'outs': 0, 'sb': 3},
     'R2': {'bb': 9, 'er': 5, 'h': 11, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 10, 'er': 0, 'h': 21, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 4, 'er': 9, 'h': 25, 'hr': 15, 'outs': 30, 'sb': 5},
     'R5': {'bb': 8, 'er': 6, 'h': 16, 'hr': 10, 'outs': 30, 'sb': 3}}],
   {'R0': 24, 'R1': 11, 'R2': 38, 'R3': 42, 'R4': 30, 'R5': 23}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 6, 'er': 9, 'h': 2, 'hr': 12, 'outs': 0, 'sb': 3},
     'R1': {'bb': 8, 'er': 14, 'h': 14, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 6, 'er': 6, 'h': 12, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 12, 'R1': 15, 'R2': 21}),
  ('second regression',
   [{'R0': {'bb': 8, 'er': 12, 'h': 11, 'hr': 15, 'outs': 0, 'sb': 8},
     'R1': {'bb': 8, 'er': 12, 'h': 10, 'hr': 12, 'outs': 30, 'sb': 3},
     'R2': {'bb': 5, 'er': 14, 'h': 13, 'hr': 10, 'outs': 0, 'sb': 3}}],
   {'R0': 18, 'R1': 19, 'R2': 11}),
  ('normal control 1',
   [{'R0': {'bb': 5, 'er': 6, 'h': 4, 'hr': 12, 'outs': 30, 'sb': 5},
     'R1': {'bb': 4, 'er': 2, 'h': 10, 'hr': 15, 'outs': 27, 'sb': 5},
     'R2': {'bb': 0, 'er': 6, 'h': 14, 'hr': 10, 'outs': 81, 'sb': 5}}],
   {'R0': 14, 'R1': 17, 'R2': 17}),
  ('normal control 2',
   [{'R0': {'bb': 1, 'er': 1, 'h': 25, 'hr': 10, 'outs': 30, 'sb': 3},
     'R1': {'bb': 7, 'er': 9, 'h': 2, 'hr': 10, 'outs': 54, 'sb': 5},
     'R2': {'bb': 8, 'er': 13, 'h': 12, 'hr': 15, 'outs': 30, 'sb': 5}}],
   {'R0': 13, 'R1': 18, 'R2': 17}),
  ('normal control 3',
   [{'R0': {'bb': 9, 'er': 2, 'h': 24, 'hr': 15, 'outs': 27, 'sb': 5},
     'R1': {'bb': 3, 'er': 0, 'h': 19, 'hr': 12, 'outs': 54, 'sb': 8},
     'R2': {'bb': 5, 'er': 14, 'h': 8, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 7, 'er': 6, 'h': 18, 'hr': 12, 'outs': 30, 'sb': 8}}],
   {'R0': 19, 'R1': 27, 'R2': 15, 'R3': 19}),
  ('normal control 4',
   [{'R0': {'bb': 10, 'er': 6, 'h': 11, 'hr': 10, 'outs': 30, 'sb': 5},
     'R1': {'bb': 1, 'er': 2, 'h': 6, 'hr': 12, 'outs': 27, 'sb': 5},
     'R2': {'bb': 5, 'er': 10, 'h': 21, 'hr': 15, 'outs': 27, 'sb': 5},
     'R3': {'bb': 8, 'er': 2, 'h': 4, 'hr': 12, 'outs': 27, 'sb': 8},
     'R4': {'bb': 6, 'er': 1, 'h': 16, 'hr': 10, 'outs': 30, 'sb': 5}}],
   {'R0': 18, 'R1': 29, 'R2': 19, 'R3': 32, 'R4': 22})],
 [('regression: zero innings ratio',
   [{'R0': {'bb': 4, 'er': 9, 'h': 13, 'hr': 10, 'outs': 0, 'sb': 5},
     'R1': {'bb': 5, 'er': 10, 'h': 21, 'hr': 12, 'outs': 81, 'sb': 5},
     'R2': {'bb': 2, 'er': 2, 'h': 9, 'hr': 10, 'outs': 27, 'sb': 3},
     'R3': {'bb': 5, 'er': 14, 'h': 12, 'hr': 12, 'outs': 0, 'sb': 8}}],
   {'R0': 14, 'R1': 26, 'R2': 19, 'R3': 21}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 3, 'er': 1, 'h': 16, 'hr': 10, 'outs': 90, 'sb': 3},
     'R1': {'bb': 6, 'er': 9, 'h': 12, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 1, 'er': 11, 'h': 16, 'hr': 15, 'outs': 27, 'sb': 5},
     'R3': {'bb': 6, 'er': 10, 'h': 17, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 20, 'R1': 15, 'R2': 22, 'R3': 23}),
  ('second regression',
   [{'R0': {'bb': 7, 'er': 1, 'h': 16, 'hr': 10, 'outs': 27, 'sb': 3},
     'R1': {'bb': 9, 'er': 11, 'h': 22, 'hr': 10, 'outs': 0, 'sb': 8},
     'R2': {'bb': 1, 'er': 3, 'h': 22, 'hr': 15, 'outs': 30, 'sb': 5},
     'R3': {'bb': 9, 'er': 3, 'h': 15, 'hr': 12, 'outs': 53, 'sb': 3},
     'R4': {'bb': 1, 'er': 9, 'h': 14, 'hr': 12, 'outs': 14, 'sb': 5},
     'R5': {'bb': 7, 'er': 3, 'h': 5, 'hr': 12, 'outs': 27, 'sb': 5}}],
   {'R0': 24, 'R1': 19, 'R2': 36, 'R3': 31, 'R4': 24, 'R5': 34}),
  ('normal control 1',
   [{'R0': {'bb': 2, 'er': 2, 'h': 23, 'hr': 12, 'outs': 54, 'sb': 5},
     'R1': {'bb': 8, 'er': 13, 'h': 15, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 4, 'er': 6, 'h': 1, 'hr': 15, 'outs': 81, 'sb': 3},
     'R3': {'bb': 9, 'er': 2, 'h': 23, 'hr': 15, 'outs': 81, 'sb': 5},
     'R4': {'bb': 4, 'er': 0, 'h': 4, 'hr': 15, 'outs': 81, 'sb': 3},
     'R5': {'bb': 1, 'er': 10, 'h': 20, 'hr': 15, 'outs': 27, 'sb': 3}}],
   {'R0': 27, 'R1': 19, 'R2': 31, 'R3': 37, 'R4': 35, 'R5': 19}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 0, 'h': 15, 'hr': 10, 'outs': 54, 'sb': 8},
     'R1': {'bb': 1, 'er': 2, 'h': 14, 'hr': 12, 'outs': 20, 'sb': 5},
     'R2': {'bb': 9, 'er': 0, 'h': 9, 'hr': 12, 'outs': 54, 'sb': 3},
     'R3': {'bb': 5, 'er': 3, 'h': 21, 'hr': 10, 'outs': 68, 'sb': 5}}],
   {'R0': 24, 'R1': 16, 'R2': 24, 'R3': 16}),
  ('normal control 3',
   [{'R0': {'bb': 5, 'er': 14, 'h': 5, 'hr': 10, 'outs': 56, 'sb': 5},
     'R1': {'bb': 6, 'er': 9, 'h': 2, 'hr': 12, 'outs': 27, 'sb': 5},
     'R2': {'bb': 4, 'er': 9, 'h': 25, 'hr': 12, 'outs': 54, 'sb': 8},
     'R3': {'bb': 0, 'er': 10, 'h': 14, 'hr': 12, 'outs': 54, 'sb': 3}}],
   {'R0': 19, 'R1': 17, 'R2': 24, 'R3': 20}),
  ('normal control 4',
   [{'R0': {'bb': 9, 'er': 5, 'h': 8, 'hr': 10, 'outs': 81, 'sb': 5},
     'R1': {'bb': 1, 'er': 2, 'h': 10, 'hr': 12, 'outs': 58, 'sb': 5},
     'R2': {'bb': 2, 'er': 7, 'h': 20, 'hr': 12, 'outs': 54, 'sb': 5},
     'R3': {'bb': 0, 'er': 10, 'h': 6, 'hr': 12, 'outs': 35, 'sb': 5},
     'R4': {'bb': 5, 'er': 4, 'h': 16, 'hr': 10, 'outs': 55, 'sb': 5}}],
   {'R0': 23, 'R1': 32, 'R2': 20, 'R3': 26, 'R4': 19})],
 [('regression: zero innings ratio',
   [{'R0': {'bb': 5, 'er': 5, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 3},
     'R1': {'bb': 6, 'er': 0, 'h': 16, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 7, 'er': 2, 'h': 9, 'hr': 15, 'outs': 10, 'sb': 3},
     'R3': {'bb': 8, 'er': 8, 'h': 11, 'hr': 15, 'outs': 27, 'sb': 3}}],
   {'R0': 23, 'R1': 15, 'R2': 21, 'R3': 21}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 3, 'er': 14, 'h': 22, 'hr': 15, 'outs': 0, 'sb': 8},
     'R1': {'bb': 4, 'er': 13, 'h': 24, 'hr': 12, 'outs': 29, 'sb': 5},
     'R2': {'bb': 10, 'er': 8, 'h': 21, 'hr': 10, 'outs': 0, 'sb': 3},
     'R3': {'bb': 2, 'er': 13, 'h': 12, 'hr': 15, 'outs': 0, 'sb': 8},
     'R4': {'bb': 4, 'er': 8, 'h': 7, 'hr': 12, 'outs': 46, 'sb': 3}}],
   {'R0': 26, 'R1': 27, 'R2': 13, 'R3': 26, 'R4': 28}),
  ('second regression',
   [{'R0': {'bb': 3, 'er': 7, 'h': 6, 'hr': 10, 'outs': 81, 'sb': 3},
     'R1': {'bb': 8, 'er': 10, 'h': 13, 'hr': 12, 'outs': 32, 'sb': 5},
     'R2': {'bb': 3, 'er': 0, 'h': 13, 'hr': 15, 'outs': 0, 'sb': 5},
     'R3': {'bb': 2, 'er': 0, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 5},
     'R4': {'bb': 0, 'er': 8, 'h': 13, 'hr': 12, 'outs': 30, 'sb': 8},
     'R5': {'bb': 3, 'er': 2, 'h': 5, 'hr': 12, 'outs': 84, 'sb': 5}}],
   {'R0': 22, 'R1': 22, 'R2': 23, 'R3': 34, 'R4': 31, 'R5': 36}),
  ('normal control 1',
   [{'R0': {'bb': 5, 'er': 5, 'h': 9, 'hr': 10, 'outs': 54, 'sb': 5},
     'R1': {'bb': 7, 'er': 5, 'h': 12, 'hr': 15, 'outs': 54, 'sb': 3},
     'R2': {'bb': 10, 'er': 1, 'h': 8, 'hr': 15, 'outs': 54, 'sb': 3},
     'R3': {'bb': 8, 'er': 2, 'h': 6, 'hr': 12, 'outs': 12, 'sb': 8},
     'R4': {'bb': 6, 'er': 14, 'h': 15, 'hr': 12, 'outs': 27, 'sb': 5}}],
   {'R0': 26, 'R1': 25, 'R2': 30, 'R3': 21, 'R4': 18}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 0, 'h': 19, 'hr': 15, 'outs': 81, 'sb': 5},
     'R1': {'bb': 5, 'er': 6, 'h': 21, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 1, 'er': 4, 'h': 20, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 0, 'er': 7, 'h': 25, 'hr': 15, 'outs': 30, 'sb': 3}}],
   {'R0': 29, 'R1': 21, 'R2': 17, 'R3': 13}),
  ('normal control 3',
   [{'R0': {'bb': 3, 'er': 5, 'h': 13, 'hr': 15, 'outs': 81, 'sb': 8},
     'R1': {'bb': 6, 'er': 7, 'h': 7, 'hr': 12, 'outs': 30, 'sb': 8},
     'R2': {'bb': 4, 'er': 9, 'h': 23, 'hr': 12, 'outs': 81, 'sb': 5},
     'R3': {'bb': 10, 'er': 3, 'h': 5, 'hr': 12, 'outs': 69, 'sb': 5}}],
   {'R0': 29, 'R1': 15, 'R2': 15, 'R3': 21}),
  ('normal control 4',
   [{'R0': {'bb': 5, 'er': 1, 'h': 20, 'hr': 12, 'outs': 54, 'sb': 3},
     'R1': {'bb': 4, 'er': 10, 'h': 25, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 3, 'er': 5, 'h': 20, 'hr': 15, 'outs': 30, 'sb': 8}}],
   {'R0': 17, 'R1': 11, 'R2': 20})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(teams):
    names = sorted(teams)
    n = len(names)
    def value(t, cat):
        d = teams[t]
        if cat in ('hr', 'sb'):
            return Fraction(d[cat])
        if d['outs'] == 0:
            return None
        if cat == 'era':
            return Fraction(d['er'] * 27, d['outs'])
        return Fraction((d['bb'] + d['h']) * 3, d['outs'])
    total = {t: 0 for t in names}
    for cat in ('hr', 'sb', 'era', 'whip'):
        low = cat in ('era', 'whip')
        def key(t):
            v = value(t, cat)
            if v is None:
                return (1, 0) if cat == 'era' else (0, 0)
            return (0, v if low else -v)
        ranked = sorted(names, key=key)
        i = 0
        while i < n:
            j = i
            while j < n and key(ranked[j]) == key(ranked[i]):
                j += 1
            pts2 = sum(2 * (n - r) for r in range(i, j)) // (j - i)
            for t in ranked[i:j]:
                total[t] += pts2
            i = j
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: zero innings ratio',
   [{'R0': {'bb': 8, 'er': 11, 'h': 9, 'hr': 15, 'outs': 50, 'sb': 3},
     'R1': {'bb': 4, 'er': 8, 'h': 6, 'hr': 15, 'outs': 0, 'sb': 3},
     'R2': {'bb': 3, 'er': 5, 'h': 3, 'hr': 15, 'outs': 49, 'sb': 3}}],
   {'R0': 16, 'R1': 12, 'R2': 20}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 2, 'er': 13, 'h': 5, 'hr': 12, 'outs': 30, 'sb': 5},
     'R1': {'bb': 3, 'er': 10, 'h': 0, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 7, 'er': 0, 'h': 6, 'hr': 12, 'outs': 0, 'sb': 5},
     'R3': {'bb': 8, 'er': 5, 'h': 21, 'hr': 12, 'outs': 30, 'sb': 5},
     'R4': {'bb': 9, 'er': 1, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 8},
     'R5': {'bb': 1, 'er': 11, 'h': 8, 'hr': 10, 'outs': 0, 'sb': 5}}],
   {'R0': 30, 'R1': 34, 'R2': 20, 'R3': 30, 'R4': 40, 'R5': 14}),
  ('second regression',
   [{'R0': {'bb': 2, 'er': 0, 'h': 19, 'hr': 12, 'outs': 81, 'sb': 3},
     'R1': {'bb': 8, 'er': 12, 'h': 12, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 6, 'er': 0, 'h': 3, 'hr': 12, 'outs': 0, 'sb': 5},
     'R3': {'bb': 8, 'er': 11, 'h': 25, 'hr': 15, 'outs': 30, 'sb': 5}}],
   {'R0': 22, 'R1': 20, 'R2': 14, 'R3': 24}),
  ('normal control 1',
   [{'R0': {'bb': 3, 'er': 5, 'h': 17, 'hr': 10, 'outs': 40, 'sb': 8},
     'R1': {'bb': 0, 'er': 0, 'h': 18, 'hr': 12, 'outs': 54, 'sb': 3},
     'R2': {'bb': 5, 'er': 2, 'h': 6, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 6, 'er': 2, 'h': 24, 'hr': 12, 'outs': 27, 'sb': 5},
     'R4': {'bb': 4, 'er': 5, 'h': 20, 'hr': 12, 'outs': 30, 'sb': 3}}],
   {'R0': 22, 'R1': 30, 'R2': 29, 'R3': 23, 'R4': 16}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 0, 'h': 25, 'hr': 12, 'outs': 54, 'sb': 5},
     'R1': {'bb': 10, 'er': 11, 'h': 10, 'hr': 10, 'outs': 81, 'sb': 8},
     'R2': {'bb': 3, 'er': 5, 'h': 3, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 10, 'er': 9, 'h': 7, 'hr': 10, 'outs': 55, 'sb': 8},
     'R4': {'bb': 8, 'er': 8, 'h': 20, 'hr': 12, 'outs': 22, 'sb': 5},
     'R5': {'bb': 0, 'er': 1, 'h': 3, 'hr': 12, 'outs': 30, 'sb': 5}}],
   {'R0': 30, 'R1': 30, 'R2': 28, 'R3': 26, 'R4': 18, 'R5': 36}),
  ('normal control 3',
   [{'R0': {'bb': 3, 'er': 4, 'h': 20, 'hr': 12, 'outs': 30, 'sb': 8},
     'R1': {'bb': 8, 'er': 5, 'h': 5, 'hr': 15, 'outs': 27, 'sb': 5},
     'R2': {'bb': 8, 'er': 13, 'h': 15, 'hr': 10, 'outs': 81, 'sb': 5},
     'R3': {'bb': 2, 'er': 7, 'h': 17, 'hr': 12, 'outs': 54, 'sb': 8},
     'R4': {'bb': 0, 'er': 10, 'h': 21, 'hr': 15, 'outs': 54, 'sb': 5},
     'R5': {'bb': 8, 'er': 4, 'h': 17, 'hr': 12, 'outs': 54, 'sb': 3}}],
   {'R0': 27, 'R1': 24, 'R2': 26, 'R3': 37, 'R4': 28, 'R5': 26}),
  ('normal control 4',
   [{'R0': {'bb': 3, 'er': 14, 'h': 9, 'hr': 12, 'outs': 32, 'sb': 3},
     'R1': {'bb': 6, 'er': 12, 'h': 1, 'hr': 10, 'outs': 67, 'sb': 8},
     'R2': {'bb': 0, 'er': 0, 'h': 7, 'hr': 15, 'outs': 80, 'sb': 8}}],
   {'R0': 10, 'R1': 15, 'R2': 23})],
 [('regression: zero innings ratio',
   [{'R0': {'bb': 6, 'er': 8, 'h': 1, 'hr': 15, 'outs': 81, 'sb': 3},
     'R1': {'bb': 1, 'er': 5, 'h': 0, 'hr': 12, 'outs': 81, 'sb': 3},
     'R2': {'bb': 1, 'er': 13, 'h': 4, 'hr': 15, 'outs': 27, 'sb': 3},
     'R3': {'bb': 9, 'er': 2, 'h': 7, 'hr': 12, 'outs': 7, 'sb': 3},
     'R4': {'bb': 7, 'er': 3, 'h': 9, 'hr': 10, 'outs': 0, 'sb': 8},
     'R5': {'bb': 2, 'er': 14, 'h': 20, 'hr': 12, 'outs': 81, 'sb': 8}}],
   {'R0': 36, 'R1': 35, 'R2': 28, 'R3': 21, 'R4': 17, 'R5': 31}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 9, 'er': 13, 'h': 4, 'hr': 10, 'outs': 81, 'sb': 5},
     'R1': {'bb': 9, 'er': 4, 'h': 14, 'hr': 10, 'outs': 0, 'sb': 8},
     'R2': {'bb': 9, 'er': 12, 'h': 24, 'hr': 15, 'outs': 6, 'sb': 5},
     'R3': {'bb': 3, 'er': 5, 'h': 11, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 6, 'er': 0, 'h': 4, 'hr': 10, 'outs': 0, 'sb': 5}}],
   {'R0': 27, 'R1': 20, 'R2': 27, 'R3': 31, 'R4': 15}),
  ('second regression',
   [{'R0': {'bb': 9, 'er': 2, 'h': 1, 'hr': 12, 'outs': 0, 'sb': 3},
     'R1': {'bb': 1, 'er': 8, 'h': 3, 'hr': 12, 'outs': 0, 'sb': 8},
     'R2': {'bb': 5, 'er': 13, 'h': 13, 'hr': 15, 'outs': 54, 'sb': 3}}],
   {'R0': 12, 'R1': 15, 'R2': 21}),
  ('normal control 1',
   [{'R0': {'bb': 1, 'er': 4, 'h': 12, 'hr': 12, 'outs': 30, 'sb': 3},
     'R1': {'bb': 3, 'er': 5, 'h': 18, 'hr': 12, 'outs': 75, 'sb': 3},
     'R2': {'bb': 10, 'er': 2, 'h': 21, 'hr': 12, 'outs': 54, 'sb': 5},
     'R3': {'bb': 9, 'er': 10, 'h': 7, 'hr': 12, 'outs': 81, 'sb': 8},
     'R4': {'bb': 6, 'er': 3, 'h': 8, 'hr': 15, 'outs': 36, 'sb': 3}}],
   {'R0': 15, 'R1': 25, 'R2': 25, 'R3': 29, 'R4': 26}),
  ('normal control 2',
   [{'R0': {'bb': 6, 'er': 10, 'h': 20, 'hr': 12, 'outs': 81, 'sb': 3},
     'R1': {'bb': 7, 'er': 5, 'h': 13, 'hr': 12, 'outs': 18, 'sb': 5},
     'R2': {'bb': 9, 'er': 11, 'h': 24, 'hr': 10, 'outs': 45, 'sb': 8},
     'R3': {'bb': 4, 'er': 6, 'h': 8, 'hr': 10, 'outs': 77, 'sb': 3},
     'R4': {'bb': 6, 'er': 6, 'h': 0, 'hr': 15, 'outs': 54, 'sb': 8}}],
   {'R0': 22, 'R1': 17, 'R2': 20, 'R3': 24, 'R4': 37}),
  ('normal control 3',
   [{'R0': {'bb': 2, 'er': 5, 'h': 11, 'hr': 12, 'outs': 81, 'sb': 5},
     'R1': {'bb': 5, 'er': 6, 'h': 4, 'hr': 10, 'outs': 30, 'sb': 5},
     'R2': {'bb': 3, 'er': 6, 'h': 15, 'hr': 10, 'outs': 54, 'sb': 8},
     'R3': {'bb': 5, 'er': 12, 'h': 19, 'hr': 10, 'outs': 27, 'sb': 8},
     'R4': {'bb': 0, 'er': 6, 'h': 2, 'hr': 10, 'outs': 30, 'sb': 8},
     'R5': {'bb': 7, 'er': 7, 'h': 17, 'hr': 10, 'outs': 27, 'sb': 3}}],
   {'R0': 39, 'R1': 26, 'R2': 32, 'R3': 21, 'R4': 35, 'R5': 15}),
  ('normal control 4',
   [{'R0': {'bb': 2, 'er': 6, 'h': 4, 'hr': 15, 'outs': 81, 'sb': 5},
     'R1': {'bb': 1, 'er': 3, 'h': 23, 'hr': 15, 'outs': 49, 'sb': 5},
     'R2': {'bb': 5, 'er': 2, 'h': 11, 'hr': 10, 'outs': 90, 'sb': 5},
     'R3': {'bb': 0, 'er': 0, 'h': 2, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 4, 'er': 13, 'h': 16, 'hr': 12, 'outs': 81, 'sb': 5},
     'R5': {'bb': 9, 'er': 2, 'h': 22, 'hr': 12, 'outs': 54, 'sb': 8}}],
   {'R0': 31, 'R1': 27, 'R2': 26, 'R3': 36, 'R4': 20, 'R5': 28})],
 [('regression: zero innings ratio',
   [{'R0': {'bb': 9, 'er': 6, 'h': 16, 'hr': 12, 'outs': 27, 'sb': 3},
     'R1': {'bb': 6, 'er': 7, 'h': 19, 'hr': 10, 'outs': 0, 'sb': 3},
     'R2': {'bb': 9, 'er': 5, 'h': 11, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 10, 'er': 0, 'h': 21, 'hr': 12, 'outs': 81, 'sb': 5},
     'R4': {'bb': 4, 'er': 9, 'h': 25, 'hr': 15, 'outs': 30, 'sb': 5},
     'R5': {'bb': 8, 'er': 6, 'h': 16, 'hr': 10, 'outs': 30, 'sb': 3}}],
   {'R0': 24, 'R1': 11, 'R2': 38, 'R3': 42, 'R4': 30, 'R5': 23}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 6, 'er': 9, 'h': 2, 'hr': 12, 'outs': 0, 'sb': 3},
     'R1': {'bb': 8, 'er': 14, 'h': 14, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 6, 'er': 6, 'h': 12, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 12, 'R1': 15, 'R2': 21}),
  ('second regression',
   [{'R0': {'bb': 8, 'er': 12, 'h': 11, 'hr': 15, 'outs': 0, 'sb': 8},
     'R1': {'bb': 8, 'er': 12, 'h': 10, 'hr': 12, 'outs': 30, 'sb': 3},
     'R2': {'bb': 5, 'er': 14, 'h': 13, 'hr': 10, 'outs': 0, 'sb': 3}}],
   {'R0': 18, 'R1': 19, 'R2': 11}),
  ('normal control 1',
   [{'R0': {'bb': 5, 'er': 6, 'h': 4, 'hr': 12, 'outs': 30, 'sb': 5},
     'R1': {'bb': 4, 'er': 2, 'h': 10, 'hr': 15, 'outs': 27, 'sb': 5},
     'R2': {'bb': 0, 'er': 6, 'h': 14, 'hr': 10, 'outs': 81, 'sb': 5}}],
   {'R0': 14, 'R1': 17, 'R2': 17}),
  ('normal control 2',
   [{'R0': {'bb': 1, 'er': 1, 'h': 25, 'hr': 10, 'outs': 30, 'sb': 3},
     'R1': {'bb': 7, 'er': 9, 'h': 2, 'hr': 10, 'outs': 54, 'sb': 5},
     'R2': {'bb': 8, 'er': 13, 'h': 12, 'hr': 15, 'outs': 30, 'sb': 5}}],
   {'R0': 13, 'R1': 18, 'R2': 17}),
  ('normal control 3',
   [{'R0': {'bb': 9, 'er': 2, 'h': 24, 'hr': 15, 'outs': 27, 'sb': 5},
     'R1': {'bb': 3, 'er': 0, 'h': 19, 'hr': 12, 'outs': 54, 'sb': 8},
     'R2': {'bb': 5, 'er': 14, 'h': 8, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 7, 'er': 6, 'h': 18, 'hr': 12, 'outs': 30, 'sb': 8}}],
   {'R0': 19, 'R1': 27, 'R2': 15, 'R3': 19}),
  ('normal control 4',
   [{'R0': {'bb': 10, 'er': 6, 'h': 11, 'hr': 10, 'outs': 30, 'sb': 5},
     'R1': {'bb': 1, 'er': 2, 'h': 6, 'hr': 12, 'outs': 27, 'sb': 5},
     'R2': {'bb': 5, 'er': 10, 'h': 21, 'hr': 15, 'outs': 27, 'sb': 5},
     'R3': {'bb': 8, 'er': 2, 'h': 4, 'hr': 12, 'outs': 27, 'sb': 8},
     'R4': {'bb': 6, 'er': 1, 'h': 16, 'hr': 10, 'outs': 30, 'sb': 5}}],
   {'R0': 18, 'R1': 29, 'R2': 19, 'R3': 32, 'R4': 22})],
 [('regression: zero innings ratio',
   [{'R0': {'bb': 4, 'er': 9, 'h': 13, 'hr': 10, 'outs': 0, 'sb': 5},
     'R1': {'bb': 5, 'er': 10, 'h': 21, 'hr': 12, 'outs': 81, 'sb': 5},
     'R2': {'bb': 2, 'er': 2, 'h': 9, 'hr': 10, 'outs': 27, 'sb': 3},
     'R3': {'bb': 5, 'er': 14, 'h': 12, 'hr': 12, 'outs': 0, 'sb': 8}}],
   {'R0': 14, 'R1': 26, 'R2': 19, 'R3': 21}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 3, 'er': 1, 'h': 16, 'hr': 10, 'outs': 90, 'sb': 3},
     'R1': {'bb': 6, 'er': 9, 'h': 12, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 1, 'er': 11, 'h': 16, 'hr': 15, 'outs': 27, 'sb': 5},
     'R3': {'bb': 6, 'er': 10, 'h': 17, 'hr': 12, 'outs': 81, 'sb': 5}}],
   {'R0': 20, 'R1': 15, 'R2': 22, 'R3': 23}),
  ('second regression',
   [{'R0': {'bb': 7, 'er': 1, 'h': 16, 'hr': 10, 'outs': 27, 'sb': 3},
     'R1': {'bb': 9, 'er': 11, 'h': 22, 'hr': 10, 'outs': 0, 'sb': 8},
     'R2': {'bb': 1, 'er': 3, 'h': 22, 'hr': 15, 'outs': 30, 'sb': 5},
     'R3': {'bb': 9, 'er': 3, 'h': 15, 'hr': 12, 'outs': 53, 'sb': 3},
     'R4': {'bb': 1, 'er': 9, 'h': 14, 'hr': 12, 'outs': 14, 'sb': 5},
     'R5': {'bb': 7, 'er': 3, 'h': 5, 'hr': 12, 'outs': 27, 'sb': 5}}],
   {'R0': 24, 'R1': 19, 'R2': 36, 'R3': 31, 'R4': 24, 'R5': 34}),
  ('normal control 1',
   [{'R0': {'bb': 2, 'er': 2, 'h': 23, 'hr': 12, 'outs': 54, 'sb': 5},
     'R1': {'bb': 8, 'er': 13, 'h': 15, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 4, 'er': 6, 'h': 1, 'hr': 15, 'outs': 81, 'sb': 3},
     'R3': {'bb': 9, 'er': 2, 'h': 23, 'hr': 15, 'outs': 81, 'sb': 5},
     'R4': {'bb': 4, 'er': 0, 'h': 4, 'hr': 15, 'outs': 81, 'sb': 3},
     'R5': {'bb': 1, 'er': 10, 'h': 20, 'hr': 15, 'outs': 27, 'sb': 3}}],
   {'R0': 27, 'R1': 19, 'R2': 31, 'R3': 37, 'R4': 35, 'R5': 19}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 0, 'h': 15, 'hr': 10, 'outs': 54, 'sb': 8},
     'R1': {'bb': 1, 'er': 2, 'h': 14, 'hr': 12, 'outs': 20, 'sb': 5},
     'R2': {'bb': 9, 'er': 0, 'h': 9, 'hr': 12, 'outs': 54, 'sb': 3},
     'R3': {'bb': 5, 'er': 3, 'h': 21, 'hr': 10, 'outs': 68, 'sb': 5}}],
   {'R0': 24, 'R1': 16, 'R2': 24, 'R3': 16}),
  ('normal control 3',
   [{'R0': {'bb': 5, 'er': 14, 'h': 5, 'hr': 10, 'outs': 56, 'sb': 5},
     'R1': {'bb': 6, 'er': 9, 'h': 2, 'hr': 12, 'outs': 27, 'sb': 5},
     'R2': {'bb': 4, 'er': 9, 'h': 25, 'hr': 12, 'outs': 54, 'sb': 8},
     'R3': {'bb': 0, 'er': 10, 'h': 14, 'hr': 12, 'outs': 54, 'sb': 3}}],
   {'R0': 19, 'R1': 17, 'R2': 24, 'R3': 20}),
  ('normal control 4',
   [{'R0': {'bb': 9, 'er': 5, 'h': 8, 'hr': 10, 'outs': 81, 'sb': 5},
     'R1': {'bb': 1, 'er': 2, 'h': 10, 'hr': 12, 'outs': 58, 'sb': 5},
     'R2': {'bb': 2, 'er': 7, 'h': 20, 'hr': 12, 'outs': 54, 'sb': 5},
     'R3': {'bb': 0, 'er': 10, 'h': 6, 'hr': 12, 'outs': 35, 'sb': 5},
     'R4': {'bb': 5, 'er': 4, 'h': 16, 'hr': 10, 'outs': 55, 'sb': 5}}],
   {'R0': 23, 'R1': 32, 'R2': 20, 'R3': 26, 'R4': 19})],
 [('regression: zero innings ratio',
   [{'R0': {'bb': 5, 'er': 5, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 3},
     'R1': {'bb': 6, 'er': 0, 'h': 16, 'hr': 12, 'outs': 0, 'sb': 5},
     'R2': {'bb': 7, 'er': 2, 'h': 9, 'hr': 15, 'outs': 10, 'sb': 3},
     'R3': {'bb': 8, 'er': 8, 'h': 11, 'hr': 15, 'outs': 27, 'sb': 3}}],
   {'R0': 23, 'R1': 15, 'R2': 21, 'R3': 21}),
  ('partial repair probe: zero innings ratio',
   [{'R0': {'bb': 3, 'er': 14, 'h': 22, 'hr': 15, 'outs': 0, 'sb': 8},
     'R1': {'bb': 4, 'er': 13, 'h': 24, 'hr': 12, 'outs': 29, 'sb': 5},
     'R2': {'bb': 10, 'er': 8, 'h': 21, 'hr': 10, 'outs': 0, 'sb': 3},
     'R3': {'bb': 2, 'er': 13, 'h': 12, 'hr': 15, 'outs': 0, 'sb': 8},
     'R4': {'bb': 4, 'er': 8, 'h': 7, 'hr': 12, 'outs': 46, 'sb': 3}}],
   {'R0': 26, 'R1': 27, 'R2': 13, 'R3': 26, 'R4': 28}),
  ('second regression',
   [{'R0': {'bb': 3, 'er': 7, 'h': 6, 'hr': 10, 'outs': 81, 'sb': 3},
     'R1': {'bb': 8, 'er': 10, 'h': 13, 'hr': 12, 'outs': 32, 'sb': 5},
     'R2': {'bb': 3, 'er': 0, 'h': 13, 'hr': 15, 'outs': 0, 'sb': 5},
     'R3': {'bb': 2, 'er': 0, 'h': 12, 'hr': 12, 'outs': 54, 'sb': 5},
     'R4': {'bb': 0, 'er': 8, 'h': 13, 'hr': 12, 'outs': 30, 'sb': 8},
     'R5': {'bb': 3, 'er': 2, 'h': 5, 'hr': 12, 'outs': 84, 'sb': 5}}],
   {'R0': 22, 'R1': 22, 'R2': 23, 'R3': 34, 'R4': 31, 'R5': 36}),
  ('normal control 1',
   [{'R0': {'bb': 5, 'er': 5, 'h': 9, 'hr': 10, 'outs': 54, 'sb': 5},
     'R1': {'bb': 7, 'er': 5, 'h': 12, 'hr': 15, 'outs': 54, 'sb': 3},
     'R2': {'bb': 10, 'er': 1, 'h': 8, 'hr': 15, 'outs': 54, 'sb': 3},
     'R3': {'bb': 8, 'er': 2, 'h': 6, 'hr': 12, 'outs': 12, 'sb': 8},
     'R4': {'bb': 6, 'er': 14, 'h': 15, 'hr': 12, 'outs': 27, 'sb': 5}}],
   {'R0': 26, 'R1': 25, 'R2': 30, 'R3': 21, 'R4': 18}),
  ('normal control 2',
   [{'R0': {'bb': 5, 'er': 0, 'h': 19, 'hr': 15, 'outs': 81, 'sb': 5},
     'R1': {'bb': 5, 'er': 6, 'h': 21, 'hr': 12, 'outs': 54, 'sb': 5},
     'R2': {'bb': 1, 'er': 4, 'h': 20, 'hr': 12, 'outs': 27, 'sb': 5},
     'R3': {'bb': 0, 'er': 7, 'h': 25, 'hr': 15, 'outs': 30, 'sb': 3}}],
   {'R0': 29, 'R1': 21, 'R2': 17, 'R3': 13}),
  ('normal control 3',
   [{'R0': {'bb': 3, 'er': 5, 'h': 13, 'hr': 15, 'outs': 81, 'sb': 8},
     'R1': {'bb': 6, 'er': 7, 'h': 7, 'hr': 12, 'outs': 30, 'sb': 8},
     'R2': {'bb': 4, 'er': 9, 'h': 23, 'hr': 12, 'outs': 81, 'sb': 5},
     'R3': {'bb': 10, 'er': 3, 'h': 5, 'hr': 12, 'outs': 69, 'sb': 5}}],
   {'R0': 29, 'R1': 15, 'R2': 15, 'R3': 21}),
  ('normal control 4',
   [{'R0': {'bb': 5, 'er': 1, 'h': 20, 'hr': 12, 'outs': 54, 'sb': 3},
     'R1': {'bb': 4, 'er': 10, 'h': 25, 'hr': 12, 'outs': 30, 'sb': 5},
     'R2': {'bb': 3, 'er': 5, 'h': 20, 'hr': 15, 'outs': 30, 'sb': 8}}],
   {'R0': 17, 'R1': 11, 'R2': 20})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A roster that never pitched ranks first in both ratio categories.

Rotisserie categories HR and SB rank high-to-low; ERA (earned runs x 27 / outs) and WHIP ((walks + hits) x 3 / outs) rank low-to-high using exact ratios. A team with zero outs has no ERA/WHIP and ranks last. With n teams the best rank earns n points and the worst 1; tied teams share the average of the positions they occupy. Return team -> doubled roto points (integers).

split: open-access