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

N = 1
observations = []
def solve(d):
    try:
        outer,inner=d
        result=[]
        for ident,key,minimum in outer:
            matches=[value for k,value in inner if k==key and value>=minimum]
            if not matches: result.append([ident,None])
            for value in matches:
                result.append([ident,value])
        return result
    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('per-row bindings', solve([[[10, 'a', 1], [11, 'b', 3]], [['a', 2], ['b', 2], ['b', 4]]]), [[10, 2], [11, 4]])
    check('same key different parameter', solve([[[10, 'a', 1], [11, 'a', 3]], [['a', 2], ['a', 4]]]), [[10, 2], [10, 4], [11, 4]])
    check('null key', solve([[[10, None, 1]], [[None, 2]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 1]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 1]], [['a', 1], ['a', 1]]]), [[10, 1], [10, 1]])
    check('empty outer', solve([[], [['a', 1]]]), [])
    check('unmatched key', solve([[[10, 'z', 1]], [['a', 2]]]), [[10, None]])
elif N == 2:
    check('per-row bindings', solve([[[10, 'a', 2], [11, 'b', 4]], [['a', 3], ['b', 3], ['b', 5]]]), [[10, 3], [11, 5]])
    check('same key different parameter', solve([[[10, 'a', 2], [11, 'a', 4]], [['a', 3], ['a', 5]]]), [[10, 3], [10, 5], [11, 5]])
    check('null key', solve([[[10, None, 2]], [[None, 3]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 2]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 2]], [['a', 2], ['a', 2]]]), [[10, 2], [10, 2]])
    check('empty outer', solve([[], [['a', 2]]]), [])
    check('unmatched key', solve([[[10, 'z', 2]], [['a', 3]]]), [[10, None]])
elif N == 3:
    check('per-row bindings', solve([[[10, 'a', 3], [11, 'b', 5]], [['a', 4], ['b', 4], ['b', 6]]]), [[10, 4], [11, 6]])
    check('same key different parameter', solve([[[10, 'a', 3], [11, 'a', 5]], [['a', 4], ['a', 6]]]), [[10, 4], [10, 6], [11, 6]])
    check('null key', solve([[[10, None, 3]], [[None, 4]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 3]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 3]], [['a', 3], ['a', 3]]]), [[10, 3], [10, 3]])
    check('empty outer', solve([[], [['a', 3]]]), [])
    check('unmatched key', solve([[[10, 'z', 3]], [['a', 4]]]), [[10, None]])
elif N == 4:
    check('per-row bindings', solve([[[10, 'a', 4], [11, 'b', 6]], [['a', 5], ['b', 5], ['b', 7]]]), [[10, 5], [11, 7]])
    check('same key different parameter', solve([[[10, 'a', 4], [11, 'a', 6]], [['a', 5], ['a', 7]]]), [[10, 5], [10, 7], [11, 7]])
    check('null key', solve([[[10, None, 4]], [[None, 5]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 4]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 4]], [['a', 4], ['a', 4]]]), [[10, 4], [10, 4]])
    check('empty outer', solve([[], [['a', 4]]]), [])
    check('unmatched key', solve([[[10, 'z', 4]], [['a', 5]]]), [[10, None]])
elif N == 5:
    check('per-row bindings', solve([[[10, 'a', 5], [11, 'b', 7]], [['a', 6], ['b', 6], ['b', 8]]]), [[10, 6], [11, 8]])
    check('same key different parameter', solve([[[10, 'a', 5], [11, 'a', 7]], [['a', 6], ['a', 8]]]), [[10, 6], [10, 8], [11, 8]])
    check('null key', solve([[[10, None, 5]], [[None, 6]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 5]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 5]], [['a', 5], ['a', 5]]]), [[10, 5], [10, 5]])
    check('empty outer', solve([[], [['a', 5]]]), [])
    check('unmatched key', solve([[[10, 'z', 5]], [['a', 6]]]), [[10, None]])
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:
        outer,inner=d
        result=[]
        for ident,key,minimum in outer:
            matches=[value for k,value in inner if key is None or k==key and value>=minimum]
            if not matches: result.append([ident,None])
            for value in matches:
                result.append([ident,value])
        return result
    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('per-row bindings', solve([[[10, 'a', 1], [11, 'b', 3]], [['a', 2], ['b', 2], ['b', 4]]]), [[10, 2], [11, 4]])
    check('same key different parameter', solve([[[10, 'a', 1], [11, 'a', 3]], [['a', 2], ['a', 4]]]), [[10, 2], [10, 4], [11, 4]])
    check('null key', solve([[[10, None, 1]], [[None, 2]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 1]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 1]], [['a', 1], ['a', 1]]]), [[10, 1], [10, 1]])
    check('empty outer', solve([[], [['a', 1]]]), [])
    check('unmatched key', solve([[[10, 'z', 1]], [['a', 2]]]), [[10, None]])
elif N == 2:
    check('per-row bindings', solve([[[10, 'a', 2], [11, 'b', 4]], [['a', 3], ['b', 3], ['b', 5]]]), [[10, 3], [11, 5]])
    check('same key different parameter', solve([[[10, 'a', 2], [11, 'a', 4]], [['a', 3], ['a', 5]]]), [[10, 3], [10, 5], [11, 5]])
    check('null key', solve([[[10, None, 2]], [[None, 3]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 2]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 2]], [['a', 2], ['a', 2]]]), [[10, 2], [10, 2]])
    check('empty outer', solve([[], [['a', 2]]]), [])
    check('unmatched key', solve([[[10, 'z', 2]], [['a', 3]]]), [[10, None]])
