broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(games):
    t = {}
    for h, hg, a, ag, decided, so_winner in games:
        if decided == 'SO':
            if so_winner == h:
                hg += 1
            else:
                ag += 1
        for team, f, g in ((h, hg, ag), (a, ag, hg)):
            row = t.setdefault(team, {'pts': 0, 'rw': 0, 'row': 0, 'w': 0, 'gd': 0})
            row['gd'] += f - g
            if f > g:
                row['pts'] += 2
                row['w'] += 1
                if decided == 'REG':
                    row['rw'] += 1
                row['row'] += 1
            elif decided != 'REG':
                row['pts'] += 1
    order = sorted(t, key=lambda k: (-t[k]['pts'], -t[k]['rw'], -t[k]['row'], -t[k]['w'], -t[k]['gd'], k))
    return [[k, t[k]['pts'], t[k]['rw'], t[k]['row'], t[k]['w'], t[k]['gd']] for k in order]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Lynx', 1, 'Bears', 1, 'SO', 'Lynx'],
     ['Otters', 1, 'Bears', 0, 'OT', None],
     ['Bears', 3, 'Otters', 4, 'OT', None],
     ['Bears', 1, 'Otters', 3, 'REG', None],
     ['Lynx', 3, 'Bears', 4, 'OT', None],
     ['Lynx', 3, 'Otters', 1, 'REG', None]],),
   [['Otters', 6, 1, 3, 3, 2], ['Lynx', 5, 1, 1, 2, 2], ['Bears', 5, 0, 1, 1, -4]]),
  ('variant scenario 1',
   ([['Lynx', 1, 'Otters', 1, 'SO', 'Lynx'],
     ['Hawks', 1, 'Bears', 0, 'OT', None],
     ['Hawks', 0, 'Lynx', 5, 'REG', None],
     ['Otters', 1, 'Hawks', 1, 'SO', 'Otters'],
     ['Lynx', 3, 'Bears', 4, 'REG', None]],),
   [['Lynx', 4, 1, 1, 2, 5],
    ['Bears', 3, 1, 1, 1, 0],
    ['Hawks', 3, 0, 1, 1, -5],
    ['Otters', 3, 0, 0, 1, 0]]),
  ('variant scenario 2',
   ([['Lynx', 3, 'Hawks', 5, 'REG', None],
     ['Bears', 3, 'Hawks', 4, 'REG', None],
     ['Lynx', 5, 'Otters', 3, 'REG', None],
     ['Hawks', 1, 'Lynx', 0, 'OT', None]],),
   [['Hawks', 6, 2, 3, 3, 4],
    ['Lynx', 3, 1, 1, 1, -1],
    ['Bears', 0, 0, 0, 0, -1],
    ['Otters', 0, 0, 0, 0, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Hawks', 1, 'Otters', 2, 'OT', None],
     ['Otters', 4, 'Hawks', 2, 'REG', None],
     ['Lynx', 0, 'Otters', 5, 'REG', None],
     ['Bears', 1, 'Otters', 2, 'REG', None],
     ['Bears', 3, 'Otters', 1, 'REG', None]],),
   [['Otters', 8, 3, 4, 4, 7],
    ['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 1, 0, 0, 0, -3],
    ['Lynx', 0, 0, 0, 0, -5]]),
  ('regression: row shootout exclusion',
   ([['Lynx', 4, 'Bears', 3, 'OT', None],
     ['Otters', 3, 'Lynx', 3, 'SO', 'Lynx'],
     ['Lynx', 1, 'Otters', 0, 'OT', None],
     ['Otters', 3, 'Hawks', 3, 'SO', 'Otters'],
     ['Lynx', 0, 'Bears', 2, 'REG', None],
     ['Hawks', 0, 'Otters', 1, 'OT', None]],),
   [['Lynx', 6, 0, 2, 3, 1],
    ['Otters', 6, 0, 1, 2, 0],
    ['Bears', 3, 1, 1, 1, 1],
    ['Hawks', 2, 0, 0, 0, -2]]),
  ('variant scenario 1',
   ([['Otters', 3, 'Lynx', 4, 'OT', None],
     ['Hawks', 4, 'Lynx', 3, 'REG', None],
     ['Bears', 1, 'Hawks', 3, 'REG', None]],),
   [['Hawks', 4, 2, 2, 2, 3],
    ['Lynx', 2, 0, 1, 1, 0],
    ['Otters', 1, 0, 0, 0, -1],
    ['Bears', 0, 0, 0, 0, -2]]),
  ('variant scenario 2',
   ([['Bears', 0, 'Hawks', 0, 'SO', 'Hawks'],
     ['Bears', 5, 'Hawks', 3, 'REG', None],
     ['Hawks', 1, 'Bears', 0, 'OT', None],
     ['Bears', 1, 'Otters', 5, 'REG', None],
     ['Bears', 5, 'Lynx', 1, 'REG', None]],),
   [['Bears', 6, 2, 2, 2, 0],
    ['Hawks', 4, 0, 1, 2, 0],
    ['Otters', 2, 1, 1, 1, 4],
    ['Lynx', 0, 0, 0, 0, -4]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Otters', 0, 'Hawks', 3, 'REG', None],
     ['Bears', 0, 'Hawks', 3, 'REG', None],
     ['Lynx', 2, 'Otters', 2, 'SO', 'Lynx'],
     ['Otters', 0, 'Hawks', 0, 'SO', 'Otters'],
     ['Bears', 1, 'Lynx', 1, 'SO', 'Bears'],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Hawks'],
     ['Otters', 0, 'Hawks', 0, 'SO', 'Hawks']],),
   [['Hawks', 9, 2, 2, 4, 7],
    ['Otters', 4, 0, 0, 1, -4],
    ['Lynx', 3, 0, 0, 1, 0],
    ['Bears', 3, 0, 0, 1, -3]]),
  ('regression: row shootout exclusion',
   ([['Bears', 0, 'Hawks', 3, 'REG', None],
     ['Bears', 3, 'Lynx', 3, 'SO', 'Lynx'],
     ['Hawks', 1, 'Bears', 5, 'REG', None],
     ['Otters', 3, 'Lynx', 4, 'OT', None],
     ['Lynx', 0, 'Hawks', 2, 'REG', None],
     ['Otters', 5, 'Hawks', 4, 'OT', None],
     ['Lynx', 5, 'Hawks', 4, 'REG', None]],),
   [['Lynx', 6, 1, 2, 3, 1],
    ['Hawks', 5, 2, 2, 2, -1],
    ['Bears', 3, 1, 1, 1, 0],
    ['Otters', 3, 0, 1, 1, 0]]),
  ('variant scenario 1',
   ([['Hawks', 3, 'Otters', 4, 'OT', None],
     ['Otters', 1, 'Hawks', 3, 'REG', None],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Hawks'],
     ['Bears', 1, 'Lynx', 5, 'REG', None],
     ['Otters', 4, 'Bears', 4, 'SO', 'Otters'],
     ['Hawks', 3, 'Otters', 4, 'REG', None],
     ['Hawks', 0, 'Bears', 2, 'REG', None],
     ['Lynx', 4, 'Otters', 4, 'SO', 'Lynx']],),
   [['Otters', 7, 1, 2, 3, 0],
    ['Hawks', 5, 1, 1, 2, -1],
    ['Lynx', 4, 1, 1, 2, 5],
    ['Bears', 4, 1, 1, 1, -4]]),
  ('variant scenario 2',
   ([['Otters', 1, 'Bears', 1, 'SO', 'Otters'],
     ['Lynx', 1, 'Hawks', 1, 'SO', 'Hawks'],
     ['Otters', 5, 'Hawks', 1, 'REG', None],
     ['Lynx', 0, 'Otters', 1, 'OT', None],
     ['Hawks', 2, 'Lynx', 3, 'REG', None]],),
   [['Otters', 6, 1, 2, 3, 6],
    ['Lynx', 4, 1, 1, 1, -1],
    ['Hawks', 2, 0, 0, 1, -4],
    ['Bears', 1, 0, 0, 0, -1]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Lynx', 2, 'Otters', 0, 'REG', None],
     ['Otters', 3, 'Bears', 3, 'SO', 'Bears'],
     ['Bears', 4, 'Lynx', 3, 'REG', None],
     ['Otters', 0, 'Hawks', 3, 'REG', None]],),
   [['Bears', 4, 1, 1, 2, 2],
    ['Hawks', 2, 1, 1, 1, 3],
    ['Lynx', 2, 1, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -6]]),
  ('regression: row shootout exclusion',
   ([['Otters', 3, 'Lynx', 2, 'REG', None],
     ['Lynx', 0, 'Hawks', 4, 'REG', None],
     ['Otters', 1, 'Hawks', 0, 'REG', None],
     ['Bears', 2, 'Hawks', 2, 'SO', 'Bears'],
     ['Bears', 3, 'Otters', 2, 'OT', None],
     ['Hawks', 1, 'Bears', 4, 'REG', None],
     ['Bears', 0, 'Hawks', 2, 'REG', None],
     ['Otters', 5, 'Hawks', 1, 'REG', None],
     ['Lynx', 3, 'Otters', 2, 'OT', None]],),
   [['Otters', 8, 3, 3, 3, 4],
    ['Bears', 6, 1, 2, 3, 3],
    ['Hawks', 5, 2, 2, 2, -3],
    ['Lynx', 2, 0, 1, 1, -4]]),
  ('variant scenario 1',
   ([['Otters', 3, 'Lynx', 0, 'REG', None],
     ['Bears', 4, 'Lynx', 4, 'SO', 'Bears'],
     ['Hawks', 0, 'Lynx', 0, 'SO', 'Lynx'],
     ['Otters', 4, 'Hawks', 2, 'REG', None],
     ['Bears', 3, 'Hawks', 2, 'REG', None],
     ['Bears', 1, 'Otters', 2, 'REG', None],
     ['Otters', 1, 'Bears', 4, 'REG', None],
     ['Otters', 1, 'Bears', 1, 'SO', 'Bears'],
     ['Bears', 4, 'Otters', 4, 'SO', 'Bears']],),
   [['Bears', 10, 2, 2, 5, 6],
    ['Otters', 8, 3, 3, 3, 1],
    ['Lynx', 3, 0, 0, 1, -3],
    ['Hawks', 1, 0, 0, 0, -4]]),
  ('variant scenario 2',
   ([['Lynx', 4, 'Otters', 3, 'REG', None],
     ['Bears', 5, 'Otters', 4, 'OT', None],
     ['Bears', 4, 'Lynx', 0, 'REG', None],
     ['Bears', 3, 'Hawks', 3, 'SO', 'Hawks'],
     ['Hawks', 3, 'Lynx', 3, 'SO', 'Lynx']],),
   [['Bears', 5, 1, 2, 2, 4],
    ['Lynx', 4, 1, 1, 2, -2],
    ['Hawks', 3, 0, 0, 1, 0],
    ['Otters', 1, 0, 0, 0, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Hawks', 5, 'Bears', 1, 'REG', None],
     ['Bears', 0, 'Lynx', 0, 'SO', 'Bears'],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Bears'],
     ['Hawks', 2, 'Lynx', 1, 'OT', None],
     ['Otters', 1, 'Bears', 5, 'REG', None],
     ['Hawks', 1, 'Otters', 2, 'OT', None],
     ['Lynx', 0, 'Hawks', 4, 'REG', None],
     ['Lynx', 0, 'Bears', 4, 'REG', None],
     ['Otters', 3, 'Bears', 2, 'REG', None],
     ['Otters', 1, 'Bears', 2, 'REG', None]],),
   [['Bears', 10, 3, 3, 5, 6],
    ['Hawks', 8, 2, 3, 3, 7],
    ['Otters', 4, 1, 2, 2, -3],
    ['Lynx', 2, 0, 0, 0, -10]]),
  ('variant scenario 1',
   ([['Hawks', 4, 'Otters', 3, 'OT', None],
     ['Lynx', 1, 'Bears', 1, 'SO', 'Bears'],
     ['Bears', 4, 'Otters', 2, 'REG', None],
     ['Otters', 0, 'Lynx', 1, 'REG', None],
     ['Bears', 1, 'Hawks', 4, 'REG', None],
     ['Otters', 4, 'Lynx', 5, 'REG', None],
     ['Hawks', 2, 'Bears', 3, 'OT', None],
     ['Lynx', 0, 'Bears', 1, 'OT', None],
     ['Hawks', 2, 'Otters', 3, 'REG', None],
     ['Otters', 4, 'Lynx', 4, 'SO', 'Lynx']],),
   [['Lynx', 8, 2, 2, 3, 1],
    ['Bears', 8, 1, 3, 4, 2],
    ['Hawks', 5, 1, 2, 2, 2],
    ['Otters', 4, 1, 1, 1, -5]]),
  ('variant scenario 2',
   ([['Bears', 4, 'Lynx', 4, 'SO', 'Bears'],
     ['Bears', 2, 'Lynx', 3, 'OT', None],
     ['Lynx', 2, 'Otters', 2, 'SO', 'Lynx'],
     ['Lynx', 3, 'Hawks', 5, 'REG', None],
     ['Bears', 1, 'Lynx', 2, 'OT', None],
     ['Bears', 3, 'Lynx', 4, 'REG', None],
     ['Hawks', 2, 'Bears', 0, 'REG', None],
     ['Otters', 0, 'Lynx', 3, 'REG', None]],),
   [['Lynx', 11, 2, 4, 5, 4],
    ['Hawks', 4, 2, 2, 2, 4],
    ['Bears', 4, 0, 0, 1, -4],
    ['Otters', 1, 0, 0, 0, -4]])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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

