broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(points):
    concordant=discordant=tx=ty=0
    for i in range(len(points)):
        for j in range(i+1,len(points)):
            dx=points[i][0]-points[j][0]
            dy=points[i][1]-points[j][1]
            if dx: tx+=1
            if dy: ty+=1
            concordant+=int(dx*dy>0)
            discordant+=int(dx*dy<0)
    if not tx or not ty: return None
    d=concordant-discordant
    return str(Fraction((1 if d>=0 else -1)*d*d,tx+ty))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 1), (2, 2), (3, 3)],)), '1')
check('regression 2', solve(*([(1, 3), (2, 2), (3, 1)],)), '-1')
check('regression 3', solve(*([(1, 1), (1, 2), (2, 2), (3, 1)],)), '-1/20')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(1, 1), (1, 2)],)), None)
check('regression 6', solve(*([(1, 1), (2, 2), (2, 2), (4, 3)],)), '1')
check('regression 7', solve(*([(1, 2), (3, 1), (4, 4), (2, 5)],)), '0')
check("variable discordance direction",solve([(0,N),(N,0)]),"-1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(points):
    concordant=discordant=tx=ty=0
    for i in range(len(points)):
        for j in range(i+1,len(points)):
            dx=points[i][0]-points[j][0]
            dy=points[i][1]-points[j][1]
            if dx: tx+=1
            if dy: ty+=1
            concordant+=int(dx*dy>0)
            discordant+=int(dx*dy<0)
    if not tx or not ty: return None
    d=concordant-discordant
    return str(Fraction((1 if d>=0 else -1)*d*d,max(tx,ty)**2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 1), (2, 2), (3, 3)],)), '1')
check('regression 2', solve(*([(1, 3), (2, 2), (3, 1)],)), '-1')
check('regression 3', solve(*([(1, 1), (1, 2), (2, 2), (3, 1)],)), '-1/20')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(1, 1), (1, 2)],)), None)
check('regression 6', solve(*([(1, 1), (2, 2), (2, 2), (4, 3)],)), '1')
check('regression 7', solve(*([(1, 2), (3, 1), (4, 4), (2, 5)],)), '0')
check("variable discordance direction",solve([(0,N),(N,0)]),"-1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For paired ordinal observations return sign(tau_b)*tau_b**2 as an exact Fraction string. Every unordered observation pair contributes its coordinate comparison; normalize signed concordance squared by products of non-tied x/y pair counts. Undefined if either coordinate has no varying pairs.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(points):
    concordant=discordant=tx=ty=0
    for i in range(len(points)):
        for j in range(i+1,len(points)):
            dx=points[i][0]-points[j][0]
            dy=points[i][1]-points[j][1]
            if dx: tx+=1
            if dy: ty+=1
            concordant+=max(0,dx*dy)
            discordant+=max(0,-dx*dy)
    if not tx or not ty: return None
    d=concordant-discordant
    return str(Fraction((1 if d>=0 else -1)*d*d,tx*ty))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 1), (2, 2), (3, 3)],)), '1')
check('regression 2', solve(*([(1, 3), (2, 2), (3, 1)],)), '-1')
check('regression 3', solve(*([(1, 1), (1, 2), (2, 2), (3, 1)],)), '-1/20')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(1, 1), (1, 2)],)), None)
check('regression 6', solve(*([(1, 1), (2, 2), (2, 2), (4, 3)],)), '1')
check('regression 7', solve(*([(1, 2), (3, 1), (4, 4), (2, 5)],)), '0')
check("variable discordance direction",solve([(0,N),(N,0)]),"-1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(points):
    concordant=discordant=tx=ty=0
    for i in range(len(points)):
        for j in range(i+1,len(points)):
            dx=points[i][0]-points[j][0]
            dy=points[i][1]-points[j][1]
            if dx: tx+=1
            if dy: ty+=1
            concordant+=abs(dx) if dx*dy>0 else 0
            discordant+=abs(dy) if dx*dy<0 else 0
    if not tx or not ty: return None
    d=concordant-discordant
    return str(Fraction((1 if d>=0 else -1)*d*d,tx*ty))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 1), (2, 2), (3, 3)],)), '1')