elif N == 3:
    check('per-row bindings', solve([[[10, 'a', 3], [11, 'b', 5]], [['a', 4], ['b', 4], ['b', 6]]]), [[10, 4], [11, 6]])
    check('same key different parameter', solve([[[10, 'a', 3], [11, 'a', 5]], [['a', 4], ['a', 6]]]), [[10, 4], [10, 6], [11, 6]])
    check('null key', solve([[[10, None, 3]], [[None, 4]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 3]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 3]], [['a', 3], ['a', 3]]]), [[10, 3], [10, 3]])
    check('empty outer', solve([[], [['a', 3]]]), [])
    check('unmatched key', solve([[[10, 'z', 3]], [['a', 4]]]), [[10, None]])
elif N == 4:
    check('per-row bindings', solve([[[10, 'a', 4], [11, 'b', 6]], [['a', 5], ['b', 5], ['b', 7]]]), [[10, 5], [11, 7]])
    check('same key different parameter', solve([[[10, 'a', 4], [11, 'a', 6]], [['a', 5], ['a', 7]]]), [[10, 5], [10, 7], [11, 7]])
    check('null key', solve([[[10, None, 4]], [[None, 5]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 4]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 4]], [['a', 4], ['a', 4]]]), [[10, 4], [10, 4]])
    check('empty outer', solve([[], [['a', 4]]]), [])
    check('unmatched key', solve([[[10, 'z', 4]], [['a', 5]]]), [[10, None]])
elif N == 5:
    check('per-row bindings', solve([[[10, 'a', 5], [11, 'b', 7]], [['a', 6], ['b', 6], ['b', 8]]]), [[10, 6], [11, 8]])
    check('same key different parameter', solve([[[10, 'a', 5], [11, 'a', 7]], [['a', 6], ['a', 8]]]), [[10, 6], [10, 8], [11, 8]])
    check('null key', solve([[[10, None, 5]], [[None, 6]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 5]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 5]], [['a', 5], ['a', 5]]]), [[10, 5], [10, 5]])
    check('empty outer', solve([[], [['a', 5]]]), [])
    check('unmatched key', solve([[[10, 'z', 5]], [['a', 6]]]), [[10, None]])
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:
Lateral correlation treats absent keys as equal keys.

For each outer [id,key] row, evaluate matching [key,value] inner rows with a minimum supplied by that outer row. Emit [id,value] in source order, preserving duplicate inner matches. Empty matches emit [id,None] under outer lateral semantics.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        outer,inner=d
        result=[]
        for ident,key,minimum in outer:
            matches=[value for k,value in inner if key is not None and k==key and value>=minimum]
            if not matches: pass
            for value in matches:
                result.append([ident,value])
        return result
    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('per-row bindings', solve([[[10, 'a', 1], [11, 'b', 3]], [['a', 2], ['b', 2], ['b', 4]]]), [[10, 2], [11, 4]])
    check('same key different parameter', solve([[[10, 'a', 1], [11, 'a', 3]], [['a', 2], ['a', 4]]]), [[10, 2], [10, 4], [11, 4]])
    check('null key', solve([[[10, None, 1]], [[None, 2]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 1]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 1]], [['a', 1], ['a', 1]]]), [[10, 1], [10, 1]])
    check('empty outer', solve([[], [['a', 1]]]), [])
    check('unmatched key', solve([[[10, 'z', 1]], [['a', 2]]]), [[10, None]])
elif N == 2:
    check('per-row bindings', solve([[[10, 'a', 2], [11, 'b', 4]], [['a', 3], ['b', 3], ['b', 5]]]), [[10, 3], [11, 5]])
    check('same key different parameter', solve([[[10, 'a', 2], [11, 'a', 4]], [['a', 3], ['a', 5]]]), [[10, 3], [10, 5], [11, 5]])
    check('null key', solve([[[10, None, 2]], [[None, 3]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 2]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 2]], [['a', 2], ['a', 2]]]), [[10, 2], [10, 2]])
    check('empty outer', solve([[], [['a', 2]]]), [])
    check('unmatched key', solve([[[10, 'z', 2]], [['a', 3]]]), [[10, None]])
elif N == 3:
    check('per-row bindings', solve([[[10, 'a', 3], [11, 'b', 5]], [['a', 4], ['b', 4], ['b', 6]]]), [[10, 4], [11, 6]])
    check('same key different parameter', solve([[[10, 'a', 3], [11, 'a', 5]], [['a', 4], ['a', 6]]]), [[10, 4], [10, 6], [11, 6]])
    check('null key', solve([[[10, None, 3]], [[None, 4]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 3]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 3]], [['a', 3], ['a', 3]]]), [[10, 3], [10, 3]])
    check('empty outer', solve([[], [['a', 3]]]), [])
    check('unmatched key', solve([[[10, 'z', 3]], [['a', 4]]]), [[10, None]])
elif N == 4:
    check('per-row bindings', solve([[[10, 'a', 4], [11, 'b', 6]], [['a', 5], ['b', 5], ['b', 7]]]), [[10, 5], [11, 7]])
    check('same key different parameter', solve([[[10, 'a', 4], [11, 'a', 6]], [['a', 5], ['a', 7]]]), [[10, 5], [10, 7], [11, 7]])
    check('null key', solve([[[10, None, 4]], [[None, 5]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 4]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 4]], [['a', 4], ['a', 4]]]), [[10, 4], [10, 4]])
    check('empty outer', solve([[], [['a', 4]]]), [])
    check('unmatched key', solve([[[10, 'z', 4]], [['a', 5]]]), [[10, None]])
