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

N = 1
observations = []
def solve(results):
    fin = []
    dnf = []
    for name, t in results:
        if t == 'DQ':
            continue
        if t == 'DNF':
            dnf.append(name)
            continue
        whole, _, frac = t.partition('.')
        thous = int(whole) * 1000 + int((frac + '000')[:3])
        hund = -(-thous // 10)
        fin.append((hund, name))
    fin.sort()
    out = []
    for i, (h, name) in enumerate(fin):
        place = i + 1
        out.append([place, name, '%d.%02d' % (h // 100, h % 100)])
    for name in sorted(dnf):
        out.append([None, name, 'DNF'])
    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 distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Cy', 'DNF'],
     ['Eli', '9.972'],
     ['Bo', '9.974'],
     ['Dee', '9.971'],
     ['Fay', '9.958'],
     ['Ade', '9.961']],),
   [[1, 'Fay', '9.96'],
    [2, 'Ade', '9.97'],
    [3, 'Bo', '9.98'],
    [3, 'Dee', '9.98'],
    [3, 'Eli', '9.98'],
    [None, 'Cy', 'DNF']]),
  ('regression: shared place',
   ([['Cy', '10.043'],
     ['Eli', '10.018'],
     ['Ade', '10.04'],
     ['Dee', '10.041'],
     ['Fay', '10.024'],
     ['Bo', '10.026']],),
   [[1, 'Eli', '10.02'],
    [2, 'Bo', '10.03'],
    [2, 'Fay', '10.03'],
    [4, 'Ade', '10.04'],
    [5, 'Cy', '10.05'],
    [5, 'Dee', '10.05']]),
  ('variant scenario 1',
   ([['Dee', '10.050'], ['Cy', '10.075'], ['Bo', 'DNF'], ['Fay', 'DNF']],),
   [[1, 'Dee', '10.05'], [2, 'Cy', '10.08'], [None, 'Bo', 'DNF'], [None, 'Fay', 'DNF']]),
  ('variant scenario 2',
   ([['Fay', 'DNF'], ['Bo', 'DQ'], ['Eli', '10.893']],),
   [[1, 'Eli', '10.90'], [None, 'Fay', 'DNF']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Cy', '9.860'],
     ['Fay', '9.822'],
     ['Dee', '9.822'],
     ['Eli', 'DNF'],
     ['Ade', '9.838'],
     ['Bo', '9.83']],),
   [[1, 'Bo', '9.83'],
    [1, 'Dee', '9.83'],
    [1, 'Fay', '9.83'],
    [4, 'Ade', '9.84'],
    [5, 'Cy', '9.86'],
    [None, 'Eli', 'DNF']]),
  ('variant scenario 1',
   ([['Ade', '10.62'], ['Cy', '10.621'], ['Fay', '10.592'], ['Dee', '10.626']],),
   [[1, 'Fay', '10.60'], [2, 'Ade', '10.62'], [3, 'Cy', '10.63'], [3, 'Dee', '10.63']]),
  ('variant scenario 2',
   ([['Dee', 'DNF'], ['Ade', '9.8'], ['Eli', '9.849']],),
   [[1, 'Ade', '9.80'], [2, 'Eli', '9.85'], [None, 'Dee', 'DNF']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Dee', 'DQ'], ['Bo', '10.773'], ['Fay', '10.779']],),
   [[1, 'Bo', '10.78'], [1, 'Fay', '10.78']]),
  ('regression: shared place',
   ([['Eli', '10.187'],
     ['Fay', '10.158'],
     ['Ade', '10.157'],
     ['Bo', '10.153'],
     ['Cy', '10.155'],
     ['Dee', '10.154']],),
   [[1, 'Ade', '10.16'],
    [1, 'Bo', '10.16'],
    [1, 'Cy', '10.16'],
    [1, 'Dee', '10.16'],
    [1, 'Fay', '10.16'],
    [6, 'Eli', '10.19']]),
  ('variant scenario 1',
   ([['Bo', '10.66'],
     ['Ade', 'DQ'],
     ['Cy', '10.679'],
     ['Fay', '10.6'],
     ['Eli', '10.65'],
     ['Dee', '10.672']],),
   [[1, 'Fay', '10.60'],
    [2, 'Eli', '10.65'],
    [3, 'Bo', '10.66'],
    [4, 'Cy', '10.68'],
    [4, 'Dee', '10.68']]),
  ('variant scenario 2',
   ([['Ade', '10.895'], ['Eli', '10.87'], ['Bo', '10.'], ['Cy', '10.87'], ['Fay', '10.896']],),
   [[1, 'Bo', '10.00'],
    [2, 'Cy', '10.87'],
    [2, 'Eli', '10.87'],
    [4, 'Ade', '10.90'],
    [4, 'Fay', '10.90']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Cy', '10.313'], ['Fay', '10.309'], ['Ade', 'DQ'], ['Dee', '10.312']],),
   [[1, 'Fay', '10.31'], [2, 'Cy', '10.32'], [2, 'Dee', '10.32']]),
  ('regression: shared place',
   ([['Bo', '10.673'], ['Cy', '10.700'], ['Dee', '10.678'], ['Eli', 'DNF']],),
   [[1, 'Bo', '10.68'], [1, 'Dee', '10.68'], [3, 'Cy', '10.70'], [None, 'Eli', 'DNF']]),
  ('variant scenario 1',
   ([['Fay', '10.'],
     ['Dee', 'DNF'],
     ['Eli', 'DNF'],
     ['Ade', '10.926'],
     ['Bo', '10.913'],
     ['Cy', 'DQ']],),
   [[1, 'Fay', '10.00'],
    [2, 'Bo', '10.92'],
    [3, 'Ade', '10.93'],
    [None, 'Dee', 'DNF'],
    [None, 'Eli', 'DNF']]),
  ('variant scenario 2',
   ([['Ade', '10.146'],
     ['Fay', '10.11'],
     ['Bo', '10.144'],
     ['Eli', '10.12'],
     ['Cy', 'DNF'],
     ['Dee', '10.144']],),
   [[1, 'Fay', '10.11'],
    [2, 'Eli', '10.12'],
    [3, 'Ade', '10.15'],
    [3, 'Bo', '10.15'],
    [3, 'Dee', '10.15'],
    [None, 'Cy', 'DNF']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Bo', '10.001'],
     ['Ade', '10.033'],
     ['Eli', '10.002'],
     ['Fay', '10.018'],
     ['Cy', '10.0'],
     ['Dee', '10.04']],),
   [[1, 'Cy', '10.00'],
    [2, 'Bo', '10.01'],
    [2, 'Eli', '10.01'],
    [4, 'Fay', '10.02'],
    [5, 'Ade', '10.04'],
    [5, 'Dee', '10.04']]),
  ('variant scenario 1',
   ([['Cy', '11.31'], ['Fay', '11.302'], ['Eli', '11.3']],),
   [[1, 'Eli', '11.30'], [2, 'Cy', '11.31'], [2, 'Fay', '11.31']]),
  ('variant scenario 2',
   ([['Cy', '10.9'], ['Ade', 'DNF'], ['Fay', '10.899'], ['Dee', '10.888']],),
   [[1, 'Dee', '10.89'], [2, 'Cy', '10.90'], [2, 'Fay', '10.90'], [None, 'Ade', 'DNF']])]]
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(results):
    fin = []
    dnf = []
    for name, t in results:
        if t == 'DQ':
            continue
        if t == 'DNF':
            dnf.append(name)
            continue
        whole, _, frac = t.partition('.')
        thous = int(whole) * 1000 + int((frac + '000')[:3])
        hund = -(-thous // 10)
        fin.append((hund, name))
    fin.sort()
    out = []
    for i, (h, name) in enumerate(fin):
        place = (out[-1][0] + 1 if out else 1) if i == 0 or fin[i - 1][0] != h else out[-1][0]
        out.append([place, name, '%d.%02d' % (h // 100, h % 100)])
    for name in sorted(dnf):
        out.append([None, name, 'DNF'])
    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 distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Cy', 'DNF'],
     ['Eli', '9.972'],
     ['Bo', '9.974'],
     ['Dee', '9.971'],
     ['Fay', '9.958'],
     ['Ade', '9.961']],),
   [[1, 'Fay', '9.96'],
    [2, 'Ade', '9.97'],
    [3, 'Bo', '9.98'],
    [3, 'Dee', '9.98'],
    [3, 'Eli', '9.98'],
    [None, 'Cy', 'DNF']]),
  ('regression: shared place',
   ([['Cy', '10.043'],
     ['Eli', '10.018'],
     ['Ade', '10.04'],
     ['Dee', '10.041'],
     ['Fay', '10.024'],
     ['Bo', '10.026']],),
   [[1, 'Eli', '10.02'],
    [2, 'Bo', '10.03'],
    [2, 'Fay', '10.03'],
    [4, 'Ade', '10.04'],
    [5, 'Cy', '10.05'],
    [5, 'Dee', '10.05']]),
  ('variant scenario 1',
   ([['Dee', '10.050'], ['Cy', '10.075'], ['Bo', 'DNF'], ['Fay', 'DNF']],),
   [[1, 'Dee', '10.05'], [2, 'Cy', '10.08'], [None, 'Bo', 'DNF'], [None, 'Fay', 'DNF']]),
  ('variant scenario 2',
   ([['Fay', 'DNF'], ['Bo', 'DQ'], ['Eli', '10.893']],),
   [[1, 'Eli', '10.90'], [None, 'Fay', 'DNF']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Cy', '9.860'],
     ['Fay', '9.822'],
     ['Dee', '9.822'],
     ['Eli', 'DNF'],
     ['Ade', '9.838'],
     ['Bo', '9.83']],),
   [[1, 'Bo', '9.83'],
    [1, 'Dee', '9.83'],
    [1, 'Fay', '9.83'],
    [4, 'Ade', '9.84'],
    [5, 'Cy', '9.86'],
    [None, 'Eli', 'DNF']]),
  ('variant scenario 1',
   ([['Ade', '10.62'], ['Cy', '10.621'], ['Fay', '10.592'], ['Dee', '10.626']],),
   [[1, 'Fay', '10.60'], [2, 'Ade', '10.62'], [3, 'Cy', '10.63'], [3, 'Dee', '10.63']]),
  ('variant scenario 2',
   ([['Dee', 'DNF'], ['Ade', '9.8'], ['Eli', '9.849']],),
   [[1, 'Ade', '9.80'], [2, 'Eli', '9.85'], [None, 'Dee', 'DNF']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Dee', 'DQ'], ['Bo', '10.773'], ['Fay', '10.779']],),
   [[1, 'Bo', '10.78'], [1, 'Fay', '10.78']]),
  ('regression: shared place',
   ([['Eli', '10.187'],
     ['Fay', '10.158'],
     ['Ade', '10.157'],
     ['Bo', '10.153'],
     ['Cy', '10.155'],
     ['Dee', '10.154']],),
   [[1, 'Ade', '10.16'],
    [1, 'Bo', '10.16'],
    [1, 'Cy', '10.16'],
    [1, 'Dee', '10.16'],
    [1, 'Fay', '10.16'],
    [6, 'Eli', '10.19']]),
  ('variant scenario 1',
   ([['Bo', '10.66'],
     ['Ade', 'DQ'],
     ['Cy', '10.679'],
     ['Fay', '10.6'],
     ['Eli', '10.65'],
     ['Dee', '10.672']],),
   [[1, 'Fay', '10.60'],
    [2, 'Eli', '10.65'],
    [3, 'Bo', '10.66'],
    [4, 'Cy', '10.68'],
    [4, 'Dee', '10.68']]),
  ('variant scenario 2',
   ([['Ade', '10.895'], ['Eli', '10.87'], ['Bo', '10.'], ['Cy', '10.87'], ['Fay', '10.896']],),
   [[1, 'Bo', '10.00'],
    [2, 'Cy', '10.87'],
    [2, 'Eli', '10.87'],
    [4, 'Ade', '10.90'],
    [4, 'Fay', '10.90']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Cy', '10.313'], ['Fay', '10.309'], ['Ade', 'DQ'], ['Dee', '10.312']],),
   [[1, 'Fay', '10.31'], [2, 'Cy', '10.32'], [2, 'Dee', '10.32']]),
  ('regression: shared place',
   ([['Bo', '10.673'], ['Cy', '10.700'], ['Dee', '10.678'], ['Eli', 'DNF']],),
   [[1, 'Bo', '10.68'], [1, 'Dee', '10.68'], [3, 'Cy', '10.70'], [None, 'Eli', 'DNF']]),
  ('variant scenario 1',
   ([['Fay', '10.'],
     ['Dee', 'DNF'],
     ['Eli', 'DNF'],
     ['Ade', '10.926'],
     ['Bo', '10.913'],
     ['Cy', 'DQ']],),
   [[1, 'Fay', '10.00'],
    [2, 'Bo', '10.92'],
    [3, 'Ade', '10.93'],
    [None, 'Dee', 'DNF'],
    [None, 'Eli', 'DNF']]),
  ('variant scenario 2',
   ([['Ade', '10.146'],
     ['Fay', '10.11'],
     ['Bo', '10.144'],
     ['Eli', '10.12'],
     ['Cy', 'DNF'],
     ['Dee', '10.144']],),
   [[1, 'Fay', '10.11'],
    [2, 'Eli', '10.12'],
    [3, 'Ade', '10.15'],
    [3, 'Bo', '10.15'],
    [3, 'Dee', '10.15'],
    [None, 'Cy', 'DNF']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: shared place',
   ([['Bo', '10.001'],
     ['Ade', '10.033'],
     ['Eli', '10.002'],
     ['Fay', '10.018'],
     ['Cy', '10.0'],
     ['Dee', '10.04']],),
   [[1, 'Cy', '10.00'],
    [2, 'Bo', '10.01'],
    [2, 'Eli', '10.01'],
    [4, 'Fay', '10.02'],
    [5, 'Ade', '10.04'],
    [5, 'Dee', '10.04']]),
  ('variant scenario 1',
   ([['Cy', '11.31'], ['Fay', '11.302'], ['Eli', '11.3']],),
   [[1, 'Eli', '11.30'], [2, 'Cy', '11.31'], [2, 'Fay', '11.31']]),
  ('variant scenario 2',
   ([['Cy', '10.9'], ['Ade', 'DNF'], ['Fay', '10.899'], ['Dee', '10.888']],),
   [[1, 'Dee', '10.89'], [2, 'Cy', '10.90'], [2, 'Fay', '10.90'], [None, 'Ade', 'DNF']])]]
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:
Two athletes on the same hundredth are given places 1 and 2, or the next athlete is placed 2nd.

Sprint results. results rows are [name, time] where time is seconds with up to three decimals, or "DNF"/"DQ". Times are rounded up to the next hundredth for publication. Rank by rounded time then name; equal rounded times share the place and the next place is skipped (1, 2, 2, 4). DNF athletes follow the finishers in name order with place None and time "DNF"; DQ athletes are omitted. Return [place, name, time "S.hh"] rows.

split: open-access


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

N = 1
observations = []
def solve(results):
    fin = []
    dnf = []
    for name, t in results:
        if t in ('DNF', 'DQ'):
            dnf.append(name)
            continue
        whole, _, frac = t.partition('.')
        thous = int(whole) * 1000 + int((frac + '000')[:3])
        hund = -(-thous // 10)
        fin.append((hund, name))
    fin.sort()
    out = []
    for i, (h, name) in enumerate(fin):
        place = i + 1 if i == 0 or fin[i - 1][0] != h else out[-1][0]
        out.append([place, name, '%d.%02d' % (h // 100, h % 100)])
    for name in sorted(dnf):
        out.append([None, name, 'DNF'])
    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 distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Eli', '10.3'],
     ['Ade', '10.334'],
     ['Dee', '10.350'],
     ['Cy', '10.334'],
     ['Bo', 'DQ'],
     ['Fay', '10.319']],),
   [[1, 'Eli', '10.30'],
    [2, 'Fay', '10.32'],
    [3, 'Ade', '10.34'],
    [3, 'Cy', '10.34'],
    [5, 'Dee', '10.35']]),
  ('variant scenario 1',
   ([['Eli', 'DNF'], ['Fay', '11.371'], ['Cy', '11.370'], ['Dee', '11.385'], ['Bo', '11.384']],),
   [[1, 'Cy', '11.37'],
    [2, 'Fay', '11.38'],
    [3, 'Bo', '11.39'],
    [3, 'Dee', '11.39'],
    [None, 'Eli', 'DNF']]),
  ('variant scenario 2',
   ([['Bo', '11.191'], ['Eli', '11.212'], ['Dee', '11.20'], ['Cy', '11.192']],),
   [[1, 'Bo', '11.20'], [1, 'Cy', '11.20'], [1, 'Dee', '11.20'], [4, 'Eli', '11.22']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Ade', '9.89'], ['Cy', '9.899'], ['Dee', 'DQ'], ['Fay', '9.918']],),
   [[1, 'Ade', '9.89'], [2, 'Cy', '9.90'], [3, 'Fay', '9.92']]),
  ('variant scenario 1',
   ([['Ade', '10.372'], ['Dee', '10.400'], ['Fay', '10.370'], ['Bo', '10.39']],),
   [[1, 'Fay', '10.37'], [2, 'Ade', '10.38'], [3, 'Bo', '10.39'], [4, 'Dee', '10.40']]),
  ('variant scenario 2',
   ([['Dee', '11.459'], ['Ade', '11.47'], ['Bo', '11.476']],),
   [[1, 'Dee', '11.46'], [2, 'Ade', '11.47'], [3, 'Bo', '11.48']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Cy', 'DQ'], ['Bo', 'DQ'], ['Fay', '10.410'], ['Ade', '10.393'], ['Dee', '10.413']],),
   [[1, 'Ade', '10.40'], [2, 'Fay', '10.41'], [3, 'Dee', '10.42']]),
  ('variant scenario 1',
   ([['Fay', '10.316'], ['Cy', '10.319'], ['Dee', '10.288']],),
   [[1, 'Dee', '10.29'], [2, 'Cy', '10.32'], [2, 'Fay', '10.32']]),
  ('variant scenario 2',
   ([['Eli', '10.480'],
     ['Fay', '10.471'],
     ['Cy', '10.464'],
     ['Dee', '10.489'],
     ['Bo', '10.461'],
     ['Ade', '10.464']],),
   [[1, 'Ade', '10.47'],
    [1, 'Bo', '10.47'],
    [1, 'Cy', '10.47'],
    [4, 'Eli', '10.48'],
    [4, 'Fay', '10.48'],
    [6, 'Dee', '10.49']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Cy', '11.288'], ['Eli', 'DQ'], ['Dee', '11.295'], ['Fay', 'DQ'], ['Ade', '11.275']],),
   [[1, 'Ade', '11.28'], [2, 'Cy', '11.29'], [3, 'Dee', '11.30']]),
  ('variant scenario 1',
   ([['Bo', '11.010'],
     ['Ade', '10.979'],
     ['Fay', '11.00'],
     ['Eli', '11.005'],
     ['Dee', '10.985'],
     ['Cy', '10.98']],),
   [[1, 'Ade', '10.98'],
    [1, 'Cy', '10.98'],
    [3, 'Dee', '10.99'],
    [4, 'Fay', '11.00'],
    [5, 'Bo', '11.01'],
    [5, 'Eli', '11.01']]),
  ('variant scenario 2',
   ([['Eli', '11.514'], ['Bo', '11.50'], ['Fay', '11.506'], ['Dee', '11.52']],),
   [[1, 'Bo', '11.50'], [2, 'Fay', '11.51'], [3, 'Dee', '11.52'], [3, 'Eli', '11.52']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Ade', '11.2'], ['Fay', '11.28'], ['Bo', 'DQ']],),
   [[1, 'Ade', '11.20'], [2, 'Fay', '11.28']]),
  ('variant scenario 1',
   ([['Dee', '11.400'], ['Bo', '11.37'], ['Cy', 'DNF'], ['Ade', '11.391']],),
   [[1, 'Bo', '11.37'], [2, 'Ade', '11.40'], [2, 'Dee', '11.40'], [None, 'Cy', 'DNF']]),
  ('variant scenario 2',
   ([['Fay', '11.318'], ['Cy', '11.334'], ['Eli', '11.314'], ['Dee', 'DNF']],),
   [[1, 'Eli', '11.32'], [1, 'Fay', '11.32'], [3, 'Cy', '11.34'], [None, 'Dee', 'DNF']])]]
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(results):
    fin = []
    dnf = []
    for name, t in results:
        if t == 'DQ':
            fin.append((10 ** 9, name))
            continue
        if t == 'DNF':
            dnf.append(name)
            continue
        whole, _, frac = t.partition('.')
        thous = int(whole) * 1000 + int((frac + '000')[:3])
        hund = -(-thous // 10)
        fin.append((hund, name))
    fin.sort()
    out = []
    for i, (h, name) in enumerate(fin):
        place = i + 1 if i == 0 or fin[i - 1][0] != h else out[-1][0]
        out.append([place, name, '%d.%02d' % (h // 100, h % 100)])
    for name in sorted(dnf):
        out.append([None, name, 'DNF'])
    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 distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Eli', '10.3'],
     ['Ade', '10.334'],
     ['Dee', '10.350'],
     ['Cy', '10.334'],
     ['Bo', 'DQ'],
     ['Fay', '10.319']],),
   [[1, 'Eli', '10.30'],
    [2, 'Fay', '10.32'],
    [3, 'Ade', '10.34'],
    [3, 'Cy', '10.34'],
    [5, 'Dee', '10.35']]),
  ('variant scenario 1',
   ([['Eli', 'DNF'], ['Fay', '11.371'], ['Cy', '11.370'], ['Dee', '11.385'], ['Bo', '11.384']],),
   [[1, 'Cy', '11.37'],
    [2, 'Fay', '11.38'],
    [3, 'Bo', '11.39'],
    [3, 'Dee', '11.39'],
    [None, 'Eli', 'DNF']]),
  ('variant scenario 2',
   ([['Bo', '11.191'], ['Eli', '11.212'], ['Dee', '11.20'], ['Cy', '11.192']],),
   [[1, 'Bo', '11.20'], [1, 'Cy', '11.20'], [1, 'Dee', '11.20'], [4, 'Eli', '11.22']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Ade', '9.89'], ['Cy', '9.899'], ['Dee', 'DQ'], ['Fay', '9.918']],),
   [[1, 'Ade', '9.89'], [2, 'Cy', '9.90'], [3, 'Fay', '9.92']]),
  ('variant scenario 1',
   ([['Ade', '10.372'], ['Dee', '10.400'], ['Fay', '10.370'], ['Bo', '10.39']],),
   [[1, 'Fay', '10.37'], [2, 'Ade', '10.38'], [3, 'Bo', '10.39'], [4, 'Dee', '10.40']]),
  ('variant scenario 2',
   ([['Dee', '11.459'], ['Ade', '11.47'], ['Bo', '11.476']],),
   [[1, 'Dee', '11.46'], [2, 'Ade', '11.47'], [3, 'Bo', '11.48']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Cy', 'DQ'], ['Bo', 'DQ'], ['Fay', '10.410'], ['Ade', '10.393'], ['Dee', '10.413']],),
   [[1, 'Ade', '10.40'], [2, 'Fay', '10.41'], [3, 'Dee', '10.42']]),
  ('variant scenario 1',
   ([['Fay', '10.316'], ['Cy', '10.319'], ['Dee', '10.288']],),
   [[1, 'Dee', '10.29'], [2, 'Cy', '10.32'], [2, 'Fay', '10.32']]),
  ('variant scenario 2',
   ([['Eli', '10.480'],
     ['Fay', '10.471'],
     ['Cy', '10.464'],
     ['Dee', '10.489'],
     ['Bo', '10.461'],
     ['Ade', '10.464']],),
   [[1, 'Ade', '10.47'],
    [1, 'Bo', '10.47'],
    [1, 'Cy', '10.47'],
    [4, 'Eli', '10.48'],
    [4, 'Fay', '10.48'],
    [6, 'Dee', '10.49']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Cy', '11.288'], ['Eli', 'DQ'], ['Dee', '11.295'], ['Fay', 'DQ'], ['Ade', '11.275']],),
   [[1, 'Ade', '11.28'], [2, 'Cy', '11.29'], [3, 'Dee', '11.30']]),
  ('variant scenario 1',
   ([['Bo', '11.010'],
     ['Ade', '10.979'],
     ['Fay', '11.00'],
     ['Eli', '11.005'],
     ['Dee', '10.985'],
     ['Cy', '10.98']],),
   [[1, 'Ade', '10.98'],
    [1, 'Cy', '10.98'],
    [3, 'Dee', '10.99'],
    [4, 'Fay', '11.00'],
    [5, 'Bo', '11.01'],
    [5, 'Eli', '11.01']]),
  ('variant scenario 2',
   ([['Eli', '11.514'], ['Bo', '11.50'], ['Fay', '11.506'], ['Dee', '11.52']],),
   [[1, 'Bo', '11.50'], [2, 'Fay', '11.51'], [3, 'Dee', '11.52'], [3, 'Eli', '11.52']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: disqualification',
   ([['Ade', '11.2'], ['Fay', '11.28'], ['Bo', 'DQ']],),
   [[1, 'Ade', '11.20'], [2, 'Fay', '11.28']]),
  ('variant scenario 1',
   ([['Dee', '11.400'], ['Bo', '11.37'], ['Cy', 'DNF'], ['Ade', '11.391']],),
   [[1, 'Bo', '11.37'], [2, 'Ade', '11.40'], [2, 'Dee', '11.40'], [None, 'Cy', 'DNF']]),
  ('variant scenario 2',
   ([['Fay', '11.318'], ['Cy', '11.334'], ['Eli', '11.314'], ['Dee', 'DNF']],),
   [[1, 'Eli', '11.32'], [1, 'Fay', '11.32'], [3, 'Cy', '11.34'], [None, 'Dee', 'DNF']])]]
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 disqualified athlete appears in the results as DNF.

Sprint results. results rows are [name, time] where time is seconds with up to three decimals, or "DNF"/"DQ". Times are rounded up to the next hundredth for publication. Rank by rounded time then name; equal rounded times share the place and the next place is skipped (1, 2, 2, 4). DNF athletes follow the finishers in name order with place None and time "DNF"; DQ athletes are omitted. Return [place, name, time "S.hh"] rows.

split: open-access


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

N = 1
observations = []
def solve(records):
    rows = []
    nh = []
    for name, heights in records:
        cleared = [h for h, s in heights if 'O' in s]
        if not cleared:
            nh.append(name)
            continue
        best = max(cleared)
        at_best = sum(s.count('X') for h, s in heights if h == best)
        total = sum(s.count('X') for h, s in heights if h <= best)
        rows.append((-best, total, total, name))
    rows.sort()
    out = []
    for i, r in enumerate(rows):
        if i and rows[i - 1][:3] == r[:3]:
            place = out[-1][0]
        else:
            place = i + 1
        out.append([place, r[3], -r[0]])
    for name in sorted(nh):
        out.append([None, name, None])
    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 higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Dee', [[180, 'O'], [183, 'X-'], [186, 'O'], [189, 'XO']]],
     ['Bo', [[180, 'XX-'], [183, 'O'], [186, 'XXO'], [189, 'O']]]],),
   [[1, 'Bo', 189], [2, 'Dee', 189]]),
  ('variant scenario 1',
   ([['Cy', [[180, 'O'], [183, 'O'], [186, 'O']]],
     ['Eli', [[180, '-'], [183, 'XXX']]],
     ['Ade', [[180, 'X-'], [183, 'XO'], [186, 'XXX']]],
     ['Dee', [[180, 'XXX']]],
     ['Fay', [[180, 'XX-'], [183, 'O'], [186, 'XO']]]],),
   [[1, 'Cy', 186], [2, 'Fay', 186], [3, 'Ade', 183], [None, 'Dee', None], [None, 'Eli', None]]),
  ('variant scenario 2',
   ([['Bo', [[180, 'X-'], [183, 'XXX']]], ['Cy', [[180, 'XO'], [183, 'XX-'], [186, 'O']]]],),
   [[1, 'Cy', 186], [None, 'Bo', None]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Cy', [[180, 'O'], [183, 'XXO'], [186, 'XX-']]],
     ['Bo', [[180, 'O'], [183, 'O'], [186, 'XXO']]],
     ['Dee', [[180, 'XXX']]],
     ['Eli', [[180, 'XO'], [183, 'O'], [186, '-']]],
     ['Ade', [[180, 'XO'], [183, 'X-'], [186, 'O']]]],),
   [[1, 'Ade', 186], [2, 'Bo', 186], [3, 'Eli', 183], [4, 'Cy', 183], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Cy', [[180, 'XX-'], [183, 'XXO'], [186, 'XO'], [189, 'O'], [192, 'XO']]],
     ['Bo', [[180, 'XX-'], [183, 'XO'], [186, 'XXO'], [189, 'XX-'], [192, 'O']]],
     ['Dee', [[180, 'XO'], [183, 'XXO'], [186, 'XO'], [189, 'O'], [192, '-']]],
     ['Fay', [[180, 'XXO'], [183, 'XO'], [186, 'XX-'], [189, 'O'], [192, 'XX-']]],
     ['Eli', [[180, 'O'], [183, 'O'], [186, 'O'], [189, 'XX-'], [192, 'O']]]],),
   [[1, 'Eli', 192], [2, 'Bo', 192], [3, 'Cy', 192], [4, 'Dee', 189], [5, 'Fay', 189]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'O'], [183, 'XXO'], [186, 'XXX']]],
     ['Ade', [[180, 'O'], [183, 'XXX']]],
     ['Dee', [[180, 'O'], [183, 'XO'], [186, 'O'], [189, 'XO'], [192, 'X-']]]],),
   [[1, 'Dee', 189], [2, 'Eli', 183], [3, 'Ade', 180]]),
  ('variant scenario 2',
   ([['Fay', [[180, 'XXX']]],
     ['Ade', [[180, 'XO'], [183, 'XO'], [186, 'XO'], [189, '-'], [192, 'XO']]],
     ['Bo', [[180, 'XO'], [183, '-'], [186, 'XO'], [189, 'O'], [192, 'XXO']]]],),
   [[1, 'Ade', 192], [2, 'Bo', 192], [None, 'Fay', None]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Ade', [[180, 'O'], [183, 'XXO'], [186, 'O'], [189, 'XO']]],
     ['Eli', [[180, 'O'], [183, '-'], [186, 'XO'], [189, 'XXO']]],
     ['Fay', [[180, 'XO'], [183, 'XXX']]],
     ['Bo', [[180, 'XO'], [183, 'O'], [186, '-'], [189, 'O']]],
     ['Dee', [[180, 'O'], [183, 'XX-'], [186, 'X-'], [189, 'XXO']]]],),
   [[1, 'Bo', 189], [2, 'Ade', 189], [3, 'Eli', 189], [4, 'Dee', 189], [5, 'Fay', 180]]),
  ('regression: best height misses',
   ([['Ade', [[180, 'O'], [183, 'XXX']]],
     ['Dee', [[180, 'O'], [183, 'XO'], [186, '-']]],
     ['Bo', [[180, 'XX-'], [183, 'O'], [186, 'XXX']]]],),
   [[1, 'Bo', 183], [2, 'Dee', 183], [3, 'Ade', 180]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'O'], [183, 'XX-'], [186, 'O'], [189, '-'], [192, 'XX-']]],
     ['Bo', [[180, 'XO'], [183, 'O'], [186, 'X-'], [189, 'X-'], [192, 'XXX']]],
     ['Cy', [[180, 'XO'], [183, 'O'], [186, 'O'], [189, 'XXX']]],
     ['Fay', [[180, 'X-'], [183, 'XXX']]]],),
   [[1, 'Cy', 186], [2, 'Eli', 186], [3, 'Bo', 183], [None, 'Fay', None]]),
  ('variant scenario 2',
   ([['Dee', [[180, 'O'], [183, 'XO'], [186, 'X-']]],
     ['Cy', [[180, 'XO'], [183, 'XO'], [186, 'XX-']]]],),
   [[1, 'Dee', 183], [2, 'Cy', 183]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Cy', [[180, 'XO'], [183, 'XO'], [186, 'XX-']]],
     ['Dee', [[180, 'XXO'], [183, 'XX-'], [186, 'O']]],
     ['Ade', [[180, 'O'], [183, 'XXO'], [186, '-']]]],),
   [[1, 'Dee', 186], [2, 'Cy', 183], [3, 'Ade', 183]]),
  ('regression: best height misses',
   ([['Eli', [[180, 'O'], [183, 'O'], [186, 'O'], [189, 'XXO']]],
     ['Ade', [[180, 'O'], [183, 'O'], [186, 'XXO'], [189, '-']]],
     ['Fay', [[180, 'X-'], [183, 'XXO'], [186, 'XX-'], [189, 'XXO']]],
     ['Dee', [[180, 'XXO'], [183, 'X-'], [186, 'O'], [189, 'XXX']]],
     ['Cy', [[180, 'XXX']]]],),
   [[1, 'Eli', 189], [2, 'Fay', 189], [3, 'Dee', 186], [4, 'Ade', 186], [None, 'Cy', None]]),
  ('variant scenario 1',
   ([['Dee', [[180, 'XO'], [183, 'XXO'], [186, 'O'], [189, 'XO']]],
     ['Fay', [[180, 'XO'], [183, 'O'], [186, 'XXX']]],
     ['Ade', [[180, 'X-'], [183, '-'], [186, '-'], [189, 'XO']]],
     ['Eli', [[180, 'XO'], [183, '-'], [186, 'XX-'], [189, 'XO']]]],),
   [[1, 'Ade', 189], [2, 'Dee', 189], [2, 'Eli', 189], [4, 'Fay', 183]]),
  ('variant scenario 2',
   ([['Ade', [[180, '-'], [183, '-'], [186, 'XO']]],
     ['Cy', [[180, 'O'], [183, 'O'], [186, 'O']]],
     ['Eli', [[180, '-'], [183, 'XO'], [186, '-']]]],),
   [[1, 'Cy', 186], [2, 'Ade', 186], [3, 'Eli', 183]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Eli', [[180, 'X-'], [183, 'O'], [186, 'XXO'], [189, 'O'], [192, 'O']]],
     ['Cy', [[180, 'O'], [183, 'O'], [186, 'XO'], [189, 'XO'], [192, 'XO']]],
     ['Bo', [[180, 'O'], [183, 'X-'], [186, 'XO'], [189, 'XO'], [192, 'XX-']]],
     ['Dee', [[180, 'XX-'], [183, 'O'], [186, 'O'], [189, 'XXO'], [192, 'XO']]],
     ['Ade', [[180, 'O'], [183, 'O'], [186, '-'], [189, 'XO'], [192, 'O']]]],),
   [[1, 'Ade', 192], [2, 'Eli', 192], [3, 'Cy', 192], [4, 'Dee', 192], [5, 'Bo', 189]]),
  ('regression: best height misses',
   ([['Eli', [[180, 'O'], [183, 'XX-'], [186, 'XXX']]],
     ['Ade', [[180, 'XXO'], [183, 'O'], [186, 'O']]],
     ['Bo', [[180, '-'], [183, 'O'], [186, 'XXO']]],
     ['Cy', [[180, 'XX-'], [183, 'XXO'], [186, 'O']]]],),
   [[1, 'Ade', 186], [2, 'Cy', 186], [3, 'Bo', 186], [4, 'Eli', 180]]),
  ('variant scenario 1',
   ([['Cy', [[180, '-'], [183, 'O'], [186, 'O'], [189, 'XO'], [192, 'O'], [195, 'XXX']]],
     ['Dee', [[180, 'XXX']]],
     ['Bo', [[180, 'X-'], [183, 'O'], [186, 'XXO'], [189, 'XO'], [192, 'XX-'], [195, 'XXX']]],
     ['Eli', [[180, 'XO'], [183, '-'], [186, '-'], [189, 'O'], [192, 'O'], [195, 'XO']]]],),
   [[1, 'Eli', 195], [2, 'Cy', 192], [3, 'Bo', 189], [None, 'Dee', None]]),
  ('variant scenario 2',
   ([['Fay', [[180, 'XXX']]], ['Eli', [[180, 'O'], [183, '-'], [186, 'XO']]]],),
   [[1, 'Eli', 186], [None, 'Fay', None]])]]
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(records):
    rows = []
    nh = []
    for name, heights in records:
        cleared = [h for h, s in heights if 'O' in s]
        if not cleared:
            nh.append(name)
            continue
        best = max(cleared)
        at_best = sum(s.count('X') for h, s in heights if h == best)
        total = sum(s.count('X') for h, s in heights if h <= best)
        rows.append((-best, total, at_best, name))
    rows.sort()
    out = []
    for i, r in enumerate(rows):
        if i and rows[i - 1][:3] == r[:3]:
            place = out[-1][0]
        else:
            place = i + 1
        out.append([place, r[3], -r[0]])
    for name in sorted(nh):
        out.append([None, name, None])
    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 higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Dee', [[180, 'O'], [183, 'X-'], [186, 'O'], [189, 'XO']]],
     ['Bo', [[180, 'XX-'], [183, 'O'], [186, 'XXO'], [189, 'O']]]],),
   [[1, 'Bo', 189], [2, 'Dee', 189]]),
  ('variant scenario 1',
   ([['Cy', [[180, 'O'], [183, 'O'], [186, 'O']]],
     ['Eli', [[180, '-'], [183, 'XXX']]],
     ['Ade', [[180, 'X-'], [183, 'XO'], [186, 'XXX']]],
     ['Dee', [[180, 'XXX']]],
     ['Fay', [[180, 'XX-'], [183, 'O'], [186, 'XO']]]],),
   [[1, 'Cy', 186], [2, 'Fay', 186], [3, 'Ade', 183], [None, 'Dee', None], [None, 'Eli', None]]),
  ('variant scenario 2',
   ([['Bo', [[180, 'X-'], [183, 'XXX']]], ['Cy', [[180, 'XO'], [183, 'XX-'], [186, 'O']]]],),
   [[1, 'Cy', 186], [None, 'Bo', None]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Cy', [[180, 'O'], [183, 'XXO'], [186, 'XX-']]],
     ['Bo', [[180, 'O'], [183, 'O'], [186, 'XXO']]],
     ['Dee', [[180, 'XXX']]],
     ['Eli', [[180, 'XO'], [183, 'O'], [186, '-']]],
     ['Ade', [[180, 'XO'], [183, 'X-'], [186, 'O']]]],),
   [[1, 'Ade', 186], [2, 'Bo', 186], [3, 'Eli', 183], [4, 'Cy', 183], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Cy', [[180, 'XX-'], [183, 'XXO'], [186, 'XO'], [189, 'O'], [192, 'XO']]],
     ['Bo', [[180, 'XX-'], [183, 'XO'], [186, 'XXO'], [189, 'XX-'], [192, 'O']]],
     ['Dee', [[180, 'XO'], [183, 'XXO'], [186, 'XO'], [189, 'O'], [192, '-']]],
     ['Fay', [[180, 'XXO'], [183, 'XO'], [186, 'XX-'], [189, 'O'], [192, 'XX-']]],
     ['Eli', [[180, 'O'], [183, 'O'], [186, 'O'], [189, 'XX-'], [192, 'O']]]],),
   [[1, 'Eli', 192], [2, 'Bo', 192], [3, 'Cy', 192], [4, 'Dee', 189], [5, 'Fay', 189]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'O'], [183, 'XXO'], [186, 'XXX']]],
     ['Ade', [[180, 'O'], [183, 'XXX']]],
     ['Dee', [[180, 'O'], [183, 'XO'], [186, 'O'], [189, 'XO'], [192, 'X-']]]],),
   [[1, 'Dee', 189], [2, 'Eli', 183], [3, 'Ade', 180]]),
  ('variant scenario 2',
   ([['Fay', [[180, 'XXX']]],
     ['Ade', [[180, 'XO'], [183, 'XO'], [186, 'XO'], [189, '-'], [192, 'XO']]],
     ['Bo', [[180, 'XO'], [183, '-'], [186, 'XO'], [189, 'O'], [192, 'XXO']]]],),
   [[1, 'Ade', 192], [2, 'Bo', 192], [None, 'Fay', None]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Ade', [[180, 'O'], [183, 'XXO'], [186, 'O'], [189, 'XO']]],
     ['Eli', [[180, 'O'], [183, '-'], [186, 'XO'], [189, 'XXO']]],
     ['Fay', [[180, 'XO'], [183, 'XXX']]],
     ['Bo', [[180, 'XO'], [183, 'O'], [186, '-'], [189, 'O']]],
     ['Dee', [[180, 'O'], [183, 'XX-'], [186, 'X-'], [189, 'XXO']]]],),
   [[1, 'Bo', 189], [2, 'Ade', 189], [3, 'Eli', 189], [4, 'Dee', 189], [5, 'Fay', 180]]),
  ('regression: best height misses',
   ([['Ade', [[180, 'O'], [183, 'XXX']]],
     ['Dee', [[180, 'O'], [183, 'XO'], [186, '-']]],
     ['Bo', [[180, 'XX-'], [183, 'O'], [186, 'XXX']]]],),
   [[1, 'Bo', 183], [2, 'Dee', 183], [3, 'Ade', 180]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'O'], [183, 'XX-'], [186, 'O'], [189, '-'], [192, 'XX-']]],
     ['Bo', [[180, 'XO'], [183, 'O'], [186, 'X-'], [189, 'X-'], [192, 'XXX']]],
     ['Cy', [[180, 'XO'], [183, 'O'], [186, 'O'], [189, 'XXX']]],
     ['Fay', [[180, 'X-'], [183, 'XXX']]]],),
   [[1, 'Cy', 186], [2, 'Eli', 186], [3, 'Bo', 183], [None, 'Fay', None]]),
  ('variant scenario 2',
   ([['Dee', [[180, 'O'], [183, 'XO'], [186, 'X-']]],
     ['Cy', [[180, 'XO'], [183, 'XO'], [186, 'XX-']]]],),
   [[1, 'Dee', 183], [2, 'Cy', 183]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Cy', [[180, 'XO'], [183, 'XO'], [186, 'XX-']]],
     ['Dee', [[180, 'XXO'], [183, 'XX-'], [186, 'O']]],
     ['Ade', [[180, 'O'], [183, 'XXO'], [186, '-']]]],),
   [[1, 'Dee', 186], [2, 'Cy', 183], [3, 'Ade', 183]]),
  ('regression: best height misses',
   ([['Eli', [[180, 'O'], [183, 'O'], [186, 'O'], [189, 'XXO']]],
     ['Ade', [[180, 'O'], [183, 'O'], [186, 'XXO'], [189, '-']]],
     ['Fay', [[180, 'X-'], [183, 'XXO'], [186, 'XX-'], [189, 'XXO']]],
     ['Dee', [[180, 'XXO'], [183, 'X-'], [186, 'O'], [189, 'XXX']]],
     ['Cy', [[180, 'XXX']]]],),
   [[1, 'Eli', 189], [2, 'Fay', 189], [3, 'Dee', 186], [4, 'Ade', 186], [None, 'Cy', None]]),
  ('variant scenario 1',
   ([['Dee', [[180, 'XO'], [183, 'XXO'], [186, 'O'], [189, 'XO']]],
     ['Fay', [[180, 'XO'], [183, 'O'], [186, 'XXX']]],
     ['Ade', [[180, 'X-'], [183, '-'], [186, '-'], [189, 'XO']]],
     ['Eli', [[180, 'XO'], [183, '-'], [186, 'XX-'], [189, 'XO']]]],),
   [[1, 'Ade', 189], [2, 'Dee', 189], [2, 'Eli', 189], [4, 'Fay', 183]]),
  ('variant scenario 2',
   ([['Ade', [[180, '-'], [183, '-'], [186, 'XO']]],
     ['Cy', [[180, 'O'], [183, 'O'], [186, 'O']]],
     ['Eli', [[180, '-'], [183, 'XO'], [186, '-']]]],),
   [[1, 'Cy', 186], [2, 'Ade', 186], [3, 'Eli', 183]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: best height misses',
   ([['Eli', [[180, 'X-'], [183, 'O'], [186, 'XXO'], [189, 'O'], [192, 'O']]],
     ['Cy', [[180, 'O'], [183, 'O'], [186, 'XO'], [189, 'XO'], [192, 'XO']]],
     ['Bo', [[180, 'O'], [183, 'X-'], [186, 'XO'], [189, 'XO'], [192, 'XX-']]],
     ['Dee', [[180, 'XX-'], [183, 'O'], [186, 'O'], [189, 'XXO'], [192, 'XO']]],
     ['Ade', [[180, 'O'], [183, 'O'], [186, '-'], [189, 'XO'], [192, 'O']]]],),
   [[1, 'Ade', 192], [2, 'Eli', 192], [3, 'Cy', 192], [4, 'Dee', 192], [5, 'Bo', 189]]),
  ('regression: best height misses',
   ([['Eli', [[180, 'O'], [183, 'XX-'], [186, 'XXX']]],
     ['Ade', [[180, 'XXO'], [183, 'O'], [186, 'O']]],
     ['Bo', [[180, '-'], [183, 'O'], [186, 'XXO']]],
     ['Cy', [[180, 'XX-'], [183, 'XXO'], [186, 'O']]]],),
   [[1, 'Ade', 186], [2, 'Cy', 186], [3, 'Bo', 186], [4, 'Eli', 180]]),
  ('variant scenario 1',
   ([['Cy', [[180, '-'], [183, 'O'], [186, 'O'], [189, 'XO'], [192, 'O'], [195, 'XXX']]],
     ['Dee', [[180, 'XXX']]],
     ['Bo', [[180, 'X-'], [183, 'O'], [186, 'XXO'], [189, 'XO'], [192, 'XX-'], [195, 'XXX']]],
     ['Eli', [[180, 'XO'], [183, '-'], [186, '-'], [189, 'O'], [192, 'O'], [195, 'XO']]]],),
   [[1, 'Eli', 195], [2, 'Cy', 192], [3, 'Bo', 189], [None, 'Dee', None]]),
  ('variant scenario 2',
   ([['Fay', [[180, 'XXX']]], ['Eli', [[180, 'O'], [183, '-'], [186, 'XO']]]],),
   [[1, 'Eli', 186], [None, 'Fay', None]])]]
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 athlete with a first-attempt clearance at the best height is ranked below one who needed three.