check('regression 2', solve(*([(1, 3), (2, 2), (3, 1)],)), '-1')
check('regression 3', solve(*([(1, 1), (1, 2), (2, 2), (3, 1)],)), '-1/20')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(1, 1), (1, 2)],)), None)
check('regression 6', solve(*([(1, 1), (2, 2), (2, 2), (4, 3)],)), '1')
check('regression 7', solve(*([(1, 2), (3, 1), (4, 4), (2, 5)],)), '0')
check("variable discordance direction",solve([(0,N),(N,0)]),"-1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For paired ordinal observations return sign(tau_b)*tau_b**2 as an exact Fraction string. Every unordered observation pair contributes its coordinate comparison; normalize signed concordance squared by products of non-tied x/y pair counts. Undefined if either coordinate has no varying pairs.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(points):
    concordant=discordant=tx=ty=0
    for i in range(len(points)):
        for j in range(i+1,len(points)):
            dx=points[i][0]-points[j][0]
            dy=points[i][1]-points[j][1]
            if dx: tx+=1
            if dy: ty+=1
            concordant+=int(dx*dy>0)
            discordant+=int(dx*dy<0)
    if not tx or not ty: return "1"
    d=concordant-discordant
    return str(Fraction((1 if d>=0 else -1)*d*d,tx*ty))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 1), (2, 2), (3, 3)],)), '1')
check('regression 2', solve(*([(1, 3), (2, 2), (3, 1)],)), '-1')
check('regression 3', solve(*([(1, 1), (1, 2), (2, 2), (3, 1)],)), '-1/20')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(1, 1), (1, 2)],)), None)
check('regression 6', solve(*([(1, 1), (2, 2), (2, 2), (4, 3)],)), '1')
check('regression 7', solve(*([(1, 2), (3, 1), (4, 4), (2, 5)],)), '0')
check("variable discordance direction",solve([(0,N),(N,0)]),"-1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(points):
    concordant=discordant=tx=ty=0
    for i in range(len(points)):
        for j in range(i+1,len(points)):
            dx=points[i][0]-points[j][0]
            dy=points[i][1]-points[j][1]
            if dx: tx+=1
            if dy: ty+=1
            concordant+=int(dx*dy>0)
            discordant+=int(dx*dy<0)
    if not tx or not ty: return "0"
    d=concordant-discordant
    return str(Fraction((1 if d>=0 else -1)*d*d,tx*ty))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(1, 1), (2, 2), (3, 3)],)), '1')
check('regression 2', solve(*([(1, 3), (2, 2), (3, 1)],)), '-1')
check('regression 3', solve(*([(1, 1), (1, 2), (2, 2), (3, 1)],)), '-1/20')
check('regression 4', solve(*([],)), None)
check('regression 5', solve(*([(1, 1), (1, 2)],)), None)
check('regression 6', solve(*([(1, 1), (2, 2), (2, 2), (4, 3)],)), '1')
check('regression 7', solve(*([(1, 2), (3, 1), (4, 4), (2, 5)],)), '0')
check("variable discordance direction",solve([(0,N),(N,0)]),"-1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For paired ordinal observations return sign(tau_b)*tau_b**2 as an exact Fraction string. Every unordered observation pair contributes its coordinate comparison; normalize signed concordance squared by products of non-tied x/y pair counts. Undefined if either coordinate has no varying pairs.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(u==v for u,v in zip(a,b))
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for (u,w),v in joint.items() if u==w)
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(v*v//2 for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(v*(v+1)//2 for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x+y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs*pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(max(x,y))
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(min(x,y))
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str(same/ceiling if ceiling else Fraction(1))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/ceiling if ceiling else Fraction(1))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str(max(Fraction(0),(same-expected)/(ceiling-expected)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str(abs((same-expected)/(ceiling-expected)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=y=same
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=x
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*n
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return "0" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y,pairs)
    ceiling=Fraction(x+y,2)
    return None if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(x*y//pairs)
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(a, b):
    if len(a)!=len(b): return None
    n=len(a)
    if n<2: return "1"
    pairs=n*(n-1)//2
    joint=Counter(zip(a,b))
    ra,rb=Counter(a),Counter(b)
    choose=lambda k:k*(k-1)//2
    same=sum(choose(v) for v in joint.values())
    x=sum(choose(v) for v in ra.values())
    y=sum(choose(v) for v in rb.values())
    expected=Fraction(round(Fraction(x*y,pairs)))
    ceiling=Fraction(x+y,2)
    return "1" if ceiling==expected else str((same-expected)/(ceiling-expected))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([0, 0, 1, 1], [4, 4, 5, 5])), '1')
check('regression 2', solve(*([0, 0, 1, 1], [0, 1, 0, 1])), '-1/2')
check('regression 3', solve(*([], [])), '1')
check('regression 4', solve(*([0], [9])), '1')
check('regression 5', solve(*([0, 0, 0, 1, 2], [1, 1, 2, 2, 2])), '-2/23')
check('regression 6', solve(*([0, 1, 2], [8, 9, 10])), '1')
check('regression 7', solve(*([0, 0], [1])), None)
check('regression 8', solve(*([0, 0, 1, 2, 2, 2], [4, 5, 4, 5, 5, 5])), '34/109')
check("variable label names",solve([N,N,N+1,N+1],[7,7,8,8]),"1")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Two equal-length integer cluster label arrays describe the same observations. Return exact adjusted Rand index from pair-count contingency reduction. Label names have no numerical meaning. Matching degenerate partitions with zero normalization return "1"; length mismatch returns None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*a
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(a-d)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e) if a<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,4) if a<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if e<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if e>=-d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(e-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else abs(d*(e-d/2))
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a*a<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d*d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=min(Fraction(e*e,2),d)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=min(Fraction(e*e,2),d*d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in [sum(errors)]:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in [sum(abs(v) for v in errors)]:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in [max(errors,key=abs)]:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in set(errors):
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(a-d/2)
    return str(total/len(errors))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(a-d/2)
    return str(total/max(1,len(set(errors))))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(delta) if delta else Fraction(10**9)
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(errors, delta):
    if not errors: return "0"
    d=Fraction(max(1,delta))
    total=Fraction(0)
    for e in errors:
        a=abs(e)
        total+=Fraction(e*e,2) if a<=d else d*(a-d/2)
    return str(total)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([2, 2, 4], 2)), '10')
