source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(pings, max_acc, max_speed):
    kept = []
    seen = set()
    for p in sorted(pings, key=lambda p: -p[0])[::-1]:
        if p[3] > max_acc:
            continue
        if p[0] in seen:
            continue
        seen.add(p[0])
        kept.append(p)
    total = 0
    anchor = None
    for p in kept:
        if anchor is None:
            anchor = p
            continue
        d = math.isqrt((p[1] - anchor[1]) ** 2 + (p[2] - anchor[2]) ** 2)
        dt = p[0] - anchor[0]
        if d > max_speed * dt:
            continue
        if not (p[4] or anchor[4]):
            total += d
        anchor = p
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: time ordering',
   [[[40, 1100, 58, 20, False], [25, 270, 5, 20, False], [35, 300, 5, 5, True], [10, 90, 20, 20, False],
     [10, 150, 20, 20, False], [35, 700, 38, 20, False], [15, 210, 5, 25, False], [5, 45, 0, 20, True]],
    20, 30],
   180),
  ('partial repair probe: time ordering',
   [[[0, 45, 0, 10, False], [5, 75, 20, 5, False], [5, 75, 5, 5, True], [5, 105, 25, 10, False]], 20, 30],
   36),
  ('second regression',
   [[[5, 60, -15, 60, True], [15, 60, 5, 25, True], [20, 120, -10, 20, False], [20, 150, 10, 20, True],
     [30, 150, -5, 20, False]],
    20, 30],
   30),
  ('normal control 1',
   [[[5, 45, 20, 10, True], [5, 75, 53, 60, False], [15, 135, 73, 5, True], [20, 165, 73, 20, False],
     [30, 565, 106, 5, True]],
    20, 30],
   0),
  ('normal control 2',
   [[[5, 60, -15, 20, False], [10, 60, 5, 5, True], [15, 120, 25, 60, True], [25, 150, 10, 20, False]], 20,
    30],
   0),
  ('normal control 3',
   [[[5, 60, -15, 60, True], [10, 60, 18, 20, True], [10, 460, 38, 60, False], [15, 490, 23, 20, False],
     [20, 535, 8, 25, False], [20, 595, 41, 60, True], [25, 595, 74, 20, False], [35, 640, 74, 20, False]],
    20, 30],
   0),
  ('normal control 4',
   [[[5, 400, 0, 25, True], [10, 445, 33, 60, False], [20, 445, 66, 25, False], [25, 490, 86, 10, False]], 20,
    30],
   0)],
 [('regression: time ordering',
   [[[20, 120, 20, 10, False], [30, 610, 53, 60, False], [20, 165, 20, 60, True], [10, 60, 20, 20, False],
     [35, 670, 38, 20, True], [25, 210, 20, 60, False]],
    20, 30],
   60),
  ('partial repair probe: time ordering',
   [[[10, 400, 0, 5, False], [20, 460, 20, 20, False], [20, 490, 5, 60, True], [20, 490, 25, 5, True],
     [20, 490, 10, 20, False]],
    20, 30],
   63),
  ('second regression',
   [[[15, 505, 38, 10, False], [5, 400, -15, 60, False], [20, 535, 23, 20, False], [10, 460, 18, 5, False]],
    20, 30],
   82),
  ('normal control 1',
   [[[0, 60, 33, 20, False], [0, 90, 18, 20, False], [0, 135, 38, 20, False], [5, 535, 58, 20, False],
     [5, 595, 58, 10, True]],
    20, 30],
   0),
  ('normal control 2',
   [[[5, 400, -15, 10, False], [15, 400, -30, 10, False], [25, 430, -45, 20, False],
     [35, 830, -60, 60, False], [35, 1230, -40, 20, False], [35, 1290, -40, 25, False]],
    20, 30],
   48),
  ('normal control 3',
   [[[5, 0, 20, 60, False], [10, 400, 20, 5, False], [15, 430, 53, 20, False], [15, 430, 38, 60, False]], 20,
    30],
   44),
  ('normal control 4',
   [[[5, 400, 20, 5, True], [15, 400, 20, 5, False], [25, 445, 5, 60, False], [35, 490, 5, 25, False],
     [35, 520, 38, 60, True], [45, 550, 58, 20, False]],
    20, 30],
   154)],
 [('regression: time ordering',
   [[[20, 980, 113, 20, False], [5, 490, 73, 20, False], [20, 980, 113, 60, False], [0, 400, 20, 20, True],
     [5, 430, 53, 20, False], [10, 535, 93, 20, False], [20, 935, 93, 5, False]],
    20, 30],
   49),
  ('partial repair probe: time ordering',
   [[[5, 0, 0, 5, False], [15, 45, 20, 5, False], [20, 45, 5, 10, False], [20, 90, 38, 10, False],
     [25, 490, 38, 20, False]],
    20, 30],
   64),
  ('second regression',
   [[[10, 30, 33, 60, False], [20, 135, 33, 20, False], [15, 75, 33, 60, False], [35, 935, 73, 20, False],
     [35, 980, 106, 20, True], [30, 535, 53, 5, False], [30, 135, 53, 20, False]],
    20, 30],
   0),
  ('normal control 1',
   [[[10, 400, 0, 60, True], [15, 430, 20, 10, False], [15, 830, 40, 20, False], [25, 890, 73, 60, False]],
    20, 30],
   0),
  ('normal control 2',
   [[[10, 400, -15, 5, False], [15, 460, -30, 10, True], [20, 520, 3, 10, True], [25, 550, 23, 20, True],
     [30, 950, 8, 60, False]],
    20, 30],
   0),
  ('normal control 3',
   [[[10, 60, 20, 20, False], [15, 60, 20, 60, False], [25, 460, 5, 60, False], [25, 490, 25, 25, True]], 20,
    30],
   0),
  ('normal control 4',
   [[[10, 400, 0, 25, False], [10, 460, 0, 25, False], [15, 520, -15, 20, False], [15, 520, -15, 5, True]],
    20, 30],
   0)],
 [('regression: time ordering',
   [[[15, 860, 23, 5, True], [25, 1010, 23, 5, False], [20, 965, 23, 20, False], [10, 460, -10, 5, False],
     [20, 905, 23, 5, False], [5, 400, 20, 5, False], [10, 430, 5, 5, True]],
    20, 30],
   67),
  ('partial repair probe: time ordering',
   [[[15, 60, 20, 20, False], [25, 120, 58, 20, False], [25, 90, 25, 20, False], [15, 90, 40, 20, True],
     [40, 165, 28, 60, False], [35, 165, 43, 20, False], [45, 195, 48, 5, False], [10, 0, 20, 20, True]],
    20, 30],
   148),
  ('second regression',
   [[[35, 995, 38, 10, False], [20, 460, 20, 60, True], [35, 950, 53, 20, True], [40, 1055, 23, 20, False],
     [10, 60, 20, 5, False], [25, 490, 20, 10, False], [15, 460, 20, 20, False], [35, 890, 53, 25, False]],
    20, 30],
   430),
  ('normal control 1',
   [[[5, 60, 20, 5, False], [5, 90, 40, 5, False], [10, 150, 60, 60, False], [15, 195, 60, 20, True],
     [25, 225, 93, 20, False], [30, 255, 93, 20, False]],
    20, 30],
   30),
  ('normal control 2',
   [[[10, 445, -15, 20, False], [10, 400, 0, 25, True], [10, 490, -30, 5, False]], 20, 30], 0),
  ('normal control 3',
   [[[10, 400, 20, 20, False], [10, 845, 38, 60, False], [15, 905, 38, 25, False], [10, 800, 20, 20, False],
     [10, 845, 53, 20, True]],
    20, 30],
   0),
  ('normal control 4',
   [[[5, 45, 20, 20, True], [15, 90, 20, 25, False], [20, 490, 53, 10, False], [20, 490, 86, 20, False]], 20,
    30],
   0)],
 [('regression: time ordering',
   [[[45, 1115, 153, 20, False], [15, 90, 20, 25, False], [20, 210, 60, 5, False], [15, 150, 40, 10, False],
     [40, 1055, 133, 10, False], [35, 655, 113, 60, False], [10, 45, 20, 20, False],
     [25, 255, 93, 25, False]],
    20, 30],
   169),
  ('partial repair probe: time ordering',
   [[[40, 980, 3, 25, False], [10, 400, 0, 20, False], [15, 475, 18, 20, False], [10, 430, 33, 5, False],
     [25, 905, 18, 10, True], [15, 875, 18, 20, False], [50, 980, 3, 25, True], [30, 935, 3, 5, False]],
    20, 30],
   77),
  ('second regression',
   [[[10, 60, 53, 60, True], [25, 550, 139, 5, False], [15, 120, 86, 20, False], [5, 60, 33, 20, False],
     [25, 150, 106, 10, True]],
    20, 30],
   80),
  ('normal control 1',
   [[[15, 445, 40, 5, True], [15, 445, 20, 25, False], [15, 475, 25, 20, True], [10, 400, 20, 25, False]], 20,
    30],
   0),
  ('normal control 2',
   [[[5, 45, 33, 20, False], [10, 90, 66, 25, True], [20, 520, 132, 20, False], [15, 120, 99, 10, False]], 20,
    30],
   99),
  ('normal control 3',
   [[[5, 60, -15, 20, False], [5, 90, -15, 60, False], [15, 490, 18, 20, False], [15, 520, 18, 20, False],
     [25, 565, 3, 20, False]],
    20, 30],
   505),
  ('normal control 4',
   [[[5, 400, 0, 20, True], [15, 800, -15, 25, False], [15, 800, 18, 10, False], [25, 845, 51, 5, False]], 20,
    30],
   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:
Out-of-order uploads zigzag the trace and inflate or reject distance.

Billable distance from GPS pings [t seconds, x m, y m, accuracy m, paused]. Sort by time (stable); drop pings with accuracy worse than max_acc; among remaining pings with the same timestamp keep the first. Walk the kept pings with an anchor: segment length is the floored Euclidean distance (isqrt); if it implies a speed above max_speed m/s the ping is discarded and the anchor stays; otherwise the segment is billed unless either endpoint is paused, and the anchor moves. Return total meters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(pings, max_acc, max_speed):
    kept = []
    seen = set()
    for p in sorted(pings, key=lambda p: p[0]):
        if p[0] in seen:
            continue
        seen.add(p[0])
        if p[3] > max_acc:
            continue
        kept.append(p)
    total = 0
    anchor = None
    for p in kept:
        if anchor is None:
            anchor = p
            continue
        d = math.isqrt((p[1] - anchor[1]) ** 2 + (p[2] - anchor[2]) ** 2)
        dt = p[0] - anchor[0]
        if d > max_speed * dt:
            continue
        if not (p[4] or anchor[4]):
            total += d
        anchor = p
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accuracy before dedupe',
   [[[10, 60, -15, 20, False], [20, 120, -30, 5, False], [20, 165, -45, 20, False], [30, 565, -12, 10, False],
     [40, 610, 8, 25, False], [40, 655, 41, 20, False]],
    20, 30],
   600),
  ('partial repair probe: accuracy before dedupe',
   [[[20, 135, 18, 20, False], [10, 60, -15, 60, False], [15, 105, 18, 5, False], [30, 640, 69, 20, False],
     [45, 640, 109, 20, False], [25, 580, 36, 5, False], [40, 640, 89, 10, False], [25, 180, 51, 10, False]],
    20, 30],
   559),
  ('second regression',
   [[[5, 60, 0, 20, False], [10, 120, 20, 25, True], [15, 520, 20, 20, True], [20, 580, 5, 25, False],
     [30, 580, -10, 60, False], [30, 640, -25, 10, False], [40, 670, -5, 60, False]],
    20, 30],
   580),
  ('normal control 1', [[[0, 60, 0, 10, False], [10, 90, -15, 20, True], [10, 490, -15, 10, False]], 20, 30],
   0),
  ('normal control 2',
   [[[5, 400, 0, 10, False], [10, 800, 20, 20, False], [20, 845, 5, 20, False], [30, 1245, 5, 10, False],
     [40, 1305, 5, 5, True], [45, 1350, 25, 60, False], [50, 1380, 25, 20, False]],
    20, 30],
   445),
  ('normal control 3', [[[10, 105, 5, 5, False], [15, 505, 25, 20, False], [5, 45, -15, 20, False]], 20, 30],
   63),
  ('normal control 4',
   [[[20, 60, 40, 20, False], [10, 30, 0, 25, False], [20, 60, 20, 5, False], [25, 460, 40, 60, True],
     [0, 30, 0, 60, False]],
    20, 30],
   0)],
 [('regression: accuracy before dedupe',
   [[[45, 195, 152, 60, True], [10, 75, 53, 60, True], [35, 195, 119, 25, False], [25, 165, 119, 20, False],
     [25, 195, 119, 25, False], [20, 135, 86, 10, False], [10, 45, 33, 20, False]],
    20, 30],
   148),
  ('partial repair probe: accuracy before dedupe',
   [[[25, 610, -25, 10, False], [30, 1040, -40, 10, False], [10, 45, -15, 25, False],
     [25, 120, -30, 60, False], [25, 210, -25, 20, False], [25, 165, -10, 25, False],
     [20, 75, -30, 10, False], [25, 640, -25, 10, True]],
    20, 30],
   0),
  ('second regression',
   [[[40, 150, -9, 5, False], [25, 120, -12, 60, False], [5, 30, -15, 25, True], [35, 150, 6, 20, False],
     [20, 120, -45, 60, False], [30, 120, 21, 10, False], [5, 75, -30, 20, False],
     [15, 120, -45, 10, False]],
    20, 30],
   161),
  ('normal control 1',
   [[[15, 520, 33, 60, False], [25, 550, 33, 60, False], [10, 460, 0, 25, True], [15, 490, 0, 20, True],
     [5, 400, 0, 25, False]],
    20, 30],
   0),
  ('normal control 2',
   [[[5, 400, 0, 20, False], [5, 400, 0, 10, False], [10, 800, -15, 5, True], [15, 845, 5, 10, True]], 20,
    30],
   0),
  ('normal control 3',
   [[[0, 430, 40, 20, False], [15, 860, 80, 10, True], [20, 860, 100, 5, False], [5, 830, 40, 10, True],
     [10, 830, 60, 25, False], [20, 1260, 100, 20, False], [0, 30, 20, 60, False]],
    20, 30],
   0),
  ('normal control 4',
   [[[0, 30, 20, 5, False], [5, 75, 53, 10, False], [15, 135, 53, 20, True], [20, 165, 73, 25, False],
     [30, 210, 93, 60, False]],
    20, 30],
   55)],
 [('regression: accuracy before dedupe',
   [[[10, 430, 53, 25, False], [10, 460, 86, 20, False], [5, 400, 20, 20, False], [10, 460, 53, 25, False]],
    20, 30],
   89),
  ('partial repair probe: accuracy before dedupe',
   [[[5, 445, 20, 5, True], [20, 565, 91, 20, False], [20, 520, 58, 20, False], [10, 475, 38, 20, False],
     [0, 400, 0, 20, False], [5, 475, 5, 60, False], [30, 995, 124, 5, True], [30, 595, 91, 10, False]],
    20, 30],
   104),
  ('second regression',
   [[[10, 400, -15, 5, False], [15, 400, -30, 25, False], [15, 460, 3, 20, False]], 20, 30], 62),
  ('normal control 1',
   [[[15, 135, 33, 20, False], [15, 105, 0, 60, False], [20, 535, 53, 20, False], [25, 980, 38, 5, False],
     [10, 45, 0, 25, False], [20, 580, 38, 20, True]],
    20, 30],
   0),
  ('normal control 2', [[[5, 0, 33, 5, False], [10, 400, 33, 20, False], [15, 430, 66, 60, False]], 20, 30],
   0),
  ('normal control 3', [[[5, 60, 20, 60, False], [15, 105, 53, 20, False], [20, 165, 53, 5, False]], 20, 30],
   60),
  ('normal control 4',
   [[[5, 60, 33, 10, False], [15, 120, 18, 20, False], [25, 120, 3, 60, False], [30, 180, 23, 10, False],
     [40, 180, 43, 60, False], [45, 180, 63, 60, False]],
    20, 30],
   121)],
 [('regression: accuracy before dedupe',
   [[[5, 0, 20, 25, False], [5, 60, 40, 5, False], [10, 120, 25, 5, False]], 20, 30], 61),
  ('partial repair probe: accuracy before dedupe',
   [[[25, 475, -30, 5, False], [45, 1040, 36, 60, False], [15, 445, -30, 25, False], [30, 875, 3, 60, False],
     [45, 1100, 56, 10, True], [45, 980, 36, 20, False], [35, 920, 3, 10, False], [5, 45, -15, 20, False]],
    20, 30],
   430),
  ('second regression',
   [[[15, 490, 23, 20, False], [10, 430, 38, 25, False], [10, 430, 5, 5, False], [5, 400, -15, 20, False],
     [15, 520, 56, 5, False]],
    20, 30],
   98),
  ('normal control 1',
   [[[15, 135, 5, 10, False], [20, 195, 25, 25, False], [10, 105, -15, 60, False], [5, 45, -15, 20, False],
     [0, 45, -15, 25, True]],
    20, 30],
   92),
  ('normal control 2',
   [[[10, 60, 18, 5, False], [5, 60, 33, 60, False], [30, 120, 23, 20, False], [20, 120, 3, 60, False],
     [25, 120, 23, 20, True]],
    20, 30],
   0),
  ('normal control 3',
   [[[0, 30, 0, 20, False], [10, 90, -15, 20, False], [20, 90, -15, 60, False], [25, 135, 18, 20, False],
     [25, 165, 3, 20, False], [25, 195, 36, 25, False], [30, 225, 56, 60, False]],
    20, 30],
   116),
  ('normal control 4',
   [[[0, 30, 20, 25, False], [0, 430, 5, 25, False], [0, 475, -10, 60, True], [0, 475, -25, 5, False],
     [10, 475, -5, 25, True], [15, 505, 15, 60, True], [15, 550, 35, 20, True], [20, 610, 20, 10, True]],
    20, 30],
   0)],
 [('regression: accuracy before dedupe',
   [[[5, 60, 33, 20, False], [10, 90, 99, 25, False], [10, 60, 66, 10, False]], 20, 30], 33),
  ('partial repair probe: accuracy before dedupe',
   [[[20, 800, 40, 5, False], [35, 1290, 93, 20, False], [10, 400, 20, 20, False], [40, 1290, 126, 20, False],
     [20, 845, 40, 10, True], [30, 890, 73, 5, True], [20, 400, 40, 5, False], [5, 400, 20, 5, False]],
    20, 30],
   0),
  ('second regression', [[[10, 0, 20, 5, False], [15, 60, 38, 25, False], [15, 60, 53, 20, False]], 20, 30],
   68),
  ('normal control 1',
   [[[15, 505, -30, 10, True], [20, 905, -45, 60, True], [5, 30, -15, 20, False], [5, 60, -30, 25, False],
     [10, 105, -30, 20, False]],
    20, 30],
   76),
  ('normal control 2',
   [[[10, 45, 20, 25, False], [15, 45, 20, 10, False], [20, 75, 53, 60, False], [25, 75, 86, 10, False],
     [30, 105, 71, 25, False]],
    20, 30],
   72),
  ('normal control 3',
   [[[10, 0, 0, 20, False], [20, 30, -15, 20, False], [25, 430, -30, 25, False], [35, 475, -30, 5, False],
     [35, 875, -10, 10, False]],
    20, 30],
   478),
  ('normal control 4',
   [[[45, 640, 124, 20, False], [30, 550, 71, 60, False], [5, 45, 66, 20, True], [25, 505, 86, 25, False],
     [15, 105, 66, 60, False], [5, 0, 33, 10, False], [40, 580, 91, 20, False], [55, 700, 109, 25, True]],
    20, 30],
   68)]]
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