elif N == 5:
    check('per-row bindings', solve([[[10, 'a', 5], [11, 'b', 7]], [['a', 6], ['b', 6], ['b', 8]]]), [[10, 6], [11, 8]])
    check('same key different parameter', solve([[[10, 'a', 5], [11, 'a', 7]], [['a', 6], ['a', 8]]]), [[10, 6], [10, 8], [11, 8]])
    check('null key', solve([[[10, None, 5]], [[None, 6]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 5]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 5]], [['a', 5], ['a', 5]]]), [[10, 5], [10, 5]])
    check('empty outer', solve([[], [['a', 5]]]), [])
    check('unmatched key', solve([[[10, 'z', 5]], [['a', 6]]]), [[10, None]])
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:
        outer,inner=d
        result=[]
        for ident,key,minimum in outer:
            matches=[value for k,value in inner if key is not None and k==key and value>=minimum]
            if not matches: result.append([ident,0])
            for value in matches:
                result.append([ident,value])
        return result
    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('per-row bindings', solve([[[10, 'a', 1], [11, 'b', 3]], [['a', 2], ['b', 2], ['b', 4]]]), [[10, 2], [11, 4]])
    check('same key different parameter', solve([[[10, 'a', 1], [11, 'a', 3]], [['a', 2], ['a', 4]]]), [[10, 2], [10, 4], [11, 4]])
    check('null key', solve([[[10, None, 1]], [[None, 2]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 1]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 1]], [['a', 1], ['a', 1]]]), [[10, 1], [10, 1]])
    check('empty outer', solve([[], [['a', 1]]]), [])
    check('unmatched key', solve([[[10, 'z', 1]], [['a', 2]]]), [[10, None]])
elif N == 2:
    check('per-row bindings', solve([[[10, 'a', 2], [11, 'b', 4]], [['a', 3], ['b', 3], ['b', 5]]]), [[10, 3], [11, 5]])
    check('same key different parameter', solve([[[10, 'a', 2], [11, 'a', 4]], [['a', 3], ['a', 5]]]), [[10, 3], [10, 5], [11, 5]])
    check('null key', solve([[[10, None, 2]], [[None, 3]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 2]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 2]], [['a', 2], ['a', 2]]]), [[10, 2], [10, 2]])
    check('empty outer', solve([[], [['a', 2]]]), [])
    check('unmatched key', solve([[[10, 'z', 2]], [['a', 3]]]), [[10, None]])
elif N == 3:
    check('per-row bindings', solve([[[10, 'a', 3], [11, 'b', 5]], [['a', 4], ['b', 4], ['b', 6]]]), [[10, 4], [11, 6]])
    check('same key different parameter', solve([[[10, 'a', 3], [11, 'a', 5]], [['a', 4], ['a', 6]]]), [[10, 4], [10, 6], [11, 6]])
    check('null key', solve([[[10, None, 3]], [[None, 4]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 3]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 3]], [['a', 3], ['a', 3]]]), [[10, 3], [10, 3]])
    check('empty outer', solve([[], [['a', 3]]]), [])
    check('unmatched key', solve([[[10, 'z', 3]], [['a', 4]]]), [[10, None]])
elif N == 4:
    check('per-row bindings', solve([[[10, 'a', 4], [11, 'b', 6]], [['a', 5], ['b', 5], ['b', 7]]]), [[10, 5], [11, 7]])
    check('same key different parameter', solve([[[10, 'a', 4], [11, 'a', 6]], [['a', 5], ['a', 7]]]), [[10, 5], [10, 7], [11, 7]])
    check('null key', solve([[[10, None, 4]], [[None, 5]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 4]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 4]], [['a', 4], ['a', 4]]]), [[10, 4], [10, 4]])
    check('empty outer', solve([[], [['a', 4]]]), [])
    check('unmatched key', solve([[[10, 'z', 4]], [['a', 5]]]), [[10, None]])
elif N == 5:
    check('per-row bindings', solve([[[10, 'a', 5], [11, 'b', 7]], [['a', 6], ['b', 6], ['b', 8]]]), [[10, 6], [11, 8]])
    check('same key different parameter', solve([[[10, 'a', 5], [11, 'a', 7]], [['a', 6], ['a', 8]]]), [[10, 6], [10, 8], [11, 8]])
    check('null key', solve([[[10, None, 5]], [[None, 6]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 5]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 5]], [['a', 5], ['a', 5]]]), [[10, 5], [10, 5]])
    check('empty outer', solve([[], [['a', 5]]]), [])
    check('unmatched key', solve([[[10, 'z', 5]], [['a', 6]]]), [[10, None]])
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:
Lateral execution drops outer rows with empty subqueries.

For each outer [id,key] row, evaluate matching [key,value] inner rows with a minimum supplied by that outer row. Emit [id,value] in source order, preserving duplicate inner matches. Empty matches emit [id,None] under outer lateral semantics.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        outer,inner=d
        result=[]
        for ident,key,minimum in outer:
            matches=[value for k,value in inner if key is not None and k==key and value>=minimum]
            if not matches: result.append([ident,None])
            for value in dict.fromkeys(matches):
                result.append([ident,value])
        return result
    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('per-row bindings', solve([[[10, 'a', 1], [11, 'b', 3]], [['a', 2], ['b', 2], ['b', 4]]]), [[10, 2], [11, 4]])
    check('same key different parameter', solve([[[10, 'a', 1], [11, 'a', 3]], [['a', 2], ['a', 4]]]), [[10, 2], [10, 4], [11, 4]])
    check('null key', solve([[[10, None, 1]], [[None, 2]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 1]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 1]], [['a', 1], ['a', 1]]]), [[10, 1], [10, 1]])
    check('empty outer', solve([[], [['a', 1]]]), [])
    check('unmatched key', solve([[[10, 'z', 1]], [['a', 2]]]), [[10, None]])
elif N == 2:
    check('per-row bindings', solve([[[10, 'a', 2], [11, 'b', 4]], [['a', 3], ['b', 3], ['b', 5]]]), [[10, 3], [11, 5]])
    check('same key different parameter', solve([[[10, 'a', 2], [11, 'a', 4]], [['a', 3], ['a', 5]]]), [[10, 3], [10, 5], [11, 5]])
    check('null key', solve([[[10, None, 2]], [[None, 3]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 2]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 2]], [['a', 2], ['a', 2]]]), [[10, 2], [10, 2]])
    check('empty outer', solve([[], [['a', 2]]]), [])
    check('unmatched key', solve([[[10, 'z', 2]], [['a', 3]]]), [[10, None]])
