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

N = 1
observations = []
def solve(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        if batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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 resume cursor stops at an empty batch instead of normalizing.

Fetch at most quota rows from a sequence of batches starting at [batch-index,row-offset]. Skip exhausted and empty batches, return the emitted rows and a canonical next cursor, and mark exhaustion as [number-of-batches,0]. Quota zero preserves a normalized cursor.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=1
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=max(0,offset-1)
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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:
Cross-batch resume carries the old row offset into the next batch.

Fetch at most quota rows from a sequence of batches starting at [batch-index,row-offset]. Skip exhausted and empty batches, return the emitted rows and a canonical next cursor, and mark exhaustion as [number-of-batches,0]. Quota zero preserves a normalized cursor.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=int(offset==len(batches[batch]))
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=int(offset==1)
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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:
Fetch decrements quota per batch rather than per emitted row.

Fetch at most quota rows from a sequence of batches starting at [batch-index,row-offset]. Skip exhausted and empty batches, return the emitted rows and a canonical next cursor, and mark exhaustion as [number-of-batches,0]. Quota zero preserves a normalized cursor.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,max(0,offset-1)]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,0]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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:
Returned resume cursor points back at the last emitted row.

Fetch at most quota rows from a sequence of batches starting at [batch-index,row-offset]. Skip exhausted and empty batches, return the emitted rows and a canonical next cursor, and mark exhaustion as [number-of-batches,0]. Quota zero preserves a normalized cursor.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][0])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>0 and batch<len(batches):
            out.append(batches[batch][-1])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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:
Batch fetch reads the beginning of a partially consumed batch.

Fetch at most quota rows from a sequence of batches starting at [batch-index,row-offset]. Skip exhausted and empty batches, return the emitted rows and a canonical next cursor, and mark exhaustion as [number-of-batches,0]. Quota zero preserves a normalized cursor.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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(d):
    try:
        batches,batch,offset,quota=d
        out=[]
        while batch<len(batches) and offset>=len(batches[batch]):
            batch+=1; offset=0
        while quota>=0 and batch<len(batches):
            out.append(batches[batch][offset])
            offset+=1; quota-=1
            while batch<len(batches) and offset>=len(batches[batch]):
                batch+=1; offset=0
        return [out,[batch,offset]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
    check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
    check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
    check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
    check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
    check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
    check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
    check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
    check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
    check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
    check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
    check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
    check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
    check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
    check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
    check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
    check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
    check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
    check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
    check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
    check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
    check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
    check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
    check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
    check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
    check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
    check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
    check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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:
Fetch drains all remaining rows despite its output quota.

Fetch at most quota rows from a sequence of batches starting at [batch-index,row-offset]. Skip exhausted and empty batches, return the emitted rows and a canonical next cursor, and mark exhaustion as [number-of-batches,0]. Quota zero preserves a normalized cursor.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in selection:
            known=row_valid[row]
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in selection:
            known=scalar_valid or row_valid[row]
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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:
Constant vector materialization ignores scalar validity.

Materialize a constant vector over a requested logical length, combining scalar validity with row validity. A selection chooses logical rows and may repeat them. Return [row-index,value-or-null] for every selected row; scalar zero is a valid value.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in selection:
            known=scalar_valid
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in selection:
            known=scalar_valid and all(row_valid)
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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:
Constant vector materialization ignores row validity.

Materialize a constant vector over a requested logical length, combining scalar validity with row validity. A selection chooses logical rows and may repeat them. Return [row-index,value-or-null] for every selected row; scalar zero is a valid value.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in selection:
            known=bool(value) and scalar_valid and row_valid[row]
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in selection:
            known=value is not None and value!=0 and row_valid[row]
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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:
Constant vector treats zero as a null scalar.

Materialize a constant vector over a requested logical length, combining scalar validity with row validity. A selection chooses logical rows and may repeat them. Return [row-index,value-or-null] for every selected row; scalar zero is a valid value.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in range(len(selection)):
            known=scalar_valid and row_valid[row]
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in sorted(selection):
            known=scalar_valid and row_valid[row]
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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:
Constant vector materializes the first selection-length rows.

Materialize a constant vector over a requested logical length, combining scalar validity with row validity. A selection chooses logical rows and may repeat them. Return [row-index,value-or-null] for every selected row; scalar zero is a valid value.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in dict.fromkeys(selection):
            known=scalar_valid and row_valid[row]
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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(d):
    try:
        value,scalar_valid,row_valid,selection=d
        out=[]
        for row in sorted(set(selection)):
            known=scalar_valid and row_valid[row]
            out.append([row,value if known else None])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('selected validity', solve([1, True, [True, False, True], [2, 1, 0]]), [[2, 1], [1, None], [0, 1]])
    check('scalar null', solve([1, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([1, True, [False, True], [1, 0]]), [[1, 1], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([1, True, [True, True], [1, 1]]), [[1, 1], [1, 1]])
    check('empty selection', solve([1, True, [True], []]), [])
    check('single row control', solve([1, True, [True], [0]]), [[0, 1]])
elif N == 2:
    check('selected validity', solve([2, True, [True, False, True], [2, 1, 0]]), [[2, 2], [1, None], [0, 2]])
    check('scalar null', solve([2, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([2, True, [False, True], [1, 0]]), [[1, 2], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([2, True, [True, True], [1, 1]]), [[1, 2], [1, 2]])
    check('empty selection', solve([2, True, [True], []]), [])
    check('single row control', solve([2, True, [True], [0]]), [[0, 2]])
elif N == 3:
    check('selected validity', solve([3, True, [True, False, True], [2, 1, 0]]), [[2, 3], [1, None], [0, 3]])
    check('scalar null', solve([3, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([3, True, [False, True], [1, 0]]), [[1, 3], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([3, True, [True, True], [1, 1]]), [[1, 3], [1, 3]])
    check('empty selection', solve([3, True, [True], []]), [])
    check('single row control', solve([3, True, [True], [0]]), [[0, 3]])
elif N == 4:
    check('selected validity', solve([4, True, [True, False, True], [2, 1, 0]]), [[2, 4], [1, None], [0, 4]])
    check('scalar null', solve([4, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([4, True, [False, True], [1, 0]]), [[1, 4], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([4, True, [True, True], [1, 1]]), [[1, 4], [1, 4]])
    check('empty selection', solve([4, True, [True], []]), [])
    check('single row control', solve([4, True, [True], [0]]), [[0, 4]])
elif N == 5:
    check('selected validity', solve([5, True, [True, False, True], [2, 1, 0]]), [[2, 5], [1, None], [0, 5]])
    check('scalar null', solve([5, False, [True, True], [0, 1]]), [[0, None], [1, None]])
    check('mixed row null', solve([5, True, [False, True], [1, 0]]), [[1, 5], [0, None]])
    check('zero constant', solve([0, True, [True], [0]]), [[0, 0]])
    check('repeat row', solve([5, True, [True, True], [1, 1]]), [[1, 5], [1, 5]])
    check('empty selection', solve([5, True, [True], []]), [])
    check('single row control', solve([5, True, [True], [0]]), [[0, 5]])
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:
Constant vector removes repeated gathered rows.

Materialize a constant vector over a requested logical length, combining scalar validity with row validity. A selection chooses logical rows and may repeat them. Return [row-index,value-or-null] for every selected row; scalar zero is a valid value.

split: open-access