prompt:
A bad fix sharing a timestamp with a good fix causes both to be dropped.

Billable distance from GPS pings [t seconds, x m, y m, accuracy m, paused]. Sort by time (stable); drop pings with accuracy worse than max_acc; among remaining pings with the same timestamp keep the first. Walk the kept pings with an anchor: segment length is the floored Euclidean distance (isqrt); if it implies a speed above max_speed m/s the ping is discarded and the anchor stays; otherwise the segment is billed unless either endpoint is paused, and the anchor moves. Return total meters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(pings, max_acc, max_speed):
    kept = []
    seen = set()
    for p in sorted(pings, key=lambda p: p[0]):
        if p[3] > max_acc:
            continue
        if p[0] in seen:
            continue
        seen.add(p[0])
        kept.append(p)
    total = 0
    anchor = None
    for p in kept:
        if anchor is None:
            anchor = p
            continue
        d = math.isqrt((p[1] - anchor[1]) ** 2 + (p[2] - anchor[2]) ** 2)
        dt = p[0] - anchor[0]
        if d > max_speed * dt:
            anchor = p
            continue
        if not (p[4] or anchor[4]):
            total += d
        anchor = p
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: teleport anchor',
   [[[5, 60, 0, 25, False], [5, 460, 20, 20, False], [10, 520, 40, 5, False], [20, 920, 40, 20, True],
     [25, 920, 25, 60, True], [30, 965, 25, 20, False], [35, 965, 25, 25, False]],
    20, 30],
   508),
  ('partial repair probe: teleport anchor',
   [[[0, 45, -15, 10, False], [0, 445, -15, 10, False], [5, 505, 18, 20, False], [5, 550, 3, 25, False],
     [10, 595, 23, 20, False], [15, 595, 56, 20, False], [15, 625, 56, 5, False], [20, 670, 89, 20, True]],
    20, 30],
   0),
  ('second regression',
   [[[0, 45, 0, 5, False], [5, 445, 20, 10, False], [10, 490, 20, 5, False], [10, 890, 53, 20, False],
     [15, 1290, 86, 25, False], [20, 1320, 86, 60, False]],
    20, 30],
   0),
  ('normal control 1', [[[5, 0, 33, 60, True], [10, 45, 66, 25, True], [15, 90, 86, 25, False]], 20, 30], 0),
  ('normal control 2',
   [[[5, 30, -15, 25, False], [5, 430, -15, 20, True], [10, 460, -30, 20, False], [15, 460, -45, 60, False],
     [25, 460, -25, 25, False], [25, 860, -40, 20, True], [25, 920, -7, 25, False]],
    20, 30],
   0),
  ('normal control 3',
   [[[5, 0, 0, 25, False], [5, 0, -15, 20, False], [5, 30, 18, 20, False], [10, 90, 38, 20, False],
     [15, 150, 23, 20, False], [15, 210, 56, 5, False]],
    20, 30],
   165),
  ('normal control 4',
   [[[0, 30, 20, 20, False], [10, 90, 53, 5, True], [15, 120, 53, 10, False], [15, 150, 86, 20, False]], 20,
    30],
   0)],
 [('regression: teleport anchor',
   [[[35, 1335, -5, 5, False], [35, 1335, -20, 60, False], [20, 445, 5, 5, False], [30, 1290, 10, 25, True],
     [25, 490, 5, 5, False], [25, 890, -10, 60, False], [15, 400, -15, 10, False], [10, 0, 0, 20, False]],
    20, 30],
   0),
  ('partial repair probe: teleport anchor',
   [[[5, 60, 33, 20, False], [15, 105, 33, 10, False], [20, 505, 53, 25, False], [25, 905, 38, 20, False],
     [30, 935, 23, 60, False], [35, 935, 8, 25, False], [45, 935, -7, 5, False]],
    20, 30],
   875),
  ('second regression',
   [[[10, 30, 33, 5, False], [10, 430, 66, 20, True], [20, 430, 66, 20, False], [30, 430, 99, 10, False],
     [30, 430, 84, 10, True], [40, 830, 84, 5, False], [45, 860, 84, 20, False], [45, 920, 69, 10, True]],
    20, 30],
   835),
  ('normal control 1',
   [[[0, 60, 33, 20, True], [5, 120, 53, 25, True], [15, 165, 38, 60, False], [15, 195, 23, 20, False],
     [25, 195, 8, 5, False], [30, 240, 41, 60, False], [30, 270, 74, 10, False]],
    20, 30],
   114),
  ('normal control 2',
   [[[0, 30, 0, 20, True], [0, 430, 20, 25, False], [5, 830, 5, 5, True], [15, 860, 5, 20, True]], 20, 30],
   0),
  ('normal control 3',
   [[[20, 860, 38, 25, False], [10, 860, 5, 25, False], [10, 460, 5, 60, False], [10, 400, 20, 25, False]],
    20, 30],
   0),
  ('normal control 4', [[[5, 60, 20, 25, False], [10, 105, 53, 10, False], [15, 165, 73, 20, True]], 20, 30],
   0)],
 [('regression: teleport anchor',
   [[[15, 800, 40, 10, False], [5, 400, 20, 20, True], [20, 860, 40, 20, False], [25, 860, 60, 10, False]],
    20, 30],
   0),
  ('partial repair probe: teleport anchor',
   [[[25, 430, 51, 10, False], [25, 830, 71, 25, True], [10, 430, 18, 10, False], [0, 30, -15, 20, False],
     [20, 430, 51, 60, False]],
    20, 30],
   405),
  ('second regression',
   [[[5, 60, 33, 25, True], [15, 90, 18, 25, False], [20, 150, 38, 10, False], [30, 550, 38, 20, False],
     [35, 610, 58, 20, False], [45, 670, 91, 5, False]],
    20, 30],
   522),
  ('normal control 1',
   [[[30, 195, 23, 10, False], [30, 225, 43, 5, True], [30, 150, 38, 60, False], [15, 120, 33, 10, False],
     [25, 120, 18, 10, True], [30, 270, 28, 10, False], [5, 60, 33, 60, False]],
    20, 30],
   0),
  ('normal control 2', [[[15, 430, 5, 60, True], [10, 400, -15, 20, True], [20, 460, 25, 5, True]], 20, 30],
   0),
  ('normal control 3',
   [[[5, 0, 20, 20, True], [15, 0, 5, 20, False], [20, 30, 5, 5, True], [30, 75, 5, 60, False]], 20, 30], 0),
  ('normal control 4',
   [[[5, 90, 53, 10, False], [20, 210, 106, 10, False], [10, 120, 73, 20, False], [0, 45, 33, 60, False],
     [15, 150, 73, 20, False]],
    20, 30],
   134)],
 [('regression: teleport anchor',
   [[[0, 30, 33, 5, False], [5, 430, 66, 20, True], [15, 830, 51, 60, True], [15, 860, 84, 25, False],
     [25, 860, 104, 20, True], [30, 890, 89, 20, False]],
    20, 30],
   861),
  ('partial repair probe: teleport anchor',
   [[[10, 400, 0, 5, False], [15, 800, 33, 20, True], [20, 1200, 53, 10, False], [25, 1600, 38, 60, False],
     [30, 1600, 38, 20, True], [35, 1660, 58, 20, False], [45, 1660, 58, 20, False],
     [50, 1720, 78, 5, False]],
    20, 30],
   0),
  ('second regression',
   [[[5, 800, 25, 60, True], [20, 1200, 43, 5, False], [0, 400, 20, 5, False], [15, 1200, 58, 20, True],
     [25, 1660, 48, 10, False], [5, 800, 5, 5, False], [25, 1600, 28, 5, False], [10, 800, 58, 20, False]],
    20, 30],
   0),
  ('normal control 1',
   [[[10, 60, 0, 5, True], [15, 60, 33, 5, False], [20, 60, 66, 20, False], [25, 60, 86, 25, True],
     [30, 60, 86, 25, True], [35, 90, 119, 25, False]],
    20, 30],
   33),
  ('normal control 2', [[[20, 460, 66, 25, True], [5, 400, 0, 20, True], [15, 460, 33, 20, False]], 20, 30],
   0),
  ('normal control 3', [[[0, 30, 20, 25, False], [5, 430, 5, 20, True], [5, 490, -10, 20, False]], 20, 30],
   0),
  ('normal control 4',
   [[[15, 460, 53, 10, False], [5, 60, 20, 60, True], [20, 505, 106, 60, True], [20, 505, 73, 20, False]], 20,
    30],
   49)],
 [('regression: teleport anchor',
   [[[30, 580, 51, 20, False], [10, 490, 66, 5, False], [10, 90, 33, 10, False], [5, 45, 33, 10, False],
     [20, 550, 66, 20, False]],
    20, 30],
   535),
  ('partial repair probe: teleport anchor',
   [[[10, 60, 20, 10, False], [15, 105, 5, 5, False], [50, 1365, 76, 10, False], [30, 905, 25, 60, False],
     [20, 505, 5, 20, True], [40, 1335, 91, 20, False], [5, 60, 0, 20, False], [30, 935, 58, 25, False]],
    20, 30],
   67),
  ('second regression', [[[5, 0, 20, 20, False], [10, 400, 53, 5, False], [15, 445, 38, 20, False]], 20, 30],
   0),
  ('normal control 1',
   [[[5, 45, 0, 10, True], [15, 75, 33, 25, False], [20, 120, 53, 5, False], [25, 120, 53, 20, False],
     [30, 120, 73, 20, False], [30, 165, 73, 5, False], [35, 165, 106, 20, False]],
    20, 30],
   75),
  ('normal control 2', [[[10, 30, 0, 20, True], [15, 90, 20, 5, False], [20, 135, 40, 20, False]], 20, 30],
   49),
  ('normal control 3',
   [[[35, 210, 119, 20, False], [25, 150, 86, 20, False], [40, 240, 139, 5, False], [15, 90, 86, 20, True],
     [10, 0, 33, 25, False], [45, 270, 172, 20, False], [10, 45, 53, 10, False]],
    20, 30],
   148),
  ('normal control 4',
   [[[35, 165, 86, 5, False], [15, 75, 66, 60, False], [25, 120, 66, 20, False], [30, 165, 66, 25, True],
     [5, 45, 33, 20, True]],
    20, 30],
   49)]]
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
import math
N = 1
observations = []
def solve(pings, max_acc, max_speed):
    kept = []
    seen = set()
    for p in sorted(pings, key=lambda p: p[0]):
        if p[3] > max_acc:
            continue
        if p[0] in seen:
            continue
        seen.add(p[0])
        kept.append(p)
    total = 0
    anchor = None
    for p in kept:
        if anchor is None:
            anchor = p
            continue
        d = math.isqrt((p[1] - anchor[1]) ** 2 + (p[2] - anchor[2]) ** 2)
        dt = p[0] - anchor[0]
        if d > max_speed * dt:
            anchor = None
            continue
        if not (p[4] or anchor[4]):
            total += d
        anchor = p
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: teleport anchor',
   [[[5, 60, 0, 25, False], [5, 460, 20, 20, False], [10, 520, 40, 5, False], [20, 920, 40, 20, True],
     [25, 920, 25, 60, True], [30, 965, 25, 20, False], [35, 965, 25, 25, False]],
    20, 30],
   508),
  ('partial repair probe: teleport anchor',
   [[[0, 45, -15, 10, False], [0, 445, -15, 10, False], [5, 505, 18, 20, False], [5, 550, 3, 25, False],
     [10, 595, 23, 20, False], [15, 595, 56, 20, False], [15, 625, 56, 5, False], [20, 670, 89, 20, True]],
    20, 30],
   0),
  ('second regression',
   [[[0, 45, 0, 5, False], [5, 445, 20, 10, False], [10, 490, 20, 5, False], [10, 890, 53, 20, False],
     [15, 1290, 86, 25, False], [20, 1320, 86, 60, False]],
    20, 30],
   0),
  ('normal control 1', [[[5, 0, 33, 60, True], [10, 45, 66, 25, True], [15, 90, 86, 25, False]], 20, 30], 0),
  ('normal control 2',
   [[[5, 30, -15, 25, False], [5, 430, -15, 20, True], [10, 460, -30, 20, False], [15, 460, -45, 60, False],
     [25, 460, -25, 25, False], [25, 860, -40, 20, True], [25, 920, -7, 25, False]],
    20, 30],
   0),
  ('normal control 3',
   [[[5, 0, 0, 25, False], [5, 0, -15, 20, False], [5, 30, 18, 20, False], [10, 90, 38, 20, False],
     [15, 150, 23, 20, False], [15, 210, 56, 5, False]],
    20, 30],
   165),
  ('normal control 4',
   [[[0, 30, 20, 20, False], [10, 90, 53, 5, True], [15, 120, 53, 10, False], [15, 150, 86, 20, False]], 20,
    30],
   0)],
 [('regression: teleport anchor',
   [[[35, 1335, -5, 5, False], [35, 1335, -20, 60, False], [20, 445, 5, 5, False], [30, 1290, 10, 25, True],
     [25, 490, 5, 5, False], [25, 890, -10, 60, False], [15, 400, -15, 10, False], [10, 0, 0, 20, False]],
    20, 30],
   0),
  ('partial repair probe: teleport anchor',
   [[[5, 60, 33, 20, False], [15, 105, 33, 10, False], [20, 505, 53, 25, False], [25, 905, 38, 20, False],
     [30, 935, 23, 60, False], [35, 935, 8, 25, False], [45, 935, -7, 5, False]],
    20, 30],
   875),
  ('second regression',
   [[[10, 30, 33, 5, False], [10, 430, 66, 20, True], [20, 430, 66, 20, False], [30, 430, 99, 10, False],
     [30, 430, 84, 10, True], [40, 830, 84, 5, False], [45, 860, 84, 20, False], [45, 920, 69, 10, True]],
    20, 30],
   835),
  ('normal control 1',
   [[[0, 60, 33, 20, True], [5, 120, 53, 25, True], [15, 165, 38, 60, False], [15, 195, 23, 20, False],
     [25, 195, 8, 5, False], [30, 240, 41, 60, False], [30, 270, 74, 10, False]],
    20, 30],
   114),
  ('normal control 2',
   [[[0, 30, 0, 20, True], [0, 430, 20, 25, False], [5, 830, 5, 5, True], [15, 860, 5, 20, True]], 20, 30],
   0),
  ('normal control 3',
   [[[20, 860, 38, 25, False], [10, 860, 5, 25, False], [10, 460, 5, 60, False], [10, 400, 20, 25, False]],
    20, 30],
   0),
  ('normal control 4', [[[5, 60, 20, 25, False], [10, 105, 53, 10, False], [15, 165, 73, 20, True]], 20, 30],
   0)],
 [('regression: teleport anchor',
   [[[15, 800, 40, 10, False], [5, 400, 20, 20, True], [20, 860, 40, 20, False], [25, 860, 60, 10, False]],
    20, 30],
   0),
  ('partial repair probe: teleport anchor',
   [[[25, 430, 51, 10, False], [25, 830, 71, 25, True], [10, 430, 18, 10, False], [0, 30, -15, 20, False],
     [20, 430, 51, 60, False]],
    20, 30],
   405),
  ('second regression',
   [[[5, 60, 33, 25, True], [15, 90, 18, 25, False], [20, 150, 38, 10, False], [30, 550, 38, 20, False],
     [35, 610, 58, 20, False], [45, 670, 91, 5, False]],
    20, 30],
   522),
  ('normal control 1',
   [[[30, 195, 23, 10, False], [30, 225, 43, 5, True], [30, 150, 38, 60, False], [15, 120, 33, 10, False],
     [25, 120, 18, 10, True], [30, 270, 28, 10, False], [5, 60, 33, 60, False]],
    20, 30],
   0),
  ('normal control 2', [[[15, 430, 5, 60, True], [10, 400, -15, 20, True], [20, 460, 25, 5, True]], 20, 30],
   0),
  ('normal control 3',
   [[[5, 0, 20, 20, True], [15, 0, 5, 20, False], [20, 30, 5, 5, True], [30, 75, 5, 60, False]], 20, 30], 0),
  ('normal control 4',
   [[[5, 90, 53, 10, False], [20, 210, 106, 10, False], [10, 120, 73, 20, False], [0, 45, 33, 60, False],
     [15, 150, 73, 20, False]],
    20, 30],
   134)],
 [('regression: teleport anchor',
   [[[0, 30, 33, 5, False], [5, 430, 66, 20, True], [15, 830, 51, 60, True], [15, 860, 84, 25, False],
     [25, 860, 104, 20, True], [30, 890, 89, 20, False]],
    20, 30],
   861),
  ('partial repair probe: teleport anchor',
   [[[10, 400, 0, 5, False], [15, 800, 33, 20, True], [20, 1200, 53, 10, False], [25, 1600, 38, 60, False],
     [30, 1600, 38, 20, True], [35, 1660, 58, 20, False], [45, 1660, 58, 20, False],
     [50, 1720, 78, 5, False]],
    20, 30],
   0),
  ('second regression',
   [[[5, 800, 25, 60, True], [20, 1200, 43, 5, False], [0, 400, 20, 5, False], [15, 1200, 58, 20, True],
     [25, 1660, 48, 10, False], [5, 800, 5, 5, False], [25, 1600, 28, 5, False], [10, 800, 58, 20, False]],
    20, 30],
   0),
  ('normal control 1',
   [[[10, 60, 0, 5, True], [15, 60, 33, 5, False], [20, 60, 66, 20, False], [25, 60, 86, 25, True],
     [30, 60, 86, 25, True], [35, 90, 119, 25, False]],
    20, 30],
   33),
  ('normal control 2', [[[20, 460, 66, 25, True], [5, 400, 0, 20, True], [15, 460, 33, 20, False]], 20, 30],
   0),
  ('normal control 3', [[[0, 30, 20, 25, False], [5, 430, 5, 20, True], [5, 490, -10, 20, False]], 20, 30],
   0),
  ('normal control 4',
   [[[15, 460, 53, 10, False], [5, 60, 20, 60, True], [20, 505, 106, 60, True], [20, 505, 73, 20, False]], 20,
    30],
   49)],
 [('regression: teleport anchor',
   [[[30, 580, 51, 20, False], [10, 490, 66, 5, False], [10, 90, 33, 10, False], [5, 45, 33, 10, False],
     [20, 550, 66, 20, False]],
    20, 30],
   535),
  ('partial repair probe: teleport anchor',
   [[[10, 60, 20, 10, False], [15, 105, 5, 5, False], [50, 1365, 76, 10, False], [30, 905, 25, 60, False],
     [20, 505, 5, 20, True], [40, 1335, 91, 20, False], [5, 60, 0, 20, False], [30, 935, 58, 25, False]],
    20, 30],
   67),
  ('second regression', [[[5, 0, 20, 20, False], [10, 400, 53, 5, False], [15, 445, 38, 20, False]], 20, 30],
   0),
  ('normal control 1',
   [[[5, 45, 0, 10, True], [15, 75, 33, 25, False], [20, 120, 53, 5, False], [25, 120, 53, 20, False],
     [30, 120, 73, 20, False], [30, 165, 73, 5, False], [35, 165, 106, 20, False]],
    20, 30],
   75),
  ('normal control 2', [[[10, 30, 0, 20, True], [15, 90, 20, 5, False], [20, 135, 40, 20, False]], 20, 30],
   49),
  ('normal control 3',
   [[[35, 210, 119, 20, False], [25, 150, 86, 20, False], [40, 240, 139, 5, False], [15, 90, 86, 20, True],
     [10, 0, 33, 25, False], [45, 270, 172, 20, False], [10, 45, 53, 10, False]],
    20, 30],
   148),
  ('normal control 4',
   [[[35, 165, 86, 5, False], [15, 75, 66, 60, False], [25, 120, 66, 20, False], [30, 165, 66, 25, True],
     [5, 45, 33, 20, True]],
    20, 30],
   49)]]
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:
After a spurious jump, the next genuine segment is measured from the bogus point.