elif N == 3:
    check('per-row bindings', solve([[[10, 'a', 3], [11, 'b', 5]], [['a', 4], ['b', 4], ['b', 6]]]), [[10, 4], [11, 6]])
    check('same key different parameter', solve([[[10, 'a', 3], [11, 'a', 5]], [['a', 4], ['a', 6]]]), [[10, 4], [10, 6], [11, 6]])
    check('null key', solve([[[10, None, 3]], [[None, 4]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 3]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 3]], [['a', 3], ['a', 3]]]), [[10, 3], [10, 3]])
    check('empty outer', solve([[], [['a', 3]]]), [])
    check('unmatched key', solve([[[10, 'z', 3]], [['a', 4]]]), [[10, None]])
elif N == 4:
    check('per-row bindings', solve([[[10, 'a', 4], [11, 'b', 6]], [['a', 5], ['b', 5], ['b', 7]]]), [[10, 5], [11, 7]])
    check('same key different parameter', solve([[[10, 'a', 4], [11, 'a', 6]], [['a', 5], ['a', 7]]]), [[10, 5], [10, 7], [11, 7]])
    check('null key', solve([[[10, None, 4]], [[None, 5]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 4]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 4]], [['a', 4], ['a', 4]]]), [[10, 4], [10, 4]])
    check('empty outer', solve([[], [['a', 4]]]), [])
    check('unmatched key', solve([[[10, 'z', 4]], [['a', 5]]]), [[10, None]])
elif N == 5:
    check('per-row bindings', solve([[[10, 'a', 5], [11, 'b', 7]], [['a', 6], ['b', 6], ['b', 8]]]), [[10, 6], [11, 8]])
    check('same key different parameter', solve([[[10, 'a', 5], [11, 'a', 7]], [['a', 6], ['a', 8]]]), [[10, 6], [10, 8], [11, 8]])
    check('null key', solve([[[10, None, 5]], [[None, 6]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 5]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 5]], [['a', 5], ['a', 5]]]), [[10, 5], [10, 5]])
    check('empty outer', solve([[], [['a', 5]]]), [])
    check('unmatched key', solve([[[10, 'z', 5]], [['a', 6]]]), [[10, None]])
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:
        outer,inner=d
        result=[]
        for ident,key,minimum in outer:
            matches=[value for k,value in inner if key is not None and k==key and value>=minimum]
            if not matches: result.append([ident,None])
            for value in sorted(set(matches)):
                result.append([ident,value])
        return result
    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('per-row bindings', solve([[[10, 'a', 1], [11, 'b', 3]], [['a', 2], ['b', 2], ['b', 4]]]), [[10, 2], [11, 4]])
    check('same key different parameter', solve([[[10, 'a', 1], [11, 'a', 3]], [['a', 2], ['a', 4]]]), [[10, 2], [10, 4], [11, 4]])
    check('null key', solve([[[10, None, 1]], [[None, 2]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 1]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 1]], [['a', 1], ['a', 1]]]), [[10, 1], [10, 1]])
    check('empty outer', solve([[], [['a', 1]]]), [])
    check('unmatched key', solve([[[10, 'z', 1]], [['a', 2]]]), [[10, None]])
elif N == 2:
    check('per-row bindings', solve([[[10, 'a', 2], [11, 'b', 4]], [['a', 3], ['b', 3], ['b', 5]]]), [[10, 3], [11, 5]])
    check('same key different parameter', solve([[[10, 'a', 2], [11, 'a', 4]], [['a', 3], ['a', 5]]]), [[10, 3], [10, 5], [11, 5]])
    check('null key', solve([[[10, None, 2]], [[None, 3]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 2]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 2]], [['a', 2], ['a', 2]]]), [[10, 2], [10, 2]])
    check('empty outer', solve([[], [['a', 2]]]), [])
    check('unmatched key', solve([[[10, 'z', 2]], [['a', 3]]]), [[10, None]])
elif N == 3:
    check('per-row bindings', solve([[[10, 'a', 3], [11, 'b', 5]], [['a', 4], ['b', 4], ['b', 6]]]), [[10, 4], [11, 6]])
    check('same key different parameter', solve([[[10, 'a', 3], [11, 'a', 5]], [['a', 4], ['a', 6]]]), [[10, 4], [10, 6], [11, 6]])
    check('null key', solve([[[10, None, 3]], [[None, 4]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 3]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 3]], [['a', 3], ['a', 3]]]), [[10, 3], [10, 3]])
    check('empty outer', solve([[], [['a', 3]]]), [])
    check('unmatched key', solve([[[10, 'z', 3]], [['a', 4]]]), [[10, None]])
elif N == 4:
    check('per-row bindings', solve([[[10, 'a', 4], [11, 'b', 6]], [['a', 5], ['b', 5], ['b', 7]]]), [[10, 5], [11, 7]])
    check('same key different parameter', solve([[[10, 'a', 4], [11, 'a', 6]], [['a', 5], ['a', 7]]]), [[10, 5], [10, 7], [11, 7]])
    check('null key', solve([[[10, None, 4]], [[None, 5]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 4]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 4]], [['a', 4], ['a', 4]]]), [[10, 4], [10, 4]])
    check('empty outer', solve([[], [['a', 4]]]), [])
    check('unmatched key', solve([[[10, 'z', 4]], [['a', 5]]]), [[10, None]])