check('regression 2', solve(*([0, 1, -1, 4, -4], 2)), '13')
check('regression 3', solve(*([], 2)), '0')
check('regression 4', solve(*([2, -2], 2)), '4')
check('regression 5', solve(*([1, -1, 3], 1)), '7/2')
check('regression 6', solve(*([-5, 0, 2], 3)), '25/2')
check('regression 7', solve(*([7, -2, 1], 0)), '0')
check('regression 8', solve(*([1, 2, 3], 4)), '7')
check("variable Huber tail",solve([N+2,-N-2],2),str(4*N+4))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

For integer residuals and nonnegative integer threshold delta, sum the convex Huber loss: e**2/2 inside threshold and delta*(abs(e)-delta/2) outside. Return exact Fraction string; this is a bounded loss reduction, not an optimizer.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude//=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero^=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude//=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Process add/remove integer factors; each removal removes one currently present equal factor. Return the exact product of active factors with empty product one. Preserve zero multiplicity and signed parity while zero factors temporarily hide the nonzero product.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero=0
            else:
                magnitude//=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero=max(0,zero-2)
            else:
                magnitude//=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Process add/remove integer factors; each removal removes one currently present equal factor. Return the exact product of active factors with empty product one. Preserve zero multiplicity and signed parity while zero factors temporarily hide the nonzero product.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude*=abs(x) if not zero else 1
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude//=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude=abs(x) if zero else magnitude*abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude//=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Process add/remove integer factors; each removal removes one currently present equal factor. Return the exact product of active factors with empty product one. Preserve zero multiplicity and signed parity while zero factors temporarily hide the nonzero product.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude*=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude-=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Process add/remove integer factors; each removal removes one currently present equal factor. Return the exact product of active factors with empty product one. Preserve zero multiplicity and signed parity while zero factors temporarily hide the nonzero product.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude//=abs(x)
                negative-=0
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude//=abs(x)
                negative=0
    return 0 if zero else (-magnitude if negative%2 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Process add/remove integer factors; each removal removes one currently present equal factor. Return the exact product of active factors with empty product one. Preserve zero multiplicity and signed parity while zero factors temporarily hide the nonzero product.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude//=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative>0 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
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
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(events):
    magnitude=1
    negative=zero=0
    for op,x in events:
        if op=="add":
            if x==0: zero+=1
            else:
                magnitude*=abs(x)
                negative+=int(x<0)
        else:
            if x==0: zero-=1
            else:
                magnitude//=abs(x)
                negative-=int(x<0)
    return 0 if zero else (-magnitude if negative==1 else magnitude)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([('add', 0), ('add', 0)],)), 0)
check('regression 2', solve(*([('add', 0), ('add', -3)],)), 0)
check('regression 3', solve(*([('add', -1), ('add', -2), ('add', -3)],)), -6)
check('regression 4', solve(*([('add', 2), ('add', 0), ('add', -3), ('remove', 0)],)), -6)
check('regression 5', solve(*([('add', 0), ('add', 0), ('remove', 0)],)), 0)
check('regression 6', solve(*([],)), 1)
check('regression 7', solve(*([('add', -2), ('add', -3), ('remove', -2)],)), -3)
check('regression 8', solve(*([('add', 3), ('add', 3), ('remove', 3)],)), 3)
check('regression 9', solve(*([('add', -1), ('remove', -1)],)), 1)
check('regression 10', solve(*([('add', -2), ('add', 5), ('add', -3)],)), 30)
check("variable zero removal",solve([("add",N),("add",0),("add",-2),("remove",0)]),-2*N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reduction disagrees with its explicit aggregation oracle.

Process add/remove integer factors; each removal removes one currently present equal factor. Return the exact product of active factors with empty product one. Preserve zero multiplicity and signed parity while zero factors temporarily hide the nonzero product.

split: open-access