Billable distance from GPS pings [t seconds, x m, y m, accuracy m, paused]. Sort by time (stable); drop pings with accuracy worse than max_acc; among remaining pings with the same timestamp keep the first. Walk the kept pings with an anchor: segment length is the floored Euclidean distance (isqrt); if it implies a speed above max_speed m/s the ping is discarded and the anchor stays; otherwise the segment is billed unless either endpoint is paused, and the anchor moves. Return total meters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(pings, max_acc, max_speed):
    kept = []
    seen = set()
    for p in sorted(pings, key=lambda p: p[0]):
        if p[3] > max_acc:
            continue
        if p[0] in seen:
            continue
        seen.add(p[0])
        kept.append(p)
    total = 0
    anchor = None
    for p in kept:
        if anchor is None:
            anchor = p
            continue
        d = math.isqrt((p[1] - anchor[1]) ** 2 + (p[2] - anchor[2]) ** 2)
        dt = p[0] - anchor[0]
        if d > max_speed * dt:
            continue
        if not p[4]:
            total += d
        anchor = p
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: paused endpoints',
   [[[0, 30, -15, 20, True], [0, 30, -30, 60, False], [0, 30, -45, 25, False], [0, 90, -45, 20, False],
     [5, 120, -60, 10, False], [15, 520, -40, 20, False], [20, 550, -40, 20, True],
     [30, 610, -55, 20, False]],
    20, 30],
   0),
  ('partial repair probe: paused endpoints',
   [[[20, 505, 3, 5, False], [40, 550, 76, 20, True], [30, 550, 23, 25, False], [35, 550, 43, 5, False],
     [35, 550, 23, 20, False], [10, 45, -15, 20, False], [15, 105, -30, 20, False]],
    20, 30],
   511),
  ('second regression',
   [[[10, 60, 20, 10, False], [10, 90, 53, 20, False], [15, 135, 53, 25, False], [15, 135, 53, 5, False],
     [25, 165, 53, 20, True]],
    20, 30],
   81),
  ('normal control 1',
   [[[5, 120, 60, 20, False], [5, 520, 80, 5, False], [15, 565, 80, 25, False], [5, 120, 40, 20, False],
     [5, 60, 20, 20, False]],
    20, 30],
   0),
  ('normal control 2',
   [[[15, 860, 36, 10, False], [5, 800, 3, 5, False], [5, 800, -30, 25, False], [0, 400, -15, 60, False]], 20,
    30],
   68),
  ('normal control 3', [[[10, 45, 33, 20, False], [15, 90, 33, 5, False], [15, 120, 66, 5, False]], 20, 30],
   45),
  ('normal control 4',
   [[[5, 60, 33, 60, False], [15, 460, 33, 60, False], [15, 860, 66, 25, False], [20, 905, 66, 25, False],
     [20, 1305, 86, 10, True]],
    20, 30],
   0)],
 [('regression: paused endpoints',
   [[[10, 45, 20, 20, True], [15, 90, 20, 60, False], [15, 120, 53, 5, False], [20, 520, 38, 5, False]], 20,
    30],
   0),
  ('partial repair probe: paused endpoints',
   [[[0, 60, -15, 5, False], [0, 105, 18, 10, False], [5, 505, 38, 20, False], [15, 505, 38, 20, False],
     [25, 505, 58, 20, True]],
    20, 30],
   448),
  ('second regression',
   [[[10, 30, 0, 60, True], [10, 75, 20, 10, False], [5, 30, 0, 25, False], [15, 135, 53, 20, True]], 20, 30],
   0),
  ('normal control 1',
   [[[5, 430, -30, 10, False], [5, 460, -30, 5, False], [10, 505, 3, 5, False], [5, 30, -15, 25, False]], 20,
    30],
   81),
  ('normal control 2',
   [[[0, 45, 0, 25, False], [0, 75, 20, 60, False], [0, 475, 40, 5, False], [0, 875, 73, 20, False],
     [10, 935, 58, 5, False], [15, 965, 91, 60, True], [20, 995, 76, 10, False], [30, 1040, 76, 5, False]],
    20, 30],
   566),
  ('normal control 3',
   [[[5, 30, 0, 25, True], [10, 90, -15, 20, True], [15, 490, -30, 5, True], [25, 490, -30, 20, True]], 20,
    30],
   0),
  ('normal control 4',
   [[[5, 30, -15, 10, False], [10, 90, 5, 25, False], [15, 490, -10, 20, False], [20, 490, -25, 20, False],
     [25, 550, -5, 25, False], [30, 595, 15, 60, False], [40, 655, 15, 5, False], [45, 685, 48, 20, False]],
    20, 30],
   669)],
 [('regression: paused endpoints',
   [[[10, 520, 33, 20, True], [25, 580, 33, 20, False], [15, 550, 33, 60, False], [30, 640, 66, 10, True],
     [30, 685, 86, 5, False], [10, 120, 33, 25, False], [5, 60, 33, 5, True]],
    20, 30],
   0),
  ('partial repair probe: paused endpoints',
   [[[5, 150, 38, 10, False], [5, 60, 20, 10, False], [5, 90, 5, 20, False], [10, 195, 23, 20, False],
     [20, 625, 28, 25, False], [15, 225, 8, 20, True]],
    20, 30],
   47),
  ('second regression',
   [[[35, 135, 71, 20, False], [10, 30, 33, 25, False], [15, 30, 66, 5, True], [35, 165, 91, 20, True],
     [25, 90, 51, 25, False], [40, 195, 111, 10, False]],
    20, 30],
   72),
  ('normal control 1',
   [[[0, 60, -15, 25, False], [0, 460, 5, 20, False], [5, 860, -10, 60, False], [15, 1260, 23, 20, False],
     [20, 1305, 43, 25, True], [25, 1350, 43, 60, False], [25, 1380, 63, 60, False],
     [30, 1780, 48, 5, False]],
    20, 30],
   0),
  ('normal control 2', [[[10, 45, 33, 10, False], [10, 105, 33, 60, True], [15, 150, 66, 20, False]], 20, 30],
   110),
  ('normal control 3', [[[5, 0, -15, 20, False], [15, 60, -30, 5, False], [25, 105, -30, 25, False]], 20, 30],
   61),
  ('normal control 4',
   [[[0, 30, 33, 20, False], [25, 610, 119, 20, False], [20, 550, 119, 20, False], [30, 640, 139, 20, False],
     [10, 90, 66, 10, False], [20, 490, 86, 5, True]],
    20, 30],
   622)],
 [('regression: paused endpoints',
   [[[0, 45, -15, 20, True], [5, 90, -15, 60, True], [15, 150, 18, 20, False], [25, 180, 18, 5, True]], 20,
    30],
   0),
  ('partial repair probe: paused endpoints',
   [[[5, 45, 0, 25, False], [10, 90, 20, 60, True], [20, 135, 5, 10, False], [20, 135, 25, 25, False],
     [25, 135, 45, 60, False], [30, 180, 45, 20, True], [35, 225, 45, 5, False]],
    20, 30],
   0),
  ('second regression',
   [[[10, 400, 3, 20, True], [25, 505, 8, 20, False], [20, 460, 23, 20, False], [35, 565, 28, 5, False],
     [0, 400, 33, 20, False], [5, 400, 18, 25, True], [40, 965, 48, 20, False], [45, 1365, 68, 60, False]],
    20, 30],
   110),
  ('normal control 1', [[[5, 30, 20, 60, False], [5, 430, 53, 25, False], [10, 830, 38, 5, True]], 20, 30],
   0),
  ('normal control 2', [[[10, 0, 0, 60, False], [10, 45, 0, 20, False], [10, 90, 33, 20, True]], 20, 30], 0),
  ('normal control 3',
   [[[10, 45, 33, 60, False], [15, 445, 33, 60, False], [25, 490, 18, 20, False], [30, 520, 18, 60, True],
     [40, 565, 3, 25, True], [45, 595, 36, 10, False], [50, 595, 21, 20, False], [55, 655, 54, 20, False]],
    20, 30],
   189),
  ('normal control 4',
   [[[10, 90, 53, 60, True], [5, 60, 20, 20, False], [35, 950, 113, 20, True], [30, 890, 73, 60, False],
     [35, 920, 93, 5, False], [20, 490, 53, 20, False]],
    20, 30],
   431)],
 [('regression: paused endpoints',
   [[[45, 965, 139, 5, False], [5, 400, 0, 10, True], [15, 430, 33, 10, True], [60, 1040, 172, 5, False],
     [45, 920, 106, 5, False], [50, 995, 172, 20, False], [25, 490, 53, 5, False], [35, 890, 73, 5, False]],
    20, 30],
   571),
  ('partial repair probe: paused endpoints',
   [[[20, 105, 33, 20, True], [10, 75, 0, 20, False], [5, 45, 0, 10, False], [25, 150, 53, 10, False]], 20,
    30],
   30),
  ('second regression',
   [[[25, 475, 73, 60, False], [5, 0, 0, 5, False], [15, 400, 33, 10, False], [35, 520, 93, 60, False],
     [20, 445, 53, 10, True]],
    20, 30],
   0),
  ('normal control 1',
   [[[20, 830, 53, 60, False], [15, 800, 53, 5, False], [10, 400, 20, 10, False], [30, 890, 119, 5, False],
     [25, 860, 86, 60, False], [15, 400, 53, 20, True]],
    20, 30],
   499),
  ('normal control 2',
   [[[20, 90, 86, 5, False], [10, 30, 33, 25, False], [30, 890, 71, 10, False], [15, 60, 66, 20, False],
     [30, 490, 71, 60, False]],
    20, 30],
   36),
  ('normal control 3',
   [[[5, 30, -15, 25, False], [10, 90, -15, 25, False], [15, 120, 18, 25, True], [25, 520, 3, 20, True],
     [30, 580, 36, 60, False], [35, 980, 69, 5, False], [35, 1040, 102, 60, False]],
    20, 30],
   0),
  ('normal control 4', [[[5, 45, 33, 20, False], [20, 165, 33, 60, False], [10, 105, 33, 20, False]], 20, 30],
   60)]]
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
import math
N = 1
observations = []
def solve(pings, max_acc, max_speed):
    kept = []
    seen = set()
    for p in sorted(pings, key=lambda p: p[0]):
        if p[3] > max_acc:
            continue
        if p[0] in seen:
            continue
        seen.add(p[0])
        kept.append(p)
    total = 0
    anchor = None
    for p in kept:
        if anchor is None:
            anchor = p
            continue
        d = math.isqrt((p[1] - anchor[1]) ** 2 + (p[2] - anchor[2]) ** 2)
        dt = p[0] - anchor[0]
        if d > max_speed * dt:
            continue
        if not anchor[4]:
            total += d
        anchor = p
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: paused endpoints',
   [[[0, 30, -15, 20, True], [0, 30, -30, 60, False], [0, 30, -45, 25, False], [0, 90, -45, 20, False],
     [5, 120, -60, 10, False], [15, 520, -40, 20, False], [20, 550, -40, 20, True],
     [30, 610, -55, 20, False]],
    20, 30],
   0),
  ('partial repair probe: paused endpoints',
   [[[20, 505, 3, 5, False], [40, 550, 76, 20, True], [30, 550, 23, 25, False], [35, 550, 43, 5, False],
     [35, 550, 23, 20, False], [10, 45, -15, 20, False], [15, 105, -30, 20, False]],
    20, 30],
   511),
  ('second regression',
   [[[10, 60, 20, 10, False], [10, 90, 53, 20, False], [15, 135, 53, 25, False], [15, 135, 53, 5, False],
     [25, 165, 53, 20, True]],
    20, 30],
   81),
  ('normal control 1',
   [[[5, 120, 60, 20, False], [5, 520, 80, 5, False], [15, 565, 80, 25, False], [5, 120, 40, 20, False],
     [5, 60, 20, 20, False]],
    20, 30],
   0),
  ('normal control 2',
   [[[15, 860, 36, 10, False], [5, 800, 3, 5, False], [5, 800, -30, 25, False], [0, 400, -15, 60, False]], 20,
    30],
   68),
  ('normal control 3', [[[10, 45, 33, 20, False], [15, 90, 33, 5, False], [15, 120, 66, 5, False]], 20, 30],
   45),
  ('normal control 4',
   [[[5, 60, 33, 60, False], [15, 460, 33, 60, False], [15, 860, 66, 25, False], [20, 905, 66, 25, False],
     [20, 1305, 86, 10, True]],
    20, 30],
   0)],
 [('regression: paused endpoints',
   [[[10, 45, 20, 20, True], [15, 90, 20, 60, False], [15, 120, 53, 5, False], [20, 520, 38, 5, False]], 20,
    30],
   0),
  ('partial repair probe: paused endpoints',
   [[[0, 60, -15, 5, False], [0, 105, 18, 10, False], [5, 505, 38, 20, False], [15, 505, 38, 20, False],
     [25, 505, 58, 20, True]],
    20, 30],
   448),
  ('second regression',
   [[[10, 30, 0, 60, True], [10, 75, 20, 10, False], [5, 30, 0, 25, False], [15, 135, 53, 20, True]], 20, 30],
   0),
  ('normal control 1',
   [[[5, 430, -30, 10, False], [5, 460, -30, 5, False], [10, 505, 3, 5, False], [5, 30, -15, 25, False]], 20,
    30],
   81),
  ('normal control 2',
   [[[0, 45, 0, 25, False], [0, 75, 20, 60, False], [0, 475, 40, 5, False], [0, 875, 73, 20, False],
     [10, 935, 58, 5, False], [15, 965, 91, 60, True], [20, 995, 76, 10, False], [30, 1040, 76, 5, False]],
    20, 30],
   566),
  ('normal control 3',
   [[[5, 30, 0, 25, True], [10, 90, -15, 20, True], [15, 490, -30, 5, True], [25, 490, -30, 20, True]], 20,
    30],
   0),
  ('normal control 4',
   [[[5, 30, -15, 10, False], [10, 90, 5, 25, False], [15, 490, -10, 20, False], [20, 490, -25, 20, False],
     [25, 550, -5, 25, False], [30, 595, 15, 60, False], [40, 655, 15, 5, False], [45, 685, 48, 20, False]],
    20, 30],
   669)],
 [('regression: paused endpoints',
   [[[10, 520, 33, 20, True], [25, 580, 33, 20, False], [15, 550, 33, 60, False], [30, 640, 66, 10, True],
     [30, 685, 86, 5, False], [10, 120, 33, 25, False], [5, 60, 33, 5, True]],
    20, 30],
   0),
  ('partial repair probe: paused endpoints',
   [[[5, 150, 38, 10, False], [5, 60, 20, 10, False], [5, 90, 5, 20, False], [10, 195, 23, 20, False],
     [20, 625, 28, 25, False], [15, 225, 8, 20, True]],
    20, 30],
   47),
  ('second regression',
   [[[35, 135, 71, 20, False], [10, 30, 33, 25, False], [15, 30, 66, 5, True], [35, 165, 91, 20, True],
     [25, 90, 51, 25, False], [40, 195, 111, 10, False]],
    20, 30],
   72),
  ('normal control 1',
   [[[0, 60, -15, 25, False], [0, 460, 5, 20, False], [5, 860, -10, 60, False], [15, 1260, 23, 20, False],
     [20, 1305, 43, 25, True], [25, 1350, 43, 60, False], [25, 1380, 63, 60, False],
     [30, 1780, 48, 5, False]],
    20, 30],
   0),
  ('normal control 2', [[[10, 45, 33, 10, False], [10, 105, 33, 60, True], [15, 150, 66, 20, False]], 20, 30],
   110),
  ('normal control 3', [[[5, 0, -15, 20, False], [15, 60, -30, 5, False], [25, 105, -30, 25, False]], 20, 30],
   61),
  ('normal control 4',
   [[[0, 30, 33, 20, False], [25, 610, 119, 20, False], [20, 550, 119, 20, False], [30, 640, 139, 20, False],
     [10, 90, 66, 10, False], [20, 490, 86, 5, True]],
    20, 30],
   622)],
 [('regression: paused endpoints',
   [[[0, 45, -15, 20, True], [5, 90, -15, 60, True], [15, 150, 18, 20, False], [25, 180, 18, 5, True]], 20,
    30],
   0),
  ('partial repair probe: paused endpoints',
   [[[5, 45, 0, 25, False], [10, 90, 20, 60, True], [20, 135, 5, 10, False], [20, 135, 25, 25, False],
     [25, 135, 45, 60, False], [30, 180, 45, 20, True], [35, 225, 45, 5, False]],
    20, 30],
   0),
  ('second regression',
   [[[10, 400, 3, 20, True], [25, 505, 8, 20, False], [20, 460, 23, 20, False], [35, 565, 28, 5, False],
     [0, 400, 33, 20, False], [5, 400, 18, 25, True], [40, 965, 48, 20, False], [45, 1365, 68, 60, False]],
    20, 30],
   110),
  ('normal control 1', [[[5, 30, 20, 60, False], [5, 430, 53, 25, False], [10, 830, 38, 5, True]], 20, 30],
   0),
  ('normal control 2', [[[10, 0, 0, 60, False], [10, 45, 0, 20, False], [10, 90, 33, 20, True]], 20, 30], 0),
  ('normal control 3',
   [[[10, 45, 33, 60, False], [15, 445, 33, 60, False], [25, 490, 18, 20, False], [30, 520, 18, 60, True],
     [40, 565, 3, 25, True], [45, 595, 36, 10, False], [50, 595, 21, 20, False], [55, 655, 54, 20, False]],
    20, 30],
   189),
  ('normal control 4',
   [[[10, 90, 53, 60, True], [5, 60, 20, 20, False], [35, 950, 113, 20, True], [30, 890, 73, 60, False],
     [35, 920, 93, 5, False], [20, 490, 53, 20, False]],
    20, 30],
   431)],
 [('regression: paused endpoints',
   [[[45, 965, 139, 5, False], [5, 400, 0, 10, True], [15, 430, 33, 10, True], [60, 1040, 172, 5, False],
     [45, 920, 106, 5, False], [50, 995, 172, 20, False], [25, 490, 53, 5, False], [35, 890, 73, 5, False]],
    20, 30],
   571),
  ('partial repair probe: paused endpoints',
   [[[20, 105, 33, 20, True], [10, 75, 0, 20, False], [5, 45, 0, 10, False], [25, 150, 53, 10, False]], 20,
    30],
   30),
  ('second regression',
   [[[25, 475, 73, 60, False], [5, 0, 0, 5, False], [15, 400, 33, 10, False], [35, 520, 93, 60, False],
     [20, 445, 53, 10, True]],
    20, 30],
   0),
  ('normal control 1',
   [[[20, 830, 53, 60, False], [15, 800, 53, 5, False], [10, 400, 20, 10, False], [30, 890, 119, 5, False],
     [25, 860, 86, 60, False], [15, 400, 53, 20, True]],
    20, 30],
   499),
  ('normal control 2',
   [[[20, 90, 86, 5, False], [10, 30, 33, 25, False], [30, 890, 71, 10, False], [15, 60, 66, 20, False],
     [30, 490, 71, 60, False]],
    20, 30],
   36),
  ('normal control 3',
   [[[5, 30, -15, 25, False], [10, 90, -15, 25, False], [15, 120, 18, 25, True], [25, 520, 3, 20, True],
     [30, 580, 36, 60, False], [35, 980, 69, 5, False], [35, 1040, 102, 60, False]],
    20, 30],
   0),
  ('normal control 4', [[[5, 45, 33, 20, False], [20, 165, 33, 60, False], [10, 105, 33, 20, False]], 20, 30],
   60)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The first segment after resuming a paused trip is charged.

Billable distance from GPS pings [t seconds, x m, y m, accuracy m, paused]. Sort by time (stable); drop pings with accuracy worse than max_acc; among remaining pings with the same timestamp keep the first. Walk the kept pings with an anchor: segment length is the floored Euclidean distance (isqrt); if it implies a speed above max_speed m/s the ping is discarded and the anchor stays; otherwise the segment is billed unless either endpoint is paused, and the anchor moves. Return total meters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(pings, max_acc, max_speed):
    kept = []
    seen = set()
    for p in sorted(pings, key=lambda p: p[0]):
        if p[3] > max_acc:
            continue
        if p[0] in seen:
            continue
        seen.add(p[0])
        kept.append(p)
    total = 0
    anchor = None
    for p in kept:
        if anchor is None:
            anchor = p
            continue
        d = math.hypot(p[1] - anchor[1], p[2] - anchor[2])
        dt = p[0] - anchor[0]
        if d > max_speed * dt:
            continue
        if not (p[4] or anchor[4]):
            total += d
        anchor = p
    return int(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: segment floor',
   [[[20, 475, 38, 5, False], [5, 75, 53, 5, False], [30, 505, 71, 5, False], [10, 475, 53, 20, True],
     [40, 610, 76, 5, False], [35, 565, 56, 10, False], [5, 45, 20, 60, False]],
    20, 30],
   554),
  ('partial repair probe: segment floor',
   [[[5, 45, 33, 10, False], [10, 90, 66, 10, False], [10, 135, 86, 20, False], [15, 535, 71, 25, False],
     [20, 535, 104, 20, False]],
    20, 30],
   55),
  ('second regression',
   [[[20, 520, 38, 20, True], [5, 30, -15, 5, False], [30, 965, 104, 5, False], [15, 490, 38, 25, False],
     [5, 90, 18, 5, False], [0, 0, -15, 20, False], [25, 565, 71, 5, False]],
    20, 30],
   571),
  ('normal control 1',
   [[[30, 980, 83, 5, False], [25, 520, 43, 10, True], [15, 60, 38, 10, True], [5, 60, 18, 25, False],
     [25, 490, 58, 5, False], [20, 90, 38, 20, False], [5, 60, 33, 25, False], [25, 580, 63, 20, True]],
    20, 30],
   0),
  ('normal control 2',
   [[[25, 550, 43, 20, True], [5, 460, 40, 20, False], [20, 550, 58, 20, False], [35, 655, 48, 60, False],
     [10, 520, 73, 60, False], [0, 60, 20, 10, True], [25, 595, 28, 20, False], [40, 700, 68, 60, False]],
    20, 30],
   0),
  ('normal control 3',
   [[[30, 520, 53, 20, True], [20, 120, 53, 25, False], [40, 1025, 78, 25, False], [35, 625, 58, 25, False],
     [10, 45, 33, 20, False], [35, 580, 38, 20, False], [15, 75, 33, 25, False]],
    20, 30],
   0),
  ('normal control 4',
   [[[0, 400, 33, 25, False], [10, 445, 66, 20, False], [15, 845, 99, 10, False], [20, 875, 132, 20, True],
     [25, 875, 117, 20, False]],
    20, 30],
   433)],
 [('regression: segment floor',
   [[[10, 45, 33, 20, False], [10, 90, 18, 60, True], [15, 135, 38, 60, False], [15, 180, 38, 60, False],
     [20, 180, 23, 20, False], [25, 225, 56, 20, False], [30, 225, 41, 20, True]],
    20, 30],
   190),
  ('partial repair probe: segment floor',
   [[[5, 30, 33, 10, False], [10, 30, 33, 25, False], [15, 90, 18, 10, False]], 20, 30], 61),
  ('second regression',
   [[[40, 1365, 21, 25, False], [35, 1335, 36, 20, False], [30, 1230, 3, 25, False],
     [15, 800, -15, 60, False], [45, 1425, 54, 10, False], [20, 830, 18, 25, False], [10, 400, 0, 60, False],
     [35, 1275, 3, 20, False]],
    20, 30],
   91),
  ('normal control 1', [[[10, 400, 20, 5, False], [15, 800, 5, 60, False], [5, 0, 20, 10, True]], 20, 30], 0),
  ('normal control 2',
   [[[0, 45, -15, 10, False], [30, 1010, 177, 20, False], [0, 90, 38, 20, False], [15, 210, 111, 20, False],
     [0, 45, 5, 25, False], [10, 150, 91, 20, True], [5, 120, 71, 20, False], [25, 610, 144, 20, False]],
    20, 30],
   114),
  ('normal control 3',
   [[[30, 460, 18, 60, False], [20, 400, 18, 10, False], [10, 400, -15, 20, False], [40, 1260, 36, 25, False],
     [35, 860, 51, 60, True], [50, 1260, 36, 20, False]],
    20, 30],
   893),
  ('normal control 4', [[[0, 400, 0, 20, True], [5, 800, 33, 20, True], [5, 830, 33, 5, False]], 20, 30], 0)],
 [('regression: segment floor',
   [[[5, 75, 66, 60, True], [25, 180, 69, 20, False], [35, 285, 89, 10, False], [30, 240, 69, 25, True],
     [10, 135, 51, 60, True], [0, 45, 33, 20, False], [45, 315, 122, 60, False], [20, 135, 84, 5, False]],
    20, 30],
   256),
  ('partial repair probe: segment floor',
   [[[30, 460, 23, 20, False], [10, 30, 18, 10, False], [25, 460, 23, 25, False], [15, 60, 3, 60, False],
     [5, 0, 33, 10, False]],
    20, 30],
   463),
  ('second regression',
   [[[5, 0, 33, 20, False], [5, 30, 53, 60, True], [5, 60, 38, 20, False], [10, 105, 71, 5, False],
     [15, 105, 104, 20, False], [20, 505, 137, 20, False]],
    20, 30],
   144),
  ('normal control 1',
   [[[25, 75, 60, 25, False], [25, 75, 40, 20, False], [10, 45, 20, 10, False], [20, 45, 40, 20, True]], 20,
    30],
   0),
  ('normal control 2',
   [[[20, 30, 20, 20, True], [25, 30, 53, 20, False], [10, 30, 20, 10, False], [35, 75, 73, 25, False]], 20,
    30],
   0),
  ('normal control 3',
   [[[30, 625, 139, 10, False], [0, 0, 20, 10, False], [25, 565, 106, 5, False], [10, 105, 53, 20, False],
     [5, 45, 20, 20, False], [15, 505, 53, 10, False], [20, 565, 73, 5, False]],
    20, 30],
   640),
  ('normal control 4',
   [[[5, 400, 33, 20, True], [15, 445, 18, 60, False], [15, 445, 3, 5, False], [25, 445, 23, 25, False],
     [35, 490, 23, 20, False]],
    20, 30],
   49)],
 [('regression: segment floor',
   [[[5, 460, 38, 20, False], [20, 520, 56, 10, False], [5, 60, 53, 20, False], [10, 490, 23, 10, False],
     [5, 0, 33, 5, True], [35, 565, 89, 20, False], [25, 565, 56, 20, False]],
    20, 30],
   155),
  ('partial repair probe: segment floor',
   [[[0, 30, 20, 10, False], [5, 75, 53, 20, False], [10, 75, 38, 20, False], [15, 105, 58, 20, False]], 20,
    30],
   106),
  ('second regression', [[[10, 45, 0, 20, False], [15, 75, -15, 5, False], [15, 75, 5, 60, False]], 20, 30],
   33),
  ('normal control 1',
   [[[10, 60, -15, 60, False], [15, 105, -15, 20, False], [20, 105, 18, 20, True], [20, 105, 18, 25, False],
     [25, 505, 38, 10, False]],
    20, 30],
   0),
  ('normal control 2',
   [[[5, 400, 33, 25, False], [15, 800, 53, 60, False], [20, 1200, 86, 25, False]], 20, 30], 0),
  ('normal control 3', [[[10, 430, 53, 20, True], [15, 475, 38, 25, False], [0, 30, 33, 20, False]], 20, 30],
   0),
  ('normal control 4',
   [[[5, 60, -15, 25, False], [15, 105, -30, 20, False], [15, 150, 3, 20, False], [20, 550, 23, 10, False],
     [25, 580, 23, 10, False], [35, 610, 56, 20, False]],
    20, 30],
   512)],
 [('regression: segment floor',
   [[[5, 0, 20, 20, False], [15, 45, 53, 20, False], [20, 105, 86, 10, False], [20, 135, 71, 10, False],
     [20, 180, 71, 10, False]],
    20, 30],
   123),
  ('partial repair probe: segment floor',
   [[[5, 45, 18, 25, False], [5, 0, -15, 5, False], [10, 45, 18, 5, False]], 20, 30], 55),
  ('second regression',
   [[[25, 550, 99, 10, False], [40, 995, 84, 20, False], [10, 105, 33, 10, False], [10, 45, 33, 25, False],
     [30, 950, 99, 25, False], [5, 0, 0, 10, False], [15, 150, 66, 20, False], [40, 1040, 69, 10, True]],
    20, 30],
   165),
  ('normal control 1',
   [[[35, 595, 99, 20, False], [5, 400, 0, 25, True], [40, 700, 139, 5, False], [15, 430, 33, 10, False],
     [30, 535, 99, 10, False], [25, 535, 99, 60, False], [35, 640, 119, 20, False], [20, 490, 66, 25, True]],
    20, 30],
   296),
  ('normal control 2',
   [[[20, 535, 89, 5, False], [10, 445, 23, 25, False], [30, 535, 89, 5, True], [15, 505, 56, 5, True],
     [0, 0, -15, 20, False], [5, 445, 3, 10, True], [0, 45, -30, 20, True], [35, 595, 89, 20, False]],
    20, 30],
   545),
  ('normal control 3',
   [[[30, 550, 25, 10, False], [20, 460, 20, 60, False], [25, 505, 40, 5, True], [10, 400, 0, 20, False]], 20,
    30],
   0),
  ('normal control 4',
   [[[0, 30, 33, 25, True], [10, 90, 33, 25, False], [20, 90, 18, 60, False], [25, 135, 18, 25, False],
     [30, 165, 38, 60, True], [40, 210, 38, 20, True]],
    20, 30],
   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
import math
N = 1
observations = []
def solve(pings, max_acc, max_speed):
    kept = []
    seen = set()
    for p in sorted(pings, key=lambda p: p[0]):
        if p[3] > max_acc:
            continue
        if p[0] in seen:
            continue
        seen.add(p[0])
        kept.append(p)
    total = 0
    anchor = None
    for p in kept:
        if anchor is None:
            anchor = p
            continue
        d = round(math.hypot(p[1] - anchor[1], p[2] - anchor[2]))
        dt = p[0] - anchor[0]
        if d > max_speed * dt:
            continue
        if not (p[4] or anchor[4]):
            total += d
        anchor = p
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: segment floor',
   [[[20, 475, 38, 5, False], [5, 75, 53, 5, False], [30, 505, 71, 5, False], [10, 475, 53, 20, True],
     [40, 610, 76, 5, False], [35, 565, 56, 10, False], [5, 45, 20, 60, False]],
    20, 30],
   554),
  ('partial repair probe: segment floor',
   [[[5, 45, 33, 10, False], [10, 90, 66, 10, False], [10, 135, 86, 20, False], [15, 535, 71, 25, False],
     [20, 535, 104, 20, False]],
    20, 30],
   55),
  ('second regression',
   [[[20, 520, 38, 20, True], [5, 30, -15, 5, False], [30, 965, 104, 5, False], [15, 490, 38, 25, False],
     [5, 90, 18, 5, False], [0, 0, -15, 20, False], [25, 565, 71, 5, False]],
    20, 30],
   571),
  ('normal control 1',
   [[[30, 980, 83, 5, False], [25, 520, 43, 10, True], [15, 60, 38, 10, True], [5, 60, 18, 25, False],
     [25, 490, 58, 5, False], [20, 90, 38, 20, False], [5, 60, 33, 25, False], [25, 580, 63, 20, True]],
    20, 30],
   0),
  ('normal control 2',
   [[[25, 550, 43, 20, True], [5, 460, 40, 20, False], [20, 550, 58, 20, False], [35, 655, 48, 60, False],
     [10, 520, 73, 60, False], [0, 60, 20, 10, True], [25, 595, 28, 20, False], [40, 700, 68, 60, False]],
    20, 30],
   0),
  ('normal control 3',
   [[[30, 520, 53, 20, True], [20, 120, 53, 25, False], [40, 1025, 78, 25, False], [35, 625, 58, 25, False],
     [10, 45, 33, 20, False], [35, 580, 38, 20, False], [15, 75, 33, 25, False]],
    20, 30],
   0),
  ('normal control 4',
   [[[0, 400, 33, 25, False], [10, 445, 66, 20, False], [15, 845, 99, 10, False], [20, 875, 132, 20, True],
     [25, 875, 117, 20, False]],
    20, 30],
   433)],
 [('regression: segment floor',
   [[[10, 45, 33, 20, False], [10, 90, 18, 60, True], [15, 135, 38, 60, False], [15, 180, 38, 60, False],
     [20, 180, 23, 20, False], [25, 225, 56, 20, False], [30, 225, 41, 20, True]],
    20, 30],
   190),
  ('partial repair probe: segment floor',
   [[[5, 30, 33, 10, False], [10, 30, 33, 25, False], [15, 90, 18, 10, False]], 20, 30], 61),
  ('second regression',
   [[[40, 1365, 21, 25, False], [35, 1335, 36, 20, False], [30, 1230, 3, 25, False],
     [15, 800, -15, 60, False], [45, 1425, 54, 10, False], [20, 830, 18, 25, False], [10, 400, 0, 60, False],
     [35, 1275, 3, 20, False]],
    20, 30],
   91),
  ('normal control 1', [[[10, 400, 20, 5, False], [15, 800, 5, 60, False], [5, 0, 20, 10, True]], 20, 30], 0),
  ('normal control 2',
   [[[0, 45, -15, 10, False], [30, 1010, 177, 20, False], [0, 90, 38, 20, False], [15, 210, 111, 20, False],
     [0, 45, 5, 25, False], [10, 150, 91, 20, True], [5, 120, 71, 20, False], [25, 610, 144, 20, False]],
    20, 30],
   114),
  ('normal control 3',
   [[[30, 460, 18, 60, False], [20, 400, 18, 10, False], [10, 400, -15, 20, False], [40, 1260, 36, 25, False],
     [35, 860, 51, 60, True], [50, 1260, 36, 20, False]],
    20, 30],
   893),
  ('normal control 4', [[[0, 400, 0, 20, True], [5, 800, 33, 20, True], [5, 830, 33, 5, False]], 20, 30], 0)],
 [('regression: segment floor',
   [[[5, 75, 66, 60, True], [25, 180, 69, 20, False], [35, 285, 89, 10, False], [30, 240, 69, 25, True],
     [10, 135, 51, 60, True], [0, 45, 33, 20, False], [45, 315, 122, 60, False], [20, 135, 84, 5, False]],
    20, 30],
   256),
  ('partial repair probe: segment floor',
   [[[30, 460, 23, 20, False], [10, 30, 18, 10, False], [25, 460, 23, 25, False], [15, 60, 3, 60, False],
     [5, 0, 33, 10, False]],
    20, 30],
   463),
  ('second regression',
   [[[5, 0, 33, 20, False], [5, 30, 53, 60, True], [5, 60, 38, 20, False], [10, 105, 71, 5, False],
     [15, 105, 104, 20, False], [20, 505, 137, 20, False]],
    20, 30],
   144),
  ('normal control 1',
   [[[25, 75, 60, 25, False], [25, 75, 40, 20, False], [10, 45, 20, 10, False], [20, 45, 40, 20, True]], 20,
    30],
   0),
  ('normal control 2',
   [[[20, 30, 20, 20, True], [25, 30, 53, 20, False], [10, 30, 20, 10, False], [35, 75, 73, 25, False]], 20,
    30],
   0),
  ('normal control 3',
   [[[30, 625, 139, 10, False], [0, 0, 20, 10, False], [25, 565, 106, 5, False], [10, 105, 53, 20, False],
     [5, 45, 20, 20, False], [15, 505, 53, 10, False], [20, 565, 73, 5, False]],
    20, 30],
   640),
  ('normal control 4',
   [[[5, 400, 33, 20, True], [15, 445, 18, 60, False], [15, 445, 3, 5, False], [25, 445, 23, 25, False],
     [35, 490, 23, 20, False]],
    20, 30],
   49)],
 [('regression: segment floor',
   [[[5, 460, 38, 20, False], [20, 520, 56, 10, False], [5, 60, 53, 20, False], [10, 490, 23, 10, False],
     [5, 0, 33, 5, True], [35, 565, 89, 20, False], [25, 565, 56, 20, False]],
    20, 30],
   155),
  ('partial repair probe: segment floor',
   [[[0, 30, 20, 10, False], [5, 75, 53, 20, False], [10, 75, 38, 20, False], [15, 105, 58, 20, False]], 20,
    30],
   106),
  ('second regression', [[[10, 45, 0, 20, False], [15, 75, -15, 5, False], [15, 75, 5, 60, False]], 20, 30],
   33),
  ('normal control 1',
   [[[10, 60, -15, 60, False], [15, 105, -15, 20, False], [20, 105, 18, 20, True], [20, 105, 18, 25, False],
     [25, 505, 38, 10, False]],
    20, 30],
   0),
  ('normal control 2',
   [[[5, 400, 33, 25, False], [15, 800, 53, 60, False], [20, 1200, 86, 25, False]], 20, 30], 0),
  ('normal control 3', [[[10, 430, 53, 20, True], [15, 475, 38, 25, False], [0, 30, 33, 20, False]], 20, 30],
   0),
  ('normal control 4',
   [[[5, 60, -15, 25, False], [15, 105, -30, 20, False], [15, 150, 3, 20, False], [20, 550, 23, 10, False],
     [25, 580, 23, 10, False], [35, 610, 56, 20, False]],
    20, 30],
   512)],
 [('regression: segment floor',
   [[[5, 0, 20, 20, False], [15, 45, 53, 20, False], [20, 105, 86, 10, False], [20, 135, 71, 10, False],
     [20, 180, 71, 10, False]],
    20, 30],
   123),
  ('partial repair probe: segment floor',
   [[[5, 45, 18, 25, False], [5, 0, -15, 5, False], [10, 45, 18, 5, False]], 20, 30], 55),
  ('second regression',
   [[[25, 550, 99, 10, False], [40, 995, 84, 20, False], [10, 105, 33, 10, False], [10, 45, 33, 25, False],
     [30, 950, 99, 25, False], [5, 0, 0, 10, False], [15, 150, 66, 20, False], [40, 1040, 69, 10, True]],
    20, 30],
   165),
  ('normal control 1',
   [[[35, 595, 99, 20, False], [5, 400, 0, 25, True], [40, 700, 139, 5, False], [15, 430, 33, 10, False],
     [30, 535, 99, 10, False], [25, 535, 99, 60, False], [35, 640, 119, 20, False], [20, 490, 66, 25, True]],
    20, 30],
   296),
  ('normal control 2',
   [[[20, 535, 89, 5, False], [10, 445, 23, 25, False], [30, 535, 89, 5, True], [15, 505, 56, 5, True],
     [0, 0, -15, 20, False], [5, 445, 3, 10, True], [0, 45, -30, 20, True], [35, 595, 89, 20, False]],
    20, 30],
   545),
  ('normal control 3',
   [[[30, 550, 25, 10, False], [20, 460, 20, 60, False], [25, 505, 40, 5, True], [10, 400, 0, 20, False]], 20,
    30],
   0),
  ('normal control 4',
   [[[0, 30, 33, 25, True], [10, 90, 33, 25, False], [20, 90, 18, 60, False], [25, 135, 18, 25, False],
     [30, 165, 38, 60, True], [40, 210, 38, 20, True]],
    20, 30],
   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:
Trips with many short segments bill a few more meters than the per-segment rule.

Billable distance from GPS pings [t seconds, x m, y m, accuracy m, paused]. Sort by time (stable); drop pings with accuracy worse than max_acc; among remaining pings with the same timestamp keep the first. Walk the kept pings with an anchor: segment length is the floored Euclidean distance (isqrt); if it implies a speed above max_speed m/s the ping is discarded and the anchor stays; otherwise the segment is billed unless either endpoint is paused, and the anchor moves. Return total meters.

split: open-access


prompt:
When only one rider meets the overlap threshold, that rider still receives the matched discount.

In a shared ride, a rider counts as matched if they shared at least min_overlap_s seconds with another rider; a match needs at least two such riders, otherwise nobody is matched. Matched riders pay solo x (100 - discount_pct)% and unmatched riders pay solo x 95%, both floored to the cent in the rider's favor. Return id -> price.

split: open-access


prompt:
Riders sharing exactly three minutes lose the matched discount.

In a shared ride, a rider counts as matched if they shared at least min_overlap_s seconds with another rider; a match needs at least two such riders, otherwise nobody is matched. Matched riders pay solo x (100 - discount_pct)% and unmatched riders pay solo x 95%, both floored to the cent in the rider's favor. Return id -> price.

split: open-access


prompt:
Discounted prices are a cent higher than quoted whenever the discount leaves a fraction.

In a shared ride, a rider counts as matched if they shared at least min_overlap_s seconds with another rider; a match needs at least two such riders, otherwise nobody is matched. Matched riders pay solo x (100 - discount_pct)% and unmatched riders pay solo x 95%, both floored to the cent in the rider's favor. Return id -> price.

split: open-access


prompt:
Riders who chose pool but were never matched pay the full solo price.

In a shared ride, a rider counts as matched if they shared at least min_overlap_s seconds with another rider; a match needs at least two such riders, otherwise nobody is matched. Matched riders pay solo x (100 - discount_pct)% and unmatched riders pay solo x 95%, both floored to the cent in the rider's favor. Return id -> price.

split: open-access


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

N = 1
observations = []
def solve(trip, plan):
    surged = (trip['core'] * trip['surge'] * 2 + 10) // 20
    share = (surged + trip['tip']) * (100 - plan['commission']) // 100
    share = max(share, plan['min_pay'])
    pay = share + trip['tolls']
    n = plan['trips_before'] + 1
    bonus = 0
    for need, amount in plan['quests']:
        if n == need:
            bonus += amount
    return {'pay': pay, 'bonus': bonus}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: commission on tips',
   [{'booking_fee': 0, 'core': 900, 'surge': 15, 'tip': 200, 'tolls': 0},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 1280}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 0, 'core': 2500, 'surge': 20, 'tip': 0, 'tolls': 300},
    {'commission': 25, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 4050}),
  ('second regression',
   [{'booking_fee': 0, 'core': 2500, 'surge': 15, 'tip': 500, 'tolls': 0},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 3312}),
  ('normal control 1',
   [{'booking_fee': 250, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2080}),
  ('normal control 2',
   [{'booking_fee': 250, 'core': 2500, 'surge': 10, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2000}),
  ('normal control 3',
   [{'booking_fee': 250, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 1440}),
  ('normal control 4',
   [{'booking_fee': 0, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 2080})],
 [('regression: commission on tips',
   [{'booking_fee': 250, 'core': 900, 'surge': 15, 'tip': 500, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 1580}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 250, 'core': 450, 'surge': 15, 'tip': 0, 'tolls': 300},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 840}),
  ('second regression',
   [{'booking_fee': 0, 'core': 450, 'surge': 10, 'tip': 0, 'tolls': 300},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 700}),
  ('normal control 1',
   [{'booking_fee': 0, 'core': 900, 'surge': 12, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 810}),
  ('normal control 2',
   [{'booking_fee': 0, 'core': 450, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 675}),
  ('normal control 3',
   [{'booking_fee': 250, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 2080}),
  ('normal control 4',
   [{'booking_fee': 250, 'core': 1733, 'surge': 12, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 1560})],
 [('regression: commission on tips',
   [{'booking_fee': 0, 'core': 1733, 'surge': 10, 'tip': 200, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 1586}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 0, 'core': 2500, 'surge': 10, 'tip': 0, 'tolls': 300},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 2175}),
  ('second regression',
   [{'booking_fee': 0, 'core': 2500, 'surge': 15, 'tip': 0, 'tolls': 300},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 10}],
   {'bonus': 0, 'pay': 3112}),
  ('normal control 1',
   [{'booking_fee': 0, 'core': 1733, 'surge': 12, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 1560}),
  ('normal control 2',
   [{'booking_fee': 250, 'core': 2500, 'surge': 10, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2000}),
  ('normal control 3',
   [{'booking_fee': 0, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 20}],
   {'bonus': 0, 'pay': 1950}),
  ('normal control 4',
   [{'booking_fee': 0, 'core': 900, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 1012})],
 [('regression: commission on tips',
   [{'booking_fee': 0, 'core': 2500, 'surge': 10, 'tip': 500, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 2375}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 250, 'core': 450, 'surge': 12, 'tip': 0, 'tolls': 300},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 20}],
   {'bonus': 0, 'pay': 800}),
  ('second regression',
   [{'booking_fee': 0, 'core': 1733, 'surge': 15, 'tip': 500, 'tolls': 300},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2750}),
  ('normal control 1',
   [{'booking_fee': 250, 'core': 450, 'surge': 12, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 432}),
  ('normal control 2',
   [{'booking_fee': 0, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 10}],
   {'bonus': 0, 'pay': 1440}),
  ('normal control 3',
   [{'booking_fee': 0, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 1440}),
  ('normal control 4',
   [{'booking_fee': 0, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 20}],
   {'bonus': 0, 'pay': 1440})],
 [('regression: commission on tips',
   [{'booking_fee': 250, 'core': 2500, 'surge': 10, 'tip': 200, 'tolls': 300},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2500}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 250, 'core': 1733, 'surge': 20, 'tip': 500, 'tolls': 300},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 10}],
   {'bonus': 0, 'pay': 3399}),
  ('second regression',
   [{'booking_fee': 250, 'core': 450, 'surge': 10, 'tip': 200, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 10}],
   {'bonus': 0, 'pay': 700}),
  ('normal control 1',
   [{'booking_fee': 250, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 2080}),
  ('normal control 2',
   [{'booking_fee': 0, 'core': 1733, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 2599}),
  ('normal control 3',
   [{'booking_fee': 250, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 1440}),
  ('normal control 4',
   [{'booking_fee': 0, 'core': 1733, 'surge': 10, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 1386})]]
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(trip, plan):
    surged = (trip['core'] * trip['surge'] * 2 + 10) // 20
    share = (surged + trip['tolls']) * (100 - plan['commission']) // 100
    share = max(share, plan['min_pay'])
    pay = share + trip['tolls'] + trip['tip']
    n = plan['trips_before'] + 1
    bonus = 0
    for need, amount in plan['quests']:
        if n == need:
            bonus += amount
    return {'pay': pay, 'bonus': bonus}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: commission on tips',
   [{'booking_fee': 0, 'core': 900, 'surge': 15, 'tip': 200, 'tolls': 0},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 1280}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 0, 'core': 2500, 'surge': 20, 'tip': 0, 'tolls': 300},
    {'commission': 25, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 4050}),
  ('second regression',
   [{'booking_fee': 0, 'core': 2500, 'surge': 15, 'tip': 500, 'tolls': 0},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 3312}),
  ('normal control 1',
   [{'booking_fee': 250, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2080}),
  ('normal control 2',
   [{'booking_fee': 250, 'core': 2500, 'surge': 10, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2000}),
  ('normal control 3',
   [{'booking_fee': 250, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 1440}),
  ('normal control 4',
   [{'booking_fee': 0, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 2080})],
 [('regression: commission on tips',
   [{'booking_fee': 250, 'core': 900, 'surge': 15, 'tip': 500, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 1580}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 250, 'core': 450, 'surge': 15, 'tip': 0, 'tolls': 300},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 840}),
  ('second regression',
   [{'booking_fee': 0, 'core': 450, 'surge': 10, 'tip': 0, 'tolls': 300},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 700}),
  ('normal control 1',
   [{'booking_fee': 0, 'core': 900, 'surge': 12, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 810}),
  ('normal control 2',
   [{'booking_fee': 0, 'core': 450, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 675}),
  ('normal control 3',
   [{'booking_fee': 250, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 2080}),
  ('normal control 4',
   [{'booking_fee': 250, 'core': 1733, 'surge': 12, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 1560})],
 [('regression: commission on tips',
   [{'booking_fee': 0, 'core': 1733, 'surge': 10, 'tip': 200, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 1586}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 0, 'core': 2500, 'surge': 10, 'tip': 0, 'tolls': 300},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 2175}),
  ('second regression',
   [{'booking_fee': 0, 'core': 2500, 'surge': 15, 'tip': 0, 'tolls': 300},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 10}],
   {'bonus': 0, 'pay': 3112}),
  ('normal control 1',
   [{'booking_fee': 0, 'core': 1733, 'surge': 12, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 1560}),
  ('normal control 2',
   [{'booking_fee': 250, 'core': 2500, 'surge': 10, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2000}),
  ('normal control 3',
   [{'booking_fee': 0, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 20}],
   {'bonus': 0, 'pay': 1950}),
  ('normal control 4',
   [{'booking_fee': 0, 'core': 900, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 1012})],
 [('regression: commission on tips',
   [{'booking_fee': 0, 'core': 2500, 'surge': 10, 'tip': 500, 'tolls': 0},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 2375}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 250, 'core': 450, 'surge': 12, 'tip': 0, 'tolls': 300},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 20}],
   {'bonus': 0, 'pay': 800}),
  ('second regression',
   [{'booking_fee': 0, 'core': 1733, 'surge': 15, 'tip': 500, 'tolls': 300},
    {'commission': 25, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2750}),
  ('normal control 1',
   [{'booking_fee': 250, 'core': 450, 'surge': 12, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 432}),
  ('normal control 2',
   [{'booking_fee': 0, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 10}],
   {'bonus': 0, 'pay': 1440}),
  ('normal control 3',
   [{'booking_fee': 0, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 1440}),
  ('normal control 4',
   [{'booking_fee': 0, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 20}],
   {'bonus': 0, 'pay': 1440})],
 [('regression: commission on tips',
   [{'booking_fee': 250, 'core': 2500, 'surge': 10, 'tip': 200, 'tolls': 300},
    {'commission': 20, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 2500}),
  ('partial repair probe: commission on tips',
   [{'booking_fee': 250, 'core': 1733, 'surge': 20, 'tip': 500, 'tolls': 300},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 10}],
   {'bonus': 0, 'pay': 3399}),
  ('second regression',
   [{'booking_fee': 250, 'core': 450, 'surge': 10, 'tip': 200, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 10}],
   {'bonus': 0, 'pay': 700}),
  ('normal control 1',
   [{'booking_fee': 250, 'core': 1733, 'surge': 15, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 3}],
   {'bonus': 0, 'pay': 2080}),
  ('normal control 2',
   [{'booking_fee': 0, 'core': 1733, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 25, 'min_pay': 700, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 19}],
   {'bonus': 2500, 'pay': 2599}),
  ('normal control 3',
   [{'booking_fee': 250, 'core': 900, 'surge': 20, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 400, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 9}],
   {'bonus': 1500, 'pay': 1440}),
  ('normal control 4',
   [{'booking_fee': 0, 'core': 1733, 'surge': 10, 'tip': 0, 'tolls': 0},
    {'commission': 20, 'min_pay': 500, 'quests': [[10, 1500], [20, 2500], [25, 1000]], 'trips_before': 24}],
   {'bonus': 1000, 'pay': 1386})]]
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:
Drivers receive only 75% of every tip.

Driver pay per trip in cents: the surged core fare (core x surge tenths, half up) minus the commission percentage (floored), raised to min_pay if lower; tolls and tips pass through untouched and are outside commission and the minimum; the booking fee is platform revenue. A quest bonus is paid when this trip is exactly the Nth trip for a quest threshold N (trips_before + 1 == N). Return pay and bonus.

split: open-access