elif N == 5:
    check('per-row bindings', solve([[[10, 'a', 5], [11, 'b', 7]], [['a', 6], ['b', 6], ['b', 8]]]), [[10, 6], [11, 8]])
    check('same key different parameter', solve([[[10, 'a', 5], [11, 'a', 7]], [['a', 6], ['a', 8]]]), [[10, 6], [10, 8], [11, 8]])
    check('null key', solve([[[10, None, 5]], [[None, 6]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 5]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 5]], [['a', 5], ['a', 5]]]), [[10, 5], [10, 5]])
    check('empty outer', solve([[], [['a', 5]]]), [])
    check('unmatched key', solve([[[10, 'z', 5]], [['a', 6]]]), [[10, None]])
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:
Lateral execution deduplicates repeated inner matches.

For each outer [id,key] row, evaluate matching [key,value] inner rows with a minimum supplied by that outer row. Emit [id,value] in source order, preserving duplicate inner matches. Empty matches emit [id,None] under outer lateral semantics.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        outer,inner=d
        result=[]
        for ident,key,minimum in outer:
            matches=[value for k,value in inner if key is not None and k==key and value>=minimum]
            if not matches: result.append([ident,None])
            for value in matches:
                result.append([key,value])
        return result
    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('per-row bindings', solve([[[10, 'a', 1], [11, 'b', 3]], [['a', 2], ['b', 2], ['b', 4]]]), [[10, 2], [11, 4]])
    check('same key different parameter', solve([[[10, 'a', 1], [11, 'a', 3]], [['a', 2], ['a', 4]]]), [[10, 2], [10, 4], [11, 4]])
    check('null key', solve([[[10, None, 1]], [[None, 2]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 1]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 1]], [['a', 1], ['a', 1]]]), [[10, 1], [10, 1]])
    check('empty outer', solve([[], [['a', 1]]]), [])
    check('unmatched key', solve([[[10, 'z', 1]], [['a', 2]]]), [[10, None]])
elif N == 2:
    check('per-row bindings', solve([[[10, 'a', 2], [11, 'b', 4]], [['a', 3], ['b', 3], ['b', 5]]]), [[10, 3], [11, 5]])
    check('same key different parameter', solve([[[10, 'a', 2], [11, 'a', 4]], [['a', 3], ['a', 5]]]), [[10, 3], [10, 5], [11, 5]])
    check('null key', solve([[[10, None, 2]], [[None, 3]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 2]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 2]], [['a', 2], ['a', 2]]]), [[10, 2], [10, 2]])
    check('empty outer', solve([[], [['a', 2]]]), [])
    check('unmatched key', solve([[[10, 'z', 2]], [['a', 3]]]), [[10, None]])
elif N == 3:
    check('per-row bindings', solve([[[10, 'a', 3], [11, 'b', 5]], [['a', 4], ['b', 4], ['b', 6]]]), [[10, 4], [11, 6]])
    check('same key different parameter', solve([[[10, 'a', 3], [11, 'a', 5]], [['a', 4], ['a', 6]]]), [[10, 4], [10, 6], [11, 6]])
    check('null key', solve([[[10, None, 3]], [[None, 4]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 3]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 3]], [['a', 3], ['a', 3]]]), [[10, 3], [10, 3]])
    check('empty outer', solve([[], [['a', 3]]]), [])
    check('unmatched key', solve([[[10, 'z', 3]], [['a', 4]]]), [[10, None]])
elif N == 4:
    check('per-row bindings', solve([[[10, 'a', 4], [11, 'b', 6]], [['a', 5], ['b', 5], ['b', 7]]]), [[10, 5], [11, 7]])
    check('same key different parameter', solve([[[10, 'a', 4], [11, 'a', 6]], [['a', 5], ['a', 7]]]), [[10, 5], [10, 7], [11, 7]])
    check('null key', solve([[[10, None, 4]], [[None, 5]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 4]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 4]], [['a', 4], ['a', 4]]]), [[10, 4], [10, 4]])
    check('empty outer', solve([[], [['a', 4]]]), [])
    check('unmatched key', solve([[[10, 'z', 4]], [['a', 5]]]), [[10, None]])
elif N == 5:
    check('per-row bindings', solve([[[10, 'a', 5], [11, 'b', 7]], [['a', 6], ['b', 6], ['b', 8]]]), [[10, 6], [11, 8]])
    check('same key different parameter', solve([[[10, 'a', 5], [11, 'a', 7]], [['a', 6], ['a', 8]]]), [[10, 6], [10, 8], [11, 8]])
    check('null key', solve([[[10, None, 5]], [[None, 6]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 5]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 5]], [['a', 5], ['a', 5]]]), [[10, 5], [10, 5]])
    check('empty outer', solve([[], [['a', 5]]]), [])
    check('unmatched key', solve([[[10, 'z', 5]], [['a', 6]]]), [[10, None]])
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:
        outer,inner=d
        result=[]
        for ident,key,minimum in outer:
            matches=[value for k,value in inner if key is not None and k==key and value>=minimum]
            if not matches: result.append([ident,None])
            for value in matches:
                result.append([minimum,value])
        return result
    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('per-row bindings', solve([[[10, 'a', 1], [11, 'b', 3]], [['a', 2], ['b', 2], ['b', 4]]]), [[10, 2], [11, 4]])
    check('same key different parameter', solve([[[10, 'a', 1], [11, 'a', 3]], [['a', 2], ['a', 4]]]), [[10, 2], [10, 4], [11, 4]])
    check('null key', solve([[[10, None, 1]], [[None, 2]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 1]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 1]], [['a', 1], ['a', 1]]]), [[10, 1], [10, 1]])
    check('empty outer', solve([[], [['a', 1]]]), [])
    check('unmatched key', solve([[[10, 'z', 1]], [['a', 2]]]), [[10, None]])
