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

N = 1
observations = []
def solve(ev, policy):
    start = ev['arrive']
    wait = ev['board'] - start
    if wait <= policy['grace']:
        return 0
    minutes = -(-(wait - policy['grace']) // 60)
    return min(minutes, policy['cap_min']) * policy['per_min']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10300, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 0),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   280),
  ('second regression',
   [{'arrive': 10000, 'board': 10568, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   210),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10720, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10769, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 35}],
   175),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10181, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 50),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0)],
 [('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10720, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   320),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10180, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 35),
  ('second regression',
   [{'arrive': 10000, 'board': 10180, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 25),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11090, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 200),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10600, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10705, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   400)],
 [('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 70),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('second regression',
   [{'arrive': 10000, 'board': 10421, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 35),
  ('normal control 1',
   [{'arrive': 10000, 'board': 11020, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10121, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 35),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10900, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350)],
 [('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 0),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0),
  ('second regression',
   [{'arrive': 10000, 'board': 10720, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   280),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10996, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10180, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 25),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10800, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125)],
 [('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 50),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10121, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 40),
  ('second regression',
   [{'arrive': 10000, 'board': 10481, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   70),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 200),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11681, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 35}],
   175),
  ('normal control 3',
   [{'arrive': 10000, 'board': 11243, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10060, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(ev, policy):
    start = ev['arrive'] if ev['scheduled'] is None else min(ev['arrive'], ev['scheduled'])
    wait = ev['board'] - start
    if wait <= policy['grace']:
        return 0
    minutes = -(-(wait - policy['grace']) // 60)
    return min(minutes, policy['cap_min']) * policy['per_min']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10300, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 0),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   280),
  ('second regression',
   [{'arrive': 10000, 'board': 10568, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   210),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10720, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10769, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 35}],
   175),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10181, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 50),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0)],
 [('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10720, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   320),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10180, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 35),
  ('second regression',
   [{'arrive': 10000, 'board': 10180, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 25),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11090, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 200),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10600, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10705, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   400)],
 [('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 70),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('second regression',
   [{'arrive': 10000, 'board': 10421, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 35),
  ('normal control 1',
   [{'arrive': 10000, 'board': 11020, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10121, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 35),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10900, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350)],
 [('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 0),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0),
  ('second regression',
   [{'arrive': 10000, 'board': 10720, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   280),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10996, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10180, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 25),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10800, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125)],
 [('regression: scheduled pickup start',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 50),
  ('partial repair probe: scheduled pickup start',
   [{'arrive': 10000, 'board': 10121, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 40),
  ('second regression',
   [{'arrive': 10000, 'board': 10481, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   70),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 200),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11681, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 35}],
   175),
  ('normal control 3',
   [{'arrive': 10000, 'board': 11243, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10060, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A driver arriving five minutes before a scheduled pickup bills the rider for those minutes.

Wait time starts at driver arrival, or at the scheduled pickup time if the ride was scheduled and the driver arrived early. The first grace seconds are free; beyond that each started minute is billed at per_min cents, up to cap_min billed minutes. Return the wait fee in cents.

split: open-access


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

N = 1
observations = []
def solve(ev, policy):
    start = ev['arrive'] if ev['scheduled'] is None else max(ev['arrive'], ev['scheduled'])
    wait = ev['board'] - start
    if wait <= policy['grace']:
        return 0
    minutes = -(-(wait - policy['grace']) // 60)
    return min(minutes * policy['per_min'], policy['cap_min'])
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: cap unit',
   [{'arrive': 10000, 'board': 10121, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 35),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 11563, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('second regression',
   [{'arrive': 10000, 'board': 10480, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 25),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10120, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10300, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10240, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   0)],
 [('regression: cap unit',
   [{'arrive': 10000, 'board': 10701, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   125),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 11200, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   250),
  ('second regression',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 80),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10240, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   0)],
 [('regression: cap unit',
   [{'arrive': 10000, 'board': 10241, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 35),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 11497, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 125),
  ('second regression',
   [{'arrive': 10000, 'board': 10600, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   200),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10000, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10120, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0)],
 [('regression: cap unit',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   320),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('second regression',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   200),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10060, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10420, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0)],
 [('regression: cap unit',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   280),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 200),
  ('second regression',
   [{'arrive': 10000, 'board': 10421, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   40),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10060, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10420, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10300, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10180, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(ev, policy):
    start = ev['arrive'] if ev['scheduled'] is None else max(ev['arrive'], ev['scheduled'])
    wait = ev['board'] - start
    if wait <= policy['grace']:
        return 0
    minutes = -(-(wait - policy['grace']) // 60)
    return min(minutes * policy['per_min'], policy['cap_min'] * 100)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: cap unit',
   [{'arrive': 10000, 'board': 10121, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 35),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 11563, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('second regression',
   [{'arrive': 10000, 'board': 10480, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 25),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10120, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10300, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10240, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   0)],
 [('regression: cap unit',
   [{'arrive': 10000, 'board': 10701, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   125),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 11200, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   250),
  ('second regression',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 80),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10240, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   0)],
 [('regression: cap unit',
   [{'arrive': 10000, 'board': 10241, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 35),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 11497, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 125),
  ('second regression',
   [{'arrive': 10000, 'board': 10600, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   200),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10000, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10360, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10120, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0)],
 [('regression: cap unit',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   320),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('second regression',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   200),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10060, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10420, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0)],
 [('regression: cap unit',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   280),
  ('partial repair probe: cap unit',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 200),
  ('second regression',
   [{'arrive': 10000, 'board': 10421, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   40),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10060, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10420, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10300, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10180, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Every wait fee is capped at a few cents.

Wait time starts at driver arrival, or at the scheduled pickup time if the ride was scheduled and the driver arrived early. The first grace seconds are free; beyond that each started minute is billed at per_min cents, up to cap_min billed minutes. Return the wait fee in cents.

split: open-access


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

N = 1
observations = []
def solve(ev, policy):
    start = ev['arrive'] if ev['scheduled'] is None else max(ev['arrive'], ev['scheduled'])
    wait = ev['board'] - start
    if wait <= policy['grace']:
        return 0
    minutes = -(-wait // 60)
    return min(minutes, policy['cap_min']) * policy['per_min']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grace deduction',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   50),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   200),
  ('second regression',
   [{'arrive': 10000, 'board': 10180, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 25),
  ('normal control 1',
   [{'arrive': 10000, 'board': 11020, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   250),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10600, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}],
   200)],
 [('regression: grace deduction',
   [{'arrive': 10000, 'board': 10181, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 70),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   320),
  ('second regression',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   80),
  ('normal control 1',
   [{'arrive': 10000, 'board': 11483, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11200, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}],
   200),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125)],
 [('regression: grace deduction',
   [{'arrive': 10000, 'board': 10181, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 70),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10480, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   40),
  ('second regression',
   [{'arrive': 10000, 'board': 10180, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 35),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11020, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350),
  ('normal control 3',
   [{'arrive': 10000, 'board': 11200, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}],
   200)],
 [('regression: grace deduction',
   [{'arrive': 10000, 'board': 10121, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 25),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10300, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   40),
  ('second regression',
   [{'arrive': 10000, 'board': 10181, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 50),
  ('normal control 1',
   [{'arrive': 10000, 'board': 11487, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   250),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10000, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10120, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0)],
 [('regression: grace deduction',
   [{'arrive': 10000, 'board': 10121, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 25),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10480, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   25),
  ('second regression',
   [{'arrive': 10000, 'board': 10181, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 50),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11200, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}],
   200),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 0)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(ev, policy):
    start = ev['arrive'] if ev['scheduled'] is None else max(ev['arrive'], ev['scheduled'])
    wait = ev['board'] - start
    if wait <= policy['grace']:
        return 0
    minutes = (wait - policy['grace']) // 60 + 1
    return min(minutes, policy['cap_min']) * policy['per_min']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grace deduction',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   50),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   200),
  ('second regression',
   [{'arrive': 10000, 'board': 10180, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 25),
  ('normal control 1',
   [{'arrive': 10000, 'board': 11020, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   250),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10600, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}],
   200)],
 [('regression: grace deduction',
   [{'arrive': 10000, 'board': 10181, 'scheduled': 9940}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 70),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   320),
  ('second regression',
   [{'arrive': 10000, 'board': 10301, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   80),
  ('normal control 1',
   [{'arrive': 10000, 'board': 11483, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11200, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}],
   200),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125)],
 [('regression: grace deduction',
   [{'arrive': 10000, 'board': 10181, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 70),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10480, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   40),
  ('second regression',
   [{'arrive': 10000, 'board': 10180, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 35),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 25}],
   125),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11020, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350),
  ('normal control 3',
   [{'arrive': 10000, 'board': 11200, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 35}],
   350),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10600, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 40}],
   200)],
 [('regression: grace deduction',
   [{'arrive': 10000, 'board': 10121, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 25),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10300, 'scheduled': 10120}, {'cap_min': 10, 'grace': 120, 'per_min': 40}],
   40),
  ('second regression',
   [{'arrive': 10000, 'board': 10181, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 25}], 50),
  ('normal control 1',
   [{'arrive': 10000, 'board': 11487, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   250),
  ('normal control 2',
   [{'arrive': 10000, 'board': 10000, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10120, 'scheduled': 10120}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 0),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10120, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 35}], 0)],
 [('regression: grace deduction',
   [{'arrive': 10000, 'board': 10121, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 25),
  ('partial repair probe: grace deduction',
   [{'arrive': 10000, 'board': 10480, 'scheduled': 10300}, {'cap_min': 10, 'grace': 120, 'per_min': 25}],
   25),
  ('second regression',
   [{'arrive': 10000, 'board': 10181, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 50),
  ('normal control 1',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 5, 'grace': 120, 'per_min': 25}], 0),
  ('normal control 2',
   [{'arrive': 10000, 'board': 11200, 'scheduled': 10300}, {'cap_min': 5, 'grace': 120, 'per_min': 40}],
   200),
  ('normal control 3',
   [{'arrive': 10000, 'board': 10900, 'scheduled': 9940}, {'cap_min': 5, 'grace': 120, 'per_min': 35}], 175),
  ('normal control 4',
   [{'arrive': 10000, 'board': 10000, 'scheduled': None}, {'cap_min': 10, 'grace': 120, 'per_min': 40}], 0)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A wait one second past the grace is billed for the full wait including the free minutes.

Wait time starts at driver arrival, or at the scheduled pickup time if the ride was scheduled and the driver arrived early. The first grace seconds are free; beyond that each started minute is billed at per_min cents, up to cap_min billed minutes. Return the wait fee in cents.

split: open-access


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

N = 1
observations = []
def solve(ev, policy):
    if ev['arrived_t'] is not None and ev['cancel_t'] >= ev['arrived_t']:
        if ev['cancel_t'] - ev['arrived_t'] >= policy['noshow_wait']:
            return [policy['noshow_fee'], 'no_show']
        return [policy['fee'], 'after_arrival']
    if ev['cancel_t'] - ev['accept_t'] <= policy['free_window']:
        return [0, 'free_window']
    if ev['eta_latest'] - ev['eta_at_accept'] > policy['late_margin']:
        return [0, 'driver_late']
    if ev['cancel_t'] > ev['accept_t'] + ev['eta_at_accept'] + policy['late_margin']:
        return [0, 'driver_late']
    return [policy['fee'], 'late_cancel']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1440,
     'cancel_by': 'driver',
     'cancel_t': 1740,
     'eta_at_accept': 240,
     'eta_latest': 541},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1240,
     'cancel_by': 'driver',
     'cancel_t': 1541,
     'eta_at_accept': 240,
     'eta_latest': 120},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 2200,
     'eta_at_accept': 240,
     'eta_latest': -160},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'rider',
     'cancel_t': 1979,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1121,
     'eta_at_accept': 900,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 2200,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': 1900,
     'cancel_by': 'rider',
     'cancel_t': 2201,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show'])],
 [('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1440,
     'cancel_by': 'driver',
     'cancel_t': 1060,
     'eta_at_accept': 240,
     'eta_latest': 120},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1121,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1781,
     'eta_at_accept': 480,
     'eta_latest': 781},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': 1300,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 300,
     'eta_latest': 900},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 480,
     'eta_latest': 1080},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'rider',
     'cancel_t': 2180,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show'])],
 [('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'driver',
     'cancel_t': 1780,
     'eta_at_accept': 480,
     'eta_latest': 80},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 2100,
     'cancel_by': 'driver',
     'cancel_t': 2401,
     'eta_at_accept': 900,
     'eta_latest': 1201},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1600,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1900,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 900,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1980,
     'eta_at_accept': 480,
     'eta_latest': 80},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 480,
     'eta_latest': 781},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late'])],
 [('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1120,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'driver',
     'cancel_t': 1600,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1120,
     'eta_at_accept': 240,
     'eta_latest': 240},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1240,
     'cancel_by': 'rider',
     'cancel_t': 1340,
     'eta_at_accept': 240,
     'eta_latest': 840},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': 2100,
     'cancel_by': 'rider',
     'cancel_t': 2399,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1780,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 300,
     'eta_latest': 601},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late'])],
 [('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 2100,
     'cancel_by': 'driver',
     'cancel_t': 2200,
     'eta_at_accept': 900,
     'eta_latest': 1200},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1240,
     'cancel_by': 'driver',
     'cancel_t': 1060,
     'eta_at_accept': 240,
     'eta_latest': 541},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1900,
     'eta_at_accept': 240,
     'eta_latest': 541},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 2200,
     'eta_at_accept': 300,
     'eta_latest': 601},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 300,
     'eta_latest': 900},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(ev, policy):
    if ev['cancel_by'] == 'driver' and ev['arrived_t'] is None:
        return [0, 'driver']
    if ev['arrived_t'] is not None and ev['cancel_t'] >= ev['arrived_t']:
        if ev['cancel_t'] - ev['arrived_t'] >= policy['noshow_wait']:
            return [policy['noshow_fee'], 'no_show']
        return [policy['fee'], 'after_arrival']
    if ev['cancel_t'] - ev['accept_t'] <= policy['free_window']:
        return [0, 'free_window']
    if ev['eta_latest'] - ev['eta_at_accept'] > policy['late_margin']:
        return [0, 'driver_late']
    if ev['cancel_t'] > ev['accept_t'] + ev['eta_at_accept'] + policy['late_margin']:
        return [0, 'driver_late']
    return [policy['fee'], 'late_cancel']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1440,
     'cancel_by': 'driver',
     'cancel_t': 1740,
     'eta_at_accept': 240,
     'eta_latest': 541},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1240,
     'cancel_by': 'driver',
     'cancel_t': 1541,
     'eta_at_accept': 240,
     'eta_latest': 120},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 2200,
     'eta_at_accept': 240,
     'eta_latest': -160},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'rider',
     'cancel_t': 1979,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1121,
     'eta_at_accept': 900,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 2200,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': 1900,
     'cancel_by': 'rider',
     'cancel_t': 2201,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show'])],
 [('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1440,
     'cancel_by': 'driver',
     'cancel_t': 1060,
     'eta_at_accept': 240,
     'eta_latest': 120},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1121,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1781,
     'eta_at_accept': 480,
     'eta_latest': 781},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': 1300,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 300,
     'eta_latest': 900},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 480,
     'eta_latest': 1080},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'rider',
     'cancel_t': 2180,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show'])],
 [('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'driver',
     'cancel_t': 1780,
     'eta_at_accept': 480,
     'eta_latest': 80},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 2100,
     'cancel_by': 'driver',
     'cancel_t': 2401,
     'eta_at_accept': 900,
     'eta_latest': 1201},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1600,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1900,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 900,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1980,
     'eta_at_accept': 480,
     'eta_latest': 80},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 480,
     'eta_latest': 781},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late'])],
 [('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1120,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'driver',
     'cancel_t': 1600,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1120,
     'eta_at_accept': 240,
     'eta_latest': 240},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1240,
     'cancel_by': 'rider',
     'cancel_t': 1340,
     'eta_at_accept': 240,
     'eta_latest': 840},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': 2100,
     'cancel_by': 'rider',
     'cancel_t': 2399,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1780,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 300,
     'eta_latest': 601},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late'])],
 [('regression: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 2100,
     'cancel_by': 'driver',
     'cancel_t': 2200,
     'eta_at_accept': 900,
     'eta_latest': 1200},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('partial repair probe: driver-initiated cancel',
   [{'accept_t': 1000,
     'arrived_t': 1240,
     'cancel_by': 'driver',
     'cancel_t': 1060,
     'eta_at_accept': 240,
     'eta_latest': 541},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1900,
     'eta_at_accept': 240,
     'eta_latest': 541},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 2200,
     'eta_at_accept': 300,
     'eta_latest': 601},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 300,
     'eta_latest': 900},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Riders receive cancellation fees for trips the driver cancelled.

Decide a cancellation charge [cents, reason]. Driver cancellations are free. A rider cancelling at or after driver arrival pays the no-show fee if at least noshow_wait seconds passed since arrival, else the regular fee. Before arrival, cancelling within free_window seconds of acceptance is free; it is also free if the ETA grew by more than late_margin since acceptance, or if the driver is more than late_margin past the ETA promised at acceptance; otherwise the regular fee applies.

split: open-access


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

N = 1
observations = []
def solve(ev, policy):
    if ev['cancel_by'] == 'driver':
        return [0, 'driver']
    if ev['arrived_t'] is not None and ev['cancel_t'] >= ev['arrived_t']:
        if ev['cancel_t'] - ev['arrived_t'] >= policy['noshow_wait']:
            return [policy['noshow_fee'], 'no_show']
        return [policy['fee'], 'after_arrival']
    if ev['cancel_t'] - ev['accept_t'] < policy['free_window']:
        return [0, 'free_window']
    if ev['eta_latest'] - ev['eta_at_accept'] > policy['late_margin']:
        return [0, 'driver_late']
    if ev['cancel_t'] > ev['accept_t'] + ev['eta_at_accept'] + policy['late_margin']:
        return [0, 'driver_late']
    return [policy['fee'], 'late_cancel']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': 1900,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 1500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 300,
     'eta_latest': 600},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 480,
     'eta_latest': 360},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1674,
     'eta_at_accept': 240,
     'eta_latest': 540},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1440,
     'cancel_by': 'rider',
     'cancel_t': 1740,
     'eta_at_accept': 240,
     'eta_latest': 240},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show'])],
 [('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 300,
     'eta_latest': 180},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1121,
     'eta_at_accept': 480,
     'eta_latest': 781},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late'])],
 [('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 1200},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 1201},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 240,
     'eta_latest': 240},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1440,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 240,
     'eta_latest': 840},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'driver',
     'cancel_t': 1300,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1500,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 300,
     'eta_latest': 900},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window'])],
 [('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 900},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 480,
     'eta_latest': 1080},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 300,
     'eta_latest': 600},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1500,
     'cancel_by': 'rider',
     'cancel_t': 2301,
     'eta_at_accept': 300,
     'eta_latest': 600},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1900,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver'])],
 [('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 240,
     'eta_latest': 540},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 240,
     'eta_latest': 240},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1500,
     'cancel_by': 'rider',
     'cancel_t': 2200,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1300,
     'eta_at_accept': 300,
     'eta_latest': 600},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1900,
     'eta_at_accept': 240,
     'eta_latest': 541},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(ev, policy):
    if ev['cancel_by'] == 'driver':
        return [0, 'driver']
    if ev['arrived_t'] is not None and ev['cancel_t'] >= ev['arrived_t']:
        if ev['cancel_t'] - ev['arrived_t'] >= policy['noshow_wait']:
            return [policy['noshow_fee'], 'no_show']
        return [policy['fee'], 'after_arrival']
    if ev['cancel_t'] - ev['accept_t'] <= policy['free_window'] and ev['eta_latest'] <= ev['eta_at_accept']:
        return [0, 'free_window']
    if ev['eta_latest'] - ev['eta_at_accept'] > policy['late_margin']:
        return [0, 'driver_late']
    if ev['cancel_t'] > ev['accept_t'] + ev['eta_at_accept'] + policy['late_margin']:
        return [0, 'driver_late']
    return [policy['fee'], 'late_cancel']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': 1900,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 1500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 300,
     'eta_latest': 600},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 480,
     'eta_latest': 360},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1674,
     'eta_at_accept': 240,
     'eta_latest': 540},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1440,
     'cancel_by': 'rider',
     'cancel_t': 1740,
     'eta_at_accept': 240,
     'eta_latest': 240},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show'])],
 [('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 300,
     'eta_latest': 180},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1121,
     'eta_at_accept': 480,
     'eta_latest': 781},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late'])],
 [('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 1200},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 1201},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 240,
     'eta_latest': 240},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1440,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 240,
     'eta_latest': 840},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': 1480,
     'cancel_by': 'driver',
     'cancel_t': 1300,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1500,
     'cancel_by': 'rider',
     'cancel_t': 1600,
     'eta_at_accept': 300,
     'eta_latest': 900},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'after_arrival']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window'])],
 [('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 900},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 480,
     'eta_latest': 1080},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 300,
     'eta_latest': 600},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver_late']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1900,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': 1500,
     'cancel_by': 'rider',
     'cancel_t': 2301,
     'eta_at_accept': 300,
     'eta_latest': 600},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1900,
     'eta_at_accept': 900,
     'eta_latest': 500},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver'])],
 [('regression: free window edge',
   [{'accept_t': 1000,
     'arrived_t': 1680,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 480,
     'eta_latest': 780},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('partial repair probe: free window edge',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1060,
     'eta_at_accept': 240,
     'eta_latest': 540},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('second regression',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1120,
     'eta_at_accept': 240,
     'eta_latest': 240},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'free_window']),
  ('normal control 1',
   [{'accept_t': 1000,
     'arrived_t': 1500,
     'cancel_by': 'rider',
     'cancel_t': 2200,
     'eta_at_accept': 300,
     'eta_latest': 300},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [700, 'no_show']),
  ('normal control 2',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1300,
     'eta_at_accept': 300,
     'eta_latest': 600},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 3',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'driver',
     'cancel_t': 1900,
     'eta_at_accept': 240,
     'eta_latest': 541},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [0, 'driver']),
  ('normal control 4',
   [{'accept_t': 1000,
     'arrived_t': None,
     'cancel_by': 'rider',
     'cancel_t': 1300,
     'eta_at_accept': 480,
     'eta_latest': 480},
    {'fee': 500, 'free_window': 120, 'late_margin': 300, 'noshow_fee': 700, 'noshow_wait': 300}],
   [500, 'late_cancel'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Cancelling exactly two minutes after acceptance incurs the fee.

Decide a cancellation charge [cents, reason]. Driver cancellations are free. A rider cancelling at or after driver arrival pays the no-show fee if at least noshow_wait seconds passed since arrival, else the regular fee. Before arrival, cancelling within free_window seconds of acceptance is free; it is also free if the ETA grew by more than late_margin since acceptance, or if the driver is more than late_margin past the ETA promised at acceptance; otherwise the regular fee applies.

split: open-access