N = 1
observations = []
def solve(games):
    t = {}
    for h, hg, a, ag, decided, so_winner in games:
        if decided == 'SO':
            if so_winner == h:
                hg += 1
            else:
                ag += 1
        for team, f, g in ((h, hg, ag), (a, ag, hg)):
            row = t.setdefault(team, {'pts': 0, 'rw': 0, 'row': 0, 'w': 0, 'gd': 0})
            row['gd'] += f - g
            if f > g:
                row['pts'] += 2
                row['w'] += 1
                if decided == 'REG':
                    row['rw'] += 1
                if decided == 'REG':
                    row['row'] += 1
            elif decided != 'REG':
                row['pts'] += 1
    order = sorted(t, key=lambda k: (-t[k]['pts'], -t[k]['rw'], -t[k]['row'], -t[k]['w'], -t[k]['gd'], k))
    return [[k, t[k]['pts'], t[k]['rw'], t[k]['row'], t[k]['w'], t[k]['gd']] for k in order]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Lynx', 1, 'Bears', 1, 'SO', 'Lynx'],
     ['Otters', 1, 'Bears', 0, 'OT', None],
     ['Bears', 3, 'Otters', 4, 'OT', None],
     ['Bears', 1, 'Otters', 3, 'REG', None],
     ['Lynx', 3, 'Bears', 4, 'OT', None],
     ['Lynx', 3, 'Otters', 1, 'REG', None]],),
   [['Otters', 6, 1, 3, 3, 2], ['Lynx', 5, 1, 1, 2, 2], ['Bears', 5, 0, 1, 1, -4]]),
  ('variant scenario 1',
   ([['Lynx', 1, 'Otters', 1, 'SO', 'Lynx'],
     ['Hawks', 1, 'Bears', 0, 'OT', None],
     ['Hawks', 0, 'Lynx', 5, 'REG', None],
     ['Otters', 1, 'Hawks', 1, 'SO', 'Otters'],
     ['Lynx', 3, 'Bears', 4, 'REG', None]],),
   [['Lynx', 4, 1, 1, 2, 5],
    ['Bears', 3, 1, 1, 1, 0],
    ['Hawks', 3, 0, 1, 1, -5],
    ['Otters', 3, 0, 0, 1, 0]]),
  ('variant scenario 2',
   ([['Lynx', 3, 'Hawks', 5, 'REG', None],
     ['Bears', 3, 'Hawks', 4, 'REG', None],
     ['Lynx', 5, 'Otters', 3, 'REG', None],
     ['Hawks', 1, 'Lynx', 0, 'OT', None]],),
   [['Hawks', 6, 2, 3, 3, 4],
    ['Lynx', 3, 1, 1, 1, -1],
    ['Bears', 0, 0, 0, 0, -1],
    ['Otters', 0, 0, 0, 0, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Hawks', 1, 'Otters', 2, 'OT', None],
     ['Otters', 4, 'Hawks', 2, 'REG', None],
     ['Lynx', 0, 'Otters', 5, 'REG', None],
     ['Bears', 1, 'Otters', 2, 'REG', None],
     ['Bears', 3, 'Otters', 1, 'REG', None]],),
   [['Otters', 8, 3, 4, 4, 7],
    ['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 1, 0, 0, 0, -3],
    ['Lynx', 0, 0, 0, 0, -5]]),
  ('regression: row shootout exclusion',
   ([['Lynx', 4, 'Bears', 3, 'OT', None],
     ['Otters', 3, 'Lynx', 3, 'SO', 'Lynx'],
     ['Lynx', 1, 'Otters', 0, 'OT', None],
     ['Otters', 3, 'Hawks', 3, 'SO', 'Otters'],
     ['Lynx', 0, 'Bears', 2, 'REG', None],
     ['Hawks', 0, 'Otters', 1, 'OT', None]],),
   [['Lynx', 6, 0, 2, 3, 1],
    ['Otters', 6, 0, 1, 2, 0],
    ['Bears', 3, 1, 1, 1, 1],
    ['Hawks', 2, 0, 0, 0, -2]]),
  ('variant scenario 1',
   ([['Otters', 3, 'Lynx', 4, 'OT', None],
     ['Hawks', 4, 'Lynx', 3, 'REG', None],
     ['Bears', 1, 'Hawks', 3, 'REG', None]],),
   [['Hawks', 4, 2, 2, 2, 3],
    ['Lynx', 2, 0, 1, 1, 0],
    ['Otters', 1, 0, 0, 0, -1],
    ['Bears', 0, 0, 0, 0, -2]]),
  ('variant scenario 2',
   ([['Bears', 0, 'Hawks', 0, 'SO', 'Hawks'],
     ['Bears', 5, 'Hawks', 3, 'REG', None],
     ['Hawks', 1, 'Bears', 0, 'OT', None],
     ['Bears', 1, 'Otters', 5, 'REG', None],
     ['Bears', 5, 'Lynx', 1, 'REG', None]],),
   [['Bears', 6, 2, 2, 2, 0],
    ['Hawks', 4, 0, 1, 2, 0],
    ['Otters', 2, 1, 1, 1, 4],
    ['Lynx', 0, 0, 0, 0, -4]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Otters', 0, 'Hawks', 3, 'REG', None],
     ['Bears', 0, 'Hawks', 3, 'REG', None],
     ['Lynx', 2, 'Otters', 2, 'SO', 'Lynx'],
     ['Otters', 0, 'Hawks', 0, 'SO', 'Otters'],
     ['Bears', 1, 'Lynx', 1, 'SO', 'Bears'],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Hawks'],
     ['Otters', 0, 'Hawks', 0, 'SO', 'Hawks']],),
   [['Hawks', 9, 2, 2, 4, 7],
    ['Otters', 4, 0, 0, 1, -4],
    ['Lynx', 3, 0, 0, 1, 0],
    ['Bears', 3, 0, 0, 1, -3]]),
  ('regression: row shootout exclusion',
   ([['Bears', 0, 'Hawks', 3, 'REG', None],
     ['Bears', 3, 'Lynx', 3, 'SO', 'Lynx'],
     ['Hawks', 1, 'Bears', 5, 'REG', None],
     ['Otters', 3, 'Lynx', 4, 'OT', None],
     ['Lynx', 0, 'Hawks', 2, 'REG', None],
     ['Otters', 5, 'Hawks', 4, 'OT', None],
     ['Lynx', 5, 'Hawks', 4, 'REG', None]],),
   [['Lynx', 6, 1, 2, 3, 1],
    ['Hawks', 5, 2, 2, 2, -1],
    ['Bears', 3, 1, 1, 1, 0],
    ['Otters', 3, 0, 1, 1, 0]]),
  ('variant scenario 1',
   ([['Hawks', 3, 'Otters', 4, 'OT', None],
     ['Otters', 1, 'Hawks', 3, 'REG', None],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Hawks'],
     ['Bears', 1, 'Lynx', 5, 'REG', None],
     ['Otters', 4, 'Bears', 4, 'SO', 'Otters'],
     ['Hawks', 3, 'Otters', 4, 'REG', None],
     ['Hawks', 0, 'Bears', 2, 'REG', None],
     ['Lynx', 4, 'Otters', 4, 'SO', 'Lynx']],),
   [['Otters', 7, 1, 2, 3, 0],
    ['Hawks', 5, 1, 1, 2, -1],
    ['Lynx', 4, 1, 1, 2, 5],
    ['Bears', 4, 1, 1, 1, -4]]),
  ('variant scenario 2',
   ([['Otters', 1, 'Bears', 1, 'SO', 'Otters'],
     ['Lynx', 1, 'Hawks', 1, 'SO', 'Hawks'],
     ['Otters', 5, 'Hawks', 1, 'REG', None],
     ['Lynx', 0, 'Otters', 1, 'OT', None],
     ['Hawks', 2, 'Lynx', 3, 'REG', None]],),
   [['Otters', 6, 1, 2, 3, 6],
    ['Lynx', 4, 1, 1, 1, -1],
    ['Hawks', 2, 0, 0, 1, -4],
    ['Bears', 1, 0, 0, 0, -1]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Lynx', 2, 'Otters', 0, 'REG', None],
     ['Otters', 3, 'Bears', 3, 'SO', 'Bears'],
     ['Bears', 4, 'Lynx', 3, 'REG', None],
     ['Otters', 0, 'Hawks', 3, 'REG', None]],),
   [['Bears', 4, 1, 1, 2, 2],
    ['Hawks', 2, 1, 1, 1, 3],
    ['Lynx', 2, 1, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -6]]),
  ('regression: row shootout exclusion',
   ([['Otters', 3, 'Lynx', 2, 'REG', None],
     ['Lynx', 0, 'Hawks', 4, 'REG', None],
     ['Otters', 1, 'Hawks', 0, 'REG', None],
     ['Bears', 2, 'Hawks', 2, 'SO', 'Bears'],
     ['Bears', 3, 'Otters', 2, 'OT', None],
     ['Hawks', 1, 'Bears', 4, 'REG', None],
     ['Bears', 0, 'Hawks', 2, 'REG', None],
     ['Otters', 5, 'Hawks', 1, 'REG', None],
     ['Lynx', 3, 'Otters', 2, 'OT', None]],),
   [['Otters', 8, 3, 3, 3, 4],
    ['Bears', 6, 1, 2, 3, 3],
    ['Hawks', 5, 2, 2, 2, -3],
    ['Lynx', 2, 0, 1, 1, -4]]),
  ('variant scenario 1',
   ([['Otters', 3, 'Lynx', 0, 'REG', None],
     ['Bears', 4, 'Lynx', 4, 'SO', 'Bears'],
     ['Hawks', 0, 'Lynx', 0, 'SO', 'Lynx'],
     ['Otters', 4, 'Hawks', 2, 'REG', None],
     ['Bears', 3, 'Hawks', 2, 'REG', None],
     ['Bears', 1, 'Otters', 2, 'REG', None],
     ['Otters', 1, 'Bears', 4, 'REG', None],
     ['Otters', 1, 'Bears', 1, 'SO', 'Bears'],
     ['Bears', 4, 'Otters', 4, 'SO', 'Bears']],),
   [['Bears', 10, 2, 2, 5, 6],
    ['Otters', 8, 3, 3, 3, 1],
    ['Lynx', 3, 0, 0, 1, -3],
    ['Hawks', 1, 0, 0, 0, -4]]),
  ('variant scenario 2',
   ([['Lynx', 4, 'Otters', 3, 'REG', None],
     ['Bears', 5, 'Otters', 4, 'OT', None],
     ['Bears', 4, 'Lynx', 0, 'REG', None],
     ['Bears', 3, 'Hawks', 3, 'SO', 'Hawks'],
     ['Hawks', 3, 'Lynx', 3, 'SO', 'Lynx']],),
   [['Bears', 5, 1, 2, 2, 4],
    ['Lynx', 4, 1, 1, 2, -2],
    ['Hawks', 3, 0, 0, 1, 0],
    ['Otters', 1, 0, 0, 0, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: row shootout exclusion',
   ([['Hawks', 5, 'Bears', 1, 'REG', None],
     ['Bears', 0, 'Lynx', 0, 'SO', 'Bears'],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Bears'],
     ['Hawks', 2, 'Lynx', 1, 'OT', None],
     ['Otters', 1, 'Bears', 5, 'REG', None],
     ['Hawks', 1, 'Otters', 2, 'OT', None],
     ['Lynx', 0, 'Hawks', 4, 'REG', None],
     ['Lynx', 0, 'Bears', 4, 'REG', None],
     ['Otters', 3, 'Bears', 2, 'REG', None],
     ['Otters', 1, 'Bears', 2, 'REG', None]],),
   [['Bears', 10, 3, 3, 5, 6],
    ['Hawks', 8, 2, 3, 3, 7],
    ['Otters', 4, 1, 2, 2, -3],
    ['Lynx', 2, 0, 0, 0, -10]]),
  ('variant scenario 1',
   ([['Hawks', 4, 'Otters', 3, 'OT', None],
     ['Lynx', 1, 'Bears', 1, 'SO', 'Bears'],
     ['Bears', 4, 'Otters', 2, 'REG', None],
     ['Otters', 0, 'Lynx', 1, 'REG', None],
     ['Bears', 1, 'Hawks', 4, 'REG', None],
     ['Otters', 4, 'Lynx', 5, 'REG', None],
     ['Hawks', 2, 'Bears', 3, 'OT', None],
     ['Lynx', 0, 'Bears', 1, 'OT', None],
     ['Hawks', 2, 'Otters', 3, 'REG', None],
     ['Otters', 4, 'Lynx', 4, 'SO', 'Lynx']],),
   [['Lynx', 8, 2, 2, 3, 1],
    ['Bears', 8, 1, 3, 4, 2],
    ['Hawks', 5, 1, 2, 2, 2],
    ['Otters', 4, 1, 1, 1, -5]]),
  ('variant scenario 2',
   ([['Bears', 4, 'Lynx', 4, 'SO', 'Bears'],
     ['Bears', 2, 'Lynx', 3, 'OT', None],
     ['Lynx', 2, 'Otters', 2, 'SO', 'Lynx'],
     ['Lynx', 3, 'Hawks', 5, 'REG', None],
     ['Bears', 1, 'Lynx', 2, 'OT', None],
     ['Bears', 3, 'Lynx', 4, 'REG', None],
     ['Hawks', 2, 'Bears', 0, 'REG', None],
     ['Otters', 0, 'Lynx', 3, 'REG', None]],),
   [['Lynx', 11, 2, 4, 5, 4],
    ['Hawks', 4, 2, 2, 2, 4],
    ['Bears', 4, 0, 0, 1, -4],
    ['Otters', 1, 0, 0, 0, -4]])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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 team with shootout wins is ranked ahead on ROW.

Ice hockey standings. games rows are [home, home_goals, away, away_goals, decided, so_winner] with decided in REG, OT, SO; for SO the listed goals are tied and so_winner names the winner. A win is 2 points and an OT or SO loss 1 point. The shootout winner is credited with one extra goal for, the loser one extra goal against. RW counts regulation wins, ROW regulation plus overtime wins (not shootouts). Rank by points, then RW, then ROW, then total wins, then goal difference, then name. Return [team, points, RW, ROW, W, GD].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(games):
    t = {}
    for h, hg, a, ag, decided, so_winner in games:
        for team, f, g in ((h, hg, ag), (a, ag, hg)):
            row = t.setdefault(team, {'pts': 0, 'rw': 0, 'row': 0, 'w': 0, 'gd': 0})
            row['gd'] += f - g
            if f > g:
                row['pts'] += 2
                row['w'] += 1
                if decided == 'REG':
                    row['rw'] += 1
                if decided != 'SO':
                    row['row'] += 1
            elif decided != 'REG':
                row['pts'] += 1
    order = sorted(t, key=lambda k: (-t[k]['pts'], -t[k]['rw'], -t[k]['row'], -t[k]['w'], -t[k]['gd'], k))
    return [[k, t[k]['pts'], t[k]['rw'], t[k]['row'], t[k]['w'], t[k]['gd']] for k in order]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Hawks', 1, 'Lynx', 2, 'OT', None],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Hawks'],
     ['Otters', 2, 'Hawks', 2, 'SO', 'Otters'],
     ['Otters', 2, 'Lynx', 1, 'REG', None]],),
   [['Otters', 4, 1, 1, 2, 2],
    ['Hawks', 4, 0, 0, 1, -1],
    ['Lynx', 2, 0, 1, 1, 0],
    ['Bears', 1, 0, 0, 0, -1]]),
  ('variant scenario 1',
   ([['Lynx', 2, 'Otters', 3, 'OT', None],
     ['Lynx', 1, 'Otters', 1, 'SO', 'Otters'],
     ['Hawks', 4, 'Lynx', 5, 'OT', None],
     ['Lynx', 5, 'Bears', 2, 'REG', None]],),
   [['Lynx', 6, 1, 2, 2, 2],
    ['Otters', 4, 0, 1, 2, 2],
    ['Hawks', 1, 0, 0, 0, -1],
    ['Bears', 0, 0, 0, 0, -3]]),
  ('variant scenario 2',
   ([['Otters', 3, 'Lynx', 2, 'OT', None],
     ['Lynx', 2, 'Otters', 4, 'REG', None],
     ['Bears', 0, 'Otters', 5, 'REG', None],
     ['Hawks', 5, 'Lynx', 2, 'REG', None],
     ['Hawks', 2, 'Otters', 3, 'OT', None]],),
   [['Otters', 8, 2, 4, 4, 9],
    ['Hawks', 3, 1, 1, 1, 2],
    ['Lynx', 1, 0, 0, 0, -6],
    ['Bears', 0, 0, 0, 0, -5]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Otters', 2, 'Lynx', 4, 'REG', None],
     ['Bears', 0, 'Lynx', 0, 'SO', 'Bears'],
     ['Hawks', 4, 'Bears', 4, 'SO', 'Hawks'],
     ['Hawks', 4, 'Lynx', 5, 'OT', None],
     ['Bears', 0, 'Hawks', 3, 'REG', None],
     ['Otters', 2, 'Lynx', 0, 'REG', None]],),
   [['Lynx', 5, 1, 2, 2, 0],
    ['Hawks', 5, 1, 1, 2, 3],
    ['Bears', 3, 0, 0, 1, -3],
    ['Otters', 2, 1, 1, 1, 0]]),
  ('variant scenario 1',
   ([['Lynx', 4, 'Hawks', 4, 'SO', 'Lynx'],
     ['Lynx', 1, 'Bears', 1, 'SO', 'Bears'],
     ['Otters', 1, 'Bears', 1, 'SO', 'Otters'],
     ['Bears', 0, 'Lynx', 1, 'OT', None],
     ['Hawks', 1, 'Bears', 4, 'REG', None],
     ['Bears', 3, 'Hawks', 3, 'SO', 'Hawks']],),
   [['Bears', 7, 1, 1, 2, 1],
    ['Lynx', 5, 0, 1, 2, 1],
    ['Hawks', 3, 0, 0, 1, -3],
    ['Otters', 2, 0, 0, 1, 1]]),
  ('variant scenario 2',
   ([['Lynx', 4, 'Hawks', 5, 'REG', None],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Hawks'],
     ['Otters', 4, 'Bears', 0, 'REG', None],
     ['Lynx', 5, 'Otters', 4, 'REG', None],
     ['Hawks', 5, 'Otters', 2, 'REG', None],
     ['Otters', 2, 'Bears', 2, 'SO', 'Bears'],
     ['Hawks', 3, 'Lynx', 2, 'OT', None]],),
   [['Hawks', 8, 2, 3, 4, 6],
    ['Lynx', 3, 1, 1, 1, -1],
    ['Otters', 3, 1, 1, 1, -1],
    ['Bears', 3, 0, 0, 1, -4]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Lynx', 4, 'Otters', 3, 'OT', None],
     ['Bears', 0, 'Lynx', 3, 'REG', None],
     ['Lynx', 3, 'Bears', 5, 'REG', None],
     ['Lynx', 0, 'Otters', 0, 'SO', 'Otters'],
     ['Otters', 3, 'Bears', 5, 'REG', None],
     ['Otters', 3, 'Hawks', 3, 'SO', 'Otters'],
     ['Otters', 1, 'Bears', 1, 'SO', 'Bears']],),
   [['Bears', 6, 2, 2, 3, 2],
    ['Otters', 6, 0, 0, 2, -2],
    ['Lynx', 5, 1, 2, 2, 1],
    ['Hawks', 1, 0, 0, 0, -1]]),
  ('variant scenario 1',
   ([['Bears', 3, 'Otters', 2, 'OT', None],
     ['Hawks', 0, 'Lynx', 4, 'REG', None],
     ['Otters', 4, 'Lynx', 4, 'SO', 'Lynx'],
     ['Bears', 4, 'Otters', 4, 'SO', 'Otters'],
     ['Bears', 1, 'Hawks', 0, 'OT', None],
     ['Lynx', 3, 'Otters', 2, 'OT', None],
     ['Otters', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Lynx', 6, 1, 2, 3, 6],
    ['Otters', 6, 0, 0, 1, -3],
    ['Bears', 5, 0, 2, 2, 1],
    ['Hawks', 3, 0, 0, 1, -4]]),
  ('variant scenario 2',
   ([['Hawks', 2, 'Otters', 3, 'OT', None],
     ['Hawks', 5, 'Lynx', 4, 'REG', None],
     ['Bears', 2, 'Hawks', 5, 'REG', None],
     ['Otters', 2, 'Bears', 5, 'REG', None]],),
   [['Hawks', 5, 2, 2, 2, 3],
    ['Bears', 2, 1, 1, 1, 0],
    ['Otters', 2, 0, 1, 1, -2],
    ['Lynx', 0, 0, 0, 0, -1]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Lynx', 0, 'Bears', 1, 'REG', None],
     ['Lynx', 4, 'Otters', 5, 'REG', None],
     ['Otters', 4, 'Hawks', 1, 'REG', None],
     ['Hawks', 1, 'Lynx', 1, 'SO', 'Lynx'],
     ['Bears', 3, 'Hawks', 3, 'SO', 'Bears'],
     ['Hawks', 4, 'Lynx', 5, 'OT', None],
     ['Bears', 2, 'Otters', 0, 'REG', None],
     ['Otters', 4, 'Hawks', 4, 'SO', 'Otters']],),
   [['Bears', 6, 2, 2, 3, 4],
    ['Otters', 6, 2, 2, 3, 3],
    ['Lynx', 4, 0, 1, 2, 0],
    ['Hawks', 4, 0, 0, 0, -7]]),
  ('variant scenario 1',
   ([['Lynx', 1, 'Hawks', 1, 'SO', 'Lynx'],
     ['Otters', 0, 'Lynx', 0, 'SO', 'Lynx'],
     ['Otters', 2, 'Bears', 2, 'SO', 'Otters'],
     ['Bears', 2, 'Otters', 2, 'SO', 'Otters'],
     ['Hawks', 2, 'Lynx', 3, 'REG', None],
     ['Bears', 0, 'Otters', 5, 'REG', None],
     ['Otters', 2, 'Lynx', 2, 'SO', 'Otters'],
     ['Hawks', 1, 'Otters', 1, 'SO', 'Otters'],
     ['Lynx', 0, 'Otters', 2, 'REG', None]],),
   [['Otters', 13, 2, 2, 6, 10],
    ['Lynx', 7, 1, 1, 3, 0],
    ['Hawks', 2, 0, 0, 0, -3],
    ['Bears', 2, 0, 0, 0, -7]]),
  ('variant scenario 2',
   ([['Otters', 4, 'Bears', 4, 'SO', 'Otters'],
     ['Lynx', 4, 'Otters', 3, 'OT', None],
     ['Hawks', 1, 'Otters', 3, 'REG', None]],),
   [['Otters', 5, 1, 1, 2, 2],
    ['Lynx', 2, 0, 1, 1, 1],
    ['Bears', 1, 0, 0, 0, -1],
    ['Hawks', 0, 0, 0, 0, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Lynx', 5, 'Otters', 4, 'REG', None],
     ['Lynx', 2, 'Bears', 4, 'REG', None],
     ['Hawks', 4, 'Bears', 5, 'REG', None],
     ['Hawks', 0, 'Otters', 1, 'REG', None],
     ['Bears', 3, 'Otters', 3, 'SO', 'Otters'],
     ['Bears', 1, 'Hawks', 0, 'OT', None],
     ['Hawks', 1, 'Otters', 1, 'SO', 'Hawks']],),
   [['Bears', 7, 2, 3, 3, 3],
    ['Otters', 5, 1, 1, 2, 0],
    ['Hawks', 3, 0, 0, 1, -2],
    ['Lynx', 2, 1, 1, 1, -1]]),
  ('variant scenario 1',
   ([['Lynx', 0, 'Bears', 3, 'REG', None],
     ['Bears', 3, 'Lynx', 2, 'OT', None],
     ['Lynx', 2, 'Hawks', 2, 'SO', 'Lynx'],
     ['Hawks', 0, 'Lynx', 0, 'SO', 'Lynx'],
     ['Lynx', 1, 'Hawks', 2, 'OT', None]],),
   [['Lynx', 6, 0, 0, 2, -3], ['Bears', 4, 1, 2, 2, 4], ['Hawks', 4, 0, 1, 1, -1]]),
  ('variant scenario 2',
   ([['Bears', 2, 'Otters', 3, 'OT', None],
     ['Hawks', 3, 'Bears', 0, 'REG', None],
     ['Otters', 5, 'Bears', 2, 'REG', None],
     ['Bears', 1, 'Hawks', 3, 'REG', None],
     ['Hawks', 3, 'Otters', 5, 'REG', None],
     ['Lynx', 4, 'Bears', 4, 'SO', 'Bears'],
     ['Lynx', 4, 'Otters', 5, 'OT', None]],),
   [['Otters', 8, 2, 4, 4, 7],
    ['Hawks', 4, 2, 2, 2, 3],
    ['Bears', 3, 0, 0, 1, -8],
    ['Lynx', 2, 0, 0, 0, -2]])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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

N = 1
observations = []
def solve(games):
    t = {}
    for h, hg, a, ag, decided, so_winner in games:
        if decided == 'SO':
            if so_winner == h:
                hg += 1
            else:
                ag += 1
        for team, f, g in ((h, hg, ag), (a, ag, hg)):
            row = t.setdefault(team, {'pts': 0, 'rw': 0, 'row': 0, 'w': 0, 'gd': 0})
            row['gd'] += f - g
            if decided == 'SO' and team == so_winner:
                row['gd'] += 1
            if f > g:
                row['pts'] += 2
                row['w'] += 1
                if decided == 'REG':
                    row['rw'] += 1
                if decided != 'SO':
                    row['row'] += 1
            elif decided != 'REG':
                row['pts'] += 1
    order = sorted(t, key=lambda k: (-t[k]['pts'], -t[k]['rw'], -t[k]['row'], -t[k]['w'], -t[k]['gd'], k))
    return [[k, t[k]['pts'], t[k]['rw'], t[k]['row'], t[k]['w'], t[k]['gd']] for k in order]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Hawks', 1, 'Lynx', 2, 'OT', None],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Hawks'],
     ['Otters', 2, 'Hawks', 2, 'SO', 'Otters'],
     ['Otters', 2, 'Lynx', 1, 'REG', None]],),
   [['Otters', 4, 1, 1, 2, 2],
    ['Hawks', 4, 0, 0, 1, -1],
    ['Lynx', 2, 0, 1, 1, 0],
    ['Bears', 1, 0, 0, 0, -1]]),
  ('variant scenario 1',
   ([['Lynx', 2, 'Otters', 3, 'OT', None],
     ['Lynx', 1, 'Otters', 1, 'SO', 'Otters'],
     ['Hawks', 4, 'Lynx', 5, 'OT', None],
     ['Lynx', 5, 'Bears', 2, 'REG', None]],),
   [['Lynx', 6, 1, 2, 2, 2],
    ['Otters', 4, 0, 1, 2, 2],
    ['Hawks', 1, 0, 0, 0, -1],
    ['Bears', 0, 0, 0, 0, -3]]),
  ('variant scenario 2',
   ([['Otters', 3, 'Lynx', 2, 'OT', None],
     ['Lynx', 2, 'Otters', 4, 'REG', None],
     ['Bears', 0, 'Otters', 5, 'REG', None],
     ['Hawks', 5, 'Lynx', 2, 'REG', None],
     ['Hawks', 2, 'Otters', 3, 'OT', None]],),
   [['Otters', 8, 2, 4, 4, 9],
    ['Hawks', 3, 1, 1, 1, 2],
    ['Lynx', 1, 0, 0, 0, -6],
    ['Bears', 0, 0, 0, 0, -5]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Otters', 2, 'Lynx', 4, 'REG', None],
     ['Bears', 0, 'Lynx', 0, 'SO', 'Bears'],
     ['Hawks', 4, 'Bears', 4, 'SO', 'Hawks'],
     ['Hawks', 4, 'Lynx', 5, 'OT', None],
     ['Bears', 0, 'Hawks', 3, 'REG', None],
     ['Otters', 2, 'Lynx', 0, 'REG', None]],),
   [['Lynx', 5, 1, 2, 2, 0],
    ['Hawks', 5, 1, 1, 2, 3],
    ['Bears', 3, 0, 0, 1, -3],
    ['Otters', 2, 1, 1, 1, 0]]),
  ('variant scenario 1',
   ([['Lynx', 4, 'Hawks', 4, 'SO', 'Lynx'],
     ['Lynx', 1, 'Bears', 1, 'SO', 'Bears'],
     ['Otters', 1, 'Bears', 1, 'SO', 'Otters'],
     ['Bears', 0, 'Lynx', 1, 'OT', None],
     ['Hawks', 1, 'Bears', 4, 'REG', None],
     ['Bears', 3, 'Hawks', 3, 'SO', 'Hawks']],),
   [['Bears', 7, 1, 1, 2, 1],
    ['Lynx', 5, 0, 1, 2, 1],
    ['Hawks', 3, 0, 0, 1, -3],
    ['Otters', 2, 0, 0, 1, 1]]),
  ('variant scenario 2',
   ([['Lynx', 4, 'Hawks', 5, 'REG', None],
     ['Hawks', 0, 'Bears', 0, 'SO', 'Hawks'],
     ['Otters', 4, 'Bears', 0, 'REG', None],
     ['Lynx', 5, 'Otters', 4, 'REG', None],
     ['Hawks', 5, 'Otters', 2, 'REG', None],
     ['Otters', 2, 'Bears', 2, 'SO', 'Bears'],
     ['Hawks', 3, 'Lynx', 2, 'OT', None]],),
   [['Hawks', 8, 2, 3, 4, 6],
    ['Lynx', 3, 1, 1, 1, -1],
    ['Otters', 3, 1, 1, 1, -1],
    ['Bears', 3, 0, 0, 1, -4]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Lynx', 4, 'Otters', 3, 'OT', None],
     ['Bears', 0, 'Lynx', 3, 'REG', None],
     ['Lynx', 3, 'Bears', 5, 'REG', None],
     ['Lynx', 0, 'Otters', 0, 'SO', 'Otters'],
     ['Otters', 3, 'Bears', 5, 'REG', None],
     ['Otters', 3, 'Hawks', 3, 'SO', 'Otters'],
     ['Otters', 1, 'Bears', 1, 'SO', 'Bears']],),
   [['Bears', 6, 2, 2, 3, 2],
    ['Otters', 6, 0, 0, 2, -2],
    ['Lynx', 5, 1, 2, 2, 1],
    ['Hawks', 1, 0, 0, 0, -1]]),
  ('variant scenario 1',
   ([['Bears', 3, 'Otters', 2, 'OT', None],
     ['Hawks', 0, 'Lynx', 4, 'REG', None],
     ['Otters', 4, 'Lynx', 4, 'SO', 'Lynx'],
     ['Bears', 4, 'Otters', 4, 'SO', 'Otters'],
     ['Bears', 1, 'Hawks', 0, 'OT', None],
     ['Lynx', 3, 'Otters', 2, 'OT', None],
     ['Otters', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Lynx', 6, 1, 2, 3, 6],
    ['Otters', 6, 0, 0, 1, -3],
    ['Bears', 5, 0, 2, 2, 1],
    ['Hawks', 3, 0, 0, 1, -4]]),
  ('variant scenario 2',
   ([['Hawks', 2, 'Otters', 3, 'OT', None],
     ['Hawks', 5, 'Lynx', 4, 'REG', None],
     ['Bears', 2, 'Hawks', 5, 'REG', None],
     ['Otters', 2, 'Bears', 5, 'REG', None]],),
   [['Hawks', 5, 2, 2, 2, 3],
    ['Bears', 2, 1, 1, 1, 0],
    ['Otters', 2, 0, 1, 1, -2],
    ['Lynx', 0, 0, 0, 0, -1]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Lynx', 0, 'Bears', 1, 'REG', None],
     ['Lynx', 4, 'Otters', 5, 'REG', None],
     ['Otters', 4, 'Hawks', 1, 'REG', None],
     ['Hawks', 1, 'Lynx', 1, 'SO', 'Lynx'],
     ['Bears', 3, 'Hawks', 3, 'SO', 'Bears'],
     ['Hawks', 4, 'Lynx', 5, 'OT', None],
     ['Bears', 2, 'Otters', 0, 'REG', None],
     ['Otters', 4, 'Hawks', 4, 'SO', 'Otters']],),
   [['Bears', 6, 2, 2, 3, 4],
    ['Otters', 6, 2, 2, 3, 3],
    ['Lynx', 4, 0, 1, 2, 0],
    ['Hawks', 4, 0, 0, 0, -7]]),
  ('variant scenario 1',
   ([['Lynx', 1, 'Hawks', 1, 'SO', 'Lynx'],
     ['Otters', 0, 'Lynx', 0, 'SO', 'Lynx'],
     ['Otters', 2, 'Bears', 2, 'SO', 'Otters'],
     ['Bears', 2, 'Otters', 2, 'SO', 'Otters'],
     ['Hawks', 2, 'Lynx', 3, 'REG', None],
     ['Bears', 0, 'Otters', 5, 'REG', None],
     ['Otters', 2, 'Lynx', 2, 'SO', 'Otters'],
     ['Hawks', 1, 'Otters', 1, 'SO', 'Otters'],
     ['Lynx', 0, 'Otters', 2, 'REG', None]],),
   [['Otters', 13, 2, 2, 6, 10],
    ['Lynx', 7, 1, 1, 3, 0],
    ['Hawks', 2, 0, 0, 0, -3],
    ['Bears', 2, 0, 0, 0, -7]]),
  ('variant scenario 2',
   ([['Otters', 4, 'Bears', 4, 'SO', 'Otters'],
     ['Lynx', 4, 'Otters', 3, 'OT', None],
     ['Hawks', 1, 'Otters', 3, 'REG', None]],),
   [['Otters', 5, 1, 1, 2, 2],
    ['Lynx', 2, 0, 1, 1, 1],
    ['Bears', 1, 0, 0, 0, -1],
    ['Hawks', 0, 0, 0, 0, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: shootout goal credit',
   ([['Lynx', 5, 'Otters', 4, 'REG', None],
     ['Lynx', 2, 'Bears', 4, 'REG', None],
     ['Hawks', 4, 'Bears', 5, 'REG', None],
     ['Hawks', 0, 'Otters', 1, 'REG', None],
     ['Bears', 3, 'Otters', 3, 'SO', 'Otters'],
     ['Bears', 1, 'Hawks', 0, 'OT', None],
     ['Hawks', 1, 'Otters', 1, 'SO', 'Hawks']],),
   [['Bears', 7, 2, 3, 3, 3],
    ['Otters', 5, 1, 1, 2, 0],
    ['Hawks', 3, 0, 0, 1, -2],
    ['Lynx', 2, 1, 1, 1, -1]]),
  ('variant scenario 1',
   ([['Lynx', 0, 'Bears', 3, 'REG', None],
     ['Bears', 3, 'Lynx', 2, 'OT', None],
     ['Lynx', 2, 'Hawks', 2, 'SO', 'Lynx'],
     ['Hawks', 0, 'Lynx', 0, 'SO', 'Lynx'],
     ['Lynx', 1, 'Hawks', 2, 'OT', None]],),
   [['Lynx', 6, 0, 0, 2, -3], ['Bears', 4, 1, 2, 2, 4], ['Hawks', 4, 0, 1, 1, -1]]),
  ('variant scenario 2',
   ([['Bears', 2, 'Otters', 3, 'OT', None],
     ['Hawks', 3, 'Bears', 0, 'REG', None],
     ['Otters', 5, 'Bears', 2, 'REG', None],
     ['Bears', 1, 'Hawks', 3, 'REG', None],
     ['Hawks', 3, 'Otters', 5, 'REG', None],
     ['Lynx', 4, 'Bears', 4, 'SO', 'Bears'],
     ['Lynx', 4, 'Otters', 5, 'OT', None]],),
   [['Otters', 8, 2, 4, 4, 7],
    ['Hawks', 4, 2, 2, 2, 3],
    ['Bears', 3, 0, 0, 1, -8],
    ['Lynx', 2, 0, 0, 0, -2]])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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:
After a shootout both teams show an unchanged goal difference.

Ice hockey standings. games rows are [home, home_goals, away, away_goals, decided, so_winner] with decided in REG, OT, SO; for SO the listed goals are tied and so_winner names the winner. A win is 2 points and an OT or SO loss 1 point. The shootout winner is credited with one extra goal for, the loser one extra goal against. RW counts regulation wins, ROW regulation plus overtime wins (not shootouts). Rank by points, then RW, then ROW, then total wins, then goal difference, then name. Return [team, points, RW, ROW, W, GD].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(games):
    t = {}
    for h, hg, a, ag, decided, so_winner in games:
        if decided == 'SO':
            if so_winner == h:
                hg += 1
            else:
                ag += 1
        for team, f, g in ((h, hg, ag), (a, ag, hg)):
            row = t.setdefault(team, {'pts': 0, 'rw': 0, 'row': 0, 'w': 0, 'gd': 0})
            row['gd'] += f - g
            if f > g:
                row['pts'] += 2
                row['w'] += 1
                if decided == 'REG':
                    row['rw'] += 1
                if decided != 'SO':
                    row['row'] += 1
            elif decided != 'REG':
                row['pts'] += 1
    order = sorted(t, key=lambda k: (-t[k]['pts'], -t[k]['row'], -t[k]['rw'], -t[k]['w'], -t[k]['gd'], k))
    return [[k, t[k]['pts'], t[k]['rw'], t[k]['row'], t[k]['w'], t[k]['gd']] for k in order]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Bears', 3, 'Hawks', 3, 'SO', 'Hawks'],
     ['Lynx', 3, 'Bears', 5, 'REG', None],
     ['Lynx', 5, 'Bears', 4, 'OT', None],
     ['Lynx', 3, 'Otters', 3, 'SO', 'Lynx'],
     ['Otters', 3, 'Hawks', 3, 'SO', 'Otters']],),
   [['Bears', 4, 1, 1, 1, 0],
    ['Lynx', 4, 0, 1, 2, 0],
    ['Hawks', 3, 0, 0, 1, 0],
    ['Otters', 3, 0, 0, 1, 0]]),
  ('regression: rw row order',
   ([['Otters', 4, 'Hawks', 3, 'OT', None],
     ['Lynx', 4, 'Bears', 1, 'REG', None],
     ['Bears', 1, 'Hawks', 0, 'OT', None],
     ['Bears', 0, 'Lynx', 0, 'SO', 'Lynx'],
     ['Lynx', 0, 'Bears', 1, 'OT', None]],),
   [['Lynx', 5, 1, 1, 2, 3],
    ['Bears', 5, 0, 2, 2, -2],
    ['Otters', 2, 0, 1, 1, 1],
    ['Hawks', 2, 0, 0, 0, -2]]),
  ('variant scenario 1',
   ([['Otters', 0, 'Hawks', 0, 'SO', 'Hawks'],
     ['Lynx', 4, 'Hawks', 3, 'OT', None],
     ['Otters', 1, 'Bears', 2, 'REG', None],
     ['Otters', 5, 'Bears', 4, 'REG', None],
     ['Lynx', 1, 'Bears', 3, 'REG', None]],),
   [['Bears', 4, 2, 2, 2, 2],
    ['Otters', 3, 1, 1, 1, -1],
    ['Hawks', 3, 0, 0, 1, 0],
    ['Lynx', 2, 0, 1, 1, -1]]),
  ('variant scenario 2',
   ([['Bears', 0, 'Lynx', 1, 'REG', None],
     ['Lynx', 4, 'Bears', 4, 'SO', 'Lynx'],
     ['Bears', 4, 'Lynx', 5, 'OT', None],
     ['Otters', 3, 'Bears', 4, 'OT', None],
     ['Otters', 0, 'Hawks', 3, 'REG', None],
     ['Lynx', 2, 'Otters', 3, 'REG', None]],),
   [['Lynx', 6, 1, 2, 3, 2],
    ['Bears', 4, 0, 1, 1, -2],
    ['Otters', 3, 1, 1, 1, -3],
    ['Hawks', 2, 1, 1, 1, 3]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Otters', 4, 'Bears', 5, 'REG', None],
     ['Lynx', 3, 'Hawks', 3, 'SO', 'Lynx'],
     ['Bears', 2, 'Otters', 2, 'SO', 'Otters'],
     ['Otters', 0, 'Hawks', 0, 'SO', 'Hawks'],
     ['Lynx', 0, 'Hawks', 1, 'OT', None],
     ['Lynx', 5, 'Otters', 1, 'REG', None],
     ['Bears', 1, 'Otters', 5, 'REG', None]],),
   [['Lynx', 5, 1, 1, 2, 4],
    ['Otters', 5, 1, 1, 2, -1],
    ['Hawks', 5, 0, 1, 2, 1],
    ['Bears', 3, 1, 1, 1, -4]]),
  ('regression: rw row order',
   ([['Bears', 4, 'Hawks', 3, 'OT', None],
     ['Otters', 1, 'Hawks', 5, 'REG', None],
     ['Bears', 2, 'Lynx', 3, 'REG', None],
     ['Hawks', 0, 'Bears', 1, 'OT', None]],),
   [['Hawks', 4, 1, 1, 1, 2],
    ['Bears', 4, 0, 2, 2, 1],
    ['Lynx', 2, 1, 1, 1, 1],
    ['Otters', 0, 0, 0, 0, -4]]),
  ('variant scenario 1',
   ([['Otters', 2, 'Hawks', 3, 'OT', None],
     ['Otters', 2, 'Bears', 3, 'OT', None],
     ['Otters', 4, 'Hawks', 3, 'OT', None]],),
   [['Otters', 4, 0, 1, 1, -1], ['Hawks', 3, 0, 1, 1, 0], ['Bears', 2, 0, 1, 1, 1]]),
  ('variant scenario 2',
   ([['Lynx', 3, 'Otters', 4, 'REG', None],
     ['Hawks', 1, 'Otters', 0, 'REG', None],
     ['Hawks', 0, 'Bears', 3, 'REG', None],
     ['Bears', 2, 'Lynx', 3, 'OT', None],
     ['Bears', 2, 'Lynx', 0, 'REG', None]],),
   [['Bears', 5, 2, 2, 2, 4],
    ['Otters', 2, 1, 1, 1, 0],
    ['Hawks', 2, 1, 1, 1, -2],
    ['Lynx', 2, 0, 1, 1, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Bears', 1, 'Lynx', 0, 'OT', None],
     ['Bears', 0, 'Hawks', 4, 'REG', None],
     ['Otters', 0, 'Bears', 5, 'REG', None],
     ['Lynx', 5, 'Otters', 4, 'OT', None],
     ['Bears', 2, 'Lynx', 4, 'REG', None],
     ['Hawks', 2, 'Otters', 3, 'REG', None],
     ['Otters', 4, 'Hawks', 3, 'REG', None]],),
   [['Otters', 5, 2, 2, 2, -4],
    ['Lynx', 5, 1, 2, 2, 2],
    ['Bears', 4, 1, 2, 2, 0],
    ['Hawks', 2, 1, 1, 1, 2]]),
  ('regression: rw row order',
   ([['Otters', 2, 'Bears', 3, 'OT', None],
     ['Hawks', 5, 'Lynx', 4, 'OT', None],
     ['Bears', 3, 'Otters', 2, 'OT', None],
     ['Otters', 4, 'Bears', 3, 'REG', None]],),
   [['Otters', 4, 1, 1, 1, -1],
    ['Bears', 4, 0, 2, 2, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Lynx', 1, 0, 0, 0, -1]]),
  ('variant scenario 1',
   ([['Lynx', 1, 'Hawks', 0, 'OT', None],
     ['Bears', 0, 'Hawks', 0, 'SO', 'Hawks'],
     ['Lynx', 4, 'Hawks', 3, 'OT', None],
     ['Lynx', 2, 'Bears', 2, 'SO', 'Bears'],
     ['Lynx', 1, 'Hawks', 0, 'REG', None],
     ['Hawks', 1, 'Otters', 4, 'REG', None],
     ['Bears', 3, 'Otters', 0, 'REG', None],
     ['Lynx', 5, 'Otters', 4, 'REG', None]],),
   [['Lynx', 9, 2, 4, 4, 3],
    ['Bears', 5, 1, 1, 2, 3],
    ['Hawks', 4, 0, 0, 1, -5],
    ['Otters', 2, 1, 1, 1, -1]]),
  ('variant scenario 2',
   ([['Otters', 1, 'Hawks', 1, 'SO', 'Hawks'],
     ['Bears', 3, 'Hawks', 5, 'REG', None],
     ['Lynx', 2, 'Bears', 1, 'OT', None],
     ['Otters', 5, 'Bears', 4, 'REG', None],
     ['Lynx', 1, 'Hawks', 1, 'SO', 'Lynx'],
     ['Bears', 3, 'Otters', 1, 'REG', None],
     ['Otters', 2, 'Hawks', 3, 'OT', None],
     ['Otters', 0, 'Lynx', 1, 'OT', None]],),
   [['Hawks', 7, 1, 2, 3, 3],
    ['Lynx', 6, 0, 2, 3, 3],
    ['Otters', 5, 1, 1, 1, -4],
    ['Bears', 3, 1, 1, 1, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Bears', 1, 'Lynx', 1, 'SO', 'Bears'],
     ['Bears', 1, 'Lynx', 0, 'OT', None],
     ['Hawks', 5, 'Lynx', 0, 'REG', None],
     ['Lynx', 5, 'Bears', 1, 'REG', None]],),
   [['Lynx', 4, 1, 1, 1, -3], ['Bears', 4, 0, 1, 2, -2], ['Hawks', 2, 1, 1, 1, 5]]),
  ('regression: rw row order',
   ([['Bears', 1, 'Hawks', 0, 'REG', None],
     ['Lynx', 0, 'Bears', 0, 'SO', 'Bears'],
     ['Bears', 5, 'Otters', 2, 'REG', None],
     ['Lynx', 4, 'Otters', 2, 'REG', None],
     ['Hawks', 4, 'Otters', 3, 'OT', None],
     ['Otters', 2, 'Bears', 4, 'REG', None],
     ['Hawks', 0, 'Otters', 1, 'REG', None],
     ['Otters', 0, 'Bears', 1, 'REG', None],
     ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 10, 4, 4, 5, 8],
    ['Otters', 4, 1, 1, 1, -9],
    ['Hawks', 4, 0, 2, 2, 0],
    ['Lynx', 3, 1, 1, 1, 1]]),
  ('variant scenario 1',
   ([['Hawks', 3, 'Otters', 5, 'REG', None],
     ['Lynx', 2, 'Otters', 2, 'SO', 'Otters'],
     ['Otters', 3, 'Lynx', 3, 'SO', 'Lynx']],),
   [['Otters', 5, 1, 1, 2, 2], ['Lynx', 3, 0, 0, 1, 0], ['Hawks', 0, 0, 0, 0, -2]]),
  ('variant scenario 2',
   ([['Otters', 3, 'Bears', 3, 'SO', 'Otters'],
     ['Otters', 1, 'Lynx', 5, 'REG', None],
     ['Otters', 3, 'Lynx', 1, 'REG', None],
     ['Hawks', 5, 'Otters', 0, 'REG', None],
     ['Hawks', 5, 'Lynx', 0, 'REG', None],
     ['Lynx', 2, 'Otters', 3, 'REG', None],
     ['Otters', 5, 'Bears', 3, 'REG', None],
     ['Lynx', 0, 'Otters', 2, 'REG', None]],),
   [['Otters', 10, 4, 4, 5, -1],
    ['Hawks', 4, 2, 2, 2, 10],
    ['Lynx', 2, 1, 1, 1, -6],
    ['Bears', 1, 0, 0, 0, -3]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Otters', 1, 'Bears', 5, 'REG', None],
     ['Lynx', 0, 'Bears', 0, 'SO', 'Lynx'],
     ['Otters', 3, 'Lynx', 2, 'REG', None],
     ['Bears', 3, 'Lynx', 2, 'OT', None],
     ['Hawks', 3, 'Otters', 3, 'SO', 'Hawks'],
     ['Bears', 2, 'Lynx', 3, 'REG', None],
     ['Otters', 4, 'Bears', 4, 'SO', 'Bears'],
     ['Otters', 2, 'Lynx', 4, 'REG', None],
     ['Hawks', 3, 'Bears', 2, 'OT', None],
     ['Otters', 4, 'Lynx', 4, 'SO', 'Otters']],),
   [['Lynx', 8, 2, 2, 3, 1],
    ['Bears', 8, 1, 2, 3, 3],
    ['Otters', 6, 1, 1, 2, -6],
    ['Hawks', 4, 0, 1, 2, 2]]),
  ('regression: rw row order',
   ([['Otters', 3, 'Bears', 4, 'OT', None],
     ['Hawks', 0, 'Bears', 1, 'OT', None],
     ['Bears', 2, 'Otters', 5, 'REG', None],
     ['Hawks', 4, 'Lynx', 3, 'OT', None],
     ['Lynx', 2, 'Otters', 1, 'OT', None]],),
   [['Otters', 4, 1, 1, 1, 1],
    ['Bears', 4, 0, 2, 2, -1],
    ['Hawks', 3, 0, 1, 1, 0],
    ['Lynx', 3, 0, 1, 1, 0]]),
  ('variant scenario 1',
   ([['Bears', 3, 'Hawks', 5, 'REG', None],
     ['Hawks', 3, 'Lynx', 4, 'REG', None],
     ['Otters', 1, 'Lynx', 2, 'OT', None]],),
   [['Lynx', 4, 1, 2, 2, 2],
    ['Hawks', 2, 1, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Bears', 0, 0, 0, 0, -2]]),
  ('variant scenario 2',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Bears'],
     ['Otters', 2, 'Bears', 2, 'SO', 'Bears'],
     ['Bears', 0, 'Hawks', 3, 'REG', None],
     ['Hawks', 2, 'Bears', 2, 'SO', 'Bears'],
     ['Lynx', 0, 'Hawks', 0, 'SO', 'Lynx'],
     ['Lynx', 5, 'Otters', 1, 'REG', None]],),
   [['Bears', 6, 0, 0, 3, 0],
    ['Hawks', 5, 1, 1, 1, 0],
    ['Lynx', 4, 1, 1, 2, 5],
    ['Otters', 1, 0, 0, 0, -5]])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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

N = 1
observations = []
def solve(games):
    t = {}
    for h, hg, a, ag, decided, so_winner in games:
        if decided == 'SO':
            if so_winner == h:
                hg += 1
            else:
                ag += 1
        for team, f, g in ((h, hg, ag), (a, ag, hg)):
            row = t.setdefault(team, {'pts': 0, 'rw': 0, 'row': 0, 'w': 0, 'gd': 0})
            row['gd'] += f - g
            if f > g:
                row['pts'] += 2
                row['w'] += 1
                if decided == 'REG':
                    row['rw'] += 1
                if decided != 'SO':
                    row['row'] += 1
            elif decided != 'REG':
                row['pts'] += 1
    order = sorted(t, key=lambda k: (-t[k]['pts'], -t[k]['w'], -t[k]['row'], -t[k]['w'], -t[k]['gd'], k))
    return [[k, t[k]['pts'], t[k]['rw'], t[k]['row'], t[k]['w'], t[k]['gd']] for k in order]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Bears', 3, 'Hawks', 3, 'SO', 'Hawks'],
     ['Lynx', 3, 'Bears', 5, 'REG', None],
     ['Lynx', 5, 'Bears', 4, 'OT', None],
     ['Lynx', 3, 'Otters', 3, 'SO', 'Lynx'],
     ['Otters', 3, 'Hawks', 3, 'SO', 'Otters']],),
   [['Bears', 4, 1, 1, 1, 0],
    ['Lynx', 4, 0, 1, 2, 0],
    ['Hawks', 3, 0, 0, 1, 0],
    ['Otters', 3, 0, 0, 1, 0]]),
  ('regression: rw row order',
   ([['Otters', 4, 'Hawks', 3, 'OT', None],
     ['Lynx', 4, 'Bears', 1, 'REG', None],
     ['Bears', 1, 'Hawks', 0, 'OT', None],
     ['Bears', 0, 'Lynx', 0, 'SO', 'Lynx'],
     ['Lynx', 0, 'Bears', 1, 'OT', None]],),
   [['Lynx', 5, 1, 1, 2, 3],
    ['Bears', 5, 0, 2, 2, -2],
    ['Otters', 2, 0, 1, 1, 1],
    ['Hawks', 2, 0, 0, 0, -2]]),
  ('variant scenario 1',
   ([['Otters', 0, 'Hawks', 0, 'SO', 'Hawks'],
     ['Lynx', 4, 'Hawks', 3, 'OT', None],
     ['Otters', 1, 'Bears', 2, 'REG', None],
     ['Otters', 5, 'Bears', 4, 'REG', None],
     ['Lynx', 1, 'Bears', 3, 'REG', None]],),
   [['Bears', 4, 2, 2, 2, 2],
    ['Otters', 3, 1, 1, 1, -1],
    ['Hawks', 3, 0, 0, 1, 0],
    ['Lynx', 2, 0, 1, 1, -1]]),
  ('variant scenario 2',
   ([['Bears', 0, 'Lynx', 1, 'REG', None],
     ['Lynx', 4, 'Bears', 4, 'SO', 'Lynx'],
     ['Bears', 4, 'Lynx', 5, 'OT', None],
     ['Otters', 3, 'Bears', 4, 'OT', None],
     ['Otters', 0, 'Hawks', 3, 'REG', None],
     ['Lynx', 2, 'Otters', 3, 'REG', None]],),
   [['Lynx', 6, 1, 2, 3, 2],
    ['Bears', 4, 0, 1, 1, -2],
    ['Otters', 3, 1, 1, 1, -3],
    ['Hawks', 2, 1, 1, 1, 3]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Otters', 4, 'Bears', 5, 'REG', None],
     ['Lynx', 3, 'Hawks', 3, 'SO', 'Lynx'],
     ['Bears', 2, 'Otters', 2, 'SO', 'Otters'],
     ['Otters', 0, 'Hawks', 0, 'SO', 'Hawks'],
     ['Lynx', 0, 'Hawks', 1, 'OT', None],
     ['Lynx', 5, 'Otters', 1, 'REG', None],
     ['Bears', 1, 'Otters', 5, 'REG', None]],),
   [['Lynx', 5, 1, 1, 2, 4],
    ['Otters', 5, 1, 1, 2, -1],
    ['Hawks', 5, 0, 1, 2, 1],
    ['Bears', 3, 1, 1, 1, -4]]),
  ('regression: rw row order',
   ([['Bears', 4, 'Hawks', 3, 'OT', None],
     ['Otters', 1, 'Hawks', 5, 'REG', None],
     ['Bears', 2, 'Lynx', 3, 'REG', None],
     ['Hawks', 0, 'Bears', 1, 'OT', None]],),
   [['Hawks', 4, 1, 1, 1, 2],
    ['Bears', 4, 0, 2, 2, 1],
    ['Lynx', 2, 1, 1, 1, 1],
    ['Otters', 0, 0, 0, 0, -4]]),
  ('variant scenario 1',
   ([['Otters', 2, 'Hawks', 3, 'OT', None],
     ['Otters', 2, 'Bears', 3, 'OT', None],
     ['Otters', 4, 'Hawks', 3, 'OT', None]],),
   [['Otters', 4, 0, 1, 1, -1], ['Hawks', 3, 0, 1, 1, 0], ['Bears', 2, 0, 1, 1, 1]]),
  ('variant scenario 2',
   ([['Lynx', 3, 'Otters', 4, 'REG', None],
     ['Hawks', 1, 'Otters', 0, 'REG', None],
     ['Hawks', 0, 'Bears', 3, 'REG', None],
     ['Bears', 2, 'Lynx', 3, 'OT', None],
     ['Bears', 2, 'Lynx', 0, 'REG', None]],),
   [['Bears', 5, 2, 2, 2, 4],
    ['Otters', 2, 1, 1, 1, 0],
    ['Hawks', 2, 1, 1, 1, -2],
    ['Lynx', 2, 0, 1, 1, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Bears', 1, 'Lynx', 0, 'OT', None],
     ['Bears', 0, 'Hawks', 4, 'REG', None],
     ['Otters', 0, 'Bears', 5, 'REG', None],
     ['Lynx', 5, 'Otters', 4, 'OT', None],
     ['Bears', 2, 'Lynx', 4, 'REG', None],
     ['Hawks', 2, 'Otters', 3, 'REG', None],
     ['Otters', 4, 'Hawks', 3, 'REG', None]],),
   [['Otters', 5, 2, 2, 2, -4],
    ['Lynx', 5, 1, 2, 2, 2],
    ['Bears', 4, 1, 2, 2, 0],
    ['Hawks', 2, 1, 1, 1, 2]]),
  ('regression: rw row order',
   ([['Otters', 2, 'Bears', 3, 'OT', None],
     ['Hawks', 5, 'Lynx', 4, 'OT', None],
     ['Bears', 3, 'Otters', 2, 'OT', None],
     ['Otters', 4, 'Bears', 3, 'REG', None]],),
   [['Otters', 4, 1, 1, 1, -1],
    ['Bears', 4, 0, 2, 2, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Lynx', 1, 0, 0, 0, -1]]),
  ('variant scenario 1',
   ([['Lynx', 1, 'Hawks', 0, 'OT', None],
     ['Bears', 0, 'Hawks', 0, 'SO', 'Hawks'],
     ['Lynx', 4, 'Hawks', 3, 'OT', None],
     ['Lynx', 2, 'Bears', 2, 'SO', 'Bears'],
     ['Lynx', 1, 'Hawks', 0, 'REG', None],
     ['Hawks', 1, 'Otters', 4, 'REG', None],
     ['Bears', 3, 'Otters', 0, 'REG', None],
     ['Lynx', 5, 'Otters', 4, 'REG', None]],),
   [['Lynx', 9, 2, 4, 4, 3],
    ['Bears', 5, 1, 1, 2, 3],
    ['Hawks', 4, 0, 0, 1, -5],
    ['Otters', 2, 1, 1, 1, -1]]),
  ('variant scenario 2',
   ([['Otters', 1, 'Hawks', 1, 'SO', 'Hawks'],
     ['Bears', 3, 'Hawks', 5, 'REG', None],
     ['Lynx', 2, 'Bears', 1, 'OT', None],
     ['Otters', 5, 'Bears', 4, 'REG', None],
     ['Lynx', 1, 'Hawks', 1, 'SO', 'Lynx'],
     ['Bears', 3, 'Otters', 1, 'REG', None],
     ['Otters', 2, 'Hawks', 3, 'OT', None],
     ['Otters', 0, 'Lynx', 1, 'OT', None]],),
   [['Hawks', 7, 1, 2, 3, 3],
    ['Lynx', 6, 0, 2, 3, 3],
    ['Otters', 5, 1, 1, 1, -4],
    ['Bears', 3, 1, 1, 1, -2]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Bears', 1, 'Lynx', 1, 'SO', 'Bears'],
     ['Bears', 1, 'Lynx', 0, 'OT', None],
     ['Hawks', 5, 'Lynx', 0, 'REG', None],
     ['Lynx', 5, 'Bears', 1, 'REG', None]],),
   [['Lynx', 4, 1, 1, 1, -3], ['Bears', 4, 0, 1, 2, -2], ['Hawks', 2, 1, 1, 1, 5]]),
  ('regression: rw row order',
   ([['Bears', 1, 'Hawks', 0, 'REG', None],
     ['Lynx', 0, 'Bears', 0, 'SO', 'Bears'],
     ['Bears', 5, 'Otters', 2, 'REG', None],
     ['Lynx', 4, 'Otters', 2, 'REG', None],
     ['Hawks', 4, 'Otters', 3, 'OT', None],
     ['Otters', 2, 'Bears', 4, 'REG', None],
     ['Hawks', 0, 'Otters', 1, 'REG', None],
     ['Otters', 0, 'Bears', 1, 'REG', None],
     ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 10, 4, 4, 5, 8],
    ['Otters', 4, 1, 1, 1, -9],
    ['Hawks', 4, 0, 2, 2, 0],
    ['Lynx', 3, 1, 1, 1, 1]]),
  ('variant scenario 1',
   ([['Hawks', 3, 'Otters', 5, 'REG', None],
     ['Lynx', 2, 'Otters', 2, 'SO', 'Otters'],
     ['Otters', 3, 'Lynx', 3, 'SO', 'Lynx']],),
   [['Otters', 5, 1, 1, 2, 2], ['Lynx', 3, 0, 0, 1, 0], ['Hawks', 0, 0, 0, 0, -2]]),
  ('variant scenario 2',
   ([['Otters', 3, 'Bears', 3, 'SO', 'Otters'],
     ['Otters', 1, 'Lynx', 5, 'REG', None],
     ['Otters', 3, 'Lynx', 1, 'REG', None],
     ['Hawks', 5, 'Otters', 0, 'REG', None],
     ['Hawks', 5, 'Lynx', 0, 'REG', None],
     ['Lynx', 2, 'Otters', 3, 'REG', None],
     ['Otters', 5, 'Bears', 3, 'REG', None],
     ['Lynx', 0, 'Otters', 2, 'REG', None]],),
   [['Otters', 10, 4, 4, 5, -1],
    ['Hawks', 4, 2, 2, 2, 10],
    ['Lynx', 2, 1, 1, 1, -6],
    ['Bears', 1, 0, 0, 0, -3]])],
 [('control regulation win',
   ([['Bears', 3, 'Hawks', 1, 'REG', None]],),
   [['Bears', 2, 1, 1, 1, 2], ['Hawks', 0, 0, 0, 0, -2]]),
  ('boundary overtime loss point',
   ([['Bears', 2, 'Hawks', 3, 'OT', None]],),
   [['Hawks', 2, 0, 1, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary shootout goal credit',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Hawks']],),
   [['Hawks', 2, 0, 0, 1, 1], ['Bears', 1, 0, 0, 0, -1]]),
  ('boundary RW breaks tie',
   ([['Bears', 1, 'Lynx', 0, 'REG', None], ['Hawks', 1, 'Otters', 0, 'OT', None]],),
   [['Bears', 2, 1, 1, 1, 1],
    ['Hawks', 2, 0, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Lynx', 0, 0, 0, 0, -1]]),
  ('regression: rw row order',
   ([['Otters', 1, 'Bears', 5, 'REG', None],
     ['Lynx', 0, 'Bears', 0, 'SO', 'Lynx'],
     ['Otters', 3, 'Lynx', 2, 'REG', None],
     ['Bears', 3, 'Lynx', 2, 'OT', None],
     ['Hawks', 3, 'Otters', 3, 'SO', 'Hawks'],
     ['Bears', 2, 'Lynx', 3, 'REG', None],
     ['Otters', 4, 'Bears', 4, 'SO', 'Bears'],
     ['Otters', 2, 'Lynx', 4, 'REG', None],
     ['Hawks', 3, 'Bears', 2, 'OT', None],
     ['Otters', 4, 'Lynx', 4, 'SO', 'Otters']],),
   [['Lynx', 8, 2, 2, 3, 1],
    ['Bears', 8, 1, 2, 3, 3],
    ['Otters', 6, 1, 1, 2, -6],
    ['Hawks', 4, 0, 1, 2, 2]]),
  ('regression: rw row order',
   ([['Otters', 3, 'Bears', 4, 'OT', None],
     ['Hawks', 0, 'Bears', 1, 'OT', None],
     ['Bears', 2, 'Otters', 5, 'REG', None],
     ['Hawks', 4, 'Lynx', 3, 'OT', None],
     ['Lynx', 2, 'Otters', 1, 'OT', None]],),
   [['Otters', 4, 1, 1, 1, 1],
    ['Bears', 4, 0, 2, 2, -1],
    ['Hawks', 3, 0, 1, 1, 0],
    ['Lynx', 3, 0, 1, 1, 0]]),
  ('variant scenario 1',
   ([['Bears', 3, 'Hawks', 5, 'REG', None],
     ['Hawks', 3, 'Lynx', 4, 'REG', None],
     ['Otters', 1, 'Lynx', 2, 'OT', None]],),
   [['Lynx', 4, 1, 2, 2, 2],
    ['Hawks', 2, 1, 1, 1, 1],
    ['Otters', 1, 0, 0, 0, -1],
    ['Bears', 0, 0, 0, 0, -2]]),
  ('variant scenario 2',
   ([['Bears', 2, 'Hawks', 2, 'SO', 'Bears'],
     ['Otters', 2, 'Bears', 2, 'SO', 'Bears'],
     ['Bears', 0, 'Hawks', 3, 'REG', None],
     ['Hawks', 2, 'Bears', 2, 'SO', 'Bears'],
     ['Lynx', 0, 'Hawks', 0, 'SO', 'Lynx'],
     ['Lynx', 5, 'Otters', 1, 'REG', None]],),
   [['Bears', 6, 0, 0, 3, 0],
    ['Hawks', 5, 1, 1, 1, 0],
    ['Lynx', 4, 1, 1, 2, 5],
    ['Otters', 1, 0, 0, 0, -5]])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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 level on points are ordered by ROW before RW.

Ice hockey standings. games rows are [home, home_goals, away, away_goals, decided, so_winner] with decided in REG, OT, SO; for SO the listed goals are tied and so_winner names the winner. A win is 2 points and an OT or SO loss 1 point. The shootout winner is credited with one extra goal for, the loser one extra goal against. RW counts regulation wins, ROW regulation plus overtime wins (not shootouts). Rank by points, then RW, then ROW, then total wins, then goal difference, then name. Return [team, points, RW, ROW, W, GD].

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):
    def pct(w, l):
        return Fraction(w, w + l) if w + l else Fraction(0)
    rows = sorted(teams, key=lambda r: (-pct(r[1], r[2]), -r[1], r[0]))
    lw, ll = rows[0][1], rows[0][2]
    out = []
    for name, w, l in rows:
        p = '%.3f' % float(pct(w, l))
        p = p[1:]
        gb2 = (lw - w) + (l - ll)
        gb = '-' if gb2 == 0 else '%.1f' % (gb2 / 2)
        out.append([name, p, gb])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Bucks', 7, 3], ['Wolves', 17, 7]],),
   [['Wolves', '.708', '-'], ['Bucks', '.700', '3.0']]),
  ('regression: leading zero strip',
   ([['Suns', 0, 0], ['Wolves', 0, 0], ['Bucks', 20, 0]],),
   [['Bucks', '1.000', '-'], ['Suns', '.000', '10.0'], ['Wolves', '.000', '10.0']]),
  ('variant scenario 1',
   ([['Bucks', 14, 4], ['Suns', 28, 8], ['Jets', 2, 19]],),
   [['Suns', '.778', '-'], ['Bucks', '.778', '5.0'], ['Jets', '.095', '18.5']]),
  ('variant scenario 2',
   ([['Jets', 23, 7], ['Wolves', 46, 14], ['Cats', 11, 9]],),
   [['Wolves', '.767', '-'], ['Jets', '.767', '8.0'], ['Cats', '.550', '15.0']])],
 [('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Wolves', 23, 13], ['Suns', 30, 0], ['Jets', 9, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.900', '11.0'], ['Wolves', '.639', '10.0']]),
  ('variant scenario 1',
   ([['Suns', 15, 17], ['Bucks', 1, 6], ['Wolves', 2, 20], ['Jets', 2, 16]],),
   [['Suns', '.469', '-'],
    ['Bucks', '.143', '1.5'],
    ['Jets', '.111', '6.0'],
    ['Wolves', '.091', '8.0']]),
  ('variant scenario 2',
   ([['Wolves', 4, 5], ['Suns', 2, 18], ['Jets', 6, 10], ['Cats', 5, 24]],),
   [['Wolves', '.444', '-'],
    ['Jets', '.375', '1.5'],
    ['Cats', '.172', '9.0'],
    ['Suns', '.100', '7.5']])],
 [('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Jets', 2, 2], ['Bucks', 1, 16], ['Cats', 1, 3], ['Suns', 25, 8], ['Wolves', 3, 1]],),
   [['Suns', '.758', '-'],
    ['Wolves', '.750', '7.5'],
    ['Jets', '.500', '8.5'],
    ['Cats', '.250', '9.5'],
    ['Bucks', '.059', '16.0']]),
  ('regression: leading zero strip',
   ([['Jets', 25, 5], ['Wolves', 6, 7], ['Suns', 0, 0], ['Cats', 1, 0]],),
   [['Cats', '1.000', '-'],
    ['Jets', '.833', '-9.5'],
    ['Wolves', '.462', '1.0'],
    ['Suns', '.000', '0.5']]),
  ('variant scenario 1',
   ([['Cats', 0, 7], ['Bucks', 22, 8], ['Wolves', 8, 4], ['Jets', 1, 38]],),
   [['Bucks', '.733', '-'],
    ['Wolves', '.667', '5.0'],
    ['Jets', '.026', '25.5'],
    ['Cats', '.000', '10.5']]),
  ('variant scenario 2',
   ([['Bucks', 11, 15], ['Wolves', 13, 22]],),
   [['Bucks', '.423', '-'], ['Wolves', '.371', '2.5']])],
 [('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Wolves', 23, 7], ['Bucks', 46, 14], ['Cats', 0, 1], ['Suns', 28, 8]],),
   [['Suns', '.778', '-'],
    ['Bucks', '.767', '-6.0'],
    ['Wolves', '.767', '2.0'],
    ['Cats', '.000', '10.5']]),
  ('regression: leading zero strip',
   ([['Cats', 6, 0], ['Wolves', 0, 38]],),
   [['Cats', '1.000', '-'], ['Wolves', '.000', '22.0']]),
  ('variant scenario 1',
   ([['Suns', 1, 1], ['Cats', 4, 18], ['Jets', 1, 18], ['Bucks', 15, 12]],),
   [['Bucks', '.556', '-'],
    ['Suns', '.500', '1.5'],
    ['Cats', '.182', '8.5'],
    ['Jets', '.053', '10.0']]),
  ('variant scenario 2',
   ([['Suns', 5, 7], ['Jets', 7, 23]],),
   [['Suns', '.417', '-'], ['Jets', '.233', '7.0']])],
 [('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Suns', 8, 4], ['Bucks', 16, 8], ['Wolves', 1, 36], ['Jets', 12, 0]],),
   [['Jets', '1.000', '-'],
    ['Bucks', '.667', '2.0'],
    ['Suns', '.667', '4.0'],
    ['Wolves', '.027', '23.5']]),
  ('variant scenario 1',
   ([['Cats', 10, 22], ['Jets', 20, 44]],),
   [['Jets', '.312', '-'], ['Cats', '.312', '-6.0']]),
  ('variant scenario 2',
   ([['Jets', 15, 15], ['Suns', 3, 17], ['Cats', 3, 11]],),
   [['Jets', '.500', '-'], ['Cats', '.214', '4.0'], ['Suns', '.150', '7.0']])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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):
    def pct(w, l):
        return Fraction(w, w + l) if w + l else Fraction(0)
    rows = sorted(teams, key=lambda r: (-pct(r[1], r[2]), -r[1], r[0]))
    lw, ll = rows[0][1], rows[0][2]
    out = []
    for name, w, l in rows:
        p = '%.3f' % float(pct(w, l))
        p = p.strip('0')
        gb2 = (lw - w) + (l - ll)
        gb = '-' if gb2 == 0 else '%.1f' % (gb2 / 2)
        out.append([name, p, gb])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Bucks', 7, 3], ['Wolves', 17, 7]],),
   [['Wolves', '.708', '-'], ['Bucks', '.700', '3.0']]),
  ('regression: leading zero strip',
   ([['Suns', 0, 0], ['Wolves', 0, 0], ['Bucks', 20, 0]],),
   [['Bucks', '1.000', '-'], ['Suns', '.000', '10.0'], ['Wolves', '.000', '10.0']]),
  ('variant scenario 1',
   ([['Bucks', 14, 4], ['Suns', 28, 8], ['Jets', 2, 19]],),
   [['Suns', '.778', '-'], ['Bucks', '.778', '5.0'], ['Jets', '.095', '18.5']]),
  ('variant scenario 2',
   ([['Jets', 23, 7], ['Wolves', 46, 14], ['Cats', 11, 9]],),
   [['Wolves', '.767', '-'], ['Jets', '.767', '8.0'], ['Cats', '.550', '15.0']])],
 [('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Wolves', 23, 13], ['Suns', 30, 0], ['Jets', 9, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.900', '11.0'], ['Wolves', '.639', '10.0']]),
  ('variant scenario 1',
   ([['Suns', 15, 17], ['Bucks', 1, 6], ['Wolves', 2, 20], ['Jets', 2, 16]],),
   [['Suns', '.469', '-'],
    ['Bucks', '.143', '1.5'],
    ['Jets', '.111', '6.0'],
    ['Wolves', '.091', '8.0']]),
  ('variant scenario 2',
   ([['Wolves', 4, 5], ['Suns', 2, 18], ['Jets', 6, 10], ['Cats', 5, 24]],),
   [['Wolves', '.444', '-'],
    ['Jets', '.375', '1.5'],
    ['Cats', '.172', '9.0'],
    ['Suns', '.100', '7.5']])],
 [('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Jets', 2, 2], ['Bucks', 1, 16], ['Cats', 1, 3], ['Suns', 25, 8], ['Wolves', 3, 1]],),
   [['Suns', '.758', '-'],
    ['Wolves', '.750', '7.5'],
    ['Jets', '.500', '8.5'],
    ['Cats', '.250', '9.5'],
    ['Bucks', '.059', '16.0']]),
  ('regression: leading zero strip',
   ([['Jets', 25, 5], ['Wolves', 6, 7], ['Suns', 0, 0], ['Cats', 1, 0]],),
   [['Cats', '1.000', '-'],
    ['Jets', '.833', '-9.5'],
    ['Wolves', '.462', '1.0'],
    ['Suns', '.000', '0.5']]),
  ('variant scenario 1',
   ([['Cats', 0, 7], ['Bucks', 22, 8], ['Wolves', 8, 4], ['Jets', 1, 38]],),
   [['Bucks', '.733', '-'],
    ['Wolves', '.667', '5.0'],
    ['Jets', '.026', '25.5'],
    ['Cats', '.000', '10.5']]),
  ('variant scenario 2',
   ([['Bucks', 11, 15], ['Wolves', 13, 22]],),
   [['Bucks', '.423', '-'], ['Wolves', '.371', '2.5']])],
 [('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Wolves', 23, 7], ['Bucks', 46, 14], ['Cats', 0, 1], ['Suns', 28, 8]],),
   [['Suns', '.778', '-'],
    ['Bucks', '.767', '-6.0'],
    ['Wolves', '.767', '2.0'],
    ['Cats', '.000', '10.5']]),
  ('regression: leading zero strip',
   ([['Cats', 6, 0], ['Wolves', 0, 38]],),
   [['Cats', '1.000', '-'], ['Wolves', '.000', '22.0']]),
  ('variant scenario 1',
   ([['Suns', 1, 1], ['Cats', 4, 18], ['Jets', 1, 18], ['Bucks', 15, 12]],),
   [['Bucks', '.556', '-'],
    ['Suns', '.500', '1.5'],
    ['Cats', '.182', '8.5'],
    ['Jets', '.053', '10.0']]),
  ('variant scenario 2',
   ([['Suns', 5, 7], ['Jets', 7, 23]],),
   [['Suns', '.417', '-'], ['Jets', '.233', '7.0']])],
 [('control two teams',
   ([['Cats', 10, 5], ['Jets', 8, 7]],),
   [['Cats', '.667', '-'], ['Jets', '.533', '2.0']]),
  ('boundary half game',
   ([['Cats', 10, 5], ['Jets', 9, 5]],),
   [['Cats', '.667', '-'], ['Jets', '.643', '0.5']]),
  ('boundary perfect record',
   ([['Suns', 3, 0], ['Jets', 1, 1]],),
   [['Suns', '1.000', '-'], ['Jets', '.500', '1.5']]),
  ('boundary no games played',
   ([['Suns', 0, 0], ['Bucks', 0, 2]],),
   [['Bucks', '.000', '-'], ['Suns', '.000', '-1.0']]),
  ('control equal pct more wins first',
   ([['Cats', 2, 2], ['Bucks', 4, 4]],),
   [['Bucks', '.500', '-'], ['Cats', '.500', '-']]),
  ('regression: leading zero strip',
   ([['Suns', 8, 4], ['Bucks', 16, 8], ['Wolves', 1, 36], ['Jets', 12, 0]],),
   [['Jets', '1.000', '-'],
    ['Bucks', '.667', '2.0'],
    ['Suns', '.667', '4.0'],
    ['Wolves', '.027', '23.5']]),
  ('variant scenario 1',
   ([['Cats', 10, 22], ['Jets', 20, 44]],),
   [['Jets', '.312', '-'], ['Cats', '.312', '-6.0']]),
  ('variant scenario 2',
   ([['Jets', 15, 15], ['Suns', 3, 17], ['Cats', 3, 11]],),
   [['Jets', '.500', '-'], ['Cats', '.214', '4.0'], ['Suns', '.150', '7.0']])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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:
An unbeaten team shows ".000" instead of "1.000".

Division standings. teams rows are [name, wins, losses]. Win percentage is wins / games (0 for no games) shown with three decimals and the leading zero dropped (".500", but "1.000"). Sort by win percentage, then more wins, then name. The leader is the first sorted row; games behind = ((leader_wins - wins) + (losses - leader_losses)) / 2, shown as "-" when zero and otherwise with one decimal (negative values allowed). Return [name, pct, gb] rows.

split: open-access