elif N == 2:
    check('per-row bindings', solve([[[10, 'a', 2], [11, 'b', 4]], [['a', 3], ['b', 3], ['b', 5]]]), [[10, 3], [11, 5]])
    check('same key different parameter', solve([[[10, 'a', 2], [11, 'a', 4]], [['a', 3], ['a', 5]]]), [[10, 3], [10, 5], [11, 5]])
    check('null key', solve([[[10, None, 2]], [[None, 3]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 2]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 2]], [['a', 2], ['a', 2]]]), [[10, 2], [10, 2]])
    check('empty outer', solve([[], [['a', 2]]]), [])
    check('unmatched key', solve([[[10, 'z', 2]], [['a', 3]]]), [[10, None]])
elif N == 3:
    check('per-row bindings', solve([[[10, 'a', 3], [11, 'b', 5]], [['a', 4], ['b', 4], ['b', 6]]]), [[10, 4], [11, 6]])
    check('same key different parameter', solve([[[10, 'a', 3], [11, 'a', 5]], [['a', 4], ['a', 6]]]), [[10, 4], [10, 6], [11, 6]])
    check('null key', solve([[[10, None, 3]], [[None, 4]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 3]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 3]], [['a', 3], ['a', 3]]]), [[10, 3], [10, 3]])
    check('empty outer', solve([[], [['a', 3]]]), [])
    check('unmatched key', solve([[[10, 'z', 3]], [['a', 4]]]), [[10, None]])
elif N == 4:
    check('per-row bindings', solve([[[10, 'a', 4], [11, 'b', 6]], [['a', 5], ['b', 5], ['b', 7]]]), [[10, 5], [11, 7]])
    check('same key different parameter', solve([[[10, 'a', 4], [11, 'a', 6]], [['a', 5], ['a', 7]]]), [[10, 5], [10, 7], [11, 7]])
    check('null key', solve([[[10, None, 4]], [[None, 5]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 4]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 4]], [['a', 4], ['a', 4]]]), [[10, 4], [10, 4]])
    check('empty outer', solve([[], [['a', 4]]]), [])
    check('unmatched key', solve([[[10, 'z', 4]], [['a', 5]]]), [[10, None]])
elif N == 5:
    check('per-row bindings', solve([[[10, 'a', 5], [11, 'b', 7]], [['a', 6], ['b', 6], ['b', 8]]]), [[10, 6], [11, 8]])
    check('same key different parameter', solve([[[10, 'a', 5], [11, 'a', 7]], [['a', 6], ['a', 8]]]), [[10, 6], [10, 8], [11, 8]])
    check('null key', solve([[[10, None, 5]], [[None, 6]]]), [[10, None]])
    check('empty inner', solve([[[10, 'a', 5]], []]), [[10, None]])
    check('duplicate inner', solve([[[10, 'a', 5]], [['a', 5], ['a', 5]]]), [[10, 5], [10, 5]])
    check('empty outer', solve([[], [['a', 5]]]), [])
    check('unmatched key', solve([[[10, 'z', 5]], [['a', 6]]]), [[10, None]])
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:
Lateral result rows use correlation key as parent identity.

For each outer [id,key] row, evaluate matching [key,value] inner rows with a minimum supplied by that outer row. Emit [id,value] in source order, preserving duplicate inner matches. Empty matches emit [id,None] under outer lateral semantics.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None and k==key]
            count=len(set(matches))
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None and k==key]
            count=sum(v is not None for v in set(matches))
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Scalar subquery cardinality counts distinct values.

Evaluate a correlated scalar lookup per outer key. Zero rows yield None, exactly one row yields its value including None, and two or more matching rows yield the explicit value CARDINALITY. Count physical rows, not distinct or non-null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None and k==key]
            count=sum(v is not None for v in matches)
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None and k==key]
            count=sum(bool(v) for v in matches)
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Scalar subquery cardinality ignores null-valued rows.

Evaluate a correlated scalar lookup per outer key. Zero rows yield None, exactly one row yields its value including None, and two or more matching rows yield the explicit value CARDINALITY. Count physical rows, not distinct or non-null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None]
            count=len(matches)
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None and (k==key or k is None)]
            count=len(matches)
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Scalar lookup counts rows from unrelated correlation keys.

Evaluate a correlated scalar lookup per outer key. Zero rows yield None, exactly one row yields its value including None, and two or more matching rows yield the explicit value CARDINALITY. Count physical rows, not distinct or non-null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if k==key]
            count=len(matches)
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is None or k==key]
            count=len(matches)
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Scalar lookup joins absent keys to absent keys.

Evaluate a correlated scalar lookup per outer key. Zero rows yield None, exactly one row yields its value including None, and two or more matching rows yield the explicit value CARDINALITY. Count physical rows, not distinct or non-null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None and k==key]
            count=len(matches)
            if count==0: value=0
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None and k==key]
            count=len(matches)
            if count==0: value=[]
            elif count==1: value=matches[0]
            else: value='CARDINALITY'
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An empty scalar subquery yields a fabricated zero.

Evaluate a correlated scalar lookup per outer key. Zero rows yield None, exactly one row yields its value including None, and two or more matching rows yield the explicit value CARDINALITY. Count physical rows, not distinct or non-null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None and k==key]
            count=len(matches)
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value=matches[0]
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        keys,inner=d
        out=[]
        for key in keys:
            matches=[value for k,value in inner if key is not None and k==key]
            count=len(matches)
            if count==0: value=None
            elif count==1: value=matches[0]
            else: value=matches[-1]
            out.append(value)
        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('duplicate physical rows', solve([['a'], [['a', 1], ['a', 1]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 1]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 1], ['b', 2]]]), [1, 2])
    check('null correlation', solve([[None], [[None, 1]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 1], ['a', 2]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 1], [None, 2]]]), [1])
    check('no outer rows', solve([[], [['a', 1]]]), [])