High jump placing. records rows are [name, [[height_cm, attempts], ...]] where attempts is a string of X (failure), O (clearance) or "-" (pass). Best height is the highest cleared. Rank by best height descending, then fewest failures at the best height, then fewest total failures at heights up to and including the best; athletes equal on all three share the place (the next place is skipped). Athletes without a clearance come last with place None in name order. Return [place, name, best].

split: open-access


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

N = 1
observations = []
def solve(records):
    rows = []
    nh = []
    for name, heights in records:
        cleared = [h for h, s in heights if 'O' in s]
        if not cleared:
            nh.append(name)
            continue
        best = max(cleared)
        at_best = sum(s.count('X') for h, s in heights if h == best)
        total = sum(s.count('X') for h, s in heights)
        rows.append((-best, at_best, total, name))
    rows.sort()
    out = []
    for i, r in enumerate(rows):
        if i and rows[i - 1][:3] == r[:3]:
            place = out[-1][0]
        else:
            place = i + 1
        out.append([place, r[3], -r[0]])
    for name in sorted(nh):
        out.append([None, name, None])
    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 higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Fay', [[180, 'XO'], [183, 'XO'], [186, 'O'], [189, 'O'], [192, 'XXO'], [195, 'XXO']]],
     ['Ade', [[180, 'XXX']]],
     ['Dee', [[180, 'O'], [183, 'XO'], [186, 'X-'], [189, '-'], [192, 'O'], [195, 'XXX']]],
     ['Eli', [[180, 'X-'], [183, '-'], [186, 'O'], [189, 'XXO'], [192, 'O'], [195, 'XX-']]],
     ['Bo', [[180, 'O'], [183, 'O'], [186, 'O'], [189, '-'], [192, '-'], [195, 'XX-']]]],),
   [[1, 'Fay', 195], [2, 'Dee', 192], [3, 'Eli', 192], [4, 'Bo', 186], [None, 'Ade', None]]),
  ('regression: total misses range',
   ([['Cy', [[180, 'XX-'], [183, 'X-'], [186, 'O']]],
     ['Ade', [[180, 'O'], [183, 'XX-'], [186, 'O']]],
     ['Fay', [[180, 'XO'], [183, 'XO'], [186, 'O']]],
     ['Bo', [[180, 'XO'], [183, 'XX-'], [186, 'XXO']]]],),
   [[1, 'Ade', 186], [1, 'Fay', 186], [3, 'Cy', 186], [4, 'Bo', 186]]),
  ('variant scenario 1',
   ([['Cy', [[180, 'O'], [183, 'O'], [186, 'XO'], [189, 'XXO'], [192, 'XX-']]],
     ['Bo', [[180, '-'], [183, 'O'], [186, 'O'], [189, 'XO'], [192, 'XXO']]],
     ['Eli', [[180, '-'], [183, 'XO'], [186, 'O'], [189, 'XX-'], [192, 'XXX']]]],),
   [[1, 'Bo', 192], [2, 'Cy', 189], [3, 'Eli', 186]]),
  ('variant scenario 2',
   ([['Cy', [[180, 'O'], [183, 'O'], [186, '-']]],
     ['Ade', [[180, 'XO'], [183, 'X-'], [186, 'O']]]],),
   [[1, 'Ade', 186], [2, 'Cy', 183]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Bo', [[180, 'XXX']]],
     ['Fay', [[180, 'X-'], [183, 'XX-'], [186, 'O'], [189, 'O'], [192, 'X-']]],
     ['Eli', [[180, 'O'], [183, 'XO'], [186, 'XX-'], [189, 'XXO'], [192, 'O']]],
     ['Cy', [[180, 'O'], [183, 'XO'], [186, 'O'], [189, 'O'], [192, '-']]]],),
   [[1, 'Eli', 192], [2, 'Cy', 189], [3, 'Fay', 189], [None, 'Bo', None]]),
  ('regression: total misses range',
   ([['Eli', [[180, 'XO'], [183, '-'], [186, 'O']]],
     ['Fay', [[180, 'XO'], [183, 'O'], [186, 'XXX']]],
     ['Cy', [[180, 'XXO'], [183, 'O'], [186, '-']]],
     ['Bo', [[180, 'XXX']]],
     ['Dee', [[180, 'X-'], [183, '-'], [186, 'O']]]],),
   [[1, 'Dee', 186], [1, 'Eli', 186], [3, 'Fay', 183], [4, 'Cy', 183], [None, 'Bo', None]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'O'], [183, 'X-'], [186, 'XO'], [189, 'XXX']]],
     ['Fay', [[180, 'O'], [183, '-'], [186, 'O'], [189, 'O'], [192, 'XO']]],
     ['Dee', [[180, 'O'], [183, 'XO'], [186, 'XXX']]],
     ['Bo', [[180, 'XO'], [183, 'O'], [186, '-'], [189, 'XXO'], [192, 'XX-']]]],),
   [[1, 'Fay', 192], [2, 'Bo', 189], [3, 'Eli', 186], [4, 'Dee', 183]]),
  ('variant scenario 2',
   ([['Cy', [[180, 'O'], [183, 'O'], [186, 'XX-'], [189, 'O'], [192, '-']]],
     ['Fay', [[180, 'O'], [183, 'X-'], [186, '-'], [189, 'XXO'], [192, 'XXX']]],
     ['Dee', [[180, '-'], [183, '-'], [186, 'XX-'], [189, 'XXX']]],
     ['Ade', [[180, 'O'], [183, 'O'], [186, 'O'], [189, 'O'], [192, 'XO']]]],),
   [[1, 'Ade', 192], [2, 'Cy', 189], [3, 'Fay', 189], [None, 'Dee', None]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Cy', [[180, 'XO'], [183, 'XX-'], [186, 'XO'], [189, 'XXO'], [192, 'O']]],
     ['Dee', [[180, '-'], [183, 'XXO'], [186, 'X-'], [189, '-'], [192, 'O']]],
     ['Ade', [[180, 'O'], [183, '-'], [186, 'O'], [189, 'O'], [192, 'O']]],
     ['Bo', [[180, 'X-'], [183, '-'], [186, 'XO'], [189, 'XX-'], [192, 'O']]]],),
   [[1, 'Ade', 192], [2, 'Dee', 192], [3, 'Bo', 192], [4, 'Cy', 192]]),
  ('regression: total misses range',
   ([['Bo', [[180, 'X-'], [183, 'XXX']]],
     ['Cy', [[180, 'O'], [183, 'O'], [186, 'X-']]],
     ['Dee', [[180, 'XXO'], [183, 'XO'], [186, 'XXO']]],
     ['Fay', [[180, 'O'], [183, 'O'], [186, '-']]]],),
   [[1, 'Dee', 186], [2, 'Cy', 183], [2, 'Fay', 183], [None, 'Bo', None]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'XXO'], [183, 'XXX']]],
     ['Fay', [[180, '-'], [183, 'O'], [186, 'O'], [189, 'XXO']]]],),
   [[1, 'Fay', 189], [2, 'Eli', 180]]),
  ('variant scenario 2',
   ([['Fay', [[180, 'XXO'], [183, 'O'], [186, 'O'], [189, 'XO'], [192, 'XXO'], [195, 'XO']]],
     ['Eli', [[180, '-'], [183, 'O'], [186, 'XO'], [189, 'XO'], [192, 'X-'], [195, 'XXX']]],
     ['Bo', [[180, 'XX-'], [183, 'XX-'], [186, 'XO'], [189, 'XX-'], [192, 'XXO'], [195, 'X-']]],
     ['Dee', [[180, 'XO'], [183, 'XO'], [186, '-'], [189, 'XXX']]],
     ['Ade', [[180, 'XO'], [183, 'XXO'], [186, 'XO'], [189, 'XXO'], [192, 'XXO'], [195, 'XO']]]],),
   [[1, 'Fay', 195], [2, 'Ade', 195], [3, 'Bo', 192], [4, 'Eli', 189], [5, 'Dee', 183]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Fay', [[180, 'XO'], [183, 'O'], [186, 'XXO']]],
     ['Ade', [[180, 'XO'], [183, 'XX-'], [186, 'XXO']]],
     ['Bo', [[180, 'XXO'], [183, 'XX-'], [186, 'O']]]],),
   [[1, 'Bo', 186], [2, 'Fay', 186], [3, 'Ade', 186]]),
  ('regression: total misses range',
   ([['Dee', [[180, '-'], [183, 'O'], [186, 'X-']]],
     ['Ade', [[180, 'O'], [183, 'O'], [186, 'XXX']]],
     ['Fay', [[180, 'XX-'], [183, 'XXX']]],
     ['Eli', [[180, 'O'], [183, 'X-'], [186, 'XO']]]],),
   [[1, 'Eli', 186], [2, 'Ade', 183], [2, 'Dee', 183], [None, 'Fay', None]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'O'], [183, '-'], [186, 'O']]],
     ['Dee', [[180, 'XO'], [183, '-'], [186, 'XX-']]]],),
   [[1, 'Eli', 186], [2, 'Dee', 180]]),
  ('variant scenario 2',
   ([['Cy', [[180, 'X-'], [183, 'O'], [186, '-'], [189, 'XO']]],
     ['Eli', [[180, 'O'], [183, 'O'], [186, 'XO'], [189, '-']]]],),
   [[1, 'Cy', 189], [2, 'Eli', 186]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Ade', [[180, 'O'], [183, 'XO'], [186, 'XX-']]],
     ['Bo', [[180, 'O'], [183, 'O'], [186, 'X-']]],
     ['Fay', [[180, 'X-'], [183, '-'], [186, 'XX-']]],
     ['Dee', [[180, 'O'], [183, 'XXX']]],
     ['Cy', [[180, 'X-'], [183, 'XO'], [186, 'XXX']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 183], [3, 'Cy', 183], [4, 'Dee', 180], [None, 'Fay', None]]),
  ('regression: total misses range',
   ([['Eli', [[180, '-'], [183, 'XO'], [186, 'O']]],
     ['Cy', [[180, 'O'], [183, 'O'], [186, 'X-']]],
     ['Fay', [[180, 'X-'], [183, 'O'], [186, 'XXX']]],
     ['Ade', [[180, 'X-'], [183, 'O'], [186, '-']]]],),
   [[1, 'Eli', 186], [2, 'Cy', 183], [3, 'Ade', 183], [3, 'Fay', 183]]),
  ('variant scenario 1',
   ([['Bo', [[180, '-'], [183, 'O'], [186, 'O']]],
     ['Cy', [[180, 'O'], [183, 'XO'], [186, 'XX-']]],
     ['Dee', [[180, 'XO'], [183, 'X-'], [186, 'X-']]]],),
   [[1, 'Bo', 186], [2, 'Cy', 183], [3, 'Dee', 180]]),
  ('variant scenario 2',
   ([['Bo', [[180, 'X-'], [183, 'O'], [186, '-'], [189, 'XO']]],
     ['Ade', [[180, 'XO'], [183, 'XXO'], [186, 'XXO'], [189, 'O']]]],),
   [[1, 'Ade', 189], [2, 'Bo', 189]])]]
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(records):
    rows = []
    nh = []
    for name, heights in records:
        cleared = [h for h, s in heights if 'O' in s]
        if not cleared:
            nh.append(name)
            continue
        best = max(cleared)
        at_best = sum(s.count('X') for h, s in heights if h == best)
        total = sum(s.count('X') for h, s in heights if h <= best and 'O' in s)
        rows.append((-best, at_best, total, name))
    rows.sort()
    out = []
    for i, r in enumerate(rows):
        if i and rows[i - 1][:3] == r[:3]:
            place = out[-1][0]
        else:
            place = i + 1
        out.append([place, r[3], -r[0]])
    for name in sorted(nh):
        out.append([None, name, None])
    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 higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Fay', [[180, 'XO'], [183, 'XO'], [186, 'O'], [189, 'O'], [192, 'XXO'], [195, 'XXO']]],
     ['Ade', [[180, 'XXX']]],
     ['Dee', [[180, 'O'], [183, 'XO'], [186, 'X-'], [189, '-'], [192, 'O'], [195, 'XXX']]],
     ['Eli', [[180, 'X-'], [183, '-'], [186, 'O'], [189, 'XXO'], [192, 'O'], [195, 'XX-']]],
     ['Bo', [[180, 'O'], [183, 'O'], [186, 'O'], [189, '-'], [192, '-'], [195, 'XX-']]]],),
   [[1, 'Fay', 195], [2, 'Dee', 192], [3, 'Eli', 192], [4, 'Bo', 186], [None, 'Ade', None]]),
  ('regression: total misses range',
   ([['Cy', [[180, 'XX-'], [183, 'X-'], [186, 'O']]],
     ['Ade', [[180, 'O'], [183, 'XX-'], [186, 'O']]],
     ['Fay', [[180, 'XO'], [183, 'XO'], [186, 'O']]],
     ['Bo', [[180, 'XO'], [183, 'XX-'], [186, 'XXO']]]],),
   [[1, 'Ade', 186], [1, 'Fay', 186], [3, 'Cy', 186], [4, 'Bo', 186]]),
  ('variant scenario 1',
   ([['Cy', [[180, 'O'], [183, 'O'], [186, 'XO'], [189, 'XXO'], [192, 'XX-']]],
     ['Bo', [[180, '-'], [183, 'O'], [186, 'O'], [189, 'XO'], [192, 'XXO']]],
     ['Eli', [[180, '-'], [183, 'XO'], [186, 'O'], [189, 'XX-'], [192, 'XXX']]]],),
   [[1, 'Bo', 192], [2, 'Cy', 189], [3, 'Eli', 186]]),
  ('variant scenario 2',
   ([['Cy', [[180, 'O'], [183, 'O'], [186, '-']]],
     ['Ade', [[180, 'XO'], [183, 'X-'], [186, 'O']]]],),
   [[1, 'Ade', 186], [2, 'Cy', 183]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Bo', [[180, 'XXX']]],
     ['Fay', [[180, 'X-'], [183, 'XX-'], [186, 'O'], [189, 'O'], [192, 'X-']]],
     ['Eli', [[180, 'O'], [183, 'XO'], [186, 'XX-'], [189, 'XXO'], [192, 'O']]],
     ['Cy', [[180, 'O'], [183, 'XO'], [186, 'O'], [189, 'O'], [192, '-']]]],),
   [[1, 'Eli', 192], [2, 'Cy', 189], [3, 'Fay', 189], [None, 'Bo', None]]),
  ('regression: total misses range',
   ([['Eli', [[180, 'XO'], [183, '-'], [186, 'O']]],
     ['Fay', [[180, 'XO'], [183, 'O'], [186, 'XXX']]],
     ['Cy', [[180, 'XXO'], [183, 'O'], [186, '-']]],
     ['Bo', [[180, 'XXX']]],
     ['Dee', [[180, 'X-'], [183, '-'], [186, 'O']]]],),
   [[1, 'Dee', 186], [1, 'Eli', 186], [3, 'Fay', 183], [4, 'Cy', 183], [None, 'Bo', None]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'O'], [183, 'X-'], [186, 'XO'], [189, 'XXX']]],
     ['Fay', [[180, 'O'], [183, '-'], [186, 'O'], [189, 'O'], [192, 'XO']]],
     ['Dee', [[180, 'O'], [183, 'XO'], [186, 'XXX']]],
     ['Bo', [[180, 'XO'], [183, 'O'], [186, '-'], [189, 'XXO'], [192, 'XX-']]]],),
   [[1, 'Fay', 192], [2, 'Bo', 189], [3, 'Eli', 186], [4, 'Dee', 183]]),
  ('variant scenario 2',
   ([['Cy', [[180, 'O'], [183, 'O'], [186, 'XX-'], [189, 'O'], [192, '-']]],
     ['Fay', [[180, 'O'], [183, 'X-'], [186, '-'], [189, 'XXO'], [192, 'XXX']]],
     ['Dee', [[180, '-'], [183, '-'], [186, 'XX-'], [189, 'XXX']]],
     ['Ade', [[180, 'O'], [183, 'O'], [186, 'O'], [189, 'O'], [192, 'XO']]]],),
   [[1, 'Ade', 192], [2, 'Cy', 189], [3, 'Fay', 189], [None, 'Dee', None]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Cy', [[180, 'XO'], [183, 'XX-'], [186, 'XO'], [189, 'XXO'], [192, 'O']]],
     ['Dee', [[180, '-'], [183, 'XXO'], [186, 'X-'], [189, '-'], [192, 'O']]],
     ['Ade', [[180, 'O'], [183, '-'], [186, 'O'], [189, 'O'], [192, 'O']]],
     ['Bo', [[180, 'X-'], [183, '-'], [186, 'XO'], [189, 'XX-'], [192, 'O']]]],),
   [[1, 'Ade', 192], [2, 'Dee', 192], [3, 'Bo', 192], [4, 'Cy', 192]]),
  ('regression: total misses range',
   ([['Bo', [[180, 'X-'], [183, 'XXX']]],
     ['Cy', [[180, 'O'], [183, 'O'], [186, 'X-']]],
     ['Dee', [[180, 'XXO'], [183, 'XO'], [186, 'XXO']]],
     ['Fay', [[180, 'O'], [183, 'O'], [186, '-']]]],),
   [[1, 'Dee', 186], [2, 'Cy', 183], [2, 'Fay', 183], [None, 'Bo', None]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'XXO'], [183, 'XXX']]],
     ['Fay', [[180, '-'], [183, 'O'], [186, 'O'], [189, 'XXO']]]],),
   [[1, 'Fay', 189], [2, 'Eli', 180]]),
  ('variant scenario 2',
   ([['Fay', [[180, 'XXO'], [183, 'O'], [186, 'O'], [189, 'XO'], [192, 'XXO'], [195, 'XO']]],
     ['Eli', [[180, '-'], [183, 'O'], [186, 'XO'], [189, 'XO'], [192, 'X-'], [195, 'XXX']]],
     ['Bo', [[180, 'XX-'], [183, 'XX-'], [186, 'XO'], [189, 'XX-'], [192, 'XXO'], [195, 'X-']]],
     ['Dee', [[180, 'XO'], [183, 'XO'], [186, '-'], [189, 'XXX']]],
     ['Ade', [[180, 'XO'], [183, 'XXO'], [186, 'XO'], [189, 'XXO'], [192, 'XXO'], [195, 'XO']]]],),
   [[1, 'Fay', 195], [2, 'Ade', 195], [3, 'Bo', 192], [4, 'Eli', 189], [5, 'Dee', 183]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Fay', [[180, 'XO'], [183, 'O'], [186, 'XXO']]],
     ['Ade', [[180, 'XO'], [183, 'XX-'], [186, 'XXO']]],
     ['Bo', [[180, 'XXO'], [183, 'XX-'], [186, 'O']]]],),
   [[1, 'Bo', 186], [2, 'Fay', 186], [3, 'Ade', 186]]),
  ('regression: total misses range',
   ([['Dee', [[180, '-'], [183, 'O'], [186, 'X-']]],
     ['Ade', [[180, 'O'], [183, 'O'], [186, 'XXX']]],
     ['Fay', [[180, 'XX-'], [183, 'XXX']]],
     ['Eli', [[180, 'O'], [183, 'X-'], [186, 'XO']]]],),
   [[1, 'Eli', 186], [2, 'Ade', 183], [2, 'Dee', 183], [None, 'Fay', None]]),
  ('variant scenario 1',
   ([['Eli', [[180, 'O'], [183, '-'], [186, 'O']]],
     ['Dee', [[180, 'XO'], [183, '-'], [186, 'XX-']]]],),
   [[1, 'Eli', 186], [2, 'Dee', 180]]),
  ('variant scenario 2',
   ([['Cy', [[180, 'X-'], [183, 'O'], [186, '-'], [189, 'XO']]],
     ['Eli', [[180, 'O'], [183, 'O'], [186, 'XO'], [189, '-']]]],),
   [[1, 'Cy', 189], [2, 'Eli', 186]])],
 [('control higher clearance wins',
   ([['Ade', [[180, 'O'], [183, 'XXX']]], ['Bo', [[180, 'O'], [183, 'O']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 180]]),
  ('boundary fewer misses at best',
   ([['Ade', [[180, 'XO']]], ['Bo', [[180, 'O']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary total misses countback',
   ([['Ade', [[177, 'XO'], [180, 'O'], [183, 'XXX']]],
     ['Bo', [[177, 'O'], [180, 'O'], [183, 'XXX']]]],),
   [[1, 'Bo', 180], [2, 'Ade', 180]]),
  ('boundary true tie shares place',
   ([['Cy', [[180, 'XO']]], ['Ade', [[180, 'XO']]], ['Bo', [[177, 'O']]]],),
   [[1, 'Ade', 180], [1, 'Cy', 180], [3, 'Bo', 177]]),
  ('control no height',
   ([['Dee', [[180, 'XXX']]], ['Ade', [[180, 'O']]]],),
   [[1, 'Ade', 180], [None, 'Dee', None]]),
  ('regression: total misses range',
   ([['Ade', [[180, 'O'], [183, 'XO'], [186, 'XX-']]],
     ['Bo', [[180, 'O'], [183, 'O'], [186, 'X-']]],
     ['Fay', [[180, 'X-'], [183, '-'], [186, 'XX-']]],
     ['Dee', [[180, 'O'], [183, 'XXX']]],
     ['Cy', [[180, 'X-'], [183, 'XO'], [186, 'XXX']]]],),
   [[1, 'Bo', 183], [2, 'Ade', 183], [3, 'Cy', 183], [4, 'Dee', 180], [None, 'Fay', None]]),
  ('regression: total misses range',
   ([['Eli', [[180, '-'], [183, 'XO'], [186, 'O']]],
     ['Cy', [[180, 'O'], [183, 'O'], [186, 'X-']]],
     ['Fay', [[180, 'X-'], [183, 'O'], [186, 'XXX']]],
     ['Ade', [[180, 'X-'], [183, 'O'], [186, '-']]]],),
   [[1, 'Eli', 186], [2, 'Cy', 183], [3, 'Ade', 183], [3, 'Fay', 183]]),
  ('variant scenario 1',
   ([['Bo', [[180, '-'], [183, 'O'], [186, 'O']]],
     ['Cy', [[180, 'O'], [183, 'XO'], [186, 'XX-']]],
     ['Dee', [[180, 'XO'], [183, 'X-'], [186, 'X-']]]],),
   [[1, 'Bo', 186], [2, 'Cy', 183], [3, 'Dee', 180]]),
  ('variant scenario 2',
   ([['Bo', [[180, 'X-'], [183, 'O'], [186, '-'], [189, 'XO']]],
     ['Ade', [[180, 'XO'], [183, 'XXO'], [186, 'XXO'], [189, 'O']]]],),
   [[1, 'Ade', 189], [2, 'Bo', 189]])]]
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:
Failures at the height where the athlete went out count in the countback.

High jump placing. records rows are [name, [[height_cm, attempts], ...]] where attempts is a string of X (failure), O (clearance) or "-" (pass). Best height is the highest cleared. Rank by best height descending, then fewest failures at the best height, then fewest total failures at heights up to and including the best; athletes equal on all three share the place (the next place is skipped). Athletes without a clearance come last with place None in name order. Return [place, name, best].

split: open-access