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

N = 1
observations = []
def solve(d):
    try:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,right)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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 simultaneous join update omits the delta-delta product.

Apply simultaneous signed changes to two bag relations. Emit the consolidated join delta Ldelta*Rold + Lold*Rdelta + Ldelta*Rdelta. Inputs are [key,value,weight]; ordinary non-null equality joins. Return sorted [leftvalue,rightvalue,weight] nonzero rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,dr),(dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
        left,right,dl,dr=d
        terms=[(dl,right+dr),(left+dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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 simultaneous join update counts the delta-delta product twice.

Apply simultaneous signed changes to two bag relations. Emit the consolidated join delta Ldelta*Rold + Lold*Rdelta + Ldelta*Rdelta. Inputs are [key,value,weight]; ordinary non-null equality joins. Return sorted [leftvalue,rightvalue,weight] nonzero rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+abs(wa*wb)
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+wa*abs(wb)
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
Join delta weights lose retraction signs.

Apply simultaneous signed changes to two bag relations. Emit the consolidated join delta Ldelta*Rold + Lold*Rdelta + Ldelta*Rdelta. Inputs are [key,value,weight]; ordinary non-null equality joins. Return sorted [leftvalue,rightvalue,weight] nonzero rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka!=kb: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka!=kb and ka is not None and kb is not None: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
Incremental join matches null join keys.

Apply simultaneous signed changes to two bag relations. Emit the consolidated join delta Ldelta*Rold + Lold*Rdelta + Ldelta*Rdelta. Inputs are [key,value,weight]; ordinary non-null equality joins. Return sorted [leftvalue,rightvalue,weight] nonzero rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(va,va)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(vb,vb)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w!=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
Join delta consolidation groups only by left payload.

Apply simultaneous signed changes to two bag relations. Emit the consolidated join delta Ldelta*Rold + Lold*Rdelta + Ldelta*Rdelta. Inputs are [key,value,weight]; ordinary non-null equality joins. Return sorted [leftvalue,rightvalue,weight] nonzero rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if True]
    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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
        left,right,dl,dr=d
        terms=[(dl,right),(left,dr),(dl,dr)]
        weights={}
        for a,b in terms:
            for ka,va,wa in a:
                for kb,vb,wb in b:
                    if ka is None or kb is None or ka!=kb: continue
                    key=(va,vb)
                    weights[key]=weights.get(key,0)+wa*wb
        return [[a,b,w] for (a,b),w in sorted(weights.items()) if w>=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('simultaneous insert', solve([[], [], [['k', 1, 1]], [['k', 2, 1]]]), [[1, 2, 1]])
    check('right retraction', solve([[['k', 1, 2]], [['k', 2, 1]], [], [['k', 2, -1]]]), [[1, 2, -2]])
    check('left retraction', solve([[['k', 1, 1]], [['k', 2, 3]], [['k', 1, -1]], []]), [[1, 2, -3]])
    check('null equality', solve([[], [[None, 2, 1]], [[None, 1, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 2, 1]], [['k', 1, 1], ['k', 1, -1]], []]), [])
    check('two payloads', solve([[], [['k', 2, 1], ['k', 3, 1]], [['k', 1, 1]], []]), [[1, 2, 1], [1, 3, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 2:
    check('simultaneous insert', solve([[], [], [['k', 2, 1]], [['k', 3, 1]]]), [[2, 3, 1]])
    check('right retraction', solve([[['k', 2, 2]], [['k', 3, 1]], [], [['k', 3, -1]]]), [[2, 3, -2]])
    check('left retraction', solve([[['k', 2, 1]], [['k', 3, 3]], [['k', 2, -1]], []]), [[2, 3, -3]])
    check('null equality', solve([[], [[None, 3, 1]], [[None, 2, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 3, 1]], [['k', 2, 1], ['k', 2, -1]], []]), [])
    check('two payloads', solve([[], [['k', 3, 1], ['k', 4, 1]], [['k', 2, 1]], []]), [[2, 3, 1], [2, 4, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 3:
    check('simultaneous insert', solve([[], [], [['k', 3, 1]], [['k', 4, 1]]]), [[3, 4, 1]])
    check('right retraction', solve([[['k', 3, 2]], [['k', 4, 1]], [], [['k', 4, -1]]]), [[3, 4, -2]])
    check('left retraction', solve([[['k', 3, 1]], [['k', 4, 3]], [['k', 3, -1]], []]), [[3, 4, -3]])
    check('null equality', solve([[], [[None, 4, 1]], [[None, 3, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 4, 1]], [['k', 3, 1], ['k', 3, -1]], []]), [])
    check('two payloads', solve([[], [['k', 4, 1], ['k', 5, 1]], [['k', 3, 1]], []]), [[3, 4, 1], [3, 5, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 4:
    check('simultaneous insert', solve([[], [], [['k', 4, 1]], [['k', 5, 1]]]), [[4, 5, 1]])
    check('right retraction', solve([[['k', 4, 2]], [['k', 5, 1]], [], [['k', 5, -1]]]), [[4, 5, -2]])
    check('left retraction', solve([[['k', 4, 1]], [['k', 5, 3]], [['k', 4, -1]], []]), [[4, 5, -3]])
    check('null equality', solve([[], [[None, 5, 1]], [[None, 4, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 5, 1]], [['k', 4, 1], ['k', 4, -1]], []]), [])
    check('two payloads', solve([[], [['k', 5, 1], ['k', 6, 1]], [['k', 4, 1]], []]), [[4, 5, 1], [4, 6, 1]])
    check('empty change', solve([[], [], [], []]), [])
elif N == 5:
    check('simultaneous insert', solve([[], [], [['k', 5, 1]], [['k', 6, 1]]]), [[5, 6, 1]])
    check('right retraction', solve([[['k', 5, 2]], [['k', 6, 1]], [], [['k', 6, -1]]]), [[5, 6, -2]])
    check('left retraction', solve([[['k', 5, 1]], [['k', 6, 3]], [['k', 5, -1]], []]), [[5, 6, -3]])
    check('null equality', solve([[], [[None, 6, 1]], [[None, 5, 1]], []]), [])
    check('cancelled delta', solve([[], [['k', 6, 1]], [['k', 5, 1], ['k', 5, -1]], []]), [])
    check('two payloads', solve([[], [['k', 6, 1], ['k', 7, 1]], [['k', 5, 1]], []]), [[5, 6, 1], [5, 7, 1]])
    check('empty change', solve([[], [], [], []]), [])
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:
Consolidated zero-weight join rows remain in the changelog.

Apply simultaneous signed changes to two bag relations. Emit the consolidated join delta Ldelta*Rold + Lold*Rdelta + Ldelta*Rdelta. Inputs are [key,value,weight]; ordinary non-null equality joins. Return sorted [leftvalue,rightvalue,weight] nonzero rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,1 if now else -1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=max(after.get(value,0),weight)
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,1 if now else -1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
Incremental distinct replaces counts with delta weights.

Maintain bag counts from consolidated signed changes and emit only membership crossings. Old and delta entries are [value,count]; counts after each batch are nonnegative. Output sorted [value,+1/-1] for zero-to-positive or positive-to-zero transitions.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        old,changes=d
        before=dict(old)
        after=before
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,1 if now else -1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
        old,changes=d
        before=dict(old)
        after=before; before={}
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,1 if now else -1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
Distinct mutates its before-image while applying changes.

Maintain bag counts from consolidated signed changes and emit only membership crossings. Old and delta entries are [value,count]; counts after each batch are nonnegative. Output sorted [value,+1/-1] for zero-to-positive or positive-to-zero transitions.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>1
            if was!=now: out.append([value,1 if now else -1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)==1
            if was!=now: out.append([value,1 if now else -1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
Distinct requires two live copies before a value becomes present.

Maintain bag counts from consolidated signed changes and emit only membership crossings. Old and delta entries are [value,count]; counts after each batch are nonnegative. Output sorted [value,+1/-1] for zero-to-positive or positive-to-zero transitions.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(before):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,1 if now else -1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(v for v,w in changes) & set(before)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,1 if now else -1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
Distinct scans only values present before the batch.

Maintain bag counts from consolidated signed changes and emit only membership crossings. Old and delta entries are [value,count]; counts after each batch are nonnegative. Output sorted [value,+1/-1] for zero-to-positive or positive-to-zero transitions.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if before.get(value,0)!=after.get(value,0): out.append([value,1 if now else -1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if now: out.append([value,1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
Distinct forwards count changes that do not cross membership.

Maintain bag counts from consolidated signed changes and emit only membership crossings. Old and delta entries are [value,count]; counts after each batch are nonnegative. Output sorted [value,+1/-1] for zero-to-positive or positive-to-zero transitions.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,-1])
        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('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 2]], []]), [])
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:
Distinct removal events use insertion polarity.

Maintain bag counts from consolidated signed changes and emit only membership crossings. Old and delta entries are [value,count]; counts after each batch are nonnegative. Output sorted [value,+1/-1] for zero-to-positive or positive-to-zero transitions.

split: open-access