elif N == 2:
    check('duplicate physical rows', solve([['a'], [['a', 2], ['a', 2]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 2]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 2], ['b', 3]]]), [2, 3])
    check('null correlation', solve([[None], [[None, 2]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 2], ['a', 3]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 2], [None, 3]]]), [2])
    check('no outer rows', solve([[], [['a', 2]]]), [])
elif N == 3:
    check('duplicate physical rows', solve([['a'], [['a', 3], ['a', 3]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 3]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 3], ['b', 4]]]), [3, 4])
    check('null correlation', solve([[None], [[None, 3]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 3], ['a', 4]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 3], [None, 4]]]), [3])
    check('no outer rows', solve([[], [['a', 3]]]), [])
elif N == 4:
    check('duplicate physical rows', solve([['a'], [['a', 4], ['a', 4]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 4]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 4], ['b', 5]]]), [4, 5])
    check('null correlation', solve([[None], [[None, 4]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 4], ['a', 5]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 4], [None, 5]]]), [4])
    check('no outer rows', solve([[], [['a', 4]]]), [])
elif N == 5:
    check('duplicate physical rows', solve([['a'], [['a', 5], ['a', 5]]]), ['CARDINALITY'])
    check('one null and one value', solve([['a'], [['a', None], ['a', 5]]]), ['CARDINALITY'])
    check('unrelated keys', solve([['a', 'b'], [['a', 5], ['b', 6]]]), [5, 6])
    check('null correlation', solve([[None], [[None, 5]]]), [None])
    check('empty lookup', solve([['a'], []]), [None])
    check('single null', solve([['a'], [['a', None]]]), [None])
    check('two values', solve([['a'], [['a', 5], ['a', 6]]]), ['CARDINALITY'])
    check('null row cannot correlate', solve([['a'], [['a', 5], [None, 6]]]), [5])
    check('no outer rows', solve([[], [['a', 5]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A multirow scalar subquery silently picks its first result.

Evaluate a correlated scalar lookup per outer key. Zero rows yield None, exactly one row yields its value including None, and two or more matching rows yield the explicit value CARDINALITY. Count physical rows, not distinct or non-null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        rows,sets=d
        out=[]
        for group in sets:
            for a,b,value in rows:
                keys=[a,b]
                projected=[keys[i] if i in group else None for i in range(2)]
                mask=sum(1<<i for i,v in enumerate(projected) if v is None)
                out.append(projected+[mask,value])
        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('one dimension', solve([[['a', 'b', 1]], [[0]]]), [['a', None, 2, 1]])
    check('other dimension', solve([[['a', 'b', 1]], [[1]]]), [[None, 'b', 1, 1]])
    check('real null key', solve([[[None, 'b', 1]], [[0, 1]]]), [[None, 'b', 0, 1]])
    check('grand total row', solve([[['a', 'b', 1]], [[]]]), [[None, None, 3, 1]])
    check('duplicate sets', solve([[['a', 'b', 1]], [[0], [0]]]), [['a', None, 2, 1], ['a', None, 2, 1]])
    check('duplicate facts', solve([[['a', 'b', 1], ['a', 'b', 1]], [[0, 1]]]), [['a', 'b', 0, 1], ['a', 'b', 0, 1]])
    check('empty facts', solve([[], [[0], []]]), [])
elif N == 2:
    check('one dimension', solve([[['a', 'b', 2]], [[0]]]), [['a', None, 2, 2]])
    check('other dimension', solve([[['a', 'b', 2]], [[1]]]), [[None, 'b', 1, 2]])
    check('real null key', solve([[[None, 'b', 2]], [[0, 1]]]), [[None, 'b', 0, 2]])
    check('grand total row', solve([[['a', 'b', 2]], [[]]]), [[None, None, 3, 2]])
    check('duplicate sets', solve([[['a', 'b', 2]], [[0], [0]]]), [['a', None, 2, 2], ['a', None, 2, 2]])
    check('duplicate facts', solve([[['a', 'b', 2], ['a', 'b', 2]], [[0, 1]]]), [['a', 'b', 0, 2], ['a', 'b', 0, 2]])
    check('empty facts', solve([[], [[0], []]]), [])
elif N == 3:
    check('one dimension', solve([[['a', 'b', 3]], [[0]]]), [['a', None, 2, 3]])
    check('other dimension', solve([[['a', 'b', 3]], [[1]]]), [[None, 'b', 1, 3]])
    check('real null key', solve([[[None, 'b', 3]], [[0, 1]]]), [[None, 'b', 0, 3]])
    check('grand total row', solve([[['a', 'b', 3]], [[]]]), [[None, None, 3, 3]])
    check('duplicate sets', solve([[['a', 'b', 3]], [[0], [0]]]), [['a', None, 2, 3], ['a', None, 2, 3]])
    check('duplicate facts', solve([[['a', 'b', 3], ['a', 'b', 3]], [[0, 1]]]), [['a', 'b', 0, 3], ['a', 'b', 0, 3]])
    check('empty facts', solve([[], [[0], []]]), [])
elif N == 4:
    check('one dimension', solve([[['a', 'b', 4]], [[0]]]), [['a', None, 2, 4]])
    check('other dimension', solve([[['a', 'b', 4]], [[1]]]), [[None, 'b', 1, 4]])
    check('real null key', solve([[[None, 'b', 4]], [[0, 1]]]), [[None, 'b', 0, 4]])
    check('grand total row', solve([[['a', 'b', 4]], [[]]]), [[None, None, 3, 4]])
    check('duplicate sets', solve([[['a', 'b', 4]], [[0], [0]]]), [['a', None, 2, 4], ['a', None, 2, 4]])
    check('duplicate facts', solve([[['a', 'b', 4], ['a', 'b', 4]], [[0, 1]]]), [['a', 'b', 0, 4], ['a', 'b', 0, 4]])
    check('empty facts', solve([[], [[0], []]]), [])
elif N == 5:
    check('one dimension', solve([[['a', 'b', 5]], [[0]]]), [['a', None, 2, 5]])
    check('other dimension', solve([[['a', 'b', 5]], [[1]]]), [[None, 'b', 1, 5]])
    check('real null key', solve([[[None, 'b', 5]], [[0, 1]]]), [[None, 'b', 0, 5]])
    check('grand total row', solve([[['a', 'b', 5]], [[]]]), [[None, None, 3, 5]])
    check('duplicate sets', solve([[['a', 'b', 5]], [[0], [0]]]), [['a', None, 2, 5], ['a', None, 2, 5]])
    check('duplicate facts', solve([[['a', 'b', 5], ['a', 'b', 5]], [[0, 1]]]), [['a', 'b', 0, 5], ['a', 'b', 0, 5]])
    check('empty facts', solve([[], [[0], []]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        rows,sets=d
        out=[]
        for group in sets:
            for a,b,value in rows:
                keys=[a,b]
                projected=[keys[i] if i in group else None for i in range(2)]
                mask=sum(1<<i for i,v in enumerate(keys) if v is None)
                out.append(projected+[mask,value])
        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('one dimension', solve([[['a', 'b', 1]], [[0]]]), [['a', None, 2, 1]])
    check('other dimension', solve([[['a', 'b', 1]], [[1]]]), [[None, 'b', 1, 1]])
    check('real null key', solve([[[None, 'b', 1]], [[0, 1]]]), [[None, 'b', 0, 1]])
    check('grand total row', solve([[['a', 'b', 1]], [[]]]), [[None, None, 3, 1]])
    check('duplicate sets', solve([[['a', 'b', 1]], [[0], [0]]]), [['a', None, 2, 1], ['a', None, 2, 1]])
    check('duplicate facts', solve([[['a', 'b', 1], ['a', 'b', 1]], [[0, 1]]]), [['a', 'b', 0, 1], ['a', 'b', 0, 1]])
    check('empty facts', solve([[], [[0], []]]), [])
elif N == 2:
    check('one dimension', solve([[['a', 'b', 2]], [[0]]]), [['a', None, 2, 2]])
    check('other dimension', solve([[['a', 'b', 2]], [[1]]]), [[None, 'b', 1, 2]])
    check('real null key', solve([[[None, 'b', 2]], [[0, 1]]]), [[None, 'b', 0, 2]])
    check('grand total row', solve([[['a', 'b', 2]], [[]]]), [[None, None, 3, 2]])
    check('duplicate sets', solve([[['a', 'b', 2]], [[0], [0]]]), [['a', None, 2, 2], ['a', None, 2, 2]])
    check('duplicate facts', solve([[['a', 'b', 2], ['a', 'b', 2]], [[0, 1]]]), [['a', 'b', 0, 2], ['a', 'b', 0, 2]])
    check('empty facts', solve([[], [[0], []]]), [])
elif N == 3:
    check('one dimension', solve([[['a', 'b', 3]], [[0]]]), [['a', None, 2, 3]])
    check('other dimension', solve([[['a', 'b', 3]], [[1]]]), [[None, 'b', 1, 3]])
    check('real null key', solve([[[None, 'b', 3]], [[0, 1]]]), [[None, 'b', 0, 3]])
    check('grand total row', solve([[['a', 'b', 3]], [[]]]), [[None, None, 3, 3]])
    check('duplicate sets', solve([[['a', 'b', 3]], [[0], [0]]]), [['a', None, 2, 3], ['a', None, 2, 3]])
    check('duplicate facts', solve([[['a', 'b', 3], ['a', 'b', 3]], [[0, 1]]]), [['a', 'b', 0, 3], ['a', 'b', 0, 3]])
    check('empty facts', solve([[], [[0], []]]), [])
elif N == 4:
    check('one dimension', solve([[['a', 'b', 4]], [[0]]]), [['a', None, 2, 4]])
    check('other dimension', solve([[['a', 'b', 4]], [[1]]]), [[None, 'b', 1, 4]])
    check('real null key', solve([[[None, 'b', 4]], [[0, 1]]]), [[None, 'b', 0, 4]])
    check('grand total row', solve([[['a', 'b', 4]], [[]]]), [[None, None, 3, 4]])
    check('duplicate sets', solve([[['a', 'b', 4]], [[0], [0]]]), [['a', None, 2, 4], ['a', None, 2, 4]])
    check('duplicate facts', solve([[['a', 'b', 4], ['a', 'b', 4]], [[0, 1]]]), [['a', 'b', 0, 4], ['a', 'b', 0, 4]])
    check('empty facts', solve([[], [[0], []]]), [])
elif N == 5:
    check('one dimension', solve([[['a', 'b', 5]], [[0]]]), [['a', None, 2, 5]])
    check('other dimension', solve([[['a', 'b', 5]], [[1]]]), [[None, 'b', 1, 5]])
    check('real null key', solve([[[None, 'b', 5]], [[0, 1]]]), [[None, 'b', 0, 5]])
    check('grand total row', solve([[['a', 'b', 5]], [[]]]), [[None, None, 3, 5]])
    check('duplicate sets', solve([[['a', 'b', 5]], [[0], [0]]]), [['a', None, 2, 5], ['a', None, 2, 5]])
    check('duplicate facts', solve([[['a', 'b', 5], ['a', 'b', 5]], [[0, 1]]]), [['a', 'b', 0, 5], ['a', 'b', 0, 5]])
    check('empty facts', solve([[], [[0], []]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Grouping metadata mistakes real null keys for omitted dimensions.

Expand every fact [a,b,payload] once per supplied grouping-set list of column positions. Emit [projected-a,projected-b,grouping-mask,payload], using None for omitted keys and bit 1 for omitted a, bit 2 for omitted b. Preserve duplicate grouping sets and null source keys.

split: open-access